com.ibm.streamsx.rest.internal.icp4d

Class ICP4DServiceImpl

  • All Implemented Interfaces:
    ICP4DService


    public class ICP4DServiceImpl
    extends AbstractConnection
    implements ICP4DService
    Abstracts the REST API of the CP4D. Use this class only when CP4D >= 3.5 and Streams >= 5.5.
    Since:
    1.17
    • Constructor Summary

      Constructors 
      Constructor and Description
      ICP4DServiceImpl(com.google.gson.JsonObject service, boolean verify, java.util.function.Function<org.apache.http.client.fluent.Executor,java.lang.String> authenticator) 
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      JobRunConfiguration createJobRun(JobDescription jobDescrition, java.lang.String sabUrl, com.google.gson.JsonArray jobConfigOverlaysArray)
      Creates a Job run for a job description via REST.
      java.lang.String getAuthorization()
      Returns the Authorization header without the Authorization: keyword.
      java.lang.String getJobsRestUrl()
      Returns the REST URl for the jobs REST API, for example https://host.com/v2/jobs
      JobDescription getOrCreateJobDescription(java.lang.String jobName, java.lang.String spaceId, java.lang.String projectId)
      Gets or creates a CP4D job description associated with either a project or a deployment space.
      DeploymentSpace getOrCreateSpace(java.lang.String spaceName)
      Gets or creates a CP4D deployment space.
      java.lang.String getSpaceIdForName(java.lang.String spaceName)
      Gets the spaceId for a deployment space given by its name.
      java.lang.String getSpacesRestUrl()
      Returns the REST URl for the spaces REST API, for example https://host.com/v2/spaces
      boolean isExternalClient()
      true if the client is external to the CP4D.
      void test()
      Performs a GET request on the Spaces API to verify it is working
      java.lang.String toString() 
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface com.ibm.streamsx.rest.internal.icp4d.ICP4DService

        of
    • Constructor Detail

      • ICP4DServiceImpl

        public ICP4DServiceImpl(com.google.gson.JsonObject service,
                                boolean verify,
                                java.util.function.Function<org.apache.http.client.fluent.Executor,java.lang.String> authenticator)
    • Method Detail

      • isExternalClient

        public boolean isExternalClient()
        true if the client is external to the CP4D.
        Specified by:
        isExternalClient in interface ICP4DService
        Returns:
      • test

        public void test()
                  throws java.io.IOException
        Description copied from interface: ICP4DService
        Performs a GET request on the Spaces API to verify it is working
        Specified by:
        test in interface ICP4DService
        Throws:
        java.io.IOException
      • getSpaceIdForName

        public java.lang.String getSpaceIdForName(java.lang.String spaceName)
                                           throws java.io.IOException
        Gets the spaceId for a deployment space given by its name.
        Specified by:
        getSpaceIdForName in interface ICP4DService
        Parameters:
        spaceName - the space name
        Returns:
        the space ID of the first space instance with matching name or null if the space name doesn't exist.
        Throws:
        java.io.IOException
      • getOrCreateJobDescription

        public JobDescription getOrCreateJobDescription(java.lang.String jobName,
                                                        java.lang.String spaceId,
                                                        java.lang.String projectId)
                                                 throws java.io.IOException
        Gets or creates a CP4D job description associated with either a project or a deployment space.
        Specified by:
        getOrCreateJobDescription in interface ICP4DService
        Parameters:
        jobName - the name of the job
        spaceId - the space_id to associate the job with a deployment space. projectId must be null.
        projectId - the project_id to associate the job with a project. space_id must be null.
        Returns:
        the Job object.
        Throws:
        java.io.IOException
      • createJobRun

        public JobRunConfiguration createJobRun(JobDescription jobDescrition,
                                                java.lang.String sabUrl,
                                                com.google.gson.JsonArray jobConfigOverlaysArray)
                                         throws java.io.IOException
        Creates a Job run for a job description via REST.
        Specified by:
        createJobRun in interface ICP4DService
        Parameters:
        jobDescrition - the job description
        sabUrl - the URL of the Streams application bundle
        jobConfigOverlaysArray - the job configurations
        Returns:
        a JobRunConfiguration instance
        Throws:
        java.io.IOException
        See Also:
        com.ibm.streamsx.rest.internal.icp4d.ICP4DService#createJobRun(com.ibm.streamsx.rest.internal.icp4d.JobDescription, java.lang.String)
      • getAuthorization

        public java.lang.String getAuthorization()
        Returns the Authorization header without the Authorization: keyword.
        Specified by:
        getAuthorization in class AbstractConnection
        Returns:
        the the Authorization header value.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
streamsx.topology 2.1 @ IBMStreams GitHub