(usersManagement)
This enables the management of information about users (including students and teachers).
- getAllUsers - Get all Users
- createUser - Create a new User
- getUser - Get a specific User
- updateUser - Update an existing User
- deleteUser - Delete a User
- getUserWithDemographics - Get a specific User with demographics
- getClassesForUser - Get Classes for a User
To get all Users on the service provider.
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();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();| 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. |
Promise<operations.GetAllUsersResponse>
| 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 | */* |
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.
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();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();| 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. |
Promise<operations.CreateUserResponse>
| 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 | */* |
To get a specific User on the service provider.
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();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();| 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. |
Promise<operations.GetUserResponse>
| 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 | */* |
To update an existing User on the service provider. The sourcedId for the record to be updated is supplied by the requesting system.
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();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();| 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. |
Promise<operations.UpdateUserResponse>
| 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 | */* |
Perform a soft delete on a specific User on the service provider. This operation changes the status of the User to 'tobedeleted'.
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();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();| 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. |
Promise<void>
| 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 | */* |
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.'
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();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();| 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. |
Promise<operations.GetUserWithDemographicsResponse>
| 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 | */* |
To get the set of Classes a User is enrolled in.
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();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();| 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. |
Promise<operations.GetClassesForUserResponse>
| 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 | */* |