The Authentication strategy to use (e.g. new BasicAuth())
Optional
baseUrl: stringThe URL to request (optional in browser, mandatory in node)
Allows to change the current Authentication
The new Authentication information.
Static
authenticateAuthenticates 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 });
})();
Optional
baseUrl: stringStatic
deviceAllows to use http to register a device on the platform.
Deprecated Please use MQTT to bootstrap a device.
Static
getRetrieves 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'
}));
})();
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