Hierarchy

  • Client

Constructors

  • Initializes a new Client, which allows to request data from the API. Differently to Client.authenticate([...]) it needs a tenant given and does not verify if the login is correct.

    Example


    const auth = new BasicAuth({
    user: 'youruser',
    password: 'yourpassword',
    tenant: 'acme'
    }); // use CookieAuth() if your platform uses oauth (only in browser!)

    const baseUrl = 'https://acme.cumulocity.com';
    const client = new Client(auth, baseUrl);
    (async () => {
    const { data, paging, res }); = await client.inventory.list({ pageSize: 100 });
    })();

    Parameters

    • auth: IAuthentication

      The Authentication strategy to use (e.g. new BasicAuth())

    • Optional baseUrl: string

      The URL to request (optional in browser, mandatory in node)

    Returns Client

Properties

application: ApplicationService
deviceRegistration: DeviceRegistrationService
deviceRegistrationBulk: DeviceRegistrationBulkService
identity: IdentityService
inventory: InventoryService
inventoryBinary: InventoryBinaryService
inventoryRole: InventoryRoleService
measurement: MeasurementService
operation: OperationService
operationBulk: OperationBulkService
options: {
    login: TenantLoginOptionsService;
    security: TenantSecurityOptionsService;
    system: SystemOptionsService;
    tenant: TenantOptionsService;
}
realtime: Realtime
smartGroups: SmartGroupsService
smartRules: SmartRulesService
userGroup: UserGroupService
userRole: UserRoleService

Methods

  • Authenticates the given user. Determines the tenant by itself via a call to tenant/currentTenant.

    Example


    let client: Client;
    (async () => {
    client = await Client.authenticate({
    user: 'testuser',
    password: 'password1337!'
    }, 'https://acme.cumulocity.com');

    //you have access to the client api now
    const { data, paging, res }); = await client.inventory.list({ pageSize: 100 });
    })();

    Parameters

    Returns Promise<Client>

  • Retrieves microservice credentials for the subscribed tenants using provided bootstrap credentials

    Example


    (async () => {
    const subscriptions = await Client.getMicroserviceSubscriptions({
    tenant: process.env.C8Y_BOOTSTRAP_TENANT,
    user: process.env.C8Y_BOOTSTRAP_USER,
    password: process.env.C8Y_BOOTSTRAP_PASSWORD
    }, process.env.C8Y_BASEURL);

    const clients = subscriptions.map(subscription => new Client(new BasicAuth(subscription), process.env.C8Y_BASEURL));
    // you have access to the client api now
    const promiseArray = clients.map(client => client.options.tenant.detail({
    category: process.env.APPLICATION_KEY,
    key: 'someSetting'
    }));
    })();

    Parameters

    Returns Promise<ICredentials[]>