Class: Api

Api()

new Api()

Represents an api running in your space
Do not call constructor directly
Bluenimble container creates it internally and makes it available for your services to use
Source:

Members

custom :JsonObject

The custom block in the api.json spec - if any -
Type:
  • JsonObject
Source:

(readonly) description :string

The description of this api
Type:
  • string
Source:

(readonly) failure :string

The error message in case of a failure during deployment of this api
Type:
  • string
Source:

fetures :JsonObject

The features defined by this api - if any -
Type:
  • JsonObject
Source:

(readonly) name :string

The name of this api
Type:
  • string
Source:

(readonly) namespace :string

The namespace of this api
Type:
  • string
Source:

resourcesManager :ApiResourcesManager

Get the resources manager of this api
Type:
Source:

runtime :JsonObject

The runtime block in the api.json spec - if any -
Type:
  • JsonObject
Source:

security :JsonObject

The security block in the api.json spec - if any -
Type:
  • JsonObject
Source:

tracer :Tracer

The logger of this api
Type:
Source:

Methods

cache(contextopt, featureopt) → {Messenger}

Create a new Cache feature object. If called from the service execute function, the context parameter should be the ApiRequest argument of the execute method If called from the api findCosumer, the context parameter should be the ApiContext
Parameters:
Name Type Attributes Default Description
context ApiContext | ApiRequest <optional>
the context or the request in which the cache handle will be associated with
feature string <optional>
default the name of the cache feature
Source:
Returns:
an instance of a cache object
Type
Messenger

call(function)

Execute a function in a separate thread
Parameters:
Name Type Description
function function the function to be executed
Source:

database(contextopt, featureopt) → {Database}

Create a new Database feature object. If called from the service execute function, the context parameter should be the ApiRequest argument of the execute method If called from the api findCosumer, the context parameter should be the ApiContext
Parameters:
Name Type Attributes Default Description
context ApiContext | ApiRequest <optional>
the context or the request in which the database handle will be associated with
feature string <optional>
default the name of the database feature
Source:
Returns:
an instance of a database object
Type
Database

datasource(contextopt, featureopt) → {Database}

Create a new DataSource feature object. If called from the service execute function, the context parameter should be the ApiRequest argument of the execute method If called from the api findCosumer, the context parameter should be the ApiContext
Parameters:
Name Type Attributes Default Description
context ApiContext | ApiRequest <optional>
the context or the request in which the database handle will be associated with
feature string <optional>
default the name of the database feature
Source:
Returns:
an instance of a database object
Type
Database

describe(full) → {JsonObject}

Describe this api. Calling describe (true), will describe all services of the api and their corresponding runtime status
Parameters:
Name Type Description
full boolean fully describe
Source:
Returns:
a Json Object describing the api
Type
JsonObject

i18n(lang) → {JsonObject}

Get all messages in this api for a specific language
Parameters:
Name Type Description
lang string target language us, es, fr, ...
Source:
Returns:
messages object
Type
JsonObject

indexer(contextopt, featureopt) → {Messenger}

Create a new Indexer feature object. If called from the service execute function, the context parameter should be the ApiRequest argument of the execute method If called from the api findCosumer, the context parameter should be the ApiContext
Parameters:
Name Type Attributes Default Description
context ApiContext | ApiRequest <optional>
the context or the request in which the cache handle will be associated with
feature string <optional>
default the name of the remote feature
Source:
Returns:
an instance of a indexer object
Type
Messenger

message(lang, key, values) → {string}

Create an i18n message or text for a specific language and key. Keys used should be defined under resources/messages folder of the api
Parameters:
Name Type Description
lang string target language us, es, fr, ...
key string the key of text or message
values varray extra values to format the message given by the key
Source:
Returns:
message
Type
string

messenger(contextopt, featureopt) → {Messenger}

Create a new Messenger feature object. If called from the service execute function, the context parameter should be the ApiRequest argument of the execute method If called from the api findCosumer, the context parameter should be the ApiContext
Parameters:
Name Type Attributes Default Description
context ApiContext | ApiRequest <optional>
the context or the request in which the messenger handle will be associated with
feature string <optional>
default the name of the messenger feature
Source:
Returns:
an instance of a database object
Type
Messenger

push(contextopt, featureopt, an, the)

Mobile Push notification to a number of recipients (devices) If called from the service execute function, the context parameter should be the ApiRequest argument of the execute method If called from the api findCosumer, the context parameter should be the ApiContext
Parameters:
Name Type Attributes Default Description
context ApiContext | ApiRequest <optional>
the context or the request in which the cache handle will be associated with
feature string <optional>
default the name of the cache feature
an Array array of recipient objects will be receiving the push notification
the string | Object message to send
Source:

remote(contextopt, featureopt) → {Messenger}

Create a new Remote feature object (Http, Coap, Mqtt and others). If called from the service execute function, the context parameter should be the ApiRequest argument of the execute method If called from the api findCosumer, the context parameter should be the ApiContext
Parameters:
Name Type Attributes Default Description
context ApiContext | ApiRequest <optional>
the context or the request in which the cache handle will be associated with
feature string <optional>
default the name of the remote feature
Source:
Returns:
an instance of a remote object
Type
Messenger

status()

The runtime status of this api. Running, Stopped, Paused or Failed
Source:

storage(contextopt, featureopt) → {Storage}

Create a new Storage feature object. If called from the service execute function, the context parameter should be the ApiRequest argument of the execute method If called from the api findCosumer, the context parameter should be the ApiContext
Parameters:
Name Type Attributes Default Description
context ApiContext | ApiRequest <optional>
the context or the request in which the storage handle will be associated with
feature string <optional>
default the name of the database feature
Source:
Returns:
an instance of a database object
Type
Storage