Layer7 API Management

Expand all | Collapse all

WADL/XSD for the portal integration service /api/keys/* APIs?

Jump to Best Answer
  • 1.  WADL/XSD for the portal integration service /api/keys/* APIs?

    Posted 10-02-2015 12:14 PM

    Hi,

     

    We have a concept of datacenter "compartments" in our APIs, which represents a trackable, billable unit of work for a given customer.  We would like to map this to an API key in the Layer7 API portal.  Looks like the /api/keys/* portal integration service provides CRUD for API keys; however, I cannot find any documentation on these APIs.

     

    Thanks,

    Liem



  • 2.  Re: WADL/XSD for the portal integration service /api/keys/* APIs?
    Best Answer

    Posted 10-05-2015 12:56 PM

    Liem,

     

    The On Premise Portal's PORTALMAN API provides a method for generating API Keys on the Gateway. Unfortunately, PORTALMAN is not documented or supported for external use at this time.

     

    Alternatively, you may want to consider using API Key Custom Fields and database lookups to get done what you need. The Portal database stores different types of custom fields in different fields:

    • Text is stored in cmssmalltextfield
    • Numbers are stored in cmsnumberfield
    • Dates are stored in cmsdatetimefield
    • Special options are stored in cmsoptiontextfield

     

    API keys are stored in the following tables:

    • On the Gateway = generic_entity table
    • On the Portal = lrs.lrsapplication and lrs.lrsapikey tables

     

    You can use the databases to do lookups at runtime to reference information. For example, you may want to find the username of an OrgAdmin to which an API Key belongs.  To do this, you need to map "API Key to OrgId to OrgAdmin" using the following lrs database tables:

     

    If you have the OrgId, you can then retrieve the username by mapping OrgId -> userid -> username. Here's how:

    1. Lookup an apikey on the lrsapplication table to find the associated OrgId
    2. To map OrgId to userid do a lookup on the cmsorganizationusers table
      1. This may just return one userid (which would be the OrgAdmin for the organization), or it may return multiple userids for the OrgAdmin and all the Developers
    3. To map each userid (called an "id" in the cmsusers table) to a username do a lookup on the cmsusers table

     

    In some cases, you may want to figure out which userid is the OrgAdmin and which userids are actually Developers. To do this, you need to know the following:

    1. The cmsuserroles contains a mapping between userid (called uid in this table) to roleid. Here, you can find that a specific userid might have a roleid of 12, for example.
    2. To find out what "12" means, do a lookup of roleid = 12 on the cmsroles table and you should find that it maps to "OrgAdmin" if there have been no changes made to the system.

    ------------------------------------------------------------------------------------------------------------------------------------------------

    All of the above is rather complex, but is available today. Upcoming (by end of year) is our SaaS Portal API, which will be supported and documented for external use, and should simplify this use case greatly.



  • 3.  Re: WADL/XSD for the portal integration service /api/keys/* APIs?

    Posted 10-05-2015 03:36 PM

    Thanks for the detailed explanation.  For our use-case, I think that would be useful to have a CRUD ReSTful API to associate API keys to other custom metadata, so that existing metadata can be tracked via API keys as well.  We can certainly go to the database, but an API is always simpler and provides better encapsulation .

     

    Regards,

    Liem