Class DefensicsApiV2Client

  • All Implemented Interfaces:
    DefensicsApiClient

    public class DefensicsApiV2Client
    extends Object
    implements DefensicsApiClient
    Defensics API v2 client. Client is configured to use token in all requests so new client has to be created if token is to be changed. Server-provided pagination and other root-level information is stripped away and methods return bare plain object and list of objects.

    Now most of the exceptions (e.g. InterruptedExceptions, IOExceptions) are collected as a cause in the DefensicsClientException but the exception handling is subject to change when client code evolves.

    • Constructor Detail

      • DefensicsApiV2Client

        public DefensicsApiV2Client​(URI apiBaseUri,
                                    String token)
        Default constructor.
        Parameters:
        apiBaseUri - Defensics API Server address
        token - Token used to authenticate
      • DefensicsApiV2Client

        public DefensicsApiV2Client​(URI apiBaseUri,
                                    String token,
                                    Consumer<HttpClient.Builder> clientConfigurator)
        Constructor for configuring HttpClient further - allows to e.g. customize timeouts or to modify TLS configuration.
        Parameters:
        apiBaseUri - Defensics API server address
        token - Token used to authenticate
        clientConfigurator - HttpClientBuilder consumer. Do not call builder.build() in this method.
    • Method Detail

      • uploadTestPlan

        public void uploadTestPlan​(String configurationId,
                                   InputStream testplanStream)
        Description copied from interface: DefensicsApiClient
        Uploads and assigns a Defensics testplan to the test configuration of run with given ID.
        Specified by:
        uploadTestPlan in interface DefensicsApiClient
        Parameters:
        configurationId - Test configuration ID
        testplanStream - Defensics testplan file as a stream. Caller has to close the stream.
      • setTestConfigurationSettings

        public void setTestConfigurationSettings​(String runId,
                                                 SettingCliArgs settings)
        Description copied from interface: DefensicsApiClient
        Adds additional configuration settings for suite and monitor. The format is same as in the Defensics command line (e.g. '--uri http://127.0.0.1:7000' for changing URI in HTTP server suite).
        Specified by:
        setTestConfigurationSettings in interface DefensicsApiClient
        Parameters:
        runId - Run ID whose configuration is changed
        settings - Settings to add
      • getRun

        public Optional<Run> getRun​(String runId,
                                    boolean includeFailureSummary)
        Get run with optional failureSummary embedded.
        Parameters:
        runId - Run ID
        includeFailureSummary - If true, includes failureSummary information.
        Returns:
        Run, if present.
      • deleteRun

        public void deleteRun​(String runId)
        Description copied from interface: DefensicsApiClient
        Removes the Run. Also removes related RunTestConfiguration and unloads any assigned suites
        Specified by:
        deleteRun in interface DefensicsApiClient
        Parameters:
        runId - Run ID
      • downloadReport

        public InputStream downloadReport​(String resultId,
                                          String reportType)
        Description copied from interface: DefensicsApiClient
        Downloads Defensics report of given type for given result IDs. Caller has to close the stream.
        Specified by:
        downloadReport in interface DefensicsApiClient
        Parameters:
        resultId - Run IDs for which to generate report
        reportType - Report type
        Returns:
        Report as a stream
      • downloadResultPackage

        public InputStream downloadResultPackage​(String resultId)
        Description copied from interface: DefensicsApiClient
        Downloads Defensics result package for given result ID. Result package contains Defensics result files in ZIP archive. Caller has to close the stream.
        Specified by:
        downloadResultPackage in interface DefensicsApiClient
        Parameters:
        resultId - Result ID to include in the result package
        Returns:
        Result package as an inputstream. Contains Zip-package
      • getSuite

        public Optional<Suite> getSuite​(String suiteFeature,
                                        String suiteVersion)
        Description copied from interface: DefensicsApiClient
        Get single suite by the it's feature and version.
        Specified by:
        getSuite in interface DefensicsApiClient
        Parameters:
        suiteFeature - the feature of suite to get
        suiteVersion - the version of suite to get
        Returns:
        Suite
      • setUserAgent

        public void setUserAgent​(String userAgentString)