Remove Users from an Identity Domain (v1)

Deletes the identity domain accounts identified in an ANSI or UTF-8 encoded CSV file that was uploaded to the environment. Before running this command, use the Upload REST API to upload the file. The file format is as follows:

User Login
jane.doe@example.com
jdoe@example.com

This API should be run only by Service Administrators who are also assigned to the Identity Domain Administrator role in the identity domain from which users are to be removed. The CSV file should not include the account of the user who executes this command. Because user accounts are common to all service environments that an Identity Domain Administrator supports, deleting an account for one environment deletes it for all environments that share the Identity Domain Administrator. With this API, you can see which records failed and the reason why they failed in addition to how many records passed and failed.

The API is asynchronous and returns the Job ID. The presence of status -1 in the response indicates that the removal of users is in progress. Use the job status URI to determine whether the removal of users is complete. Any non-zero status except -1 indicates failure of removing users.

This API is version v1.

Required Roles

Identity Domain Administrator and any predefined role (Service Administrator, Power User, User, or Viewer)

REST Resource

DELETE /interop/rest/security/<api_version>/users?filename=<filename>

Note:

Before using the REST resources, you must understand how to access the REST resources and other important concepts. See Implementation Best Practices for EPM Cloud REST APIs. Using this REST API requires prerequisites. See Prerequisites.

Table 12-8 Tasks for Remove Users from an Identity Domain

Task Request REST Resource
Remove users DELETE /interop/rest/security/<api_version>/users?filename=<filename>
Remove users status GET /interop/rest/security/<api_version>/jobs/

Request

Supported Media Types: application/x-www-form-urlencoded

The following table summarizes the DELETE request parameters.

Table 12-9 Parameters

Name Description Type Required Default
filename

The name of the uploaded ANSI or UTF-8 encoded CSV file name of a CSV file containing the login names of the users to be removed, for example, removeUsers.csv.

Query Yes None

Response

Supported Media Types: application/json

Table 12-10 Parameters

Name Description
details In the case of errors, details are published with the error string
status See Migration Status Codes
links Detailed information about the link
href Links to API call or status API
action The HTTP call type
rel Possible values: self or Job Status. If the value is set to Job Status, you can use the href to get the status
data Parameters as key value pairs passed in the request
items Details about the resource
links Details of the first URL to be requested to get the job details; rel is "Job Details"

Examples of Response Body

The following examples show the contents of the response body in JSON format:

Example 1: Job is in Progress

{
  "links": [
    {
      "rel": "self",
      "href": "https://<BASE-URL>/interop/rest/security/<api_version>/users?filename=<filename>",
      "data": {
        "jobType": "REMOVE_USERS",
        "filename": "<filename>"
      },
      "action": "DELETE"
    },
    {
      "rel": "Job Status",
      "href": "https://<BASE-URL>/interop/rest/security/<api_version>/jobs/",
      "data": null,
      "action": "GET"
    }
  ],
  "details": null,
  "status": -1,
  "items": null
}

Example 2: Job Completes with Errors

{
  "links": [
    {
      "rel": "self",
      "href": "https://<BASE-URL>/interop/rest/security/<api_version>/jobs/",
      "data": null,
      "action": "GET"
    }
  ],
  "details": "Failed to remove users. Input file <filename> is not found. Specify a valid file name.",
  "status": 1,
  "items": null
}

Example 3: Job Completes without Errors

{
  "links": [
    {
      "rel": "self",
      "href": "https://<BASE-URL>/interop/rest/security/<api_version>/jobs/",
      "data": null,
      "action": "GET"
    }
  ],
  "details": "Processed - 3, Succeeded - 1, Failed - 2.",
  "status": 0,
  "items": [
     {
          "UserName":"<USERNAME>","Error_Details": "User <USERNAME> is not found. Verify that the user exists."
    },
}

Java Sample Code

Prerequisites: json.jar

Common Functions: See CSS Common Helper Functions for Java.

public void removeUsers(String fileName) {
		try {
			String url = this.serverUrl + "/interop/rest/security/<api_version>/users";
			Map<String, String> reqHeaders = new HashMap<String, String>();
			reqHeaders.put("Authorization", "Basic " + DatatypeConverter
					.printBase64Binary((this.userName + ":" + this.password).getBytes(Charset.defaultCharset())));

			Map<String, String> reqParams = new HashMap<String, String>();
			reqParams.put("filename", fileName);

			Map<String, String> restResult = CSSRESTHelper.callRestApi(new HashMap(), url, reqHeaders, reqParams,
					"DELETE");
			String jobStatus = CSSRESTHelper.getCSSRESTJobCompletionStatus(restResult, reqHeaders);
			System.out.println(jobStatus);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

Shell Script Sample Code

Prerequisites: jq (http://stedolan.github.io/jq/download/linux64/jq)

Common Functions: See CSS Common Helper Functions for cURL.

funcRemoveUsers() {
        url="$SERVER_URL/interop/rest/security/<api_version>/users"
        params="filename=$1"
        header="Content-Type: application/x-www-form-urlencoded;charset=UTF-8"
        cssRESTAPI="RemoveUsers"
        statusMessage=$(funcCSSRESTHelper "DELETE" "$url" "$header" "$USERNAME" "$PASSWORD" "$params" "$cssRESTAPI")
        echo $statusMessage
}

Groovy Sample Code

CSS Common Helper Functions for Groovy.

def deleteUsers(fileName) {

	String scenario = "Deleting users in " + fileName;
	String params = null;
	def url = null;
	def response = null;
	try {
		url = new URL(serverUrl + "/interop/rest/security/<api_version>/users?filename=" + fileName);
	} catch (MalformedURLException e) {
		println "Please enter a valid URL"
		System.exit(0);
	}
	response = executeRequest(url, "DELETE", null, "application/x-www-form-urlencoded");
	if (response != null) {
		getJobStatus(getUrlFromResponse(scenario, response, "Job Status"), "GET");
	}
}

Common Functions

Sample cURL Command Basic Auth

curl -X DELETE -s -u '<USERNAME>:<PASSWORD>' -H
'Content-Type: application/x-www-form-urlencoded'
'https://<BASE-URL>/interop/rest/security/v1/users?filename=<CSV-FILE-NAME>'

Sample cURL Command OAuth 2.0

curl -X DELETE --header "Authorization: Bearer <OAUTH_ACCESS_TOKEN>" -H
'Content-Type: application/x-www-form-urlencoded' 
'https://<BASE-URL>/interop/rest/security/v1/users?filename=<CSV-FILE-NAME>'