com.ibm.broker.config.appdev

Class RestApi

  • java.lang.Object
    • com.ibm.broker.config.appdev.RestApi
  • All Implemented Interfaces:
    java.beans.PropertyChangeListener, java.util.EventListener


    public class RestApi
    extends java.lang.Object
    implements java.beans.PropertyChangeListener
    A REST API in IBM App Connect Enterprise is a specialized type of application that allows you to expose a set of integrations as a RESTful web service. This class can be used to create the artifacts for a new REST API project, or work with the artifacts from an existing REST API project.
    Since:
    IBM Integration Bus v10
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class and Description
      static class  RestApi.ErrorType
      For each REST API, an error handler can be implemented.
    • Constructor Summary

      Constructors 
      Constructor and Description
      RestApi(java.nio.file.Path projectDirectory, java.lang.String projectName)
      Create a new REST API with the given project directory and project name.
      RestApi(java.lang.String projectName)
      Create a new REST API with the given project name.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      Api getApi()
      Get the REST API definitions for the REST API.
      java.lang.String getErrorHandlerFlowName(RestApi.ErrorType type)
      Get the name of the error handler subflow for this REST API and given error type.
      java.util.Map<RestApi.ErrorType,MessageFlow> getImplementedErrorHandlers()
      Retrieve a read-only map containing all implemented error handlers.
      java.util.Map<java.lang.String,MessageFlow> getImplementedOperations()
      Retrieve a read-only map containing all implemented operations.
      Operation getOperation(java.lang.String operationName)
      Get an operation from the REST API definitions using the name of that operation.
      java.lang.String getOperationFlowName(Operation operation)
      Get the name of the operation subflow for this REST API and given operation.
      java.lang.String getOperationFlowName(java.lang.String operationName)
      Get the name of the operation subflow for this REST API and given operation.
      java.util.List<Operation> getOperations()
      Get a list of all the operations that are defined in the REST API definitions.
      java.nio.file.Path getProjectDirectory()
      Get the project directory for the REST API.
      java.lang.String getProjectName()
      Get the project name for the REST API.
      java.util.List<MessageFlow> getSubFlows()
      Retrieve a read-only list containing all sub flows.
      MessageFlow implementErrorHandler(RestApi.ErrorType type)
      Implement an error handler in the REST API.
      MessageFlow implementOperation(java.lang.String operationName)
      Implement an operation in the REST API.
      boolean isErrorHandlerImplemented(RestApi.ErrorType type)
      Determine whether or not an error handler has been implemented.
      boolean isHTTPSEnabled()
      Determine whether or not HTTPS is enabled for this REST API.
      boolean isOperationImplemented(java.lang.String operationName)
      Determine whether or not an operation has been implemented.
      static RestApi load(java.nio.file.Path projectDirectory, java.lang.String projectName)
      Load an existing REST API from the specified project directory with the specified project name.
      void propertyChange(java.beans.PropertyChangeEvent evt)
      Run whenever there is a property change we're listening for
      void save()
      Save the REST API and its message flow, sub flows, REST API definitions and descriptor to disk.
      void save(boolean overwrite)
      Save the REST API and its message flow, sub flows, REST API definitions and descriptor to disk.
      void saveFlow(MessageFlow flow, boolean overwrite)
      Save a flow (either a message flow or sub flow) to disk.
      void saveToZip(java.nio.file.Path zipFile)
      Serialize the REST API to a project interchange ZIP file that can be imported into the Integration Toolkit.
      RestApi setApi(Api api)
      Set the REST API definitions for the REST API.
      void setHTTPSEnabled(boolean enabled)
      Specify whether or not this REST API should enable HTTPS instead of HTTP.
      RestApi setProjectDirectory(java.nio.file.Path projectDirectory)
      Set the project directory for the REST API.
      RestApi setProjectName(java.lang.String projectName)
      Set the project name for the REST API.
      boolean unimplementOperation(java.lang.String operationName)
      Unimplement an already implemented operation in the REST API.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • RestApi

        public RestApi(java.nio.file.Path projectDirectory,
                       java.lang.String projectName)
                throws RestApiException
        Create a new REST API with the given project directory and project name.
        Parameters:
        projectDirectory - the directory of the new REST API project.
        projectName - the name of the new REST API project.
        Throws:
        RestApiException - if an error occurred initialising the REST API.
      • RestApi

        public RestApi(java.lang.String projectName)
                throws RestApiException
        Create a new REST API with the given project name. If you want to save the REST API, then you must set a project directory beforehand.
        Parameters:
        projectName - the name of the new REST API project.
        Throws:
        RestApiException - if an error occurred initialising the REST API.
    • Method Detail

      • load

        public static RestApi load(java.nio.file.Path projectDirectory,
                                   java.lang.String projectName)
                            throws RestApiException,
                                   ApiException
        Load an existing REST API from the specified project directory with the specified project name.
        Parameters:
        projectDirectory - the directory of the existing REST API project.
        projectName - the name of the existing REST API project.
        Returns:
        RestApi the loaded REST API.
        Throws:
        RestApiException
        ApiException
      • getProjectDirectory

        public java.nio.file.Path getProjectDirectory()
        Get the project directory for the REST API.
        Returns:
        the project directory for the REST API, or null if it has not been set.
      • setProjectDirectory

        public RestApi setProjectDirectory(java.nio.file.Path projectDirectory)
        Set the project directory for the REST API.
        Parameters:
        projectDirectory - the project directory for the REST API.
        Returns:
        the REST API.
      • getProjectName

        public java.lang.String getProjectName()
        Get the project name for the REST API.
        Returns:
        the project name for the REST API, or null if it has not been set.
      • getErrorHandlerFlowName

        public java.lang.String getErrorHandlerFlowName(RestApi.ErrorType type)
                                                 throws RestApiException
        Get the name of the error handler subflow for this REST API and given error type.
        Parameters:
        type - the type of the error handler.
        Returns:
        the name of the error handler subflow for this REST API and given error type.
        Throws:
        RestApiException - if the project name has not been set.
      • setProjectName

        public RestApi setProjectName(java.lang.String projectName)
        Set the project name for the REST API.
        Parameters:
        projectName - the project name for the REST API.
        Returns:
        the REST API.
      • getApi

        public Api getApi()
        Get the REST API definitions for the REST API.
        Returns:
        the REST API definitions for the REST API, or null if they have not been set.
      • setApi

        public RestApi setApi(Api api)
                       throws RestApiException
        Set the REST API definitions for the REST API.
        Parameters:
        api - the REST API definitions for the REST API.
        Returns:
        the REST API.
        Throws:
        RestApiException - if the REST API definitions are not valid for use with this REST API.
      • saveFlow

        public void saveFlow(MessageFlow flow,
                             boolean overwrite)
                      throws RestApiException
        Save a flow (either a message flow or sub flow) to disk.
        Parameters:
        flow - the message flow or sub flow to save to disk.
        Throws:
        RestApiException - if an error occurs saving the message flow or sub flow to disk.
      • getOperations

        public java.util.List<Operation> getOperations()
                                                throws RestApiException
        Get a list of all the operations that are defined in the REST API definitions.
        Returns:
        a list of all the operations that are defined.
        Throws:
        RestApiException - if no REST API definitions have been set.
      • getOperation

        public Operation getOperation(java.lang.String operationName)
                               throws RestApiException
        Get an operation from the REST API definitions using the name of that operation.
        Parameters:
        operationName - the name of the operation.
        Returns:
        the operation.
        Throws:
        RestApiException - if the operation does not exist or no REST API definitions have been set.
      • implementOperation

        public MessageFlow implementOperation(java.lang.String operationName)
                                       throws RestApiException
        Implement an operation in the REST API. Creates an empty sub flow for the operation if it does not already exist.
        Parameters:
        operationName - the name of the operation to implement.
        Returns:
        the operation sub flow for the REST API.
        Throws:
        RestApiException - if an error occurred implementing the operation.
      • unimplementOperation

        public boolean unimplementOperation(java.lang.String operationName)
                                     throws RestApiException
        Unimplement an already implemented operation in the REST API. Removes the implementation from the list of implementations.
        Parameters:
        operationName - the name of the operation to unimplemented.
        Returns:
        true if the operation has been unimplemented, false if not.
        Throws:
        RestApiException - if an error occurred unimplementing the operation.
      • getImplementedOperations

        public java.util.Map<java.lang.String,MessageFlow> getImplementedOperations()
        Retrieve a read-only map containing all implemented operations.
        Returns:
        a read-only map containing all implemented operations. The map key is the operation name, and the map value is the implementation.
      • isOperationImplemented

        public boolean isOperationImplemented(java.lang.String operationName)
        Determine whether or not an operation has been implemented.
        Parameters:
        operationName - the name of the operation to check.
        Returns:
        true if the operation has been implemented, false if not.
      • implementErrorHandler

        public MessageFlow implementErrorHandler(RestApi.ErrorType type)
                                          throws RestApiException
        Implement an error handler in the REST API. Creates an empty sub flow for the operation if it does not already exist.
        Parameters:
        type - the type of the error to implement a handler for.
        Returns:
        the operation sub flow for the REST API.
        Throws:
        RestApiException - if an error occurred implementing the operation.
      • getImplementedErrorHandlers

        public java.util.Map<RestApi.ErrorType,MessageFlow> getImplementedErrorHandlers()
        Retrieve a read-only map containing all implemented error handlers.
        Returns:
        a read-only map containing all implemented error handlers. The map key is the error type, and the map value is the implementation.
      • isErrorHandlerImplemented

        public boolean isErrorHandlerImplemented(RestApi.ErrorType type)
        Determine whether or not an error handler has been implemented.
        Parameters:
        type - the type of the error handler to check.
        Returns:
        true if the error handler has been implemented, false if not.
      • getSubFlows

        public java.util.List<MessageFlow> getSubFlows()
        Retrieve a read-only list containing all sub flows.
        Returns:
        a read-only map containing all sub flows.
      • save

        public void save()
                  throws RestApiException
        Save the REST API and its message flow, sub flows, REST API definitions and descriptor to disk. All user implemented files (such as operation subflows) are forcibly overwritten.
        Throws:
        RestApiException - if an error occurs saving the REST API to disk.
      • save

        public void save(boolean overwrite)
                  throws RestApiException
        Save the REST API and its message flow, sub flows, REST API definitions and descriptor to disk.
        Parameters:
        overwrite - set to true if all user implemented files should be forcibly overwritten, false if not.
        Throws:
        RestApiException - if an error occurs saving the REST API to disk.
      • saveToZip

        public void saveToZip(java.nio.file.Path zipFile)
                       throws RestApiException
        Serialize the REST API to a project interchange ZIP file that can be imported into the Integration Toolkit.
        Parameters:
        zipFile - to project interchange ZIP file to create.
        Throws:
        RestApiException - if an error occurs creating the project interchange ZIP file.
      • setHTTPSEnabled

        public void setHTTPSEnabled(boolean enabled)
        Specify whether or not this REST API should enable HTTPS instead of HTTP.
        Parameters:
        enabled - true to enable HTTPS, false to enable HTTP.
      • isHTTPSEnabled

        public boolean isHTTPSEnabled()
        Determine whether or not HTTPS is enabled for this REST API.
        Returns:
        true if HTTPS is enabled, false if HTTP is enabled.
      • getOperationFlowName

        public java.lang.String getOperationFlowName(Operation operation)
        Get the name of the operation subflow for this REST API and given operation.
        Parameters:
        operation - the operation.
        Returns:
        the name of the operation subflow for this REST API and given operation.
      • getOperationFlowName

        public java.lang.String getOperationFlowName(java.lang.String operationName)
        Get the name of the operation subflow for this REST API and given operation.
        Parameters:
        operationName - the name of the operation.
        Returns:
        the name of the operation subflow for this REST API and given operation.
      • propertyChange

        public void propertyChange(java.beans.PropertyChangeEvent evt)
        Run whenever there is a property change we're listening for
        Specified by:
        propertyChange in interface java.beans.PropertyChangeListener
        Parameters:
        evt - the PropertyChangeEvent