View a markdown version of this page

获取配置包 - 亚马逊基岩 AgentCore

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

获取配置包

检索配置包以检查其元数据或读取特定版本的完整配置内容。有两种操作可用:

  • GetConfigurationBundle— 返回捆绑包的最新版本。如果指定,branchName则返回该分支的最新版本。如果省略,则返回所有分支的最新版本。使用它来读取当前的活动配置。

  • GetConfigurationBundleVersion— 按版本 ID 返回特定的历史版本。使用它来检查过去的配置或比较版本。

捆绑元数据与版本内容

GetConfigurationBundle返回包级元数据(名称、描述、ARN)和完整版本内容(组件及其配置键值对)。如果您只需要知道哪些版本存在而不获取其完整内容,请ListConfigurationBundleVersions改用。

GetConfigurationBundleVersion返回相同的字段 plusversionCreatedAt,它会告诉你该特定版本的确切创建时间(相反createdAt,这是包本身首次创建的时间)。

代码示例

例
AgentCore CLI

查看捆绑包的版本历史记录:

agentcore config-bundle versions --name myAgentConfig

并排比较两个版本:

agentcore config-bundle diff --name myAgentConfig \ --from <version-1> \ --to <version-2>
注意

没有直接的 “获取捆绑内容” CLI 命令—— config-bundle 子命令是versionsdiff、和create-branch。要枚举版本并捕获其 ID,请使用agentcore config-bundle versions --name myAgentConfig --json(可选地与--branch <name>--latest-per-branch、或--created-by <name>),然后将版本 ID 输入到config-bundle diff。要获取捆绑版本的完整配置内容,请使用如下所示的 SDK/REST GetConfigurationBundleVersion操作。

AWS SDK (boto3)

获取套装元数据和最新版本内容:

import boto3 client = boto3.client("bedrock-agentcore-control", region_name="us-west-2") response = client.get_configuration_bundle( bundleId="myAgentConfig-a1b2c3d4e5" ) print(f"Bundle: {response['bundleName']}") print(f"Version: {response['versionId']}") print(f"Branch: {response.get('lineageMetadata', {}).get('branchName', 'N/A')}") print(f"Components: {response['components']}")

获取特定的历史版本:

response = client.get_configuration_bundle_version( bundleId="myAgentConfig-a1b2c3d4e5", versionId="12345678-1234-1234-1234-123456789012" ) print(f"Version: {response['versionId']}") print(f"Version created at: {response['versionCreatedAt']}") print(f"Commit message: {response.get('lineageMetadata', {}).get('commitMessage', '')}") print(f"Components: {response['components']}")

请求参数

GetConfigurationBundle

参数 Type 必需 描述

bundleId

字符串

是

配置包的 ID。作为路径参数传递。

branchName

字符串

否

从中获取最新版本的分支名称。如果省略,则返回所有分支的最新版本。

GetConfigurationBundleVersion

参数 Type 必需 描述

bundleId

字符串

是

配置包的 ID。作为路径参数传递。

versionId

字符串

是

要检索的特定版本的 UUID。作为路径参数传递。

响应

这两个操作返回相同的字段。GetConfigurationBundleVersion另外返回versionCreatedAt。

字段 Type 说明

bundleArn

字符串

配置包的 ARN。

bundleId

字符串

配置包的 ID。

bundleName

字符串

捆绑包的名称。

description

字符串

捆绑包的描述(如果已设置)。

versionId

字符串

返回版本的 UUID。

components

Map

组件标识符映射到组件配置。每个值都包含一个configuration对象,其键值对存储在此版本中。

lineageMetadata

对象

版本世系元数据包括parentVersionIds、branchNamecreatedBy、和。commitMessage

createdAt

Timestamp

最初创建捆绑包的时间。

updatedAt

Timestamp

上次更新捆绑包的时间(GetConfigurationBundle 仅限)。

versionCreatedAt

Timestamp

创建此特定版本的时间(GetConfigurationBundleVersion 仅限)。

错误

错误 HTTP 状态 说明

ValidationException

400

请求参数无效。

ResourceNotFoundException

404

指定的bundleId或versionId不存在。

AccessDeniedException

403

权限不足。验证 IAM 策略是否包含bedrock-agentcore:GetConfigurationBundle或bedrock-agentcore:GetConfigurationBundleVersion。

ThrottlingException

429

超出请求速率。使用指数回退进行重试。

InternalServerException

500

Service-side 错误。重试请求。