Skip to content

Latest commit

 

History

History
667 lines (521 loc) · 50.1 KB

File metadata and controls

667 lines (521 loc) · 50.1 KB

UsersManagement

(usersManagement)

Overview

This enables the management of information about users (including students and teachers).

Available Operations

getAllUsers

To get all Users on the service provider.

Example Usage

import { OneRoster } from "@superbuilders/oneroster";

const oneRoster = new OneRoster({
  security: {
    clientID: process.env["ONEROSTER_CLIENT_ID"] ?? "",
    clientSecret: process.env["ONEROSTER_CLIENT_SECRET"] ?? "",
  },
});

async function run() {
  const result = await oneRoster.usersManagement.getAllUsers({
    fields: "sourcedId,name",
    filter: "status='active'",
  });

  for await (const page of result) {
    console.log(page);
  }
}

run();

Standalone function

The standalone function version of this method:

import { OneRosterCore } from "@superbuilders/oneroster/core.js";
import { usersManagementGetAllUsers } from "@superbuilders/oneroster/funcs/usersManagementGetAllUsers.js";

// Use `OneRosterCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const oneRoster = new OneRosterCore({
  security: {
    clientID: process.env["ONEROSTER_CLIENT_ID"] ?? "",
    clientSecret: process.env["ONEROSTER_CLIENT_SECRET"] ?? "",
  },
});

async function run() {
  const res = await usersManagementGetAllUsers(oneRoster, {
    fields: "sourcedId,name",
    filter: "status='active'",
  });
  if (res.ok) {
    const { value: result } = res;
    for await (const page of result) {
    console.log(page);
  }
  } else {
    console.log("usersManagementGetAllUsers failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
request operations.GetAllUsersRequest ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.

Response

Promise<operations.GetAllUsersResponse>

Errors

Error Type Status Code Content Type
errors.BadRequestResponseError 400 application/json
errors.UnauthorizedRequestResponseError 401 application/json
errors.ForbiddenResponseError 403 application/json
errors.NotFoundResponseError 404 application/json
errors.UnprocessableEntityResponseError 422 application/json
errors.TooManyRequestsResponseError 429 application/json
errors.InternalServerErrorResponse 500 application/json
errors.APIError 4XX, 5XX */*

createUser

To create a new User on the service provider. The responding system must return the set of sourcedIds that have been allocated to the newly created user record.

Example Usage

import { OneRoster } from "@superbuilders/oneroster";

const oneRoster = new OneRoster({
  security: {
    clientID: process.env["ONEROSTER_CLIENT_ID"] ?? "",
    clientSecret: process.env["ONEROSTER_CLIENT_SECRET"] ?? "",
  },
});

async function run() {
  const result = await oneRoster.usersManagement.createUser({
    user: {
      enabledUser: true,
      givenName: "<value>",
      familyName: "<value>",
      roles: [],
    },
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { OneRosterCore } from "@superbuilders/oneroster/core.js";
import { usersManagementCreateUser } from "@superbuilders/oneroster/funcs/usersManagementCreateUser.js";

// Use `OneRosterCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const oneRoster = new OneRosterCore({
  security: {
    clientID: process.env["ONEROSTER_CLIENT_ID"] ?? "",
    clientSecret: process.env["ONEROSTER_CLIENT_SECRET"] ?? "",
  },
});

async function run() {
  const res = await usersManagementCreateUser(oneRoster, {
    user: {
      enabledUser: true,
      givenName: "<value>",
      familyName: "<value>",
      roles: [],
    },
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("usersManagementCreateUser failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
request operations.CreateUserRequest ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.

Response

Promise<operations.CreateUserResponse>

Errors

Error Type Status Code Content Type
errors.BadRequestResponseError 400 application/json
errors.UnauthorizedRequestResponseError 401 application/json
errors.ForbiddenResponseError 403 application/json
errors.NotFoundResponseError 404 application/json
errors.UnprocessableEntityResponseError 422 application/json
errors.TooManyRequestsResponseError 429 application/json
errors.InternalServerErrorResponse 500 application/json
errors.APIError 4XX, 5XX */*

getUser

To get a specific User on the service provider.

Example Usage

import { OneRoster } from "@superbuilders/oneroster";

const oneRoster = new OneRoster({
  security: {
    clientID: process.env["ONEROSTER_CLIENT_ID"] ?? "",
    clientSecret: process.env["ONEROSTER_CLIENT_SECRET"] ?? "",
  },
});

async function run() {
  const result = await oneRoster.usersManagement.getUser({
    sourcedId: "<id>",
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { OneRosterCore } from "@superbuilders/oneroster/core.js";
import { usersManagementGetUser } from "@superbuilders/oneroster/funcs/usersManagementGetUser.js";

// Use `OneRosterCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const oneRoster = new OneRosterCore({
  security: {
    clientID: process.env["ONEROSTER_CLIENT_ID"] ?? "",
    clientSecret: process.env["ONEROSTER_CLIENT_SECRET"] ?? "",
  },
});

async function run() {
  const res = await usersManagementGetUser(oneRoster, {
    sourcedId: "<id>",
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("usersManagementGetUser failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
request operations.GetUserRequest ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.

Response

Promise<operations.GetUserResponse>

Errors

Error Type Status Code Content Type
errors.BadRequestResponseError 400 application/json
errors.UnauthorizedRequestResponseError 401 application/json
errors.ForbiddenResponseError 403 application/json
errors.NotFoundResponseError 404 application/json
errors.UnprocessableEntityResponseError 422 application/json
errors.TooManyRequestsResponseError 429 application/json
errors.InternalServerErrorResponse 500 application/json
errors.APIError 4XX, 5XX */*

updateUser

To update an existing User on the service provider. The sourcedId for the record to be updated is supplied by the requesting system.

Example Usage

import { OneRoster } from "@superbuilders/oneroster";

const oneRoster = new OneRoster({
  security: {
    clientID: process.env["ONEROSTER_CLIENT_ID"] ?? "",
    clientSecret: process.env["ONEROSTER_CLIENT_SECRET"] ?? "",
  },
});

async function run() {
  const result = await oneRoster.usersManagement.updateUser({
    sourcedId: "<id>",
    requestBody: {
      user: {
        enabledUser: true,
        givenName: "<value>",
        familyName: "<value>",
        roles: [
          {
            roleType: "primary",
            role: "aide",
            org: {
              sourcedId: "<id>",
            },
          },
        ],
      },
    },
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { OneRosterCore } from "@superbuilders/oneroster/core.js";
import { usersManagementUpdateUser } from "@superbuilders/oneroster/funcs/usersManagementUpdateUser.js";

// Use `OneRosterCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const oneRoster = new OneRosterCore({
  security: {
    clientID: process.env["ONEROSTER_CLIENT_ID"] ?? "",
    clientSecret: process.env["ONEROSTER_CLIENT_SECRET"] ?? "",
  },
});

async function run() {
  const res = await usersManagementUpdateUser(oneRoster, {
    sourcedId: "<id>",
    requestBody: {
      user: {
        enabledUser: true,
        givenName: "<value>",
        familyName: "<value>",
        roles: [
          {
            roleType: "primary",
            role: "aide",
            org: {
              sourcedId: "<id>",
            },
          },
        ],
      },
    },
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("usersManagementUpdateUser failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
request operations.UpdateUserRequest ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.

Response

Promise<operations.UpdateUserResponse>

Errors

Error Type Status Code Content Type
errors.BadRequestResponseError 400 application/json
errors.UnauthorizedRequestResponseError 401 application/json
errors.ForbiddenResponseError 403 application/json
errors.NotFoundResponseError 404 application/json
errors.UnprocessableEntityResponseError 422 application/json
errors.TooManyRequestsResponseError 429 application/json
errors.InternalServerErrorResponse 500 application/json
errors.APIError 4XX, 5XX */*

deleteUser

Perform a soft delete on a specific User on the service provider. This operation changes the status of the User to 'tobedeleted'.

Example Usage

import { OneRoster } from "@superbuilders/oneroster";

const oneRoster = new OneRoster({
  security: {
    clientID: process.env["ONEROSTER_CLIENT_ID"] ?? "",
    clientSecret: process.env["ONEROSTER_CLIENT_SECRET"] ?? "",
  },
});

async function run() {
  await oneRoster.usersManagement.deleteUser({
    sourcedId: "<id>",
  });


}

run();

Standalone function

The standalone function version of this method:

import { OneRosterCore } from "@superbuilders/oneroster/core.js";
import { usersManagementDeleteUser } from "@superbuilders/oneroster/funcs/usersManagementDeleteUser.js";

// Use `OneRosterCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const oneRoster = new OneRosterCore({
  security: {
    clientID: process.env["ONEROSTER_CLIENT_ID"] ?? "",
    clientSecret: process.env["ONEROSTER_CLIENT_SECRET"] ?? "",
  },
});

async function run() {
  const res = await usersManagementDeleteUser(oneRoster, {
    sourcedId: "<id>",
  });
  if (res.ok) {
    const { value: result } = res;
    
  } else {
    console.log("usersManagementDeleteUser failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
request operations.DeleteUserRequest ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.

Response

Promise<void>

Errors

Error Type Status Code Content Type
errors.BadRequestResponseError 400 application/json
errors.UnauthorizedRequestResponseError 401 application/json
errors.ForbiddenResponseError 403 application/json
errors.NotFoundResponseError 404 application/json
errors.UnprocessableEntityResponseError 422 application/json
errors.TooManyRequestsResponseError 429 application/json
errors.InternalServerErrorResponse 500 application/json
errors.APIError 4XX, 5XX */*

getUserWithDemographics

To get a specific User with demographics on the service provider. If the corresponding record cannot be located, the api will return a 404 error code and message 'User not found.'

Example Usage

import { OneRoster } from "@superbuilders/oneroster";

const oneRoster = new OneRoster({
  security: {
    clientID: process.env["ONEROSTER_CLIENT_ID"] ?? "",
    clientSecret: process.env["ONEROSTER_CLIENT_SECRET"] ?? "",
  },
});

async function run() {
  const result = await oneRoster.usersManagement.getUserWithDemographics({
    sourcedId: "<id>",
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { OneRosterCore } from "@superbuilders/oneroster/core.js";
import { usersManagementGetUserWithDemographics } from "@superbuilders/oneroster/funcs/usersManagementGetUserWithDemographics.js";

// Use `OneRosterCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const oneRoster = new OneRosterCore({
  security: {
    clientID: process.env["ONEROSTER_CLIENT_ID"] ?? "",
    clientSecret: process.env["ONEROSTER_CLIENT_SECRET"] ?? "",
  },
});

async function run() {
  const res = await usersManagementGetUserWithDemographics(oneRoster, {
    sourcedId: "<id>",
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("usersManagementGetUserWithDemographics failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
request operations.GetUserWithDemographicsRequest ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.

Response

Promise<operations.GetUserWithDemographicsResponse>

Errors

Error Type Status Code Content Type
errors.BadRequestResponseError 400 application/json
errors.UnauthorizedRequestResponseError 401 application/json
errors.ForbiddenResponseError 403 application/json
errors.NotFoundResponseError 404 application/json
errors.UnprocessableEntityResponseError 422 application/json
errors.TooManyRequestsResponseError 429 application/json
errors.InternalServerErrorResponse 500 application/json
errors.APIError 4XX, 5XX */*

getClassesForUser

To get the set of Classes a User is enrolled in.

Example Usage

import { OneRoster } from "@superbuilders/oneroster";

const oneRoster = new OneRoster({
  security: {
    clientID: process.env["ONEROSTER_CLIENT_ID"] ?? "",
    clientSecret: process.env["ONEROSTER_CLIENT_SECRET"] ?? "",
  },
});

async function run() {
  const result = await oneRoster.usersManagement.getClassesForUser({
    userSourcedId: "<id>",
    fields: "sourcedId,name",
    filter: "status='active'",
  });

  for await (const page of result) {
    console.log(page);
  }
}

run();

Standalone function

The standalone function version of this method:

import { OneRosterCore } from "@superbuilders/oneroster/core.js";
import { classesManagementGetClassesForUser } from "@superbuilders/oneroster/funcs/classesManagementGetClassesForUser.js";

// Use `OneRosterCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const oneRoster = new OneRosterCore({
  security: {
    clientID: process.env["ONEROSTER_CLIENT_ID"] ?? "",
    clientSecret: process.env["ONEROSTER_CLIENT_SECRET"] ?? "",
  },
});

async function run() {
  const res = await classesManagementGetClassesForUser(oneRoster, {
    userSourcedId: "<id>",
    fields: "sourcedId,name",
    filter: "status='active'",
  });
  if (res.ok) {
    const { value: result } = res;
    for await (const page of result) {
    console.log(page);
  }
  } else {
    console.log("classesManagementGetClassesForUser failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
request operations.GetClassesForUserRequest ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.

Response

Promise<operations.GetClassesForUserResponse>

Errors

Error Type Status Code Content Type
errors.BadRequestResponseError 400 application/json
errors.UnauthorizedRequestResponseError 401 application/json
errors.ForbiddenResponseError 403 application/json
errors.NotFoundResponseError 404 application/json
errors.UnprocessableEntityResponseError 422 application/json
errors.TooManyRequestsResponseError 429 application/json
errors.InternalServerErrorResponse 500 application/json
errors.APIError 4XX, 5XX */*