An API reference for the Java SDK for Trend Vision One™ File Security
AMaasClient
AMaasClient class is the main class of the SDK and provides methods to use the AMaaS
scanning services.
Create a new instance of the
AmaasClient
class and provision
essential settings including authentication/authorization credentials (API key), for
example the preferred service region.public AMaasClient (String region, String apikey, long timeoutInSecs, boolean enabledTLS) throw AMaasException
AMaaS Client Instance Parameters
Parameter
|
Description
|
region
|
The region corresponding to your API key. The provided value must
be one of the Trend Vision One regions:
|
apikey
|
Your Trend Vision One API Key.
|
timeoutInSecs
|
Timeout, in seconds, to cancel the server connection. The default
is 0 with a maximum of 180 seconds.
|
enabledTLS
|
Enable or disable TLS. TLS should always be enabled when
connecting to the AMaaS server.
|
Return An AMaaS Client instance.
Create instance
Create a new instance of the
AmaasClient
class, and provisions
essential settings, including authentication/authorization credentials (API key),
preferred service region, etc. The enabledTLS is default to true.public AMaasClient(String region, String apiKey, long timeoutInSecs) throws AMaasException
AMaasClient Instance Parameters
Parameter
|
Description
|
region
|
The region corresponding to your API key. The provided value must
be one of the Trend Vision One regions:
|
apikey
|
Your Trend Vision One API key
|
timeoutInSecs
|
Timeout, in seconds, to cancel the connection to the server. The
default is 0 and the maximum is 180 seconds.
|
Return An AMaasClient instance
Scan file
Scan a file for malware and retrieves response data from the API.
public String scanFile(string fileName) throws AMaasException
Parameters
Parameter
|
Description
|
fileName
|
The name of the file with the file directory path containing the
file to scan.
|
Return String the scanned result in JSON format.
Scan buffer
Scan a buffer for malware and retrieves response data from the API.
public String scanBuffer(byte[] buffer, String identifier) throws
AMaasException
Parameters
Parameter
|
Description
|
buffer
|
The byte buffer to scan
|
identifier
|
A unique name to identify the buffer
|
ReturnString the scanned result in JSON format.
AmaasScanResult
The AmaasScanResult has the data elements of the response data that is retrieved from
the Trend Vision One™ API. The class has the following private
members. Each of the members have getter and setter methods.
public class AmaasScanResult { private String version; // API version private int scanResult; // Number of malwares found. A value of 0 means no malware was found private String scanId; // ID of the scan private String scanTimestamp; // Timestamp of the scan in ISO 8601 format private String fileName: // Name of the file scanned private MalwareItem[] foundMalwares; // A list of malware names and the filenames found by AMaaS // getter and seter methods for the above private variables. }
MalwareItem
The MalwareItem contains a detected malware information in the response data that
is
retrieved from our API. The class has the following private members. There are
getter and setter methods for each of the members.
public class MalwareItem { private String malwareName; // A detected Malware name private String fileName: // File name that the malware is detected. // getter and seter methods for the above private variables. }
AMaasException
The AMaasException class is the AMaaS SDK exception class.
public final class AMaasException extends Exception { private AMaasErrorCode erroCode; public AMaasException(AMaasErrorCode erroCode, Object... params) { ... } }
AMaasErrorCode
AMaasErrorCode is a enum type containing all the error conditions thrown by the
AMaasException
class. Error Conditions
Enum type
|
Error message template
|
Description
|
MSG_ID_ERR_INVALID_REGION
|
%s is not a supported region.
|
The region code provided to the AMaasClient constructor is not a
valid region.
|
MSG_ID_ERR_MISSING_AUTH
|
Must provide an API key to use the client.
|
The API key provided to the AMaasClient constructor cannot be
empty or
null . |
MSG_ID_ERR_KEY_AUTH_FAILED
|
You are not authenticated. Invalid C1 token or API key.
|
The API key is invalid. Please make sure a correct Trend Vision
One API key is used.
|
MSG_ID_ERR_FILE_NOT_FOUND
|
Failed to open file. No such directory or file %s.
|
The given file cannot be found. Please make sure the file
exists.
|
MSG_ID_ERR_FILE_NO_PERMISSION
|
Failed to open file. Permission denied to open %s.
|
There is a file access permission issue. Please make sure the SDK
has read permission to the file.
|
MSG_ID_GRPC_ERROR
|
Received gRPC status code %d, msg: %s.
|
A gRPC error was reported with the status code. For details, see
gRPC Status Codes.
|
MSG_ID_ERR_UNEXPECTED_INTERRUPT
|
Unexpected interrupt encountered.
|
An unexpected interrupt signal was received at the client.
|
Thread safety
Both scanFile() and scanBuffer() are designed to be thread-safe. They should be able
to invoke scanFile() concurrently from multiple threads without protecting
scanFile() with mutex or other synchronization mechanisms.