Skip to main content
Version: v5.2

IafApplication

Use the IafApplication API to manage applications and application users on the platform.

getAppAdminsUserGroup

Gets the App Admins platform-role user group for the application.

ParameterRequiredTypeDescription
ctxNoCtxContext storage that contains data, such as authorization token requirements, namespaces, or session storage. Optional; when omitted, the current session context is used.
Returns

Promise<UserGroup> - Resolves with the App Admins UserGroup when it exists; returns undefined when the group has not been provisioned.

Examples
await IafApplication.getAppAdminsUserGroup(ctx);

getAppDeveloperUserGroup

Gets the App Developer platform-role user group for the application.

ParameterRequiredTypeDescription
ctxNoCtxContext storage that contains data, such as authorization token requirements, namespaces, or session storage. Optional; when omitted, the current session context is used.
Returns

Promise<UserGroup> - Resolves with the App Developer UserGroup when it exists; returns undefined when the group has not been provisioned.

Examples
const developerGroup = await IafApplication.getAppDeveloperUserGroup(ctx);

getApplications

Gets the session user's Application class objects.

ParameterRequiredTypeDescription
criteriaNoApplicationPass a JSON object to filter results by a supported Application field, such as _id, _name, _shortName, _userType, or _orgId (e.g. { _name: "my_app" }).
ctxNoCtxContext storage that contains data, such as authorization token requirements, namespaces, or session storage.
optionsNoOptionsPass an Options class object with one or more response pagination parameters, such as _offset and _pageSize. The default value for _offset is 0 and for _pageSize is 10.
Returns

Promise<Array<Application>> - An array of Application class objects

Examples
let criteria = {
_name: "my_app"
};
let options = {
_offset: 3,
_pageSize: 15
};

const userApps = await IafApplication.getApplications(criteria, ctx, options);

getAppOwnerUserGroup

Gets the App Owner platform-role user group for the application.

ParameterRequiredTypeDescription
ctxNoCtxContext storage that contains data, such as authorization token requirements, namespaces, or session storage. Optional; when omitted, the current session context is used.
Returns

Promise<UserGroup> - Resolves with the App Owner UserGroup when it exists; returns undefined when the group has not been provisioned.

Examples
const ownerGroup = await IafApplication.getAppOwnerUserGroup(ctx);

getById

Gets an Application class object when you pass its id.

ParameterRequiredTypeDescription
idYesStringPass the application's id.
ctxNoCtxContext storage that contains data, such as authorization token requirements, namespaces, or session storage.
optionsNoOptionsPass an Options class object.
Returns

Promise<Application> - Application, 404 response if not found

Examples
let options = {
withConfigs: true
};

const app = await IafApplication.getById('abc123', ctx, options);

promoteUserAsAppOwner

Grants the App Owner platform role to a user for the specified application.

ParameterRequiredTypeDescription
appIdYesStringPass the Application class object's id.
userIdYesStringThe User class object's id.
ctxNoCtxContext storage that contains data, such as authorization token requirements, namespaces, or session storage.
Returns

Promise<void> -

Examples
await IafApplication.promoteUserAsAppOwner(appId, userId);

revokeAppOwner

Removes the App Owner platform role from a user for the specified application.

ParameterRequiredTypeDescription
appIdYesStringPass the application's id.
userIdYesStringPass the user's id.
ctxNoCtxContext storage that contains data, such as authorization token requirements, namespaces, or session storage.
Returns

Promise<void> -

Examples
await IafApplication.revokeAppOwner(appId, userId);

switchApplication

Sets your Application class object as the current application in ctx storage.

ParameterRequiredTypeDescription
idYesStringPass the app's UUID.
ctxNoCtxContext storage that contains data, such as authorization token requirements, namespaces, or session storage.
Returns

Promise<void> - Resolves once the application has been switched; no value is returned. As a side effect, sets the new app-specific auth token on (when is provided) and in session storage, so subsequent calls authenticate against the new application.

Examples
const res = await IafApplication.switchApplication(app._id, ctx);

updateApplication

Updates an Application class object.

ParameterRequiredTypeDescription
appYesApplicationPass an Application class object with updated properties or values.
ctxNoCtxContext storage that contains data, such as authorization token requirements, namespaces, or session storage.
Returns

Promise<Application> - Returns the updated Application object or a 404 response if the application is not found.

Examples
app._name = "new_app_name";

const updatedApp = await IafApplication.updateApplication(app);