Skip to content

Latest commit

 

History

History
441 lines (335 loc) · 35.1 KB

File metadata and controls

441 lines (335 loc) · 35.1 KB

OrganizationsManagement

(organizationsManagement)

Overview

This enables the management of orgs i.e. an organization involved in the learning in some form or other.

Available Operations

getAllOrgs

To get all Organizations 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.organizationsManagement.getAllOrgs({
    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 { 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();

Parameters

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.

Response

Promise<operations.GetAllOrgsResponse>

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 */*

createOrg

To create a new Organization. The responding system must return the set of sourcedIds that have been allocated to the newly created org 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.organizationsManagement.createOrg();

  console.log(result);
}

run();

Standalone function

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();

Parameters

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.

Response

Promise<operations.CreateOrgResponse>

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 */*

getOrg

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.'

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.organizationsManagement.getOrg({
    sourcedId: "<id>",
  });

  console.log(result);
}

run();

Standalone function

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();

Parameters

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.

Response

Promise<operations.GetOrgResponse>

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 */*

updateOrg

To update an existing Organization. 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.organizationsManagement.updateOrg({
    sourcedId: "<id>",
  });

  console.log(result);
}

run();

Standalone function

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();

Parameters

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.

Response

Promise<{ [k: string]: any }>

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 */*

deleteOrg

Perform a soft delete on a specific Organization on the service provider. The operation changes the status of the Organization 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.organizationsManagement.deleteOrg({
    sourcedId: "<id>",
  });


}

run();

Standalone function

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();

Parameters

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.

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 */*