Porovnávané verzie

Kľúč

  • Tento riadok sa pridal
  • Riadok je odstránený.
  • Formátovanie sa zmenilo.

...

  • interface for authentication
  • interface for access to data and services of the D2000 system 
  • administrative interface for monitoring calls into D2000 and a the state of the SmartWeb server

...

As we have already mentioned in the chapter Other Functions of the SmartWeb Platform, the supported way of authentication for the REST API is HTTP-BASIC. This type of authentication sends the user name and password directly in the header of every HTTP request. This means that every REST API request also automatically authenticates the user. In the case of an unsuccessful authentication, the server returns the status 404 in the header of the HTTP response. That is why it is not necessary to have an explicit login into the REST API interface via a special URL. Despite that, it is optimal to extract the function because of applications in which users login log in explicitly, and thus the application needs to verify the given name and password.

...

Info

Calling of an explicit logout is recommended because the SmartWeb server keeps the session of a logged-in user of the REST service (identified by their login name) until the expiration of the session configurable in in the part Configuration of Authentication of the SmartWeb Platform.

...

POST https://<domain.sk>/<application name>/api/rest/v0/d2/archive/<archive object name>?beginTime=<integer>&endTime=<integer>&oversampleSeconds=<integer>&limitDataLength=<integer>returnFields=<text>

Meanings The meanings of individual parameters are as follows: 

Parameter nameTypeMandatoryDescription
beginTimeinteger (number of milliseconds from the epoch)yesthe beginning of a time interval of requested historical values
endTimeinteger (number of milliseconds from the epoch)yesthe end of a time interval of requested historical values 
oversampleSecondsinteger (number of seconds)nointerval length in seconds for data oversamplingresampling, if it is not defined, the original data will return
limitDataLengthinteger (number of values)nomaximal number of returned values, if it is not defined, all values from the interval will return
returnFields

text (defined Unival attributes separated by a comma)

norequested Unival attributes which which will be returned together with a time stamp timestamp and a value, e.g. "Status,Flags"

...

Via the REST interface, it is possible to call D2000 RPC procedures written in ESL and also in Java. Calling of ESL RPC procedures happens by sending a POST request with the HTTP header Content-Type: application/json to the address:

...

The body of the sent message is the JSON array with parameters of for calling RPC. The output of such a request are values of output RPC parameters stored in the JSON object, attributes of which are required names of output parameters defined by the attributes returnAs. Details of the serialization of RPC method parameters were described in the the previous chapterThe example of calling RPC with the name TestInOut on the event E.E.SmartWebApiTutorial with with five parameters, while the first, the third, and the fourth parameter is an parameters are input-output one ones and defines a define a logical name for the returned parameters' values. Input parameters (the second and the fifth) also use implicit conversion on the Unival object from simple JSON types.

...