Class CortexCliApi

java.lang.Object
org.jenkinsci.plugins.cortexcloud.api.CortexCliApi

public class CortexCliApi extends Object
Thin REST client for the Cortex tenant API. It is responsible for the one platform endpoint the plugin needs at build time: the unified-CLI download-link lookup (CortexConstants.DOWNLOAD_LINK_PATH). That endpoint both (a) proves the base URL and credentials are valid (used by the global config's Test Connection) and (b) yields the signed URL + checksum used to provision the cortexcli binary onto an agent. Authentication uses the same credentials the CLI consumes, sent as HTTP headers: - Authorization: <api key> - x-xdr-auth-id: <api key id> HTTP requests use HttpClient configured via ProxyConfiguration.newHttpClientBuilder() to honour the Jenkins global proxy configuration.
  • Constructor Details

    • CortexCliApi

      public CortexCliApi(String baseUrl, String apiKey, String apiKeyId)
      Parameters:
      baseUrl - tenant API base URL (trailing slash optional)
      apiKey - API key (secret)
      apiKeyId - API key ID (maps to the x-xdr-auth-id header)
  • Method Details

    • testConnection

      public void testConnection() throws IOException
      Verifies connectivity and credentials by requesting a download link for the current platform. A 2xx response with a usable signed URL means the tenant is reachable and the credentials are accepted.
      Throws:
      IOException - if the request fails or the tenant rejects the credentials
    • getDownloadLink

      public CortexCliApi.DownloadLink getDownloadLink(String os, String arch) throws IOException
      Requests a signed download link + checksum for the cortexcli binary matching the given OS and architecture.
      Parameters:
      os - one of CortexConstants.OS_LINUX, OS_DARWIN, OS_WINDOWS
      arch - one of CortexConstants.ARCH_AMD64, ARCH_ARM64
      Returns:
      the parsed download link metadata
      Throws:
      IOException - on transport error or non-2xx response