Back to Aws Sdk Js V3

@aws-sdk/client-organizations

clients/client-organizations/README.md

3.1091.043.0 KB
Original Source
<!-- generated file, do not edit directly -->

@aws-sdk/client-organizations

Description

AWS SDK for JavaScript Organizations Client for Node.js, Browser and React Native.

<p>Organizations is a web service that enables you to consolidate your multiple Amazon Web Services accounts into an <i>organization</i> and centrally manage your accounts and their resources.</p> <p>This guide provides descriptions of the Organizations API. For more information about using this service, see the <a href="https://docs.aws.amazon.com/organizations/latest/userguide/orgs_introduction.html">Organizations User Guide</a>.</p> <p> <b>API version</b> </p> <p>This version of the Organizations API Reference documents the Organizations API version 2016-11-28.</p> <note> <p>As an alternative to using the API directly, you can use one of the Amazon Web Services SDKs, which consist of libraries and sample code for various programming languages and platforms (Java, Ruby, .NET, iOS, Android, and more). The SDKs provide a convenient way to create programmatic access to Organizations. For example, the SDKs take care of cryptographically signing requests, managing errors, and retrying requests automatically. For more information about the Amazon Web Services SDKs, including how to download and install them, see <a href="http://aws.amazon.com/tools/">Tools for Amazon Web Services</a>.</p> </note> <p>We recommend that you use the Amazon Web Services SDKs to make programmatic API calls to Organizations. However, you also can use the Organizations Query API to make direct calls to the Organizations web service. To learn more about the Organizations Query API, see <a href="https://docs.aws.amazon.com/organizations/latest/userguide/orgs_query-requests.html">Calling the API by making HTTP Query requests</a> in the <i>Organizations User Guide</i>. Organizations supports GET and POST requests for all actions. That is, the API doesn't require you to use GET for some actions and POST for others. However, GET requests are subject to the limitation size of a URL. Therefore, for operations that require larger sizes, use a POST request.</p> <p> <b>Signing requests</b> </p> <p>When you send HTTP requests to Amazon Web Services, sign the requests so that Amazon Web Services can identify who sent them. You sign requests with your Amazon Web Services access key, which consists of an access key ID and a secret access key. We strongly recommend that you don't create an access key for your root account. Anyone who has the access key for your root account has unrestricted access to all the resources in your account. Instead, create an access key for an IAM user that has administrative permissions. As another option, use Amazon Web Services Security Token Service (Amazon Web Services STS) to generate temporary security credentials, and use those credentials to sign requests.</p> <p>To sign requests, we recommend that you use <a href="https://docs.aws.amazon.com/general/latest/gr/signature-version-4.html">Signature Version 4</a>. If you have an existing application that uses Signature Version 2, you don't have to update it to use Signature Version 4. However, some operations now require Signature Version 4. The documentation for operations that require version 4 indicate this requirement.</p> <p>When you use the Command Line Interface (CLI) or one of the Amazon Web Services SDKs to make requests to Amazon Web Services, these tools automatically sign the requests for you with the access key that you specify when you configure the tools.</p> <p>In this release, each organization can have only one root.</p> <p> <b>Support and feedback for Organizations</b> </p> <p>We welcome your feedback. You can post your feedback and questions in the <a href="https://forums.aws.amazon.com/forum.jspa?forumID=219">Organizations support forum</a>. For more information about the Amazon Web Services Support forums, see <a href="https://forums.aws.amazon.com/help.jspa">Forums Help</a>.</p> <p> <b>Endpoint to call When using the CLI or the Amazon Web Services SDK</b> </p> <p>For the current release of Organizations, specify the <code>us-east-1</code> region for all Amazon Web Services API and CLI calls made from the commercial Amazon Web Services Regions outside of China. If calling from one of the Amazon Web Services Regions in China, then specify <code>cn-northwest-1</code>. You can do this in the CLI by using these parameters and commands:</p> <ul> <li> <p>Use the following parameter with each command to specify both the endpoint and its region:</p> <p> <code>--endpoint-url https://organizations.us-east-1.amazonaws.com</code> <i>(from commercial Amazon Web Services Regions outside of China)</i> </p> <p>or</p> <p> <code>--endpoint-url https://organizations.cn-northwest-1.amazonaws.com.cn</code> <i>(from Amazon Web Services Regions in China)</i> </p> </li> <li> <p>Use the default endpoint, but configure your default region with this command:</p> <p> <code>aws configure set default.region us-east-1</code> <i>(from commercial Amazon Web Services Regions outside of China)</i> </p> <p>or</p> <p> <code>aws configure set default.region cn-northwest-1</code> <i>(from Amazon Web Services Regions in China)</i> </p> </li> <li> <p>Use the following parameter with each command to specify the endpoint:</p> <p> <code>--region us-east-1</code> <i>(from commercial Amazon Web Services Regions outside of China)</i> </p> <p>or</p> <p> <code>--region cn-northwest-1</code> <i>(from Amazon Web Services Regions in China)</i> </p> </li> </ul> <p> <b>How examples are presented</b> </p> <p>The JSON returned by the Organizations service as response to your requests arrives as a single long string without line breaks or formatting whitespace. The examples in this guide include both line breaks and whitespace to improve readability. When example input parameters also would result in long strings that would extend beyond the screen, we insert line breaks to enhance readability. Always submit the input as a single JSON text string.</p> <p> <b>Recording API Requests</b> </p> <p>Organizations supports CloudTrail, a service that records Amazon Web Services API calls for your Amazon Web Services account and delivers log files to an Amazon S3 bucket. By using information collected by CloudTrail, you can determine which requests the Organizations service received, who made the request and when, and so on. For more about Organizations and its support for CloudTrail, see <a href="https://docs.aws.amazon.com/organizations/latest/userguide/orgs_security_incident-response.html#orgs_cloudtrail-integration">Logging Organizations API calls with CloudTrail</a> in the <i>Organizations User Guide</i>. To learn more about CloudTrail, including how to turn it on and find your log files, see the <a href="https://docs.aws.amazon.com/awscloudtrail/latest/userguide/what_is_cloud_trail_top_level.html">CloudTrail User Guide</a>.</p>

Installing

To install this package, use the CLI of your favorite package manager:

  • npm install @aws-sdk/client-organizations
  • yarn add @aws-sdk/client-organizations
  • pnpm add @aws-sdk/client-organizations

Getting Started

Import

The AWS SDK is modulized by clients and commands. To send a request, you only need to import the OrganizationsClient and the commands you need, for example ListRootsCommand:

js
// ES5 example
const { OrganizationsClient, ListRootsCommand } = require("@aws-sdk/client-organizations");
ts
// ES6+ example
import { OrganizationsClient, ListRootsCommand } from "@aws-sdk/client-organizations";

Usage

To send a request:

  • Instantiate a client with configuration (e.g. credentials, region).
  • Instantiate a command with input parameters.
  • Call the send operation on the client, providing the command object as input.
js
const client = new OrganizationsClient({ region: "REGION" });

const params = { /** input parameters */ };
const command = new ListRootsCommand(params);

Async/await

We recommend using the await operator to wait for the promise returned by send operation as follows:

js
// async/await.
try {
  const data = await client.send(command);
  // process data.
} catch (error) {
  // error handling.
} finally {
  // finally.
}

Promises

You can also use Promise chaining.

js
client
  .send(command)
  .then((data) => {
    // process data.
  })
  .catch((error) => {
    // error handling.
  })
  .finally(() => {
    // finally.
  });

Aggregated client

The aggregated client class is exported from the same package, but without the "Client" suffix.

Organizations extends OrganizationsClient and additionally supports all operations, waiters, and paginators as methods. This style may be familiar to you from the AWS SDK for JavaScript v2.

If you are bundling the AWS SDK, we recommend using only the bare-bones client (OrganizationsClient). More details are in the blog post on modular packages in AWS SDK for JavaScript.

ts
import { Organizations } from "@aws-sdk/client-organizations";

const client = new Organizations({ region: "REGION" });

// async/await.
try {
  const data = await client.listRoots(params);
  // process data.
} catch (error) {
  // error handling.
}

// Promises.
client
  .listRoots(params)
  .then((data) => {
    // process data.
  })
  .catch((error) => {
    // error handling.
  });

// callbacks (not recommended).
client.listRoots(params, (err, data) => {
  // process err and data.
});

Troubleshooting

When the service returns an exception, the error will include the exception information, as well as response metadata (e.g. request id).

js
try {
  const data = await client.send(command);
  // process data.
} catch (error) {
  const { requestId, cfId, extendedRequestId } = error.$metadata;
  console.log({ requestId, cfId, extendedRequestId });
  /**
   * The keys within exceptions are also parsed.
   * You can access them by specifying exception names:
   * if (error.name === 'SomeServiceException') {
   *     const value = error.specialKeyInException;
   * }
   */
}

See also docs/ERROR_HANDLING.

Getting Help

Please use these community resources for getting help. We use GitHub issues for tracking bugs and feature requests, but have limited bandwidth to address them.

To test your universal JavaScript code in Node.js, browser and react-native environments, visit our code samples repo.

Contributing

This client code is generated automatically. Any modifications will be overwritten the next time the @aws-sdk/client-organizations package is updated. To contribute to client you can check our generate clients scripts.

License

This SDK is distributed under the Apache License, Version 2.0, see LICENSE for more information.

Client Commands (Operations List)

<details> <summary> AcceptHandshake </summary>

Command API Reference / Input / Output

</details> <details> <summary> AttachPolicy </summary>

Command API Reference / Input / Output

</details> <details> <summary> CancelHandshake </summary>

Command API Reference / Input / Output

</details> <details> <summary> CloseAccount </summary>

Command API Reference / Input / Output

</details> <details> <summary> CreateAccount </summary>

Command API Reference / Input / Output

</details> <details> <summary> CreateGovCloudAccount </summary>

Command API Reference / Input / Output

</details> <details> <summary> CreateOrganization </summary>

Command API Reference / Input / Output

</details> <details> <summary> CreateOrganizationalUnit </summary>

Command API Reference / Input / Output

</details> <details> <summary> CreatePolicy </summary>

Command API Reference / Input / Output

</details> <details> <summary> DeclineHandshake </summary>

Command API Reference / Input / Output

</details> <details> <summary> DeleteOrganization </summary>

Command API Reference / Input / Output

</details> <details> <summary> DeleteOrganizationalUnit </summary>

Command API Reference / Input / Output

</details> <details> <summary> DeletePolicy </summary>

Command API Reference / Input / Output

</details> <details> <summary> DeleteResourcePolicy </summary>

Command API Reference / Input / Output

</details> <details> <summary> DeregisterDelegatedAdministrator </summary>

Command API Reference / Input / Output

</details> <details> <summary> DescribeAccount </summary>

Command API Reference / Input / Output

</details> <details> <summary> DescribeCreateAccountStatus </summary>

Command API Reference / Input / Output

</details> <details> <summary> DescribeEffectivePolicy </summary>

Command API Reference / Input / Output

</details> <details> <summary> DescribeHandshake </summary>

Command API Reference / Input / Output

</details> <details> <summary> DescribeOrganization </summary>

Command API Reference / Input / Output

</details> <details> <summary> DescribeOrganizationalUnit </summary>

Command API Reference / Input / Output

</details> <details> <summary> DescribePolicy </summary>

Command API Reference / Input / Output

</details> <details> <summary> DescribeResourcePolicy </summary>

Command API Reference / Input / Output

</details> <details> <summary> DescribeResponsibilityTransfer </summary>

Command API Reference / Input / Output

</details> <details> <summary> DetachPolicy </summary>

Command API Reference / Input / Output

</details> <details> <summary> DisableAWSServiceAccess </summary>

Command API Reference / Input / Output

</details> <details> <summary> DisablePolicyType </summary>

Command API Reference / Input / Output

</details> <details> <summary> EnableAllFeatures </summary>

Command API Reference / Input / Output

</details> <details> <summary> EnableAWSServiceAccess </summary>

Command API Reference / Input / Output

</details> <details> <summary> EnablePolicyType </summary>

Command API Reference / Input / Output

</details> <details> <summary> InviteAccountToOrganization </summary>

Command API Reference / Input / Output

</details> <details> <summary> InviteOrganizationToTransferResponsibility </summary>

Command API Reference / Input / Output

</details> <details> <summary> LeaveOrganization </summary>

Command API Reference / Input / Output

</details> <details> <summary> ListAccounts </summary>

Command API Reference / Input / Output

</details> <details> <summary> ListAccountsForParent </summary>

Command API Reference / Input / Output

</details> <details> <summary> ListAccountsWithInvalidEffectivePolicy </summary>

Command API Reference / Input / Output

</details> <details> <summary> ListAWSServiceAccessForOrganization </summary>

Command API Reference / Input / Output

</details> <details> <summary> ListChildren </summary>

Command API Reference / Input / Output

</details> <details> <summary> ListCreateAccountStatus </summary>

Command API Reference / Input / Output

</details> <details> <summary> ListDelegatedAdministrators </summary>

Command API Reference / Input / Output

</details> <details> <summary> ListDelegatedServicesForAccount </summary>

Command API Reference / Input / Output

</details> <details> <summary> ListEffectivePolicyValidationErrors </summary>

Command API Reference / Input / Output

</details> <details> <summary> ListHandshakesForAccount </summary>

Command API Reference / Input / Output

</details> <details> <summary> ListHandshakesForOrganization </summary>

Command API Reference / Input / Output

</details> <details> <summary> ListInboundResponsibilityTransfers </summary>

Command API Reference / Input / Output

</details> <details> <summary> ListOrganizationalUnitsForParent </summary>

Command API Reference / Input / Output

</details> <details> <summary> ListOutboundResponsibilityTransfers </summary>

Command API Reference / Input / Output

</details> <details> <summary> ListParents </summary>

Command API Reference / Input / Output

</details> <details> <summary> ListPolicies </summary>

Command API Reference / Input / Output

</details> <details> <summary> ListPoliciesForTarget </summary>

Command API Reference / Input / Output

</details> <details> <summary> ListRoots </summary>

Command API Reference / Input / Output

</details> <details> <summary> ListTagsForResource </summary>

Command API Reference / Input / Output

</details> <details> <summary> ListTargetsForPolicy </summary>

Command API Reference / Input / Output

</details> <details> <summary> MoveAccount </summary>

Command API Reference / Input / Output

</details> <details> <summary> PutResourcePolicy </summary>

Command API Reference / Input / Output

</details> <details> <summary> RegisterDelegatedAdministrator </summary>

Command API Reference / Input / Output

</details> <details> <summary> RemoveAccountFromOrganization </summary>

Command API Reference / Input / Output

</details> <details> <summary> TagResource </summary>

Command API Reference / Input / Output

</details> <details> <summary> TerminateResponsibilityTransfer </summary>

Command API Reference / Input / Output

</details> <details> <summary> UntagResource </summary>

Command API Reference / Input / Output

</details> <details> <summary> UpdateOrganizationalUnit </summary>

Command API Reference / Input / Output

</details> <details> <summary> UpdatePolicy </summary>

Command API Reference / Input / Output

</details> <details> <summary> UpdateResponsibilityTransfer </summary>

Command API Reference / Input / Output

</details>