UNPKG

@c8y/client

Version:

Client application programming interface to access the Cumulocity IoT-Platform REST services.

226 lines 7.17 kB
import { __awaiter } from "tslib"; import { Service } from '../core/index.js'; /** * @description * This service allows to get tenant login options. */ export class TenantLoginOptionsService extends 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); * })(); * ``` */ detail(entityIdentityOrId) { const _super = Object.create(null, { detail: { get: () => super.detail } }); return __awaiter(this, void 0, void 0, function* () { return _super.detail.call(this, 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); * })(); * ``` */ list() { const _super = Object.create(null, { list: { get: () => super.list } }); return __awaiter(this, arguments, void 0, function* (filter = {}) { return _super.list.call(this, 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(); * })(); * ``` */ listForCurrentTenant() { const _super = Object.create(null, { list: { get: () => super.list } }); return __awaiter(this, void 0, void 0, function* () { return _super.list.call(this, { 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(); * })(); * ``` */ listForManagement() { const _super = Object.create(null, { list: { get: () => super.list } }); return __awaiter(this, void 0, void 0, function* () { return _super.list.call(this, { 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); * })(); * ``` */ create(entity_1) { const _super = Object.create(null, { create: { get: () => super.create } }); return __awaiter(this, arguments, void 0, function* (entity, params = {}) { return _super.create.call(this, 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); * })(); * ``` */ update(entity_1) { const _super = Object.create(null, { update: { get: () => super.update } }); return __awaiter(this, arguments, void 0, function* (entity, params = {}) { return _super.update.call(this, 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); * })(); * ``` */ save(entity_1) { return __awaiter(this, arguments, void 0, function* (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); * })(); * ``` */ delete(entityOrId) { const _super = Object.create(null, { delete: { get: () => super.delete } }); return __awaiter(this, void 0, void 0, function* () { return _super.delete.call(this, entityOrId); }); } } //# sourceMappingURL=TenantLoginOptionsService.js.map