使用 Amazon 开发工具包列出 IAM 的 SAML 提供商 - Amazon Identity and Access Management
Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅 中国的 Amazon Web Services 服务入门 (PDF)

使用 Amazon 开发工具包列出 IAM 的 SAML 提供商

以下代码示例展示如何列出 IAM 的 SAML 提供商。

.NET
Amazon SDK for .NET
注意

在 GitHub 上查看更多内容。查找完整示例,学习如何在 Amazon 代码示例存储库中进行设置和运行。

/// <summary> /// List SAML authentication providers. /// </summary> /// <returns>A list of SAML providers.</returns> public async Task<List<SAMLProviderListEntry>> ListSAMLProvidersAsync() { var response = await _IAMService.ListSAMLProvidersAsync(new ListSAMLProvidersRequest()); return response.SAMLProviderList; }
  • 有关 API 详细信息,请参阅《Amazon SDK for .NET API 参考》中的 ListSAMLProviders

Go
SDK for Go V2
注意

在 GitHub 上查看更多内容。查找完整示例,学习如何在 Amazon 代码示例存储库中进行设置和运行。

// AccountWrapper encapsulates AWS Identity and Access Management (IAM) account actions // used in the examples. // It contains an IAM service client that is used to perform account actions. type AccountWrapper struct { IamClient *iam.Client } // ListSAMLProviders gets the SAML providers for the account. func (wrapper AccountWrapper) ListSAMLProviders() ([]types.SAMLProviderListEntry, error) { var providers []types.SAMLProviderListEntry result, err := wrapper.IamClient.ListSAMLProviders(context.TODO(), &iam.ListSAMLProvidersInput{}) if err != nil { log.Printf("Couldn't list SAML providers. Here's why: %v\n", err) } else { providers = result.SAMLProviderList } return providers, err }
  • 有关 API 详细信息,请参阅《Amazon SDK for Go API 参考》中的 ListSAMLProviders

JavaScript
SDK for JavaScript (v3)
注意

在 GitHub 上查看更多内容。在 Amazon 代码示例存储库 中查找完整示例,了解如何进行设置和运行。

列出 SAML 提供商。

import { ListSAMLProvidersCommand, IAMClient } from "@aws-sdk/client-iam"; const client = new IAMClient({}); export const listSamlProviders = async () => { const command = new ListSAMLProvidersCommand({}); const response = await client.send(command); console.log(response); return response; };
  • 有关 API 详细信息,请参阅《Amazon SDK for JavaScript API 参考》中的 ListSAMLProviders

PHP
SDK for PHP
注意

在 GitHub 上查看更多内容。查找完整示例,学习如何在 Amazon 代码示例存储库中进行设置和运行。

$uuid = uniqid(); $service = new IAMService(); public function listSAMLProviders() { return $this->iamClient->listSAMLProviders(); }
  • 有关 API 详细信息,请参阅《Amazon SDK for PHP API 参考》中的 ListSAMLProviders

Python
适用于 Python (Boto3) 的 SDK
注意

在 GitHub 上查看更多内容。在 Amazon 代码示例存储库 中查找完整示例,了解如何进行设置和运行。

def list_saml_providers(count): """ Lists the SAML providers for the account. :param count: The maximum number of providers to list. """ try: found = 0 for provider in iam.saml_providers.limit(count): logger.info('Got SAML provider %s.', provider.arn) found += 1 if found == 0: logger.info("Your account has no SAML providers.") except ClientError: logger.exception("Couldn't list SAML providers.") raise
  • 有关 API 详细信息,请参阅《Amazon SDK for Python(Boto3)API 参考》中的 ListSAMLProviders

Ruby
SDK for Ruby
注意

在 GitHub 上查看更多内容。查找完整示例,学习如何在 Amazon 代码示例存储库中进行设置和运行。

# Lists up to a specified number of SAML providers for the account. # # @param count [Integer] The maximum number of providers to list. def list_saml_providers(count) @iam_resource.saml_providers.limit(count).each do |provider| puts("\t#{provider.arn}") end rescue Aws::Errors::ServiceError => e puts("Couldn't list SAML providers. Here's why:") puts("\t#{e.code}: #{e.message}") raise end
  • 有关 API 详细信息,请参阅《Amazon SDK for Ruby API 参考》中的 ListSAMLProviders

Rust
SDK for Rust
注意

本文档适用于预览版中的软件开发工具包。软件开发工具包可能随时发生变化,不应在生产环境中使用。

注意

在 GitHub 上查看更多内容。查找完整示例,学习如何在 Amazon 代码示例存储库中进行设置和运行。

pub async fn list_saml_providers( client: &Client, ) -> Result<ListSamlProvidersOutput, SdkError<ListSAMLProvidersError>> { let response = client.list_saml_providers().send().await?; Ok(response) }
  • 有关 API 详细信息,请参阅《Amazon SDK for Rust API 参考》中的 ListSAMLProviders

有关 Amazon 软件开发工具包开发人员指南和代码示例的完整列表,请参阅 将 IAM 与 Amazon 开发工具包配合使用。本主题还包括有关入门的信息以及有关先前的软件开发工具包版本的详细信息。