JobsManager

management. JobsManager

Abstract the creation as well as the retrieval of async jobs.

Constructor

new JobsManager(options)

Source:
Parameters:
Name Type Description
options Object

The client options.

Name Type Attributes Description
baseUrl String

The URL of the API.

headers Object <optional>

Headers to be included in all requests.

retry Object <optional>

Retry Policy Config

Members

(inner) auth0RestClient :external:RestClient

Provides an abstraction layer for consuming the Jobs endpoint.

Source:
Type:

(inner) jobErrorsRestClient :external:RestClient

Provides an abstraction layer for consuming the Errors endpoint.

Source:
Type:

(inner, constant) usersExportsRestClient :external:RestClient

Provides an abstraction layer for consuming the Create job to export users endpoint

Source:
Type:

Methods

exportUsers(data, cbopt) → {Promise|undefined}

Export all users to a file using a long running job.

Source:
Parameters:
Name Type Attributes Description
data Object

Users export data.

Name Type Attributes Description
connection_id String <optional>

The connection id of the connection from which users will be exported

format String <optional>

The format of the file. Valid values are: "json" and "csv".

limit Number <optional>

Limit the number of records.

fields Array.<Object> <optional>

A list of fields to be included in the CSV. If omitted, a set of predefined fields will be exported.

cb function <optional>

Callback function.

Returns:
Type:
Promise | undefined
Example
var data = {
  connection_id: 'con_0000000000000001',
  format: 'csv',
  limit: 5,
  fields: [
    {
      "name": "user_id"
    },
    {
      "name": "name"
    },
    {
      "name": "email"
    },
    {
      "name": "identities[0].connection",
      "export_as": "provider"
    },
    {
      "name": "user_metadata.some_field"
    }
  ]
}

management.jobs.exportUsers(data, function (err, results) {
  if (err) {
    // Handle error.
  }

  // Retrieved job.
  console.log(results);
});

get(params, cbopt) → {Promise|undefined}

Get a job by its ID.

Source:
Parameters:
Name Type Attributes Description
params Object

Job parameters.

Name Type Description
id String

Job ID.

cb function <optional>

Callback function.

Returns:
Type:
Promise | undefined
Example
var params = {
  id: '{JOB_ID}'
};

management.jobs.get(params, function (err, job) {
  if (err) {
    // Handle error.
  }

  // Retrieved job.
  console.log(job);
});

get(params, cbopt) → {Promise|undefined}

Given a job ID, retrieve the failed/errored items

Source:
Parameters:
Name Type Attributes Description
params Object

Job parameters.

Name Type Description
id String

Job ID.

cb function <optional>

Callback function.

Returns:
Type:
Promise | undefined
Example
var params = {
  id: '{JOB_ID}'
};

management.jobs.errors(params, function (err, job) {
  if (err) {
    // Handle error.
  }

  // Retrieved job.
  console.log(job);
});

importUsers(data, cbopt) → {Promise|undefined}

Given a path to a file and a connection id, create a new job that imports the users contained in the file or JSON string and associate them with the given connection.

Source:
Parameters:
Name Type Attributes Description
data Object

Users import data.

Name Type Description
connectionId String

Connection for the users insertion.

users String

Path to the users data file.

users_json String

JSON data for the users.

upsert String

OPTIONAL: set to true to upsert users, defaults to false

send_completion_email String

OPTIONAL: defaults to true

cb function <optional>

Callback function.

Returns:
Type:
Promise | undefined
Example
var params = {
  connection_id: '{CONNECTION_ID}',
  users: '{PATH_TO_USERS_FILE}',
  upsert: true, //optional
  send_completion_email: false //optional
};

management.jobs.importUsers(params, function (err) {
  if (err) {
    // Handle error.
  }
});

verifyEmail(data, cbopt) → {Promise|undefined}

Send a verification email to a user.

Source:
Parameters:
Name Type Attributes Description
data Object

User data object.

Name Type Description
user_id String

ID of the user to be verified.

cb function <optional>

Callback function.

Returns:
Type:
Promise | undefined
Example
var params = {
	user_id: '{USER_ID}'
};

management.jobs.verifyEmail(function (err) {
  if (err) {
    // Handle error.
  }
});