Terjemahan disediakan oleh mesin penerjemah. Jika konten terjemahan yang diberikan bertentangan dengan versi bahasa Inggris aslinya, utamakan versi bahasa Inggris.
Gunakan ListOrganizationalUnitsForParentdengan AWS SDK atau CLI
Contoh kode berikut menunjukkan cara menggunakanListOrganizationalUnitsForParent.
- .NET
-
- SDK untuk .NET
-
catatan
Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara mengatur dan menjalankannya di Repositori Contoh Kode AWS
. 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); } }-
Untuk detail API, lihat ListOrganizationalUnitsForParentdi Referensi AWS SDK untuk .NET API.
-
- CLI
-
- AWS CLI
-
Untuk mengambil daftar OU di OU induk atau root
Contoh berikut menunjukkan cara mendapatkan daftar OU di root tertentu:
aws organizations list-organizational-units-for-parent --parent-idr-examplerootid111Output menunjukkan bahwa root yang ditentukan berisi dua OU dan menunjukkan detail masing-masing:
{ "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/" } ] }-
Untuk detail API, lihat ListOrganizationalUnitsForParent
di Referensi AWS CLI Perintah.
-
Untuk daftar lengkap panduan pengembang AWS SDK dan contoh kode, lihatPenggunaan AWS Organizations dengan sebuah AWS SDK. Topik ini juga mencakup informasi tentang memulai dan detail tentang versi SDK sebelumnya.