View a markdown version of this page

Verwenden Sie ListOrganizationalUnitsForParentmit einem AWS SDK oder CLI - AWS Organizations

Die vorliegende Übersetzung wurde maschinell erstellt. Im Falle eines Konflikts oder eines Widerspruchs zwischen dieser übersetzten Fassung und der englischen Fassung (einschließlich infolge von Verzögerungen bei der Übersetzung) ist die englische Fassung maßgeblich.

Verwenden Sie ListOrganizationalUnitsForParentmit einem AWS SDK oder CLI

Die folgenden Code-Beispiele zeigen, wie ListOrganizationalUnitsForParent verwendet wird.

.NET
SDK für .NET
Anmerkung

Es gibt noch mehr dazu GitHub. Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das AWS -Code-Beispiel- einrichten und ausführen.

using System; using System.Threading.Tasks; using Amazon.Organizations; using Amazon.Organizations.Model; /// <summary> /// Lists the AWS Organizations organizational units that belong to an /// organization. /// </summary> public class ListOrganizationalUnitsForParent { /// <summary> /// Initializes the Organizations client object and then uses it to /// call the ListOrganizationalUnitsForParentAsync method to retrieve /// the list of organizational units. /// </summary> public static async Task Main() { // Create the client object using the default account. IAmazonOrganizations client = new AmazonOrganizationsClient(); var parentId = "r-0000"; var request = new ListOrganizationalUnitsForParentRequest { ParentId = parentId, MaxResults = 5, }; var response = new ListOrganizationalUnitsForParentResponse(); try { do { response = await client.ListOrganizationalUnitsForParentAsync(request); response.OrganizationalUnits.ForEach(u => DisplayOrganizationalUnit(u)); if (response.NextToken is not null) { request.NextToken = response.NextToken; } } while (response.NextToken is not null); } catch (Exception ex) { Console.WriteLine(ex.Message); } } /// <summary> /// Displays information about an Organizations organizational unit. /// </summary> /// <param name="unit">The OrganizationalUnit for which to display /// information.</param> public static void DisplayOrganizationalUnit(OrganizationalUnit unit) { string accountInfo = $"{unit.Id} {unit.Name}\t{unit.Arn}"; Console.WriteLine(accountInfo); } }
CLI
AWS CLI

So rufen Sie eine Liste der OUs in einer übergeordneten OU oder im Stammverzeichnis ab

Das folgende Beispiel zeigt, wie Sie eine Liste von OUs in einem angegebenen Root abrufen:

aws organizations list-organizational-units-for-parent --parent-id r-examplerootid111

Die Ausgabe zeigt, dass das angegebene Stammverzeichnis zwei Organisationseinheiten enthält, und es werden Details zu jeder Organisationseinheit angezeigt:

{ "OrganizationalUnits": [ { "Name": "AccountingDepartment", "Arn": "arn:aws:organizations::o-exampleorgid:ou/r-examplerootid111/ou-examplerootid111-exampleouid111", "Id": "ou-examplerootid111-exampleouid111", "Path": "o-exampleorgid/r-examplerootid111/ou-examplerootid111-exampleouid111/" }, { "Name": "ProductionDepartment", "Arn": "arn:aws:organizations::o-exampleorgid:ou/r-examplerootid111/ou-examplerootid111-exampleouid222", "Id": "ou-examplerootid111-exampleouid222", "Path": "o-exampleorgid/r-examplerootid111/ou-examplerootid111-exampleouid222/" } ] }

Eine vollständige Liste der AWS SDK-Entwicklerhandbücher und Codebeispiele finden Sie unterVerwenden AWS Organizations mit einem AWS SDK. Dieses Thema enthält auch Informationen zu den ersten Schritten und Details zu früheren SDK-Versionen.