Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅
中国的 Amazon Web Services 服务入门
(PDF)。
本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
DescribeTermsByClient搭配使用 Amazon SDK
以下代码示例演示了如何使用 DescribeTermsByClient。
操作示例是大型程序的代码摘录,必须在上下文中运行。在以下代码示例中,您可以查看此操作的上下文:
- Python
-
- 适用于 Python 的 SDK(Boto3)
-
def describe_terms_by_client(
self, user_pool_id: str, client_id: str, terms_name: str
) -> dict[str, Any]:
"""
Looks up a Terms document associated with an app client by client ID,
user pool ID, and terms name.
:param user_pool_id: The ID of the user pool that contains the Terms documents.
:param client_id: The ID of the app client associated with the Terms.
:param terms_name: The name of the terms document ('terms-of-use' or
'privacy-policy').
:return: A dictionary with the Terms document details.
"""
try:
response = self.cognito_idp_client.describe_terms_by_client(
UserPoolId=user_pool_id,
ClientId=client_id,
TermsName=terms_name,
)
terms = response.get("Terms", dict())
logger.info(
"Described terms '%s' for client %s in user pool %s.",
terms_name,
client_id,
user_pool_id,
)
return terms
except ClientError as err:
if err.response["Error"]["Code"] == "ResourceNotFoundException":
logger.error(
"No terms documents found for client %s, user pool %s, "
"and terms name '%s'.",
client_id,
user_pool_id,
terms_name,
)
raise
有关 S Amazon DK 开发者指南和代码示例的完整列表,请参阅将此服务与 Amazon SDK。本主题还包括有关入门的信息以及有关先前的 SDK 版本的详细信息。