Add Computers
You can use the API to add computers to Deep Security Manager as part of the process of protecting new assets.
Before using the API, consider using the following types of scheduled tasks to automatically discover and add computers:
- Discover Computers
- Synchronize Cloud Account
- Synchronize Directory
- Synchronize VMware vCenter
Use the following general procedure to add a computer:
- Create a
Computer
object and set the hostname. The hostname is the only required property. The value must be the hostname or IP address that resolves to the computer.
Pythoncomputer = api.Computer() computer.host_name = hostname
JavaScriptconst computer = new api.Computer(); computer.hostName = hostname;
JavaComputer computer = new Computer(); computer.setHostName(hostname);
- Configure any other properties as you desire. See the [Create a Computer](../api-reference/#operation/createComputer) operation in the API Reference for the available properties.
- Create a
ComputersApi
object and use it to create the computer on Deep Security Manager.
Pythoncomputers_api = api.ComputersApi(api.ApiClient(configuration)) new_computer = computers_api.create_computer(computer, api_version)
JavaScriptconst computersApi = new api.ComputersApi(); return computersApi.createComputer(computer, apiVersion, { overrides: false });
JavaComputersApi computersApi = new ComputersApi(); Expand = new Expand(); computer = computersApi.createComputer(computer, expand.list(), Boolean.FALSE, apiVersion);
To see the properties that you can configure, see the Create a Computer operation in the API Reference.
You can also use the Deep Security Manager console to create a task that automatically configures computers when they are added. See [Automatically perform tasks when a computer is added or changed](https://help.deepsecurity.trendmicro.com/20_0/on-premise/event-based-tasks.html) in the Help Center.
You can use the legacy REST API to enable the relay on a computer that is running an activated agent. The Deep Security Git repository contains scripts that accomplish this task:
For background information, see [Distribute security and software updates with relays](https://help.deepsecurity.trendmicro.com/20_0/on-premise/relays.html) on the Help Center.
The following example adds a computer to Deep Security Manager.
Python
View source
# Create the computer object computer = api.Computer() computer.host_name = hostname try: # Add the computer to Deep Security Manager computers_api = api.ComputersApi(api.ApiClient(configuration)) new_computer = computers_api.create_computer(computer, api_version) return new_computer.id except api_exception as e: return "Exception: " + str(e)
JavaScript
View source
// Create a Computer object and set the hostname const computer = new api.Computer(); computer.hostName = hostname; // Create the computer on Deep Security Manager and resolve the ID const computersApi = new api.ComputersApi(); computersApi .createComputer(computer, apiVersion, { overrides: false }) .then(returnedComputer => { resolve(returnedComputer.ID); })
Java
View source
// Create the computer Computer computer = new Computer(); computer.setHostName(hostname); // Add the computer to Deep Security Manager ComputersApi computersApi = new ComputersApi(); Expand expand = new Expand(); computer = computersApi.createComputer(computer, expand.list(), Boolean.FALSE, apiVersion); return computer.getID();