yaas-api-schema-v1
Version:
TypeScript API client-lib for YAAS Schema based on (fixed) version on Hybris SAP published API RAML, see https://devportal.yaas.io/services/schema/v1/ [Auto-generated using raml-typescript-generator]
381 lines (380 loc) • 19.9 kB
JavaScript
/// <reference types="@types/es6-shim" />
//========================================================================
// RAML-defined Typed REST Client for 'YaasApiSchemaV1'
//========================================================================
;
exports.__esModule = true;
var popsicle = require("popsicle");
var extend = require("deep-extend");
var rxjs_1 = require("@reactivex/rxjs");
//========================================================================
// Actions
//========================================================================
var TEMPLATE_REGEXP = /{([^{}]+)}/g;
function template(string, interpolate) {
return string.replace(TEMPLATE_REGEXP, function (match, key) {
if (interpolate[key] != null) {
return encodeURIComponent(interpolate[key]);
}
return '';
});
}
var YaasApiSchemaV1 = (function () {
// RAML resources without parameters
function YaasApiSchemaV1(options) {
this._path = '';
this._options = extend({
baseUri: 'https://api.eu.yaas.io/hybris/schema/v1',
baseUriParameters: {}
}, options);
//function client (method, path, options) {
// return this.request(client, method, path, options)
//}
// Initialize RAML resourcs without parameters
this._client = this;
this._form = popsicle.form;
this._version = 'v0.1';
this._Security = {};
// RAML resources with parameters
}
YaasApiSchemaV1.prototype.request = function (client, method, path, opts) {
var options = extend({}, client._options, opts);
var baseUri = template(options.baseUri, options.baseUriParameters);
var reqOpts = {
url: baseUri.replace(/\/$/, '') + template(path, options.uriParameters),
method: method,
headers: extend(options.headers, options.getHeaders ? options.getHeaders() : {}),
body: options.body,
query: options.query,
options: options.options
};
if (options.user && typeof options.user.sign === 'function') {
reqOpts = options.user.sign(reqOpts);
}
return popsicle.request(reqOpts);
};
// createProtoResources - Resource: Client
YaasApiSchemaV1.prototype.tenant = function (tenant) { return new Resources.Tenant(this._client, this._path + template('/{tenant}', extend({}, { tenant: tenant }))); };
return YaasApiSchemaV1;
}());
exports.YaasApiSchemaV1 = YaasApiSchemaV1;
var Resources;
(function (Resources) {
// createResource - Tenant
var Tenant = (function () {
function Tenant(client, path) {
this._client = client;
this._path = path;
this.all = new Tenant.TenantAll(this._client, this._path + '/all');
}
// createProtoResources - Resource: Tenant
Tenant.prototype.schema = function (schema) { return new Tenant.TenantSchema(this._client, this._path + template('/{schema}', extend({}, { schema: schema }))); };
/**
* GET on Tenant
*/
Tenant.prototype.GET = function (totalCount, pageNumber, pageSize, q, sort, opts) {
var _this = this;
return rxjs_1.Observable.create(function (observer) {
var options = extend({ query: {}, headers: {} }, opts);
if (totalCount !== undefined && totalCount !== null)
options.query['totalCount'] = totalCount;
if (pageNumber !== undefined && pageNumber < 1) {
observer.error('Parameter \'pageNumber\' outside specified range!');
return;
}
if (pageNumber !== undefined && pageNumber !== null)
options.query['pageNumber'] = pageNumber;
if (pageSize !== undefined && pageSize < 1) {
observer.error('Parameter \'pageSize\' outside specified range!');
return;
}
if (pageSize !== undefined && pageSize !== null)
options.query['pageSize'] = pageSize;
if (q !== undefined && q !== null)
options.query['q'] = q;
if (sort !== undefined && sort !== null)
options.query['sort'] = sort;
_this._client.request(_this._client, 'get', _this._path, options)
.use(popsicle.plugins.parse('json'))
.then(function (response) {
var r = { headers: response.headers, responseCode: response.status, bodyRaw: response.body };
r["_" + response.status] = response.body;
observer.next(r);
observer.complete();
});
});
};
/**
* DELETE on Tenant
*/
Tenant.prototype.DELETE = function (opts) {
var _this = this;
return rxjs_1.Observable.create(function (observer) {
var options = extend({ query: {}, headers: {} }, opts);
_this._client.request(_this._client, 'delete', _this._path, options)
.use(popsicle.plugins.parse('json'))
.then(function (response) {
var r = { headers: response.headers, responseCode: response.status, bodyRaw: response.body };
r["_" + response.status] = response.body;
observer.next(r);
observer.complete();
});
});
};
return Tenant;
}());
Resources.Tenant = Tenant;
(function (Tenant) {
// createResource - TenantSchema
var TenantSchema = (function () {
function TenantSchema(client, path) {
this._client = client;
this._path = path;
this.metadata = new Tenant.TenantSchema.TenantSchemaMetadata(this._client, this._path + '/metadata');
this.tags = new Tenant.TenantSchema.TenantSchemaTags(this._client, this._path + '/tags');
}
/**
* GET on TenantSchema
*/
TenantSchema.prototype.GET = function (opts) {
var _this = this;
return rxjs_1.Observable.create(function (observer) {
var options = extend({ query: {}, headers: {} }, opts);
_this._client.request(_this._client, 'get', _this._path, options)
.use(popsicle.plugins.parse('json'))
.then(function (response) {
var r = { headers: response.headers, responseCode: response.status, bodyRaw: response.body };
r["_" + response.status] = response.body;
observer.next(r);
observer.complete();
});
});
};
/**
* POST on TenantSchema
*/
TenantSchema.prototype.POST = function (body, opts) {
var _this = this;
return rxjs_1.Observable.create(function (observer) {
var options = extend({ query: {}, headers: {} }, opts);
options.body = body;
_this._client.request(_this._client, 'post', _this._path, options)
.use(popsicle.plugins.parse('json'))
.then(function (response) {
var r = { headers: response.headers, responseCode: response.status, bodyRaw: response.body };
r["_" + response.status] = response.body;
observer.next(r);
observer.complete();
});
});
};
return TenantSchema;
}());
Tenant.TenantSchema = TenantSchema;
(function (TenantSchema) {
// createResource - TenantSchemaMetadata
var TenantSchemaMetadata = (function () {
function TenantSchemaMetadata(client, path) {
this._client = client;
this._path = path;
}
/**
* GET on TenantSchemaMetadata
*/
TenantSchemaMetadata.prototype.GET = function (opts) {
var _this = this;
return rxjs_1.Observable.create(function (observer) {
var options = extend({ query: {}, headers: {} }, opts);
_this._client.request(_this._client, 'get', _this._path, options)
.use(popsicle.plugins.parse('json'))
.then(function (response) {
var r = { headers: response.headers, responseCode: response.status, bodyRaw: response.body };
r["_" + response.status] = response.body;
observer.next(r);
observer.complete();
});
});
};
/**
* PUT on TenantSchemaMetadata
*/
TenantSchemaMetadata.prototype.PUT = function (body, opts) {
var _this = this;
return rxjs_1.Observable.create(function (observer) {
var options = extend({ query: {}, headers: {} }, opts);
options.body = body;
_this._client.request(_this._client, 'put', _this._path, options)
.use(popsicle.plugins.parse('json'))
.then(function (response) {
var r = { headers: response.headers, responseCode: response.status, bodyRaw: response.body };
r["_" + response.status] = response.body;
observer.next(r);
observer.complete();
});
});
};
return TenantSchemaMetadata;
}());
TenantSchema.TenantSchemaMetadata = TenantSchemaMetadata;
// createResource - TenantSchemaTags
var TenantSchemaTags = (function () {
function TenantSchemaTags(client, path) {
this._client = client;
this._path = path;
}
// createProtoResources - Resource: TenantSchemaTags
TenantSchemaTags.prototype.tag = function (tag) { return new Tenant.TenantSchema.TenantSchemaTags.TenantSchemaTagsTag(this._client, this._path + template('/{tag}', extend({}, { tag: tag }))); };
/**
* GET on TenantSchemaTags
*/
TenantSchemaTags.prototype.GET = function (opts) {
var _this = this;
return rxjs_1.Observable.create(function (observer) {
var options = extend({ query: {}, headers: {} }, opts);
_this._client.request(_this._client, 'get', _this._path, options)
.use(popsicle.plugins.parse('json'))
.then(function (response) {
var r = { headers: response.headers, responseCode: response.status, bodyRaw: response.body };
r["_" + response.status] = response.body;
observer.next(r);
observer.complete();
});
});
};
return TenantSchemaTags;
}());
TenantSchema.TenantSchemaTags = TenantSchemaTags;
(function (TenantSchemaTags) {
// createResource - TenantSchemaTagsTag
var TenantSchemaTagsTag = (function () {
function TenantSchemaTagsTag(client, path) {
this._client = client;
this._path = path;
}
/**
* POST on TenantSchemaTagsTag
*/
TenantSchemaTagsTag.prototype.POST = function (tags, opts) {
var _this = this;
return rxjs_1.Observable.create(function (observer) {
var options = extend({ query: {}, headers: {} }, opts);
if (tags !== undefined && tags !== null)
options.query['tags'] = tags;
_this._client.request(_this._client, 'post', _this._path, options)
.use(popsicle.plugins.parse('json'))
.then(function (response) {
var r = { headers: response.headers, responseCode: response.status, bodyRaw: response.body };
r["_" + response.status] = response.body;
observer.next(r);
observer.complete();
});
});
};
/**
* DELETE on TenantSchemaTagsTag
*/
TenantSchemaTagsTag.prototype.DELETE = function (tags, removeEmpty, opts) {
var _this = this;
return rxjs_1.Observable.create(function (observer) {
var options = extend({ query: {}, headers: {} }, opts);
if (tags !== undefined && tags !== null)
options.query['tags'] = tags;
if (removeEmpty !== undefined && removeEmpty !== null)
options.query['removeEmpty'] = removeEmpty;
_this._client.request(_this._client, 'delete', _this._path, options)
.use(popsicle.plugins.parse('json'))
.then(function (response) {
var r = { headers: response.headers, responseCode: response.status, bodyRaw: response.body };
r["_" + response.status] = response.body;
observer.next(r);
observer.complete();
});
});
};
return TenantSchemaTagsTag;
}());
TenantSchemaTags.TenantSchemaTagsTag = TenantSchemaTagsTag;
})(TenantSchemaTags = TenantSchema.TenantSchemaTags || (TenantSchema.TenantSchemaTags = {}));
})(TenantSchema = Tenant.TenantSchema || (Tenant.TenantSchema = {}));
// createResource - TenantAll
var TenantAll = (function () {
function TenantAll(client, path) {
this._client = client;
this._path = path;
this.tagvalues = new Tenant.TenantAll.TenantAllTagvalues(this._client, this._path + '/tagvalues');
}
return TenantAll;
}());
Tenant.TenantAll = TenantAll;
(function (TenantAll) {
// createResource - TenantAllTagvalues
var TenantAllTagvalues = (function () {
function TenantAllTagvalues(client, path) {
this._client = client;
this._path = path;
}
// createProtoResources - Resource: TenantAllTagvalues
TenantAllTagvalues.prototype.tag = function (tag) { return new Tenant.TenantAll.TenantAllTagvalues.TenantAllTagvaluesTag(this._client, this._path + template('/{tag}', extend({}, { tag: tag }))); };
/**
* GET on TenantAllTagvalues
*/
TenantAllTagvalues.prototype.GET = function (pageNumber, pageSize, opts) {
var _this = this;
return rxjs_1.Observable.create(function (observer) {
var options = extend({ query: {}, headers: {} }, opts);
if (pageNumber !== undefined && pageNumber < 1) {
observer.error('Parameter \'pageNumber\' outside specified range!');
return;
}
if (pageNumber !== undefined && pageNumber !== null)
options.query['pageNumber'] = pageNumber;
if (pageSize !== undefined && pageSize < 1) {
observer.error('Parameter \'pageSize\' outside specified range!');
return;
}
if (pageSize !== undefined && pageSize !== null)
options.query['pageSize'] = pageSize;
_this._client.request(_this._client, 'get', _this._path, options)
.use(popsicle.plugins.parse('json'))
.then(function (response) {
var r = { headers: response.headers, responseCode: response.status, bodyRaw: response.body };
r["_" + response.status] = response.body;
observer.next(r);
observer.complete();
});
});
};
return TenantAllTagvalues;
}());
TenantAll.TenantAllTagvalues = TenantAllTagvalues;
(function (TenantAllTagvalues) {
// createResource - TenantAllTagvaluesTag
var TenantAllTagvaluesTag = (function () {
function TenantAllTagvaluesTag(client, path) {
this._client = client;
this._path = path;
}
/**
* GET on TenantAllTagvaluesTag
*/
TenantAllTagvaluesTag.prototype.GET = function (opts) {
var _this = this;
return rxjs_1.Observable.create(function (observer) {
var options = extend({ query: {}, headers: {} }, opts);
_this._client.request(_this._client, 'get', _this._path, options)
.use(popsicle.plugins.parse('json'))
.then(function (response) {
var r = { headers: response.headers, responseCode: response.status, bodyRaw: response.body };
r["_" + response.status] = response.body;
observer.next(r);
observer.complete();
});
});
};
return TenantAllTagvaluesTag;
}());
TenantAllTagvalues.TenantAllTagvaluesTag = TenantAllTagvaluesTag;
})(TenantAllTagvalues = TenantAll.TenantAllTagvalues || (TenantAll.TenantAllTagvalues = {}));
})(TenantAll = Tenant.TenantAll || (Tenant.TenantAll = {}));
})(Tenant = Resources.Tenant || (Resources.Tenant = {}));
})(Resources = exports.Resources || (exports.Resources = {}));