Skip to main content
Version: v5.0

IafObjectModelAPISvc

addApiConfig#

Add an API config definition

ParameterRequiredTypeDescription
configIdYesStringThe API config id
ctxYesCtxContext, such as namespaces and authentication token information
Returns

Promise<Object> - Success or failure message

Examples
const response = await IafObjectModelAPISvc.addApiConfig(config._id, ctx);

deleteApiConfig#

Deletes am API config definition

ParameterRequiredTypeDescription
namespaceYesStringNamespace as string
ctxYesCtxContext, such as namespaces and authentication token information
Returns

Promise<Object> - Success or failure message

Examples
const response = await IafObjectModelAPISvc.deleteApiConfig(namespace, ctx);

deletePermission#

Deletes a permission when you pass its id

ParameterRequiredTypeDescription
idYesStringPermission id
ctxYesCtxContext, such as namespaces and authentication token information
Returns

Promise<String> - ok:204 response

Examples
const response = await IafObjectModelAPISvc.deletePermission(perm._id, ctx);

getApiConfig#

Get an API config definition

ParameterRequiredTypeDescription
criteriaYesObjectA criteria object with _isconfigadded or _tobedeleted flag
ctxYesCtxContext, such as namespaces and authentication token information
Returns

Promise<Object> - Api config definition

getPermissions#

Gets permissions for an API config definition

ParameterRequiredTypeDescription
criteriaYesPermissionCriteriaCriteria to fetch permissions
ctxYesCtxContext, such as namespaces and authentication token information
Returns

Promise<Page<Permission>> - A promise with a page of Permission objects

Examples
const criteria = {  _namespace: project._namespaces[0]};
const permissions = await IafObjectModelAPISvc.getPermissions(criteria, ctx);

getRequestById#

Retrieve the OMAPI request for the specified request ID

ParameterRequiredTypeDescription
reqIdYesStringOMAPI request id
ctxYesCtxContext, such as namespaces and authentication token information
Returns

Promise<Object> -

getRequestLogById#

Retrieve the OMAPI request log for the specified request ID

ParameterRequiredTypeDescription
reqIdYesStringOMAPI request id
ctxYesCtxContext, such as namespaces and authentication token information
optionsNoObjectPass an options object with the format and scriptDetails options you require.
Returns

Promise<Object> -

Examples
let requestId = '0e97fcaf-f190-43f0-a1e9-d7a09e347893'let options = {     format: 'json', // Get the response in JSON format     scriptDetails: true, // Attempt to fetch script details; works only when the response is in JSON format}let requests = await IafObjectModelAPISvc.getRequestLogById(requestId, ctx, options)

getRequests#

Retrieve the OMAPI requests for the criteria

ParameterRequiredTypeDescription
criteriaYesObjectA criteria object like this {query: {key: value}}, key can be any one of below
_requestid, _status, _jobid, _namespace, _apiconfigid, _scriptid
ctxYesCtxContext, such as namespaces and authentication token information
optionsNoObjectPass an options object with the page options you require.
Returns

Promise<Object> -

Examples
let criteria = {     query:{         _status: 0    }}
let options = {     page: {_offset: 0, _pageSize: 100}}let requests = await IafObjectModelAPISvc.getRequests(criteria, ctx, options)

getScriptExecutionLogsByJobId#

Get the logs of a specific script execution by job id

ParameterRequiredTypeDescription
jobIdYesStringid of the job
ctxYesCtxContext, such as namespaces and authentication token information
optionsYesObject{headers: {X-ObjectModelSvc-Client-Id: value1, X-ObjectModelSvc-Noauth-Secret: value2}}
Returns

Promise<Object> - the logs of a particular job

getScriptExecutionResults#

Get the result of script execution

ParameterRequiredTypeDescription
criteriaYesObjectA criteria object like this {query: {key: value}}, key can be any one of below
scriptInfo, _status,_jobid, _namespace, _headers._createdby,_headers._source
ctxYesCtxContext, such as namespaces and authentication token information
optionsYesObject{headers: {X-ObjectModelSvc-Client-Id: value1, X-ObjectModelSvc-Noauth-Secret: value2}}
Returns

Promise<Object> -

updatePermissions#

Updates permissions for an Object Model Service resource, such as an API config definition, or creates a permission doesn't exist. The _resourceDesc, _namespace, _user properties are used to identify if a permission exists or not.

ParameterRequiredTypeDescription
permissionsYesArray<Permission>Array of Permission objects
ctxYesCtxContext, such as namespaces and authentication token information
Returns

Promise<CreatePermissionsResponse> - A promise with success and failure permissions

Examples
permissions.forEach( perm =>  perm._namespace = project._namespaces[0];);
const response = await IafObjectModelAPISvc.updatePermissions(permissions, ctx);