SET PATH *LIBL ; 

CREATE OR REPLACE FUNCTION SAILPOINT.SCALAR_SERVE_OPENAPI_JSON ( ) 
	RETURNS CLOB(2147483647)   
	LANGUAGE SQL 
	SPECIFIC SAILPOINT.SCALARJSON 
	NOT DETERMINISTIC 
	MODIFIES SQL DATA 
	CALLED ON NULL INPUT 
	NOT FENCED 
	SET OPTION  ALWBLK = *ALLREAD , 
	ALWCPYDTA = *OPTIMIZE , 
	COMMIT = *NONE , 
	DECRESULT = (31, 31, 00) , 
	DYNDFTCOL = *NO , 
	DYNUSRPRF = *OWNER , 
	SRTSEQ = *HEX   
	BEGIN 
RETURN 
CISTOOLS . STRIP_SPACES ( 
'      { "swagger": "2.0", "info": { "title": "SailPoint APIs", "description": "APIs available for SailPoint", "version": "1.0.0" }, "basePath": "/rest/api/SailPoint", "schemes": [ "http" ], "tags": [ { "name": "Users - Directory", "description": "Cross-environment user directory operations" }, { "name": "Users - MAPICS", "description": "MAPICS user management and lookup" }, { "name": "Roles - MAPICS", "description": "MAPICS role management" }, { "name": "Users - IBM i", "description": "IBM i user profile management" } ], "paths": { "/v1/users/all": { "post": { "tags": [ "Users - Directory" ], "summary": "List users across environments", "operationId": "getGetAllUsers", "consumes": [ "*/*" ], "produces": [ "application/json" ], "parameters": [ { "name": "inEnvList", "in": "formData", "required": false, "type": "string", "description": "Environment list (CSV or JSON array as string)." } ], "responses": { "200": { "description": "Successful operation", "schema": { "$ref": "#/definitions/AllUsersResponse" } }, "400": { "description": "Bad request", "schema": { "$ref": "#/definitions/ErrorResponse" } }, "500": { "description": "Unsuccessful operation", "schema": { "$ref": "#/definitions/ErrorResponse" } } } } }, "/v1/roles/mapics/{envId}": { "post": { "tags": [ "Roles - MAPICS" ], "summary": "List MAPICS roles", "operationId": "getGetAllMapicsRoles", "consumes": [ "*/*" ], "produces": [ "application/json" ], "parameters": [ { "name": "envId", "in": "path", "required": true, "type": "string", "description": "Environment identifier." } ], "responses": { "200": { "description": "Successful operation", "schema": { "$ref": "#/definitions/MapicsRolesResponse" }}, "400": { "description": "Bad request", "schema": { "$ref": "#/definitions/ErrorResponse" } }, "500": { "description": "Unsuccessful operation", "schema": { "$ref": "#/definitions/ErrorResponse" } } } } }, "/v1/users/mapics/{envId}": { "post": { "tags": [ "Users - MAPICS" ], "summary": "List MAPICS users", "operationId": "getGetAllAppUsers", "consumes": [ "*/*" ], "produces": [ "application/json" ], "parameters": [ { "name": "envId", "in": "path", "required": true, "type":"string", "description": "Environment identifier." } ], "responses": { "200": {"description": "Successful operation", "schema": { "$ref": "#/definitions/MapicsUsersListResponse" } }, "400": { "description": "Bad request", "schema": { "$ref": "#/definitions/ErrorResponse" } }, "500": { "description": "Unsuccessful operation", "schema": { "$ref": "#/definitions/ErrorResponse" } } } } }, "/v1/users/mapics/{envId}/{nameOrId}": { "post": { "tags": [ "Users - MAPICS" ], "summary":"Get MAPICS user details", "operationId": "getGetAppUserInfo", "consumes": [ "*/*" ], "produces": [ "application/json" ], "parameters": [ { "name": "envId", "in": "path", "required": true, "type": "string", "description": "Environment identifier." }, { "name": "nameOrId", "in": "path", "required": true, "type": "string", "description": "MAPICS user name or id." } ], "responses": { "200": { "description": "Successful operation", "schema": { "$ref": "#/definitions/MapicsUserInfoResponse" } }, "400": { "description": "Bad request", "schema": { "$ref": "#/definitions/ErrorResponse" } }, "404": { "description": "User not found", "schema": { "$ref": "#/definitions/ErrorResponse" } }, "500": { "description": "Unsuccessful operation", "schema": { "$ref": "#/definitions/ErrorResponse" } } } } }, "/v1/users/mapics/{envId}/{userName}/roles/assign": { "post": { "tags": [ "Roles- MAPICS" ], "summary": "Assign roles to MAPICS user", "operationId": "getAssignUserRoles", "consumes": [ "*/*" ], "produces": [ "application/json" ], "parameters": [ { "name": "envId", "in": "path", "required": true, "type": "string", "description": "Environment identifier." }, { "name": "userName", "in": "path", "required": true, "type": "string", "description": "MAPICS username." }, { "name": "userRoles", "in": "formData", "required": true, "type": "string", "description":"Roles to assign." } ], "responses": { "200": { "description": "Successful operation", "schema": { "$ref": "#/definitions/RoleAssignmentResponse" } }, "400": {"description": "Bad request", "schema": { "$ref": "#/definitions/ErrorResponse"} }, "500": { "description": "Unsuccessful operation", "schema": { "$ref": "#/definitions/ErrorResponse" } } } } }, "/v1/users/mapics/{envId}/{userName}/roles/remove": { "post": { "tags": [ "Roles - MAPICS" ], "summary": "Remove roles fromMAPICS user", "operationId": "getRemoveUserRoles", "consumes": [ "*/*" ], "produces": [ "application/json" ], "parameters": [ { "name": "envId", "in": "path","required": true, "type": "string", "description": "Environment identifier." },{ "name": "userName", "in": "path", "required": true, "type": "string", "description": "MAPICS username." }, { "name": "userRoles", "in": "formData", "required": true, "type": "string", "description": "Roles to remove." } ], "responses": {"200": { "description": "Successful operation", "schema": { "$ref": "#/definitions/RoleAssignmentResponse" } }, "400": { "description": "Bad request", "schema":{ "$ref": "#/definitions/ErrorResponse" } }, "500": { "description": "Unsuccessful operation", "schema": { "$ref": "#/definitions/ErrorResponse" } } } } }, "/v1/users/mapics/{envId}/create": { "post": { "tags": [ "Users - MAPICS" ], "summary": "Create MAPICS user", "operationId": "getCreateMapicsUser", "consumes": [ "*/*" ], "produces": [ "application/json" ], "parameters": [ { "name": "envId", "in": "path", "required": true, "type": "string", "description": "Environment identifier." }, { "name": "userName", "in": "formData", "required": true, "type": "string", "description": "MAPICS username." }, { "name": "userRoles", "in": "formData", "required": false, "type": "string", "description": "Roles to assign." },{ "name": "userDept", "in": "formData", "required": false, "type": "string", "description": "User department." }, { "name": "userEmpNo", "in": "formData", "required": false, "type": "string", "description": "User employee number." } ], "responses": { "201": { "description": "Successful operation", "schema": { "$ref":"#/definitions/RoleAssignmentResponse" } }, "400": { "description": "Bad request", "schema": { "$ref": "#/definitions/ErrorResponse" } }, "500": { "description": "Unsuccessful operation", "schema": { "$ref": "#/definitions/ErrorResponse" }} } } }, "/v1/users/mapics/{envId}/{userName}/remove": { "post": { "tags": [ "Users - MAPICS" ], "summary": "Remove MAPICS user", "operationId": "getRemoveMapicsUser", "consumes": [ "*/*" ], "produces": [ "application/json" ], "parameters":[ { "name": "envId", "in": "path", "required": true, "type": "string", "description": "Environment identifier." }, { "name": "userName", "in": "path", "required": true, "type": "string", "description": "MAPICS username." } ], "responses":{ "200": { "description": "Successful operation", "schema": { "$ref": "#/definitions/MapicsUserRemovalResponse" } }, "400": { "description": "Bad request", "schema": { "$ref": "#/definitions/ErrorResponse" } }, "500": { "description": "Unsuccessful operation", "schema": { "$ref": "#/definitions/ErrorResponse" } } } } }, "/v1/users/mapics/{envId}/{userName}/disable": { "post": { "tags": [ "Users -MAPICS" ], "summary": "Disable MAPICS user", "operationId": "getDisableMapicsUser", "consumes": [ "*/*" ], "produces": [ "application/json" ], "parameters": [ {"name": "envId", "in": "path", "required": true, "type": "string", "description": "Environment identifier." }, { "name": "userName", "in": "path", "required":true, "type": "string", "description": "MAPICS username." } ], "responses": { "200": { "description": "Successful operation", "schema": { "$ref": "#/definitions/SuccessResponse" } }, "400": { "description": "Bad request", "schema": { "$ref": "#/definitions/ErrorResponse" } }, "500": { "description": "Unsuccessful operation", "schema": { "$ref": "#/definitions/ErrorResponse" } } } } }, "/v1/users/mapics/{envId}/{userName}/enable": { "post": { "tags": [ "Users - MAPICS" ], "summary": "Enable MAPICS user", "operationId": "getEnableMapicsUser", "consumes": ["*/*" ], "produces": [ "application/json" ], "parameters": [ { "name": "envId","in": "path", "required": true, "type": "string", "description": "Environment identifier." }, { "name": "userName", "in": "path", "required": true, "type": "string", "description": "MAPICS username." } ], "responses": { "200": { "description": "Successful operation", "schema": { "$ref": "#/definitions/SuccessResponse"} }, "400": { "description": "Bad request", "schema": { "$ref": "#/definitions/ErrorResponse" } }, "500": { "description": "Unsuccessful operation", "schema":{ "$ref": "#/definitions/ErrorResponse" } } } } }, "/v1/users/ibmi/{authorizationName}/enable": { "post": { "tags": [ "Users - IBM i" ], "summary": "Enable IBMi user", "operationId": "getEnableIbmIUser", "consumes": [ "*/*" ], "produces":[ "application/json" ], "parameters": [ { "name": "authorizationName", "in": "path", "required": true, "type": "string", "description": "IBM i authorization name." } ], "responses": { "200": { "description": "Successful operation", "schema": { "$ref": "#/definitions/IbmIUserStatusResponse" } }, "400": { "description":"Bad request", "schema": { "$ref": "#/definitions/ErrorResponse" } }, "500": { "description": "Unsuccessful operation", "schema": { "$ref": "#/definitions/ErrorResponse" } } } } }, "/v1/users/ibmi/{authorizationName}/disable": { "post": { "tags": [ "Users - IBM i" ], "summary": "Disable IBM i user", "operationId": "getDisableIbmIUser", "consumes": [ "*/*" ], "produces": [ "application/json" ], "parameters": [ { "name": "authorizationName", "in": "path", "required": true, "type": "string", "description": "IBM i authorization name." } ], "responses": { "200": { "description": "Successful operation", "schema": { "$ref": "#/definitions/IbmIUserStatusResponse" } }, "400": { "description": "Bad request", "schema": {"$ref": "#/definitions/ErrorResponse" } }, "500": { "description": "Unsuccessfuloperation", "schema": { "$ref": "#/definitions/ErrorResponse" } } } } }, "/v1/users/ibmi/{nameOrId}": { "post": { "tags": [ "Users - IBM i" ], "summary": "GetIBM i user details", "operationId": "getGetIbmIUserInfo", "consumes": [ "*/*" ],"produces": [ "application/json" ], "parameters": [ { "name": "nameOrId", "in":"path", "required": true, "type": "string", "description": "IBM i user name orid." } ], "responses": { "200": { "description": "Successful operation", "schema": { "$ref": "#/definitions/IbmIUserInfoResponse" } }, "400": { "description": "Bad request", "schema": { "$ref": "#/definitions/ErrorResponse" } }, "404": { "description": "User not found", "schema": { "$ref": "#/definitions/ErrorResponse"} }, "500": { "description": "Unsuccessful operation", "schema": { "$ref": "#/definitions/ErrorResponse" } } } } }, "/v1/users/ibmi/create": { "post": { "tags": [ "Users - IBM i" ], "summary": "Create IBM i user", "operationId": "getCreateIbmIUser", "consumes": [ "*/*" ], "produces": [ "application/json" ], "parameters": [ { "name": "authorizationName", "in": "formData", "required": true, "type":"string", "description": "IBM i authorization name." }, { "name": "textDescription", "in": "formData", "required": false, "type": "string", "description": "Text description." }, { "name": "userClassName", "in": "formData", "required": false, "type": "string", "description": "User class." }, { "name": "status", "in": "formData", "required": false, "type": "string", "description": "Status." }, { "name": "setPasswordToExpire", "in": "formData", "required": false, "type": "string", "description": "Password expire flag." }, { "name": "userOwner", "in": "formData", "required": false, "type": "string", "description": "Owner." }, { "name":"groupProfileName", "in": "formData", "required": false, "type": "string", "description": "Group profile." }, { "name": "accountingCode", "in": "formData", "required": false, "type": "string", "description": "Accounting code." }, { "name":"jobDescriptionName", "in": "formData", "required": false, "type": "string", "description": "Job description." }, { "name": "outputQueueName", "in": "formData", "required": false, "type": "string", "description": "Output queue." }, { "name": "messageQueueName", "in": "formData", "required": false, "type": "string", "description": "Message queue." }, { "name": "limitCapabilities", "in": "formData", "required": false, "type": "string", "description": "Limit capabilities." }, {"name": "specialAuthoritiesJson", "in": "formData", "required": false, "type":"string", "description": "Special authorities JSON." } ], "responses": { "201":{ "description": "Successful operation", "schema": { "$ref": "#/definitions/IbmIUserCreateResponse" } }, "400": { "description": "Bad request", "schema": { "$ref": "#/definitions/ErrorResponse" } }, "500": { "description": "Unsuccessful operation", "schema": { "$ref": "#/definitions/ErrorResponse" } } } } }, "/v1/users/ibmi/{authorizationName}/change": { "post": { "tags": [ "Users - IBM i" ], "summary": "Change IBM i user", "operationId": "getChangeIbmIUser", "consumes": [ "*/*" ], "produces": [ "application/json" ], "parameters": [ { "name": "authorizationName", "in": "path", "required": true, "type": "string", "description": "Authorization name." }, { "name": "textDescription", "in": "formData", "required": false, "type": "string", "description": "Text description." }, { "name": "userClassName", "in": "formData", "required": false, "type": "string", "description": "User class." }, { "name": "status", "in": "formData", "required": false, "type":"string", "description": "Status." }, { "name": "setPasswordToExpire", "in": "formData", "required": false, "type": "string", "description": "Password expire flag." }, { "name": "userOwner", "in": "formData", "required": false, "type": "string", "description": "Owner." }, { "name": "groupProfileName", "in": "formData", "required": false, "type": "string", "description": "Group profile." }, { "name": "accountingCode", "in": "formData", "required": false, "type": "string", "description": "Accounting code." }, { "name": "jobDescriptionName", "in": "formData", "required": false, "type": "string", "description": "Job description." }, {"name": "outputQueueName", "in": "formData", "required": false, "type": "string", "description": "Output queue." }, { "name": "messageQueueName", "in": "formData", "required": false, "type": "string", "description": "Message queue." }, { "name": "limitCapabilities", "in": "formData", "required": false, "type": "string", "description": "Limit capabilities." }, { "name": "specialAuthoritiesJson", "in": "formData", "required": false, "type": "string", "description": "Special authorities JSON." }, { "name": "homeDirectory", "in": "formData", "required": false, "type": "string", "description": "Home directory." } ], "responses": { "200":{ "description": "Successful operation", "schema": { "$ref": "#/definitions/IbmIUserChangeResponse" } }, "400": { "description": "Bad request", "schema": { "$ref": "#/definitions/ErrorResponse" } }, "500": { "description": "Unsuccessful operation", "schema": { "$ref": "#/definitions/ErrorResponse" } } } } } }, "definitions": { "SuccessResponse": { "type": "object", "properties": { "success": { "type": "string", "description": "Operation success indicator" }, "data": { "type": "object", "description": "Response data" } } }, "ErrorResponse": { "type": "object", "properties": { "success": { "type": "string", "description": "Operationsuccess indicator" }, "SQLInfo": { "type": "object", "properties": { "SQLState":{ "type": "string", "description": "State code" }, "SQLCode": { "type": "integer", "description": "Error code" }, "messageID": { "type": "string", "description": "Message identifier" }, "message": { "type": "string", "description": "Errormessage text" }, "currentTimestamp": { "type": "string", "format": "date-time","description": "Timestamp of error" } } } } }, "AllUsersResponse": { "type": "object", "properties": { "status": { "type": "string", "description": "Operation status" }, "data": { "type": "array", "items": { "$ref": "#/definitions/UserWithAttributes" } } } }, "UserWithAttributes": { "type": "object", "properties": { "userId": { "type": "string", "description": "User identifier" }, "status": { "type": "string", "description": "User status" }, "previousSignOn": { "type": "string", "description": "Previous sign-on timestamp" }, "signonInvalidAttempts": { "type": "integer", "description": "Number of invalid sign-on attempts" }, "userClass": { "type": "string", "description": "User class" }, "specialAuths": { "type": "array", "items": { "type": "string" }, "description": "Special authorities" }, "groupProfile": { "type": "string", "description": "Group profile name" }, "daysUntilPwExpires": { "type": "integer", "description": "Days until password expires" }, "text": { "type": "string", "description": "User description text" }, "homeDir": { "type": "string", "description": "Home directory path" }, "locale": {"type": "string", "description": "Locale path" }, "localPwMgmt": { "type": "string", "description": "Local password management setting" }, "mapicsAttributes":{ "type": "array", "items": { "type": "object" }, "description": "Application-specific attributes" } } }, "MapicsRolesResponse": { "type": "object", "properties": { "success": { "type": "string", "description": "Operation success indicator"}, "data": { "type": "object", "description": "Role definitions", "additionalProperties": { "type": "string" } } } }, "MapicsUsersListResponse": { "type": "object", "properties": { "success": { "type": "string", "description": "Operation success indicator" }, "data": { "type": "array", "items": { "$ref": "#/definitions/MapicsUserSummary" } } } }, "MapicsUserSummary": { "type": "object", "properties": { "userId": { "type": "string", "description": "User identifier" }, "userName": { "type": "string", "description": "User display name" }, "userType": { "type": "string", "description": "User type classification" }, "userDept": { "type": "object", "description": "Department information" }, "status": { "type": "string", "description": "User status" } } }, "MapicsUserInfoResponse": { "type": "object", "properties": { "success": { "type": "string", "description": "Operationsuccess indicator" }, "data": { "type": "array", "items": { "$ref": "#/definitions/MapicsUserDetails" } } } }, "MapicsUserDetails": { "type": "object", "properties": { "envId": { "type": "string", "description": "Environment identifier" },"userId": { "type": "string", "description": "User identifier" }, "userName": {"type": "string", "description": "User display name" }, "operatorId": { "type":"string", "description": "Operator identifier" }, "userType": { "type": "string", "description": "User type classification" }, "userDept": { "type": "object", "description": "Department information" }, "userEmpNo": { "type": "string", "description": "Employee number" }, "status": { "type": "string", "description": "User status" }, "startMenu": { "type": "string", "description": "Start menu configuration" }, "roles": { "type": "array", "items": { "type": "object" }, "description": "Assigned roles" }, "isGroupId": { "type": "string", "description": "Groupidentifier flag" } } }, "RoleAssignmentResponse": { "type": "object", "properties": { "success": { "type": "string", "description": "Operation success indicator" }, "data": { "type": "array", "items": { "$ref": "#/definitions/UserRoles" } }} }, "UserRoles": { "type": "object", "properties": { "userId": { "type": "string", "description": "User identifier" }, "roles": { "type": "object", "description": "Role assignments", "additionalProperties": { "type": "string" } } } }, "MapicsUserRemovalResponse": { "type": "object", "properties": { "success": { "type": "string", "description": "Operation success indicator" }, "data": { "type": "string", "description": "Operation result message" } } }, "IbmIUserStatusResponse": { "type": "object", "properties": { "success": { "type": "string", "description": "Operation success indicator" }, "data": { "type": "object", "properties":{ "authorizationName": { "type": "string", "description": "Authorization name"}, "status": { "type": "string", "description": "User status" }, "lastUsedTimestamp": { "type": "string", "format": "date-time", "description": "Last used timestamp" } } } } }, "IbmIUserInfoResponse": { "type": "object", "properties": { "success": { "type": "string", "description": "Operation success indicator" }, "data": { "type": "array", "items": { "$ref": "#/definitions/IbmIUserInfo" } } } },"IbmIUserInfo": { "type": "object", "properties": { "userId": { "type": "string", "description": "User identifier" }, "status": { "type": "string", "description": "User status" }, "previousSignOn": { "type": "string", "description": "Previous sign-on timestamp" }, "signonInvalidAttempts": { "type": "integer", "description": "Invalid sign-on attempts" }, "userClass": { "type": "string", "description": "User class" }, "specialAuths": { "type": "array", "items": { "type": "string" }, "description": "Special authorities" }, "groupProfile": { "type": "string", "description": "Group profile name" }, "daysUntilPwExpires": { "type": "integer", "description": "Days until password expires" }, "text": { "type": "string","description": "User description" }, "homeDir": { "type": "string", "description": "Home directory path" }, "locale": { "type": "string", "description": "Localepath" }, "localPwMgmt": { "type": "string", "description": "Local password management" } } }, "IbmIUserCreateResponse": { "type": "object", "properties": { "success": { "type": "string", "description": "Operation success indicator" }, "data": { "type": "object", "properties": { "authorizationName": { "type": "string","description": "Authorization name" }, "tempPassword": { "type": "string", "description": "Temporary password" }, "textDescription": { "type": "string", "description": "Text description" }, "userClassName": { "type": "string", "description": "User class name" }, "status": { "type": "string", "description": "User status" }, "userOwner": { "type": "string", "description": "User owner" }, "groupProfileName": { "type": "string", "description": "Group profile name" }, "accountingCode": { "type": "string", "description": "Accounting code" }, "homeDirectory":{ "type": "string", "description": "Home directory path" }, "limitCapabilities":{ "type": "string", "description": "Capability limitations" }, "specialAuthorities": { "type": "array", "items": { "type": "string" }, "description": "Specialauthorities" }, "creationTimestamp": { "type": "string", "format": "date-time","description": "Creation timestamp" } } } } }, "IbmIUserChangeResponse": { "type": "object", "properties": { "success": { "type": "string", "description": "Operation success indicator" }, "authorizationName": { "type": "string", "description": "Authorization name" }, "textDescription": { "type": "string", "description": "Text description" }, "userClassName": { "type": "string", "description": "User class name" }, "status": { "type": "string", "description": "User status" }, "groupProfileName": { "type": "string", "description": "Group profile name" }, "homeDirectory": { "type": "string", "description": "Home directory path" }, "specialAuthorities": { "type": "array", "items": { "type": "string" }, "description": "Special authorities" }, "lastUsedTimestamp": { "type": "string", "format": "date-time", "description": "Last used timestamp" } } } } }' 
) ; 
END  ; 

GRANT ALTER , EXECUTE   
ON SPECIFIC FUNCTION SAILPOINT.SCALARJSON 
TO AMAPICS WITH GRANT OPTION ; 

GRANT EXECUTE   
ON SPECIFIC FUNCTION SAILPOINT.SCALARJSON 
TO PUBLIC ; 

