REST API

When using our skeleton project, Equinox OSGi framework starts its own web server on localhost:8080 and COPAL uses it to provide RESTful interface. You can find more information here on how to configure this web server.

ContextEventTypes Top

  • http://localhost:8080/copal/events
    GETreturn current context event types
    PUTregister new context event type; e.g. 
    <Event name="EHello" 
        xmlns="http://www.sm4all-project.eu/COPAL" />

  • http://localhost:8080/copal/events/{name}
    GETreturn context event type with specified name
    DELETEunregister context event type with specified name

  • http://localhost:8080/copal/events/{name}/namespace
    ================================================================================
    GETreturn namespace URI in context event type with specified name
    PUTset namespace URI in context event type with specified name; e.g. 
    http://www.sm4all-project.eu/COPAL/EHello>
    DELETEremove namespace URI in context event type with specified name
  • http://localhost:8080/copal/events/{name}/schema
    GETreturn schema in context event type with specified name
    PUTset schema in context event type with specified name; e.g. 
    <Schema xmlns="http://www.sm4all-project.eu/COPAL"> 
            <URL address="http://sm4all-project.eu/EHello.xsd/> u007C </Schema>
    DELETEremove schema in context event type with specified name

  • http://localhost:8080/copal/events/{name}/ttl
    GETreturn time-to-live in context event type with specified name
    PUTset time-to-live in context event type with specified name; e.g. 
    30000
    DELETEset time-to-live in context event type with specified name to default value

  • http://localhost:8080/copal/events/{name}/priority
    GETreturn priority in context event type with specified name
    PUTset priority in context event type with specified name; e.g. 
    10
    DELETEset priority in context event type with specified name to default value

  • http://localhost:8080/copal/events/{name}/attributes
    GETreturn current attributes in context event type with specified name
    PUTremove old and set new attributes in context event type with specified name; e.g. 
    <Attributes xmlns="http://www.sm4all-project.eu/COPAL"> 
            <Attribute name="test1" value="abc123" /> 
            <Attribute name="test2" value="def456" /> 
    </Attributes>
    POSTadd additional attributes in context event type with specified name; e.g. 
    <Attributes xmlns="http://www.sm4all-project.eu/COPAL"> 
            <Attribute name="test1" value="123abc" /> 
            <Attribute name="test3" value="789ghi" /> 
    </Attributes>
    DELETEremove all attributes from context event type with specified name

  • http://localhost:8080/copal/events/{eventName}/attributes/{attributeName}
    GETreturn attribute with specified name in context event type with specified event name
    DELETEremove attribute with specified name from context event type with specified event name

  • http://localhost:8080/copal/events/{name}/authorizations
    GETreturn current authorizations in context event type with specified name
    PUTremove old and set new authorizations in context event type with specified name; e.g. 
    <Authorizations 
        xmlns="http://www.sm4all-project.eu/COPAL">         <Authorization method="hasToken"> 
                    <Attribute name="token" value="1" /> 
            </Authorization> </Authorizations>
    POSTadd additional authorizations in context event type with specified name; e.g. 
    <Authorizations 
        xmlns="http://www.sm4all-project.eu/COPAL">         <Authorization method="hasToken"> 
                    <Attribute name="token" value="2" /> 
            </Authorization> </Authorizations>
    DELETEremove all authorizations from context event type with specified name

  • http://localhost:8080/copal/events/{name}/authorizations/{method}
    GETreturn authorization with specified name of its method in context event type with specified name
    DELETEremove authorization with specified name of its method from context event type with specified name

  • http://localhost:8080/copal/events/{name}/actions
    GETreturn current actions in context event type with specified name
    PUTremove old and set new actions in context event type with specified name; e.g. 
    <Actions xmlns="http://www.sm4all-project.eu/COPAL"> 
            <Action name="audit" /> 
            <Action name="translate" required="false" /> 
    </Actions>
    POSTadd new actions in context event type with specified name; e.g. 
    <Actions xmlns="http://www.sm4all-project.eu/COPAL"> 
            <Action name="log" /> 
    </Actions>
    DELETEremove all actions from context event type with specified name

  • http://localhost:8080/copal/events/{name}/actions/{index}
    GETreturn action at specified index in context event type with specified name
    PUTremove old and set new action at specified index in context event type with specified name; e.g. 
    <Action name="audit" /> 
    POSTadd new action at specified index in context event type with specified name; e.g. 
    <Action name="log" /> 
    DELETEremove the action at specified index from context event type with specified name

ContextPublishers Top

  • http://localhost:8080/copal/publishers
    GETreturn current context publishers registered through REST API
    PUTregister new context publisher; e.g. 
    <Publisher sourceID="TestSource" 
        xmlns="http://www.sm4all-project.eu/COPAL"> 
            <Events> 
                    <Event name="EHello" /> 
            </Events> 
    </Publisher> 
     
    Additionally the Publisher element can optionally have any of these elements: 
      ttl attribute - each published event will have its time-to-live set to this value 
      priority attribute - each published event will have its priority set to this value 
      Attributes element - each published event will have specified attributes 
      Authorizations element - each published event will have specified authorizations 
      Actions element - each published event will have specified actions appended

  • http://localhost:8080/copal/publishers/{sourceID}
    GETreturn context publisher with specified source ID (works only for context publishers registered through REST API)
    POSTpublish specified event using context publisher with specified source ID (works only for context publishers registered through REST API); e.g. 
    <EHello />
    DELETEunregister context publisher with specified source ID (works only for context publishers registered through REST API)

  • http://localhost:8080/copal/publishers/{sourceID}/publishedTypes
    GETreturn all published types in context publisher with specified source ID (works only for context publishers registered through REST API)
    PUTremove old and set new published types in context publisher with specified source ID (works only for context publishers registered through REST API); e.g. 
    <Events xmlns="http://www.sm4all-project.eu/COPAL"> 
            <Event name="EHello" /> 
            <Event name="ETemperature" /> 
    </Events>
    POSTadd additional published types in context publisher with specified source ID (works only for context publishers registered through REST API); e.g. 
    <Events xmlns="http://www.sm4all-project.eu/COPAL"> 
            <Event name="ETemperature" /> 
            <Event name="EMessage" /> 
    </Events>
    DELETEremove all published types from context publisher with specified source ID (works only for context publishers registered through REST API)

  • http://localhost:8080/copal/publishers/{sourceID}/publishedTypes/{name}
    DELETEremove published type with specified name from context publisher with specified source ID (works only for context publisher registered through REST API)

  • http://localhost:8080/copal/publishers/{sourceID}/ttl
    GETreturn time-to-live in context publisher with specified source ID (works only for context publishers registered through REST API)
    PUTset time-to-live in context publisher with specified source ID (works only for context publishers registered through REST API); e.g. 
    30000
    DELETEunset time-to-live in context publisher with specified source ID (works only for context publishers registered through REST API)

  • http://localhost:8080/copal/publishers/{sourceID}/priority
    GETreturn priority in context publisher with specified source ID (works only for context publishers registered through REST API)
    PUTset priority in context publisher with specified source ID (works only for context publishers registered through REST API); e.g. 
    10
    DELETEunset priority in context publisher with specified source ID (works only for context publishers registered through REST API)

  • http://localhost:8080/copal/publishers/{sourceID}/attributes
    GETreturn current attributes in context publisher with specified source ID (works only for context publishers registered through REST API)
    PUTremove old and set new attributes in context publisher with specified source ID (works only for context publishers registered through REST API); e.g. 
    <Attributes xmlns="http://www.sm4all-project.eu/COPAL"> 
            <Attribute name="test1" value="abc123" /> 
            <Attribute name="test2" value="def456" /> 
    </Attributes>
    POSTadd additional attributes in context publisher with specified source ID (works only for context publishers registered through REST API); e.g. 
    <Attributes xmlns="http://www.sm4all-project.eu/COPAL"> 
            <Attribute name="test1" value="123abc" /> 
            <Attribute name="test3" value="789ghi" /> 
    </Attributes>
    DELETEremove all attributes from context publisher with specified source ID (works only for context publishers registered through REST API)

  • http://localhost:8080/copal/publishers/{sourceID}/attributes/{name}
    GETreturn attribute with specified name in context publisher with specified source ID (works only for context publishers registered through REST API)
    DELETEremove attribute with specified name from context publisher with specified source ID (works only for context publishers registered through REST API)

  • http://localhost:8080/copal/publishers/{sourceID}/authorizations
    GETreturn current authorizations in context publisher with specified source ID (works only for context publishers registered through REST API)
    PUTremove old and set new authorizations in context publisher with specified source ID (works only for context publishers registered through REST API); e.g. 
    <Authorizations 
        xmlns="http://www.sm4all-project.eu/COPAL">         <Authorization method="hasToken"> 
                    <Attribute name="token" value="1" /> 
            </Authorization> </Authorizations>
    POSTadd additional authorizations in context publisher with specified source ID (works only for context publishers registered through REST API); e.g. 
    <Authorizations 
        xmlns="http://www.sm4all-project.eu/COPAL">         <Authorization method="hasToken"> 
                    <Attribute name="token" value="2" /> 
            </Authorization> </Authorizations>
    DELETEremove all authorizations from context publisher with specified source ID (works only for context publishers registered through REST API)

  • http://localhost:8080/copal/publishers/{sourceID}/authorizations/{method}
    GETreturn authorization with specified name of its method in context publisher with specified source ID (works only for context publishers registered through REST API)
    DELETEremove authorization with specified name of its method from context publisher with specified source ID (works only for context publishers registered through REST API)

  • http://localhost:8080/copal/publishers/{sourceID}/actions
    GETreturn current actions in context publisher with specified source ID (works only for context publishers registered through REST API)
    PUTremove old and set new actions in context publisher with specified source ID (works only for context publishers registered through REST API); e.g. 
    <Actions xmlns="http://www.sm4all-project.eu/COPAL"> 
            <Action name="audit" /> 
            <Action name="translate" required="false" /> 
    </Actions>
    POSTadd additional actions in context publisher with specified source ID (works only for context publishers registered through REST API); e.g. 
    <Actions xmlns="http://www.sm4all-project.eu/COPAL"> 
            <Action name="log" /> 
    </Actions>
    DELETEremove all actions from context publisher with specified source ID (works only for context publishers registered through REST API)

ContextProcessors Top

  • http://localhost:8080/copal/processors
    GETreturn current context processors registered through REST API
    PUTregister new context processors that will POST all received events to specified URL and return POST result as value of processing; e.g. 
    <Processor name="TestProcessor" 
        url="http://www.example.org/Test" 
        xmlns="http://www.sm4all-project.eu/COPAL">         <Actions 
                    <Action name="audit" input="EHello"> 
                            <Output> 
                                    <Event name="EHello" /> 
                            </Output> 
                    </Action> 
            </Actions> 
    </Processor>

  • http://localhost:8080/copal/processors/{name}
    GETreturn context processor with specified name (works only for context processors registered through REST API)
    DELETEunregister context processor with specified name (works only for context processors registered through REST API)

  • http://localhost:8080/copal/processors/{name}/url
    GETreturn URL in context processor with specified name (works only for context processors registered through REST API)
    PUTset URL in context processor with specified name (works only for context processors registered through REST API); e.g. 
    http://www.example.org/Test

  • http://localhost:8080/copal/processors/{name}/actions
    GETreturn current actions in context processor with specified name (works only for context processors registered through REST API)
    PUTremove old and set new actions in context processor with specified name (works only for context processors registered through REST API); e.g. 
    <Actions 
            <Action name="translate" input="EHello"> 
                    <Output> 
                            <Event name="EHello" /> 
                    </Output> 
            </Action> 
    </Actions>
    POSTadd additional actions in context processor with specified name (works only for context processors registered through REST API); e.g. 
    <Actions 
            <Action name="log" input="EHello"> 
                    <Output> 
                            <Event name="EHello" /> 
                    </Output> 
            </Action> 
    </Actions>
    DELETEremove all actions from context processor with specified name (works only for context processors registered through REST API)

ContextQueries Top

  • http://localhost:8080/copal/queries
    GETreturn current context queries
    PUTcreate new context query; e.g. 
    <Query name="TestQuery" 
        event="EHello" 
        criteria="copal:SourceID = 'TestSource'" 
        xmlns="http://www.sm4all-project.eu/COPAL" />

  • http://localhost:8080/copal/queries/{name}
    GETreturn context query with specified name
    DELETEdestroy context query with specified name

  • http://localhost:8080/copal/queries/{name}/listenedType
    GETreturn name of listened events in context query with specified name

  • http://localhost:8080/copal/queries/{name}/criteria
    GETreturn criteria in context query with specified name

ContextListeners Top

  • http://localhost:8080/copal/queries/{queryName}/listeners
    GETreturn current context listeners registered through REST API and that are registered to context query with specified name
    PUTregister new context listener with specified context query that will POST all received events to specified URL; e.g. 
    <Listener name="TestListener" 
        url="http://www.example.org/Test" 
        xmlns="http://www.sm4all-project.eu/COPAL" />

  • http://localhost:8080/copal/queries/{queryName}/listeners/{listenerName}
    GETreturn context listener with specified name registered to context query with specified query name (works only for context listeners registered through REST API)
    DELETEunregister context listener with specified name from context query with specified query name (works only for context listeners registered through REST API)

  • http://localhost:8080/copal/queries/{queryName}/listeners/{listenerName}/url
    GETreturn URL in listener with specified name that is registered to context query with specified query name (works only for context listeners registered through REST API)
    PUTset URL in listener with specified name that is registered to context query with specified query name (works only for context listeners registered through REST API); e.g. 
    http://www.example.org/Test