@c8y/client
Version:
Client application programming interface to access the Cumulocity IoT-Platform REST services.
192 lines • 5.9 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.TenantLoginOptionsService = void 0;
const index_js_1 = require("../core/index.js");
/**
* @description
* This service allows to get tenant login options.
*/
class TenantLoginOptionsService extends index_js_1.Service {
constructor() {
super(...arguments);
this.baseUrl = 'tenant';
this.listUrl = 'loginOptions';
this.propertyName = 'loginOptions';
}
/**
* Gets the details of login option.
*
* @param entityIdentityOrId Login option's id or login option object.
*
* @returns Returns promise object that is resolved with the ITenantLoginOption wrapped by IResult.
*
* **Example**
* ```typescript
*
* const tenantLoginOptionId: string = 'uniqueTenantLoginOptionId';
*
* (async () => {
* const {data, res} = await tenantLoginOptionsService.detail(tenantLoginOptionId);
* })();
* ```
*/
async detail(entityIdentityOrId) {
return super.detail(entityIdentityOrId);
}
/**
* Gets the list of tenant's login options filtered by parameters.
*
* @param filter Object containing filters for querying tenant's login options.
*
* @returns Returns promise object that is resolved with the ITenantLoginOption wrapped by IResultList.
*
* **Example**
* ```typescript
*
* const filter: object = {
* tenantId: '1111111'
* };
*
* (async () => {
* const {data, res, paging} = await tenantLoginOptionsService.list(filter);
* })();
* ```
*/
async list(filter = {}) {
return super.list(filter);
}
/**
* Gets the list of all tenant's login options for current tenant.
*
* @returns Returns promise object that is resolved with the ITenantLoginOption wrapped by IResultList.
*
* **Example**
* ```typescript
*
* (async () => {
* const {data, res, paging} = await tenantLoginOptionsService.listForCurrentTenant();
* })();
* ```
*/
async listForCurrentTenant() {
return super.list({ tenantId: this.client.tenant });
}
/**
* Gets the list of all tenant's login options for management tenant.
*
* @returns Returns promise object that is resolved with the ITenantLoginOption wrapped by IResultList.
*
* **Example**
* ```typescript
*
* (async () => {
* const {data, res, paging} = await tenantLoginOptionsService.listForManagement();
* })();
* ```
*/
async listForManagement() {
return super.list({ management: true });
}
/**
* Creates a new tenant login option.
*
* @param entity ITenantLoginOption object.
*
* @returns Returns promise object that is resolved with the details of newly created tenant login option.
*
* **Example**
* ```typescript
*
* const tenantLoginOption: ITenantLoginOption = {
* grantType: "PASSWORD",
* providerName: "Cumulocity",
* type: "BASIC",
* userManagementSource: "INTERNAL",
* visibleOnLoginPage: true
* };
*
* (async () => {
* const {data, res} = await tenantLoginOptionsService.create(tenantLoginOption);
* })();
* ```
*/
async create(entity, params = {}) {
return super.create(entity, params);
}
/**
* Updates tenant's login option data.
*
* @param entity ITenantLoginOption object.
*
* @returns Returns promise object that is resolved with the saved tenant's login option object.
*
* **Example**
* ```typescript
*
* const tenantLoginOption: ITenantLoginOption = {
* grantType: "PASSWORD",
* id: "2eff9a0b-e376-4ce8-a0f1-0a07cef8a8a1",
* providerName: "Cumulocity",
* type: "BASIC",
* userManagementSource: "INTERNAL",
* visibleOnLoginPage: true
* };
*
* (async () => {
* const {data, res} = await tenantLoginOptionsService.update(tenantLoginOption);
* })();
* ```
*/
async update(entity, params = {}) {
return super.update(entity, params);
}
/**
* Update tenant's login option data if id exists in object, otherwise create new entity.
*
* @param entity ITenantLoginOption object.
*
* @returns Returns promise object that is resolved with the saved tenant's login option object.
*
* **Example**
* ```typescript
*
* const tenantLoginOption: ITenantLoginOption = {
* grantType: "PASSWORD",
* id: "2eff9a0b-e376-4ce8-a0f1-0a07cef8a8a1",
* providerName: "Cumulocity",
* type: "BASIC",
* userManagementSource: "INTERNAL",
* visibleOnLoginPage: true
* };
*
* (async () => {
* const {data, res} = await tenantLoginOptionsService.save(tenantLoginOption);
* })();
* ```
*/
async save(entity, params = {}) {
return entity.id ? this.update(entity, params) : this.create(entity, params);
}
/**
* Removes tenant's login option.
*
* @param entityOrId Tenant's login option's id or tenant's login option object.
*
* @returns Returns promise object that is resolved with the IResult of null.
*
* **Example**
* ```typescript
*
* const tenantLoginOptionId: string = 'uniqueTenantLoginOptionId';
*
* (async () => {
* const {data, res} = await tenantLoginOptionsService.delete(tenantLoginOptionId);
* })();
* ```
*/
async delete(entityOrId) {
return super.delete(entityOrId);
}
}
exports.TenantLoginOptionsService = TenantLoginOptionsService;
//# sourceMappingURL=TenantLoginOptionsService.js.map