Package com.dnanexus

Class DXEnvironment.Builder

  • Enclosing class:
    DXEnvironment

    public static class DXEnvironment.Builder
    extends Object
    Builder class for creating DXEnvironment objects.

    The resulting DXEnvironment has its fields set from the following sources, in order (with later items overriding earlier items):

    1. Hardcoded defaults
    2. JSON config in the file specified at the Builder object's creation time (you can specify the file using fromFile(File)).
    3. DX_* environment variables
    4. Fields set by calling methods on the Builder object
    • Constructor Detail

      • Builder

        @Deprecated
        public Builder()
        Deprecated.
        Use fromDefaults() instead
        Initializes a Builder object using JSON config in the file ~/.dnanexus_config/environment.json.
    • Method Detail

      • fromDefaults

        public static DXEnvironment.Builder fromDefaults()
        Creates a Builder object using the JSON config in the file ~/.dnanexus_config/environment.json.
        Returns:
        new Builder object
      • fromEnvironment

        public static DXEnvironment.Builder fromEnvironment​(DXEnvironment templateEnvironment)
        Creates a Builder object with initial settings copied from the specified environment.
        Parameters:
        templateEnvironment - environment to initialize this Builder from
        Returns:
        new Builder object
      • fromFile

        public static DXEnvironment.Builder fromFile​(File environmentJsonFile)
        Creates a Builder object using the JSON config in the specified file.
        Parameters:
        environmentJsonFile - JSON file from which to load configuration defaults
        Returns:
        new Builder object
      • build

        public DXEnvironment build()
        Build the DXEnvironment from the settings configured so far.
        Returns:
        newly created DXEnvironment
      • setApiserverHost

        public DXEnvironment.Builder setApiserverHost​(String apiserverHost)
        Sets the API server hostname.
        Parameters:
        apiserverHost - API server hostname
        Returns:
        the same Builder object
      • setApiserverPort

        public DXEnvironment.Builder setApiserverPort​(int apiserverPort)
        Sets the API server port.
        Parameters:
        apiserverPort - API server port
        Returns:
        the same Builder object
      • setApiserverProtocol

        public DXEnvironment.Builder setApiserverProtocol​(String apiserverProtocol)
        Sets the API server protocol ("http" or "https").
        Parameters:
        apiserverProtocol - API server protocol
        Returns:
        the same Builder object
      • setBearerToken

        public DXEnvironment.Builder setBearerToken​(String token)
        Sets the token to use to authenticate to the Platform.
        Parameters:
        token - bearer token
        Returns:
        the same Builder object
      • setJob

        public DXEnvironment.Builder setJob​(DXJob job)
        Sets the current job to the specified job.
        Parameters:
        job - job object
        Returns:
        the same Builder object
      • setProjectContext

        public DXEnvironment.Builder setProjectContext​(DXProject projectContext)
        Sets the project context to the specified project.
        Parameters:
        projectContext - project context
        Returns:
        the same Builder object
      • setSecurityContext

        @Deprecated
        public DXEnvironment.Builder setSecurityContext​(com.fasterxml.jackson.databind.JsonNode json)
        Deprecated.
        Sets the security context to use to authenticate to the Platform.
        Parameters:
        json - security context JSON
        Returns:
        the same Builder object
      • setWorkspace

        public DXEnvironment.Builder setWorkspace​(DXContainer workspace)
        Sets the workspace to the specified container.
        Parameters:
        workspace - workspace container
        Returns:
        the same Builder object
      • disableRetry

        public DXEnvironment.Builder disableRetry()
        Disables automatic retry of HTTP requests.
        Returns:
        the same Builder object
      • setConnectionTimeout

        public DXEnvironment.Builder setConnectionTimeout​(int connectionTimeout)
        Sets connection timeout of HTTP requests.
        Parameters:
        connectionTimeout - integer
        Returns:
        the same Builder object
      • setSocketTimeout

        public DXEnvironment.Builder setSocketTimeout​(int socketTimeout)
        Sets socket timeout of HTTP requests.
        Parameters:
        socketTimeout - integer
        Returns:
        the same Builder object
      • maxTotalConnections

        public DXEnvironment.Builder maxTotalConnections​(int maxTotalConnections)
        Sets maxTotalConnections for httpclient
        Parameters:
        maxTotalConnections - integer
        Returns:
        the same Builder object
      • setMaxDefaultConnectionsPerRoute

        public DXEnvironment.Builder setMaxDefaultConnectionsPerRoute​(int maxDefaultConnectionsPerRoute)
        Sets maxDefaultConnectionsPerRoute for httpClient
        Parameters:
        maxDefaultConnectionsPerRoute - integer
        Returns:
        the same Builder object
      • setHttpProxy

        public DXEnvironment.Builder setHttpProxy​(String httpProxy)
        Sets the HTTP proxy server
        Parameters:
        httpProxy - String
        Returns:
        the same Builder object