reveal-sdk-node
Version:
RevealBI Node.js SDK
115 lines (114 loc) • 4.42 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.RVRESTDataSource = void 0;
const RVDashboardDataSource_1 = require("../AbstractClasses/RVDashboardDataSource");
/** REST API data source, configures the URL to get data from, HTTP method to use and optionally headers and body to send in the request. */
class RVRESTDataSource extends RVDashboardDataSource_1.RVDashboardDataSource {
/** @hidden */
constructor(json) {
super(json);
this._url = null;
this._useAnonymousAuthentication = false;
this._usePreemptiveAuthentication = false;
this._method = null;
this._contentType = null;
this._body = null;
this._headers = null;
if (json) {
var props = json.Properties;
this._url = props['Url'];
this._useAnonymousAuthentication = props['_rpUseAnonymousAuthentication'] == true;
this._usePreemptiveAuthentication = props['_rpUsePreemptiveAuthentication'] == true;
this._method = props['Method'];
this._contentType = props['Content-Type'];
this._body = props['Body'];
this._headers = props['Headers'];
}
}
/** @hidden */
toJson() {
var json = super.toJson();
var props = json.Properties;
props['Url'] = this._url;
props['_rpUseAnonymousAuthentication'] = this._useAnonymousAuthentication;
props['_rpUsePreemptiveAuthentication'] = this._usePreemptiveAuthentication;
props['Method'] = this._method;
props['Content-Type'] = this._contentType;
props['Body'] = this._body;
props['Headers'] = this._headers;
return json;
}
/** @hidden */
getProviderKey() {
return 'REST';
}
/** URL to the web resource, is expected to be a URL with HTTP or HTTPS scheme.
* Parameters might be specified using the notation {parameterName}, for example: http://server/customers/{CustomerID} defines a "CustomerID" parameter
* that must be included in the {@link RVRESTDataSourceItem.parameters} property of {@link RVRESTDataSourceItem}.
*/
get url() {
return this._url;
}
set url(value) {
this._url = value;
}
/** Boolean flag indicating if anonymous authentication should be used for this data source or credentials must be requested to the containing application. */
get useAnonymousAuthentication() {
return this._useAnonymousAuthentication;
}
set useAnonymousAuthentication(value) {
this._useAnonymousAuthentication = value;
}
/** Boolean flag indicating if preemptive authentication should be used for this data source. */
get usePreemptiveAuthentication() {
return this._usePreemptiveAuthentication;
}
set usePreemptiveAuthentication(value) {
this._usePreemptiveAuthentication = value;
}
/** HTTP method to use, it defaults to GET */
get method() {
return this._method;
}
set method(value) {
this._method = value;
}
/** Content type of the body, only used when {@link body} is not empty */
get contentType() {
return this._contentType;
}
set contentType(value) {
this._contentType = value;
}
/** Body to send, expected to be used only with POST and PUT methods. */
get body() {
return this._body;
}
set body(value) {
this._body = value;
}
/** List of headers to send in the request, each string in this list is expected to be a string in the format name=value. */
get headers() {
return this._headers;
}
set headers(value) {
this._headers = value;
}
/** @hidden */
getType() {
return "RVRESTDataSource";
}
/** @hidden */
_getWrapper() {
let wrapper = super._getWrapper();
wrapper.url(this.url);
wrapper.method(this.method);
wrapper.contentType(this.contentType);
wrapper.body(this.body);
wrapper.usePreemptiveAuthentication(this.usePreemptiveAuthentication);
wrapper.useAnonymousAuthentication(this.useAnonymousAuthentication);
wrapper.headers(this.headers);
return wrapper;
}
}
exports.RVRESTDataSource = RVRESTDataSource;