com.ibm.broker.config.appdev

Class APIConnectClient

  • java.lang.Object
    • com.ibm.broker.config.appdev.APIConnectClient


  • public class APIConnectClient
    extends java.lang.Object
    The APIConnect class is responsible for making REST requests to APIConnect server.
    • Constructor Summary

      Constructors 
      Constructor and Description
      APIConnectClient(java.lang.String hostname, int port, java.lang.String userId, java.lang.String password)
      APIConnectClient constructor This method is called to create the APIConnectClient object which is used to send REST request to APIConnect.
      APIConnectClient(java.lang.String hostname, int port, java.lang.String userId, java.lang.String password, java.util.Properties properties)
      APIConnectClient constructor This method is called to create the APIConnectClient object which is used to send REST request to APIConnect.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      APIConnectClient.APIInfo createDraftAPI(java.lang.String orgId, java.lang.String apiProtocol, java.lang.String apiHost, Api api)
      Creates a Draft API in APIConnect This method pushes a swagger document containing the definition of an API to APIConnect.
      java.lang.String createDraftProduct(java.lang.String orgId, java.lang.String productTitle, java.lang.String productName, java.lang.String productVersion, java.util.ArrayList<APIConnectClient.APIInfo> apiIdList)
      Creates a draft product containing the APIs supplied This method creates a draft product using the supplied name and the list of Draft APIs.
      APIConnectClient.APIInfo createOrReplaceDraftAPI(java.lang.String orgId, java.lang.String apiProtocol, java.lang.String apiHost, Api api)
      Create or Replace a Draft API in APIConnect This method is used to push an API to API connect.
      int getAPIConnectVersion()
      Retrieves the version of APIConnect connected.
      int getTimeout()
      Get the currently configured HTTP request timeout for all interactions with IBM API Connect.
      java.lang.String lookupCatalogId(java.lang.String orgId, java.lang.String catalogName)
      Retrieves the id for the named Catalog from APIConnect This method queries APIConnect to retrieve the id for the named catalog.
      APIConnectClient.ProductSummary lookupDraftProduct(java.lang.String orgId, java.lang.String productName, java.lang.String productVersion)
      Retrieves the product summary for a Draft product This method queries APIConnect to retrieve summary information for a draft product.
      java.util.ArrayList<APIConnectClient.ProductSummary> lookupDraftProducts(java.lang.String orgId)
      Retrieves the list of draft products This method queries APIConnect to retrieve the list of draft products which exist in the draft workspace.
      java.util.ArrayList<APIConnectClient.ProductSummary> lookupStagedProducts(java.lang.String orgId, java.lang.String catalogId)
      Retrieves the list of products which have been staged This method queries APIConnect to retrieve the list of products which have been defined and staged in the specfied catalog.
      APIConnectClient.APIInfo queryAPI(java.lang.String orgId, java.lang.String apiTitle, java.lang.String apiVersion)
      Retrieves from APIConnect details about a Draft API This method retrieves from APIConnect the details about the named Draft API.
      java.util.List<APIConnectClient.Catalog> queryCatalogIds(java.lang.String orgId)
      Retrieves the list of Catalogs defined for the Organization This method queries APIConnect to retrieve the list of Catalogs defined for the organization.
      java.lang.String queryCurrentUserInfo()
      Retrieves configuration data for the current user from APIConnect This method queries APIConnect to retrieve the configuration for the current user.
      java.util.List<APIConnectClient.Organization> queryOrganizationIds()
      Retrieves from APIConnect the list of defined organisations.
      APIConnectClient.APIInfo replaceDraftAPI(java.lang.String orgId, APIConnectClient.APIInfo apiInfo, java.lang.String apiProtocol, java.lang.String apiHost, Api api)
      Replaces an existing Draft RestAPI in APIConnect This method pushes a swagger document containing the definition of an API to APIConnect in order to replace an existing Draft API.
      APIConnectClient setTimeout(int timeout)
      Set the HTTP request timeout for all interactions with IBM API Connect.
      java.lang.String stageProductInCatalog(java.lang.String orgId, java.lang.String productId, java.lang.String catalogId)
      Stages a Draft product in a Catalog This method stages a product in the identified Catalog.
      void stop()
      This method is called to stop the httpClient associated with the APIConnectClient.
      java.lang.String updateDraftProduct(java.lang.String orgId, java.lang.String productId, java.util.ArrayList<APIConnectClient.APIInfo> apiIdList)
      Updates the list of API's in a Draft Product This method updates the product identified by it's id with the listed API's.
      • Methods inherited from class java.lang.Object

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

      • APIConnectClient

        public APIConnectClient(java.lang.String hostname,
                                int port,
                                java.lang.String userId,
                                java.lang.String password)
                         throws APIConnectClientException
        APIConnectClient constructor This method is called to create the APIConnectClient object which is used to send REST request to APIConnect.
        Parameters:
        hostname - The hostname of the APIConnect server
        port - The port of the APIConnect server
        userId - The userid to use to connect to APIConnect
        password - The password to use to connect to APIConnect
        Throws:
        APIConnectClientException
      • APIConnectClient

        public APIConnectClient(java.lang.String hostname,
                                int port,
                                java.lang.String userId,
                                java.lang.String password,
                                java.util.Properties properties)
                         throws APIConnectClientException
        APIConnectClient constructor This method is called to create the APIConnectClient object which is used to send REST request to APIConnect.
        Parameters:
        hostname - The hostname of the APIConnect server
        port - The port of the APIConnect server
        userId - The userid to use to connect to APIConnect
        password - The password to use to connect to APIConnect
        properties -
        Throws:
        APIConnectClientException
    • Method Detail

      • stop

        public void stop()
        This method is called to stop the httpClient associated with the APIConnectClient. It can be called explicitly to force the http connection to be dropped or this will be done automaticlaly with the APIConnectClient is destroyed.
      • getAPIConnectVersion

        public int getAPIConnectVersion()
                                 throws APIConnectClientException
        Retrieves the version of APIConnect connected. The actual version of the APIConnect is not available to query via the REST API interface to this method query the current user config info and if the formFactor property exists in the reply then v5 is assumed otherwise v4 is returned. This method caches the result.
        Returns:
        The integer value '4' or '5'
        Throws:
        APIConnectClientException
      • queryOrganizationIds

        public java.util.List<APIConnectClient.Organization> queryOrganizationIds()
                                                                           throws APIConnectClientException
        Retrieves from APIConnect the list of defined organisations. This method retrieves from APIConnect the list of defined organisations to which the current user has access.

        The URL used is: get ///v1/me/org

        Returns:
        A list of of Organization objects
        Throws:
        APIConnectClientException
      • queryAPI

        public APIConnectClient.APIInfo queryAPI(java.lang.String orgId,
                                                 java.lang.String apiTitle,
                                                 java.lang.String apiVersion)
                                          throws APIConnectClientException
        Retrieves from APIConnect details about a Draft API This method retrieves from APIConnect the details about the named Draft API.

        The URL used for v4 is: get ///v1/orgs//v1/apimanager/orgs//apis

        Parameters:
        orgId - The id of the organisation containing the API
        apiTitle - The name of the API to be queried
        apiVersion - The version of the API to be queried
        Returns:
        An APIInfo object containing details about the API
        Throws:
        APIConnectClientException
      • createOrReplaceDraftAPI

        public APIConnectClient.APIInfo createOrReplaceDraftAPI(java.lang.String orgId,
                                                                java.lang.String apiProtocol,
                                                                java.lang.String apiHost,
                                                                Api api)
                                                         throws APIConnectClientException
        Create or Replace a Draft API in APIConnect This method is used to push an API to API connect. It performs this by executing the following API connect operations
         - Verify the API/version does not already exist in Sandbox
         - Query if the API/version exists as a draft
         - If draft exists then replace draft api
         - Else create draft api
         
        Parameters:
        orgId - The organisation which owns the API
        apiProtocol - The protocol for the API (e.g. http or https)
        apiHost - The hostname of the API
        api - The API definition
        Returns:
        The id of the Draft API created
        Throws:
        APIConnectClientException
      • createDraftAPI

        public APIConnectClient.APIInfo createDraftAPI(java.lang.String orgId,
                                                       java.lang.String apiProtocol,
                                                       java.lang.String apiHost,
                                                       Api api)
                                                throws APIConnectClientException
        Creates a Draft API in APIConnect This method pushes a swagger document containing the definition of an API to APIConnect. The swagger is updated with the correct URL for API as well as updated to include the APIConnect 'Assembly' information to allow APIConnect to automatically route requests to App Connect Enterprise.

        This method fails if the API already exists.

        The URL used is: post ///v1/apimanager/orgs//apis

        Parameters:
        orgId - The organisation which owns the API
        apiProtocol - The protocol for the API (e.g. http or https)
        apiHost - The hostname of the API
        api - The API definition
        Returns:
        An APIInfo class containing the id and name of the Draft API created
        Throws:
        APIConnectClientException
      • replaceDraftAPI

        public APIConnectClient.APIInfo replaceDraftAPI(java.lang.String orgId,
                                                        APIConnectClient.APIInfo apiInfo,
                                                        java.lang.String apiProtocol,
                                                        java.lang.String apiHost,
                                                        Api api)
                                                 throws APIConnectClientException
        Replaces an existing Draft RestAPI in APIConnect This method pushes a swagger document containing the definition of an API to APIConnect in order to replace an existing Draft API. The swagger is updated with the correct URL for the API as well as updated to include the APIConnect 'Assembly' information required to allow APIConnect to automatically route requests to App Connect Enterprise, any existing Assembly will be replaced.

        The URL for v4 is: post ///v1/apimanager/orgs//apis//v The URL for v5 is: post ///v1/apimanager/orgs//apis/

        Parameters:
        orgId - The organisation which owns the API
        apiInfo - Detaisl of the API being updated
        apiProtocol - The protocol for the API (e.g. http or https)
        apiHost - The hostname of the API
        api - The API definition
        Returns:
        An APIInfo class containing the id and name of the Draft API created
        Throws:
        APIConnectClientException
      • queryCurrentUserInfo

        public java.lang.String queryCurrentUserInfo()
                                              throws APIConnectClientException
        Retrieves configuration data for the current user from APIConnect This method queries APIConnect to retrieve the configuration for the current user.

        The URL used is: get ///v1/me

        Returns:
        A JSON string containing the user configuration information
        Throws:
        APIConnectClientException
      • lookupCatalogId

        public java.lang.String lookupCatalogId(java.lang.String orgId,
                                                java.lang.String catalogName)
                                         throws APIConnectClientException
        Retrieves the id for the named Catalog from APIConnect This method queries APIConnect to retrieve the id for the named catalog.

        The REST API's used to query catalog information refer to catalogs as Envrionments but externally they are known as Catalogs.

        The URL used is: get ///v1/me/orgs//permissions/environments

        Parameters:
        orgId - The id of the organisation
        catalogName - The name of the catalog to be retrieved
        Returns:
        A string containing the Id for the catalog
        Throws:
        APIConnectClientException
      • queryCatalogIds

        public java.util.List<APIConnectClient.Catalog> queryCatalogIds(java.lang.String orgId)
                                                                 throws APIConnectClientException
        Retrieves the list of Catalogs defined for the Organization This method queries APIConnect to retrieve the list of Catalogs defined for the organization. catalog.

        The REST API's used to query catalog information refer to Catalogs as Environments but externally they are known as Catalogs. A Sandbox catalog is identified using the "Sandbox" property not by name.

        The URL used is: get ///v1/me/orgs//permissions/environments

        Parameters:
        orgId - The id of the organisation
        Returns:
        A list of objects contain the Catalog names and id's
        Throws:
        APIConnectClientException
      • lookupDraftProducts

        public java.util.ArrayList<APIConnectClient.ProductSummary> lookupDraftProducts(java.lang.String orgId)
                                                                                 throws APIConnectClientException
        Retrieves the list of draft products This method queries APIConnect to retrieve the list of draft products which exist in the draft workspace.

        The URL used is: get ///v1/orgs//products

        Parameters:
        orgId - The id of the owning organisation
        Returns:
        An ArrayList of Product summaries
        Throws:
        APIConnectClientException
      • lookupStagedProducts

        public java.util.ArrayList<APIConnectClient.ProductSummary> lookupStagedProducts(java.lang.String orgId,
                                                                                         java.lang.String catalogId)
                                                                                  throws APIConnectClientException
        Retrieves the list of products which have been staged This method queries APIConnect to retrieve the list of products which have been defined and staged in the specfied catalog.

        The URL used is: get ///v1/orgs//environments//products

        Parameters:
        orgId - The id of the owning organisation
        catalogId - The id of the catalog to be searched
        Returns:
        An ArrayList of Product summaries
        Throws:
        APIConnectClientException
      • lookupDraftProduct

        public APIConnectClient.ProductSummary lookupDraftProduct(java.lang.String orgId,
                                                                  java.lang.String productName,
                                                                  java.lang.String productVersion)
                                                           throws APIConnectClientException
        Retrieves the product summary for a Draft product This method queries APIConnect to retrieve summary information for a draft product.

        The URL used is: get ///v1/orgs//products

        Parameters:
        orgId - The id of the owning organisation
        productName - The name of the product
        productVersion - The version of the product
        Returns:
        A ProductSummary object containing the Id, Name and Title of the product or null if the product is not found.
        Throws:
        APIConnectClientException
      • createDraftProduct

        public java.lang.String createDraftProduct(java.lang.String orgId,
                                                   java.lang.String productTitle,
                                                   java.lang.String productName,
                                                   java.lang.String productVersion,
                                                   java.util.ArrayList<APIConnectClient.APIInfo> apiIdList)
                                            throws APIConnectClientException
        Creates a draft product containing the APIs supplied This method creates a draft product using the supplied name and the list of Draft APIs.

        The JSON product to create the product is based upon the following:

                     
         {
           product: "1.0.0",
           info: {
             title: ,
             name: <name>,
             version: <version>
           },
           visibility: {
             view: {
               enabled: true,
               type: "public"
             },
             subscribe: {
               enabled: true,
               type: "authenticated"
             }
           },
           apis: { 
             "<apiName>": {"id": "<apiId>"}
             ...
           }
           plans: {
             default: {
               title: "Default",
               apis: [ "<apidId>", ... ]
             }
           }
         }
         </pre>
         <p>
         The URL used is: post //<server>/v1/orgs/<orgId>/products</div>
        <dl>
        <dt><span class="paramLabel">Parameters:</span></dt>
        <dd><code>orgId</code> - The id of the owning organisation</dd>
        <dd><code>productTitle</code> - The title of the product</dd>
        <dd><code>productName</code> - The name of the product</dd>
        <dd><code>productVersion</code> - The version of the product</dd>
        <dd><code>apiIdList</code> - The list of Draft API's to be added to the product</dd>
        <dt><span class="returnLabel">Returns:</span></dt>
        <dd>A string containing the Id of the product which was created</dd>
        <dt><span class="throwsLabel">Throws:</span></dt>
        <dd><code><a href="../../../../../com/ibm/broker/config/appdev/APIConnectClientException.html" title="class in com.ibm.broker.config.appdev">APIConnectClientException</a></code></dd>
        </dl>
        </li>
        </ul>
        <a name="updateDraftProduct-java.lang.String-java.lang.String-java.util.ArrayList-">
        <!--   -->
        </a>
        <ul class="blockList">
        <li class="blockList">
        <h4>updateDraftProduct</h4>
        <pre>public java.lang.String updateDraftProduct(java.lang.String orgId,
                                                   java.lang.String productId,
                                                   java.util.ArrayList<<a href="../../../../../com/ibm/broker/config/appdev/APIConnectClient.APIInfo.html" title="class in com.ibm.broker.config.appdev">APIConnectClient.APIInfo</a>> apiIdList)
                                            throws <a href="../../../../../com/ibm/broker/config/appdev/APIConnectClientException.html" title="class in com.ibm.broker.config.appdev">APIConnectClientException</a></pre>
        <div class="block">Updates the list of API's in a Draft Product
         
         This method updates the product identified by it's id with the listed
         API's. API's are only added not removed. No error is generated if the
         named ia already a member of the product.
         <p>
         The URL used is: get //<server>/v1/orgs/<orgId>/products/<productId>
         The URL used is: put //<server>/v1/orgs/<orgId>/products/<productId></div>
        <dl>
        <dt><span class="paramLabel">Parameters:</span></dt>
        <dd><code>orgId</code> - The id of the owning organisation</dd>
        <dd><code>productId</code> - The id of the product to be updated</dd>
        <dd><code>apiIdList</code> - The list of Draft API's to be added to the product</dd>
        <dt><span class="returnLabel">Returns:</span></dt>
        <dd>A string containing the Id of the product which was updated</dd>
        <dt><span class="throwsLabel">Throws:</span></dt>
        <dd><code><a href="../../../../../com/ibm/broker/config/appdev/APIConnectClientException.html" title="class in com.ibm.broker.config.appdev">APIConnectClientException</a></code></dd>
        </dl>
        </li>
        </ul>
        <a name="stageProductInCatalog-java.lang.String-java.lang.String-java.lang.String-">
        <!--   -->
        </a>
        <ul class="blockList">
        <li class="blockList">
        <h4>stageProductInCatalog</h4>
        <pre>public java.lang.String stageProductInCatalog(java.lang.String orgId,
                                                      java.lang.String productId,
                                                      java.lang.String catalogId)
                                               throws <a href="../../../../../com/ibm/broker/config/appdev/APIConnectClientException.html" title="class in com.ibm.broker.config.appdev">APIConnectClientException</a></pre>
        <div class="block">Stages a Draft product in a Catalog 
         
         This method stages a product in the identified Catalog.  
         <p>
         The URL used is: post //<server>/v1/orgs/<orgId>/environments/<catalogId>/products/<productId></div>
        <dl>
        <dt><span class="paramLabel">Parameters:</span></dt>
        <dd><code>orgId</code> - The id of the owning organisation</dd>
        <dd><code>productId</code> - The id of the product to be updated</dd>
        <dd><code>catalogId</code> - The id of the catalog in which to stage the product</dd>
        <dt><span class="returnLabel">Returns:</span></dt>
        <dd>The id of the staged product</dd>
        <dt><span class="throwsLabel">Throws:</span></dt>
        <dd><code><a href="../../../../../com/ibm/broker/config/appdev/APIConnectClientException.html" title="class in com.ibm.broker.config.appdev">APIConnectClientException</a></code></dd>
        </dl>
        </li>
        </ul>
        <a name="getTimeout--">
        <!--   -->
        </a>
        <ul class="blockList">
        <li class="blockList">
        <h4>getTimeout</h4>
        <pre>public int getTimeout()</pre>
        <div class="block">Get the currently configured HTTP request timeout for all interactions
         with IBM API Connect. This property defaults to 5 seconds.</div>
        <dl>
        <dt><span class="returnLabel">Returns:</span></dt>
        <dd>the currently configured HTTP request timeout.</dd>
        </dl>
        </li>
        </ul>
        <a name="setTimeout-int-">
        <!--   -->
        </a>
        <ul class="blockListLast">
        <li class="blockList">
        <h4>setTimeout</h4>
        <pre>public <a href="../../../../../com/ibm/broker/config/appdev/APIConnectClient.html" title="class in com.ibm.broker.config.appdev">APIConnectClient</a> setTimeout(int timeout)</pre>
        <div class="block">Set the HTTP request timeout for all interactions with IBM API Connect.
         This property defaults to 5 seconds.</div>
        <dl>
        <dt><span class="paramLabel">Parameters:</span></dt>
        <dd><code>timeout</code> - the HTTP request timeout.</dd>
        <dt><span class="returnLabel">Returns:</span></dt>
        <dd>this IBM API Connect client.</dd>
        </dl>
        </li>
        </ul>
        </li>
        </ul>
        </li>
        </ul>
        </div>
        </div>
        <!-- ========= END OF CLASS DATA ========= -->
        <!-- ======= START OF BOTTOM NAVBAR ====== -->
        <div role="navigation" title ="Bottom_NAVIGATION" aria-label ="Bottom Navigation Bar"/>
        <div class="bottomNav"><a name="navbar.bottom">
        <!--   -->
        </a>
        <div class="skipNav"><a href="#skip.navbar.bottom" title="Skip navigation links">Skip navigation links</a></div>
        <a name="navbar.bottom.firstrow">
        <!--   -->
        </a>
        <ul class="navList" title="Navigation">
        <li><a href="../../../../../overview-summary.html">Overview</a></li>
        <li><a href="package-summary.html">Package</a></li>
        <li class="navBarCell1Rev">Class</li>
        <li><a href="package-tree.html">Tree</a></li>
        <li><a href="../../../../../deprecated-list.html">Deprecated</a></li>
        <li><a href="../../../../../index-all.html">Index</a></li>
        <li><a href="../../../../../help-doc.html">Help</a></li>
        </ul>
        </div>
        <div class="subNav">
        <ul class="navList">
        <li>Prev Class</li>
        <li><a href="../../../../../com/ibm/broker/config/appdev/APIConnectClient.APIInfo.html" title="class in com.ibm.broker.config.appdev"><span class="typeNameLink">Next Class</span></a></li>
        </ul>
        <ul class="navList">
        <li><a href="../../../../../index.html?com/ibm/broker/config/appdev/APIConnectClient.html" target="_top">Frames</a></li>
        <li><a href="APIConnectClient.html" target="_top">No Frames</a></li>
        </ul>
        <ul class="navList" id="allclasses_navbar_bottom">
        <li><a href="../../../../../allclasses-noframe.html">All Classes</a></li>
        </ul>
        <div>
        <script type="text/javascript"><!--
          allClassesLink = document.getElementById("allclasses_navbar_bottom");
          if(window==top) {
            allClassesLink.style.display = "block";
          }
          else {
            allClassesLink.style.display = "none";
          }
          //-->
        </script>
        </div>
        <div>
        <ul class="subNavList">
        <li>Summary: </li>
        <li><a href="#nested.class.summary">Nested</a> | </li>
        <li>Field | </li>
        <li><a href="#constructor.summary">Constr</a> | </li>
        <li><a href="#method.summary">Method</a></li>
        </ul>
        <ul class="subNavList">
        <li>Detail: </li>
        <li>Field | </li>
        <li><a href="#constructor.detail">Constr</a> | </li>
        <li><a href="#method.detail">Method</a></li>
        </ul>
        </div>
        <a name="skip.navbar.bottom">
        <!--   -->
        </a></div>
        <!-- ======== END OF BOTTOM NAVBAR ======= -->
        </body>
        </html>