How to use the @influxdata/influxdb-client.InfluxDB function in @influxdata/influxdb-client

To help you get started, we’ve selected a few @influxdata/influxdb-client 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 query = async(userName, //string
    query // string
) => {

    let user = await getUser(userName);

    const queryApi = await new InfluxDB({url: __config.influx_url, token: user.token})
        .getQueryApi(user.org);

    //need to return array of strings as result

    let result = [];

    return await new Promise((resolve,reject) => {
        queryApi.queryRows(query, {
            next(row, tableMeta) {
                const o = tableMeta.toObject(row);
                result.push(o);
            },
            error(error) {
                reject(error)
            },
            complete() {
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 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 writeData = async (userName, //string
    lines = ['testmeas value=300 ' + (nowNano - (3 * intervalNano)),
        'testmeas value=200 ' + (nowNano - (2 * intervalNano)),
        'testmeas value=100 ' + (nowNano - intervalNano)]) => {

    let user = await getUser(userName);

    const writeAPI = await new InfluxDB({url: __config.influx_url, token: user.token})
        .getWriteApi(user.org, user.bucket, 'ns');

    await writeAPI.writeRecords(lines);

    await writeAPI.close().catch(e => {
        console.error(`ERROR: closing write connection: ${e}`);
        throw e;
    })
};
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 createVariable = async(userName, name, type, values, selected = null ) => {

    let user = getUser(userName);

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

    let parseValues = JSON.parse(values);

    let reSel = selected === null ? selected : JSON.parse(selected);

    return await varAPI.postVariables({body: {name: name,
            orgID: user.orgid,
            arguments: {
                type: type,
                values: parseValues
            },
            selected: reSel
       }
    })
};
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;
};
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 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});
};

@influxdata/influxdb-client

InfluxDB 2.x client

MIT
Latest version published 4 months ago

Package Health Score

78 / 100
Full package analysis

Popular @influxdata/influxdb-client functions