@rockcarver/frodo-lib
Version:
A library to manage ForgeRock Identity Cloud tenants, ForgeOps deployments, and classic deployments.
339 lines • 12.5 kB
TypeScript
import { type PolicyCondition, type PolicySkeleton } from '../api/PoliciesApi';
import { type PolicySetSkeleton } from '../api/PolicySetApi';
import { type ResourceTypeSkeleton } from '../api/ResourceTypesApi';
import { type ScriptSkeleton } from '../api/ScriptApi';
import { State } from '../shared/State';
import { type ExportMetaData } from './OpsTypes';
export type Policy = {
/**
* Create policy export template
*/
createPolicyExportTemplate(): PolicyExportInterface;
/**
* Read all policies
* @returns {Promise<PolicySkeleton>} a promise that resolves to an array of policy set objects
*/
readPolicies(): Promise<PolicySkeleton[]>;
/**
* Get policies by policy set
* @param {string} policySetId policy set id/name
* @returns {Promise<PolicySkeleton[]>} a promise resolving to an array of policy objects
*/
readPoliciesByPolicySet(policySetId: string): Promise<PolicySkeleton[]>;
/**
* Get policy
* @param {string} policyId policy id/name
* @returns {Promise<PolicySkeleton>} promise resolving to a policy object
*/
readPolicy(policyId: string): Promise<PolicySkeleton>;
/**
* Update or create policy
* @param {string} policyId policy id/name
* @param {PolicySkeleton} policyData policy object
* @returns {Promise<PolicySkeleton>} promise resolving to a policy object
*/
createPolicy(policyId: string, policyData: PolicySkeleton): Promise<PolicySkeleton>;
/**
* Update or create policy
* @param {string} policyId policy id/name
* @param {PolicySkeleton} policyData policy object
* @returns {Promise<PolicySkeleton>} promise resolving to a policy object
*/
updatePolicy(policyId: string, policyData: PolicySkeleton): Promise<PolicySkeleton>;
/**
* Delete policy
* @param {string} policyId policy id/name
* @returns {Promise<PolicySkeleton>} promise resolving to a policy object
*/
deletePolicy(policyId: string): Promise<any>;
/**
* Export policy
* @param {string} policyId policy id/name
* @returns {Promise<PolicyExportInterface>} a promise that resolves to a PolicyExportInterface object
*/
exportPolicy(policyId: string, options?: PolicyExportOptions): Promise<PolicyExportInterface>;
/**
* Export policies
* @param {PolicyExportOptions} options export options
* @returns {Promise<PolicyExportInterface>} a promise that resolves to an PolicyExportInterface object
*/
exportPolicies(options?: PolicyExportOptions): Promise<PolicyExportInterface>;
/**
* Export policies by policy set
* @param {string} policySetName policy set id/name
* @param {PolicyExportOptions} options export options
* @returns {Promise<PolicyExportInterface>} a promise that resolves to an PolicyExportInterface object
*/
exportPoliciesByPolicySet(policySetName: string, options?: PolicyExportOptions): Promise<PolicyExportInterface>;
/**
* Import policy by id
* @param {string} policyId policy id
* @param {PolicyExportInterface} importData import data
* @param {PolicyImportOptions} options import options
* @returns {Promise<PolicySkeleton>} imported policy object
*/
importPolicy(policyId: string, importData: PolicyExportInterface, options?: PolicyImportOptions): Promise<PolicySkeleton>;
/**
* Import first policy
* @param {PolicyExportInterface} importData import data
* @param {PolicyImportOptions} options import options
* @returns {Promise<PolicySkeleton>} imported policy object
*/
importFirstPolicy(importData: PolicyExportInterface, options?: PolicyImportOptions): Promise<PolicySkeleton>;
/**
* Import policies
* @param {PolicyExportInterface} importData import data
* @param {PolicyImportOptions} options import options
* @returns {Promise<PolicySkeleton[]>} array of imported policy objects
*/
importPolicies(importData: PolicyExportInterface, options?: PolicyImportOptions): Promise<PolicySkeleton[]>;
/**
* Get all policies
* @returns {Promise<PolicySkeleton>} a promise that resolves to an array of policy set objects
* @deprecated since v2.0.0 use {@link Agent.readPolicies | readPolicies} instead
* ```javascript
* readPolicies(): Promise<PolicySkeleton[]>
* ```
* @group Deprecated
*/
getPolicies(): Promise<PolicySkeleton[]>;
/**
* Get policies by policy set
* @param {string} policySetId policy set id/name
* @returns {Promise<PolicySkeleton[]>} a promise resolving to an array of policy objects
* @deprecated since v2.0.0 use {@link Agent.readPoliciesByPolicySet | readPoliciesByPolicySet} instead
* ```javascript
* readPoliciesByPolicySet(policySetId: string): Promise<PolicySkeleton[]>
* ```
* @group Deprecated
*/
getPoliciesByPolicySet(policySetId: string): Promise<PolicySkeleton[]>;
/**
* Get policy
* @param {string} policyId policy id/name
* @returns {Promise<PolicySkeleton>} promise resolving to a policy object
* @deprecated since v2.0.0 use {@link Agent.readPolicy | readPolicy} instead
* ```javascript
* readPolicy(policyId: string): Promise<PolicySkeleton>
* ```
* @group Deprecated
*/
getPolicy(policyId: string): Promise<PolicySkeleton>;
/**
* Update or create policy
* @param {string} policyId policy id/name
* @param {PolicySkeleton} policyData policy object
* @returns {Promise<PolicySkeleton>} promise resolving to a policy object
* @deprecated since v2.0.0 use {@link Agent.updatePolicy | updatePolicy} or {@link Agent.createPolicy | createPolicy} instead
* ```javascript
* updatePolicy(policyId: string, policyData: PolicySkeleton): Promise<PolicySkeleton>
* createPolicy(policyId: string, policyData: PolicySkeleton): Promise<PolicySkeleton>
* ```
* @group Deprecated
*/
putPolicy(policyId: string, policyData: PolicySkeleton): Promise<PolicySkeleton>;
};
declare const _default: (state: State) => Policy;
export default _default;
export interface PolicyExportInterface {
meta?: ExportMetaData;
script: Record<string, ScriptSkeleton>;
resourcetype: Record<string, ResourceTypeSkeleton>;
policy: Record<string, PolicySkeleton>;
policyset: Record<string, PolicySetSkeleton>;
}
/**
* Policy export options
*/
export interface PolicyExportOptions {
/**
* Include any dependencies (scripts).
*/
deps: boolean;
/**
* Include any prerequisites (policy sets, resource types).
*/
prereqs: boolean;
/**
* Use string arrays to store multi-line text in scripts.
*/
useStringArrays: boolean;
}
/**
* Policy import options
*/
export interface PolicyImportOptions {
/**
* Include any dependencies (scripts).
*/
deps: boolean;
/**
* Include any prerequisites (policy sets, resource types).
*/
prereqs: boolean;
/**
* Import policies into different policy set
*/
policySetName?: string;
}
/**
* Create an empty export template
* @returns {PolicyExportInterface} an empty export template
*/
export declare function createPolicyExportTemplate({ state, }: {
state: State;
}): PolicyExportInterface;
/**
* Get all policies
* @returns {Promise<PolicySkeleton>} a promise that resolves to an array of policy set objects
*/
export declare function readPolicies({ state, }: {
state: State;
}): Promise<PolicySkeleton[]>;
export declare function readPolicy({ policyId, state, }: {
policyId: string;
state: State;
}): Promise<PolicySkeleton>;
export declare function deletePolicy({ policyId, state, }: {
policyId: string;
state: State;
}): Promise<any>;
/**
* Get policies by policy set
* @param {string} policySetId policy set id/name
* @returns {Promise<PolicySkeleton[]>} a promise resolving to an array of policy objects
*/
export declare function readPoliciesByPolicySet({ policySetId, state, }: {
policySetId: string;
state: State;
}): Promise<PolicySkeleton[]>;
export declare function createPolicy({ policyId, policyData, state, }: {
policyId: string;
policyData: PolicySkeleton;
state: State;
}): Promise<any>;
export declare function updatePolicy({ policyId, policyData, state, }: {
policyId: string;
policyData: PolicySkeleton;
state: State;
}): Promise<any>;
/**
* Find all script references in a deeply-nested policy condition object
* @param {PolicyCondition} condition condition object
* @returns {string[]} array of script UUIDs
*
* Sample condition block:
*
"condition": {
"type": "AND",
"conditions": [
{
"type": "Script",
"scriptId": "62f18ede-e5e7-4a7b-8b73-1b02fcbd241a"
},
{
"type": "AuthenticateToService",
"authenticateToService": "TxAuthz"
},
{
"type": "OR",
"conditions": [
{
"type": "Session",
"maxSessionTime": 5,
"terminateSession": false
},
{
"type": "OAuth2Scope",
"requiredScopes": [
"openid"
]
},
{
"type": "NOT",
"condition": {
"type": "Script",
"scriptId": "729ee140-a4e9-43af-b358-d60eeda13cc3"
}
}
]
}
]
},
*/
export declare function findScriptUuids(condition: PolicyCondition): string[];
/**
* Get scripts for a policy object
* @param {PolicySkeleton} policyData policy object
* @returns {Promise<ScriptSkeleton[]>} a promise that resolves to an array of script objects
*/
export declare function getScripts({ policyData, state, }: {
policyData: PolicySkeleton;
state: State;
}): Promise<ScriptSkeleton[]>;
/**
* Export policy
* @param {string} policyId policy id/name
* @returns {Promise<PolicyExportInterface>} a promise that resolves to a PolicyExportInterface object
*/
export declare function exportPolicy({ policyId, options, state, }: {
policyId: string;
options?: PolicyExportOptions;
state: State;
}): Promise<PolicyExportInterface>;
/**
* Export policies
* @param {PolicyExportOptions} options export options
* @returns {Promise<PolicyExportInterface>} a promise that resolves to an PolicyExportInterface object
*/
export declare function exportPolicies({ options, state, }: {
options?: PolicyExportOptions;
state: State;
}): Promise<PolicyExportInterface>;
/**
* Export policies by policy set
* @param {string} policySetName policy set id/name
* @param {PolicyExportOptions} options export options
* @returns {Promise<PolicyExportInterface>} a promise that resolves to an PolicyExportInterface object
*/
export declare function exportPoliciesByPolicySet({ policySetName, options, state, }: {
policySetName: string;
options?: PolicyExportOptions;
state: State;
}): Promise<PolicyExportInterface>;
/**
* Import policy by id
* @param {string} policyId policy id
* @param {PolicyExportInterface} importData import data
* @param {PolicyImportOptions} options import options
* @returns {Promise<PolicySkeleton>} imported policy object
*/
export declare function importPolicy({ policyId, importData, options, state, }: {
policyId: string;
importData: PolicyExportInterface;
options?: PolicyImportOptions;
state: State;
}): Promise<PolicySkeleton>;
/**
* Import first policy
* @param {PolicyExportInterface} importData import data
* @param {PolicyImportOptions} options import options
* @returns {Promise<PolicySkeleton>} imported policy object
*/
export declare function importFirstPolicy({ importData, options, state, }: {
importData: PolicyExportInterface;
options?: PolicyImportOptions;
state: State;
}): Promise<PolicySkeleton>;
/**
* Import policies
* @param {PolicyExportInterface} importData import data
* @param {PolicyImportOptions} options import options
* @returns {Promise<PolicySkeleton[]>} array of imported policy objects
*/
export declare function importPolicies({ importData, options, state, }: {
importData: PolicyExportInterface;
options?: PolicyImportOptions;
state: State;
}): Promise<PolicySkeleton[]>;
//# sourceMappingURL=PolicyOps.d.ts.map