How to use @influxdata/influxdb-client-apis - 10 common examples

To help you get started, we’ve selected a few @influxdata/influxdb-client-apis examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github influxdata / influxdb / e2e / src / utils / influxUtils.js View on Github external
const createBucket = async(orgId, // String
    orgName, //String
    bucketName, //String
) => {

    bucketAPI = new BucketsAPI(new InfluxDB({url: __config.influx_url, token: __defaultUser.token, timeout: 20000}));

    await bucketAPI.postBuckets({body: {name: bucketName, orgID: orgId}});
};
github influxdata / influxdb / e2e / src / utils / influxUtils.js View on Github external
const createDashboard = async(name, orgId) => {
    const dbdsAPI = new DashboardsAPI(new InfluxDB({url: __config.influx_url, token: __defaultUser.token, timeout: 20000}));
    await dbdsAPI.postDashboards({body: {name: name, orgID: orgId}}).catch(async error => {
        console.log('--- Error Creating dashboard ---');
        console.error(error);
        throw error;
    });
};
github influxdata / influxdb / e2e / src / utils / influxUtils.js View on Github external
const createLabel = async(userName,
    labelName,
    labelDescr,
    labelColor ) =>{

    let user = getUser(userName);

    const lblAPI = new LabelsAPI(new InfluxDB({url: __config.influx_url, token: user.token, timeout: 20000}));

    let lblCreateReq = {body: {name: labelName, orgID: user.orgid,
        properties: { description: labelDescr, color: labelColor }}};

    await lblAPI.postLabels(lblCreateReq).catch(async error => {
       console.log('--- Error Creating label ---');
       console.error(error);
       throw error;
    });
};
github influxdata / influxdb / e2e / src / utils / influxUtils.js View on Github external
const setupUserRest = async(user) => {

    const setupAPI = new SetupAPI(new InfluxDB(__config.influx_url));

    setupAPI.getSetup().then(async ({allowed}) => {

        let body = {org: user.org, bucket: user.bucket, username: user.username, password: user.password };

        if(user.token){
            body.token = user.token;
        }

        if(allowed){
            await setupAPI.postSetup({
                body: body,
            });
            console.log(`--- Setup user ${user.username} at ${__config.influx_url} success ---`)
        }else{
          console.error(`--- Failed to setup user ${user.username} at ${__config.influx_url} ---`);
github influxdata / influxdb / e2e / src / utils / influxUtils.js View on Github external
const getDashboards = async(userName) => {

    let user = getUser(userName);

    const dbdsAPI = new DashboardsAPI(new InfluxDB({url: __config.influx_url, token: user.token, timeout: 20000}));

    return await dbdsAPI.getDashboards();
};
github influxdata / influxdb / e2e / src / utils / influxUtils.js View on Github external
const getDocTemplates = async(userName) => {

    let user = getUser(userName);

    let docsAPI = new DocumentsAPI(new InfluxDB({url: __config.influx_url, token: user.token, timeout: 20000, }));

    return await docsAPI.getDocumentsTemplates({orgID: user.orgid});
};
github influxdata / influxdb / e2e / src / utils / influxUtils.js View on Github external
const createTemplateFromFile = async(userName, filepath) => {

    let user = getUser(userName);

    let docsAPI = new DocumentsAPI(new InfluxDB({url: __config.influx_url, token: user.token, timeout: 20000}));


    let content = await readFileToBuffer(process.cwd() + '/' + filepath);
    let newTemplate = JSON.parse(content);
    newTemplate.orgID = user.orgid;

    docsAPI.postDocumentsTemplates({ body: newTemplate});
};
github influxdata / influxdb / e2e / src / utils / influxUtils.js View on Github external
const getAuthorizations = async(userName) => {

    let user = getUser(userName);

    let authsAPI = new AuthorizationsAPI(new InfluxDB({url: __config.influx_url, token: user.token, timeout: 20000}));

    return await authsAPI.getAuthorizations();
};
github influxdata / influxdb / e2e / src / utils / influxUtils.js View on Github external
const createAlertCheckFromFile = async(userName, filepath) => {

    let user = getUser(userName);

    let content = await readFileToBuffer(process.cwd() + '/' + filepath);

    let newCheck = JSON.parse(content);

    newCheck.orgID = user.orgid;

    let chkAPI = new ChecksAPI(new InfluxDB({url: __config.influx_url, token: user.token, timeout: 20000}));

    chkAPI.createCheck({body: newCheck});
};
github influxdata / influxdb / e2e / src / utils / influxUtils.js View on Github external
const setUserOrgId = async(user) => {
    //now grab the first org
    let orgsAPI = new OrgsAPI(new InfluxDB({url: __config.influx_url, token: user.token, timeout: 20000}));

    let orgs = await orgsAPI.getOrgs();

    user.orgid = orgs.orgs[0].id;
};