Skip to main content

clarifai-nodejs / Exports / User

Class: User

User is a class that provides access to Clarifai API endpoints related to user information.

Hierarchy

  • Lister

    User

Table of contents

Constructors

Methods

Constructors

constructor

new User(authConfig?): User

Initializes an User object with the specified authentication configuration.

Example

import { User } from "clarifai-nodejs";

export const user = new User({
pat: process.env.CLARIFAI_PAT!,
userId: process.env.CLARIFAI_USER_ID!,
appId: process.env.CLARIFAI_APP_ID!,
});

Parameters

NameTypeDescription
authConfigAuthConfigAn object containing the authentication configuration. Defaults to an empty object.

Returns

User

Overrides

Lister.constructor

Defined in

client/user.ts:51

Methods

app

app(appId): Promise<undefined | AsObject>

Returns an App object for the specified app ID.

Example

import { User } from "clarifai-nodejs";

export const user = new User({
pat: process.env.CLARIFAI_PAT!,
userId: process.env.CLARIFAI_USER_ID!,
appId: process.env.CLARIFAI_APP_ID!,
});
const app = await user.app({
appId: "app_id",
});
console.log(app);

Parameters

NameTypeDescription
appIdObjectThe app ID for the app to interact with.
appId.appIdstring-

Returns

Promise<undefined | AsObject>

An App object for the specified app ID.

Defined in

client/user.ts:236


createApp

createApp(«destructured»): Promise<AsObject>

Creates an app for the user.

Example

import { User } from "clarifai-nodejs";

export const user = new User({
pat: process.env.CLARIFAI_PAT!,
userId: process.env.CLARIFAI_USER_ID!,
appId: process.env.CLARIFAI_APP_ID!,
});
const app = await user.createApp({
appId: "app_id",
baseWorkflow: "Universal",
});
console.log(app);

Parameters

NameTypeDefault value
«destructured»Objectundefined
› appIdstringundefined
› baseWorkflow?string"Empty"

Returns

Promise<AsObject>

An App object for the specified app ID.

Defined in

client/user.ts:143


createRunner

createRunner(«destructured»): Promise<AsObject>

Creates a runner for the user.

Example

import { User } from "clarifai-nodejs";

export const user = new User({
pat: process.env.CLARIFAI_PAT!,
userId: process.env.CLARIFAI_USER_ID!,
appId: process.env.CLARIFAI_APP_ID!,
});
const runner = await user.createRunner({
runnerId: "runner_id",
labels: ["label to link runner"],
description: "laptop runner",
});
console.log(runner);

Parameters

NameType
«destructured»Object
› descriptionstring
› labelsstring[]
› runnerIdstring

Returns

Promise<AsObject>

A runner object for the specified Runner ID.

Defined in

client/user.ts:191


deleteApp

deleteApp(appId): Promise<void>

Deletes an app for the user.

Parameters

NameTypeDescription
appIdObjectThe app ID for the app to delete.
appId.appIdstring-

Returns

Promise<void>

Example

examples/user/deleteApp.ts

Defined in

client/user.ts:294


deleteRunner

deleteRunner(runnerId): Promise<void>

Deletes a runner for the user.

Example

import { User } from "clarifai-nodejs";

export const user = new User({
pat: process.env.CLARIFAI_PAT!,
userId: process.env.CLARIFAI_USER_ID!,
appId: process.env.CLARIFAI_APP_ID!,
});
await user.deleteRunner({ runnerId: "runner_id" });

Parameters

NameTypeDescription
runnerIdObjectThe runner ID to delete.
runnerId.runnerIdstring-

Returns

Promise<void>

Defined in

client/user.ts:319


listApps

listApps(«destructured»?): AsyncGenerator<AsObject[], void, unknown>

Lists all the apps for the user.

Example

import { User } from "clarifai-nodejs";

export const user = new User({
pat: process.env.CLARIFAI_PAT!,
userId: process.env.CLARIFAI_USER_ID!,
appId: process.env.CLARIFAI_APP_ID!,
});
const list = await user
.listApps({
pageNo: 1,
perPage: 20,
params: {
sortAscending: true,
},
})
.next();
const apps = list.value;
console.log(apps);

Parameters

NameType
«destructured»Object
› pageNo?number
› params?ListAppsRequestParams
› perPage?number

Returns

AsyncGenerator<AsObject[], void, unknown>

Yields

App objects for the user.

Note

Defaults to 16 per page if pageNo is specified and perPage is not specified. If both pageNo and perPage are None, then lists all the resources.

Defined in

client/user.ts:68


listRunners

listRunners(«destructured»?): AsyncGenerator<AsObject, void, unknown>

Lists all the runners for the user.

Example

import { User } from "clarifai-nodejs";

export const user = new User({
pat: process.env.CLARIFAI_PAT!,
userId: process.env.CLARIFAI_USER_ID!,
appId: process.env.CLARIFAI_APP_ID!,
});
const list = await user.listRunners().next();
const runners = list.value;
console.log(runners);

Parameters

NameType
«destructured»Object
› pageNo?number
› params?ListRunnersRequestParams
› perPage?number

Returns

AsyncGenerator<AsObject, void, unknown>

Yields

Runner objects for the user.

Note

Defaults to 16 per page if perPage is not specified.

Defined in

client/user.ts:109


runner

runner(runnerId): Promise<undefined | AsObject>

Returns a Runner object if exists.

Example

import { User } from "clarifai-nodejs";

export const user = new User({
pat: process.env.CLARIFAI_PAT!,
userId: process.env.CLARIFAI_USER_ID!,
appId: process.env.CLARIFAI_APP_ID!,
});
const runner = await user.runner({ runnerId: "runner_id" });
console.log(runner);

Parameters

NameTypeDescription
runnerIdObjectThe runner ID to interact with.
runnerId.runnerIdstring-

Returns

Promise<undefined | AsObject>

A Runner object for the existing runner ID.

Defined in

client/user.ts:265