Create and Modify Lists

You can create several types of lists that are used to configure protection modules: directory lists, file extension lists, file lists, IP lists, MAC lists, and port lists. The way that you create each list is very similar:

  1. Create the list object.
  2. Set general properties such as the name and description.
  3. Add items to the list. The type of list determines the nature of the item that you add.
  4. Use the API object that is associated with the list object to add the list to Deep Security Manager. For example, you use a DirectoryListsApi object to add a directory list.

To modify a list, you obtain the list, modify it, then update the list. Like any other object, to obtain the list you can search, get the list by ID, or get all lists and cycle through them to find a particular list.

The following example adds a directory to a directory list.

Python

source

dir_list = api.DirectoryList()
dir_lists_api = api.DirectoryListsApi(api.ApiClient(configuration))
try:
    dir_lists = dir_lists_api.list_directory_lists(api_version)
    for dir in dir_lists.directory_lists:
        if dir.name == dir_list_name:
            dir_list.dir_list = dir
    # Create the directory list if dir_list_name was not found
    if dir_list.name == None:
        dir_list.name = dir_list_name
        dir_list = dir_lists_api.create_directory_list(dir_list, api_version)
    dir_list_with_directory = api.DirectoryList()
    dir_list_with_directory.items = dir_path
    return dir_lists_api.modify_directory_list(dir_list.id, dir_list_with_directory, api_version)
except api_exception as e:
    return "Exception: " + str(e)
JavaScript

source

exports.addItemToDirectoryList = function(api, dirListID, dirPath, apiVersion) {
  return new Promise((resolve, reject) => {
    getDirList(api, dirListID, apiVersion).then(dirList => addDirPath(api, dirList, dirPath, apiVersion)).then(data => {
        resolve(data);})
      .catch(error => {
            reject(error);
      });
  });
};//getDirList(api, dirListID, apiVersion) {
    const directoryListsApi = new api.DirectoryListsApi();
    return directoryListsApi.describeDirectoryList(dirListID, apiVersion);
}addDirPath(api, list, dirPath, apiVersion) {{
    if (!list.ID) {
      throw { error: true, message: "Directory list ID is required" };
    }
  } catch (error) {
    return error;
  }= new api.DirectoryList();
  dirList.items = list.items;
  dirList.items.push(dirPath);= new api.DirectoryListsApi();
  return directoryListsApi.modifyDirectoryList(list.ID, dirList, apiVersion);
}
Java

source

// Obtain the directory list if it exists
DirectoryListsApi dirListsApi = new DirectoryListsApi();
DirectoryList dirList = dirListsApi.describeDirectoryList(dirListID, apiVersion);= new DirectoryList();
dirListWithDirectory.setItems(dirList.getItems());
dirListWithDirectory.addItemsItem(dirPath);= dirListsApi.modifyDirectoryList(dirList.getID(), dirListWithDirectory, apiVersion);
Also see the Modify a Directory List operation in the API Reference. For information about authenticating API calls, see Authenticate with Deep Security Manager.