Package io.inversion

Class Api

java.lang.Object
io.inversion.Api

public final class Api extends Object
Contains the Servers, Dbs, Collections, Endpoints and Actions that make up a REST API.
  • Field Details

    • log

      protected final transient org.slf4j.Logger log
    • servers

      protected final List<Server> servers
      Host and root path config
    • dbs

      protected final List<Db> dbs
      The underlying data sources for the Api.
    • endpoints

      protected final List<Endpoint> endpoints
      The Request HTTP method/path combinations that map to a distinct set of Actions.

      A single Endpoint will be selected to run to service a Request. Any additional Path matching rules that exist on these Endpoint's Actions will be interpreted as relative to the end of the selected Endpoint's Path match.

    • actions

      protected final List<Action> actions
      Actions that may be selected to run regardless of the matched Endpoint.

      The Action's Path match statements will be considered relative to the Api's base URL NOT relative to the selected Endpoint.

    • collections

      protected final List<Collection> collections
      The data objects being served by this API. In a simple API these may map one-to-one to, for example, database tables from a JdbcDb connecting to a RDBMS such as MySql or SqlServer.
    • listeners

      protected final transient List<Api.ApiListener> listeners
      Listeners that receive callbacks on startup/shutdown/request/error.
    • linker

      protected transient Linker linker
    • ops

      protected transient List<Op> ops
    • name

      protected String name
    • hash

      protected transient String hash
    • debug

      protected boolean debug
    • url

      protected String url
    • version

      protected String version
  • Constructor Details

    • Api

      public Api()
    • Api

      public Api(String name)
  • Method Details

    • isStarted

      public boolean isStarted()
    • withDelayedConfig

      public void withDelayedConfig(Runnable r)
    • removeExcludes

      public void removeExcludes()
    • getHash

      public String getHash()
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • withHash

      public Api withHash(String hash)
    • getServers

      public List<Server> getServers()
    • withServers

      public Api withServers(String... urls)
    • withServer

      public Api withServer(Server server)
    • withCollection

      public Api withCollection(Collection coll)
    • getCollections

      public List<Collection> getCollections()
    • getCollection

      public Collection getCollection(String name)
    • getDb

      public Db getDb(String name)
    • getDbs

      public List<Db> getDbs()
      Returns:
      the dbs
    • withDbs

      public Api withDbs(Db... dbs)
      Parameters:
      dbs - the dbs to set
      Returns:
      this
    • withDbs

      public Api withDbs(List<Db> dbs)
    • withDb

      public <T extends Db> Api withDb(Db<T> db)
    • getName

      public String getName()
    • withName

      public Api withName(String name)
    • withVersion

      public Api withVersion(String version)
    • getVersion

      public String getVersion()
    • getLoadTime

      public long getLoadTime()
    • setLoadTime

      public void setLoadTime(long loadTime)
    • getEndpoint

      public Endpoint getEndpoint(String name)
    • getEndpoints

      public List<Endpoint> getEndpoints()
    • removeEndpoint

      public Api removeEndpoint(Endpoint ep)
    • withEndpoint

      public Api withEndpoint(Action action1, Action... actions)
    • withEndpoint

      public Api withEndpoint(String ruleMatcherSpec, Action... actions)
    • withEndpoint

      public Api withEndpoint(Endpoint... endpoints)
    • withRelationship

      public Api withRelationship(String parentCollectionName, String parentPropertyName, String childCollectionName, String childPropertyName, String... childFkProps)
      Creates a ONE_TO_MANY Relationship from the parent to child collection and the inverse MANY_TO_ONE from the child to the parent. The Relationship object along with the required Index objects are created.

      If parentPropertyName is null, the ONE_TO_MANY relationship will not be crated.

      If childPropertyName is null, the MANY_TO_ONE relationship will not be created.

      If both parentPropertyName and childPropertyName are null, nothing will be performed, this will be a noop.

      This configuration does not occur until after the Api has been started so that underlying Collections/Properties don't have to exist.

      Parameters:
      parentCollectionName - the name of the parent collection
      parentPropertyName - the name of the json property for the parent that references the children (optional)
      childCollectionName - the target child collection name
      childPropertyName - the name of hte json property for the child that references the parent (optional)
      childFkProps - names of the existing Properties that make up the foreign key
      Returns:
      this
      See Also:
    • getAction

      public Action getAction(String name)
    • getActions

      public List<Action> getActions()
    • withActions

      public Api withActions(Action... actions)
      Add Action(s) may be selected to run across multiple Endpoints.
      Parameters:
      actions - actions to match and conditionally run across all Requests
      Returns:
      this
    • withAction

      public Api withAction(Action action)
    • getEngine

      public Engine getEngine()
    • isDebug

      public boolean isDebug()
    • withDebug

      public Api withDebug(boolean debug)
    • setDebug

      public void setDebug(boolean debug)
    • getUrl

      public String getUrl()
    • withUrl

      public Api withUrl(String url)
    • getLinker

      public Linker getLinker()
    • withLinker

      public Api withLinker(Linker linker)
    • withApiListener

      public Api withApiListener(Api.ApiListener listener)
    • getApiListeners

      public List<Api.ApiListener> getApiListeners()
    • matchDb

      public Db matchDb(String method, io.inversion.utils.Path requestPath)
    • getOps

      public List<Op> getOps()
    • getOp

      public Op getOp(String name)