(organizationsManagement)
This enables the management of orgs i.e. an organization involved in the learning in some form or other.
- getAllOrgs - Get all Organizations
- createOrg - Create an Organization
- getOrg - Get a specific Organization
- updateOrg - Update an Organization
- deleteOrg - Delete an Organization
To get all Organizations 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.organizationsManagement.getAllOrgs({
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 { organizationsManagementGetAllOrgs } from "@superbuilders/oneroster/funcs/organizationsManagementGetAllOrgs.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 organizationsManagementGetAllOrgs(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("organizationsManagementGetAllOrgs failed:", res.error);
}
}
run();| Parameter | Type | Required | Description |
|---|---|---|---|
request |
operations.GetAllOrgsRequest | ✔️ | 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.GetAllOrgsResponse>
| 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 Organization. The responding system must return the set of sourcedIds that have been allocated to the newly created org 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.organizationsManagement.createOrg();
console.log(result);
}
run();The standalone function version of this method:
import { OneRosterCore } from "@superbuilders/oneroster/core.js";
import { organizationsManagementCreateOrg } from "@superbuilders/oneroster/funcs/organizationsManagementCreateOrg.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 organizationsManagementCreateOrg(oneRoster);
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("organizationsManagementCreateOrg failed:", res.error);
}
}
run();| Parameter | Type | Required | Description |
|---|---|---|---|
request |
operations.CreateOrgRequest | ✔️ | 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.CreateOrgResponse>
| 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 | */* |
Get a specific Organization on the service provider. If the corresponding record cannot be located, the api will return a 404 error code and message 'Organization 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.organizationsManagement.getOrg({
sourcedId: "<id>",
});
console.log(result);
}
run();The standalone function version of this method:
import { OneRosterCore } from "@superbuilders/oneroster/core.js";
import { organizationsManagementGetOrg } from "@superbuilders/oneroster/funcs/organizationsManagementGetOrg.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 organizationsManagementGetOrg(oneRoster, {
sourcedId: "<id>",
});
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("organizationsManagementGetOrg failed:", res.error);
}
}
run();| Parameter | Type | Required | Description |
|---|---|---|---|
request |
operations.GetOrgRequest | ✔️ | 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.GetOrgResponse>
| 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 Organization. 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.organizationsManagement.updateOrg({
sourcedId: "<id>",
});
console.log(result);
}
run();The standalone function version of this method:
import { OneRosterCore } from "@superbuilders/oneroster/core.js";
import { organizationsManagementUpdateOrg } from "@superbuilders/oneroster/funcs/organizationsManagementUpdateOrg.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 organizationsManagementUpdateOrg(oneRoster, {
sourcedId: "<id>",
});
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("organizationsManagementUpdateOrg failed:", res.error);
}
}
run();| Parameter | Type | Required | Description |
|---|---|---|---|
request |
operations.UpdateOrgRequest | ✔️ | 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<{ [k: string]: any }>
| 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 Organization on the service provider. The operation changes the status of the Organization 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.organizationsManagement.deleteOrg({
sourcedId: "<id>",
});
}
run();The standalone function version of this method:
import { OneRosterCore } from "@superbuilders/oneroster/core.js";
import { organizationsManagementDeleteOrg } from "@superbuilders/oneroster/funcs/organizationsManagementDeleteOrg.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 organizationsManagementDeleteOrg(oneRoster, {
sourcedId: "<id>",
});
if (res.ok) {
const { value: result } = res;
} else {
console.log("organizationsManagementDeleteOrg failed:", res.error);
}
}
run();| Parameter | Type | Required | Description |
|---|---|---|---|
request |
operations.DeleteOrgRequest | ✔️ | 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 | */* |