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.
| Parameter | Required | Type | Description |
|---|---|---|---|
| ctx | No | Ctx | Context storage that contains data, such as authorization token requirements, namespaces, or session storage. Optional; when omitted, the current session context is used. |
Promise<UserGroup> - Resolves with the App Admins UserGroup when it exists; returns undefined when the group has not been provisioned.
await IafApplication.getAppAdminsUserGroup(ctx);
getAppDeveloperUserGroup
Gets the App Developer platform-role user group for the application.
| Parameter | Required | Type | Description |
|---|---|---|---|
| ctx | No | Ctx | Context storage that contains data, such as authorization token requirements, namespaces, or session storage. Optional; when omitted, the current session context is used. |
Promise<UserGroup> - Resolves with the App Developer UserGroup when it exists; returns undefined when the group has not been provisioned.
const developerGroup = await IafApplication.getAppDeveloperUserGroup(ctx);
getApplications
Gets the session user's Application class objects.
| Parameter | Required | Type | Description |
|---|---|---|---|
| criteria | No | Application | Pass a JSON object to filter results by a supported Application field, such as _id, _name, _shortName, _userType, or _orgId (e.g. { _name: "my_app" }). |
| ctx | No | Ctx | Context storage that contains data, such as authorization token requirements, namespaces, or session storage. |
| options | No | Options | Pass 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. |
Promise<Array<Application>> - An array of Application class objects
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.
| Parameter | Required | Type | Description |
|---|---|---|---|
| ctx | No | Ctx | Context storage that contains data, such as authorization token requirements, namespaces, or session storage. Optional; when omitted, the current session context is used. |
Promise<UserGroup> - Resolves with the App Owner UserGroup when it exists; returns undefined when the group has not been provisioned.
const ownerGroup = await IafApplication.getAppOwnerUserGroup(ctx);
getById
Gets an Application class object when you pass its id.
| Parameter | Required | Type | Description |
|---|---|---|---|
| id | Yes | String | Pass the application's id. |
| ctx | No | Ctx | Context storage that contains data, such as authorization token requirements, namespaces, or session storage. |
| options | No | Options | Pass an Options class object. |
Promise<Application> - Application, 404 response if not found
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.
| Parameter | Required | Type | Description |
|---|---|---|---|
| appId | Yes | String | Pass the Application class object's id. |
| userId | Yes | String | The User class object's id. |
| ctx | No | Ctx | Context storage that contains data, such as authorization token requirements, namespaces, or session storage. |
await IafApplication.promoteUserAsAppOwner(appId, userId);
revokeAppOwner
Removes the App Owner platform role from a user for the specified application.
| Parameter | Required | Type | Description |
|---|---|---|---|
| appId | Yes | String | Pass the application's id. |
| userId | Yes | String | Pass the user's id. |
| ctx | No | Ctx | Context storage that contains data, such as authorization token requirements, namespaces, or session storage. |
await IafApplication.revokeAppOwner(appId, userId);
switchApplication
Sets your Application class object as the current application in ctx storage.
| Parameter | Required | Type | Description |
|---|---|---|---|
| id | Yes | String | Pass the app's UUID. |
| ctx | No | Ctx | Context storage that contains data, such as authorization token requirements, namespaces, or session storage. |
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.
const res = await IafApplication.switchApplication(app._id, ctx);
updateApplication
Updates an Application class object.
| Parameter | Required | Type | Description |
|---|---|---|---|
| app | Yes | Application | Pass an Application class object with updated properties or values. |
| ctx | No | Ctx | Context storage that contains data, such as authorization token requirements, namespaces, or session storage. |
Promise<Application> - Returns the updated Application object or a 404 response if the application is not found.
app._name = "new_app_name";
const updatedApp = await IafApplication.updateApplication(app);