

# 取得組態套件
<a name="configuration-bundles-get"></a>

擷取組態套件以檢查其中繼資料或讀取特定版本的完整組態內容。有兩個可用的操作：
+  **GetConfigurationBundle** — 傳回套件的最新版本。如果指定 `branchName` ， 會傳回該分支的最新版本。如果省略， 會傳回所有分支的最新版本。使用此項目可讀取目前的作用中組態。
+  **GetConfigurationBundleVersion** — 依版本 ID 傳回特定歷史版本。使用此項目來檢查過去的組態或比較版本。

## 套件中繼資料與版本內容
<a name="get-bundle-metadata-vs-content"></a>

 `GetConfigurationBundle` 會同時傳回套件層級中繼資料 （名稱、描述、ARN) 和完整版本內容 （具有其組態金鑰/值對的元件）。如果您只需要知道哪些版本存在，而不擷取其完整內容，請`ListConfigurationBundleVersions`改用 。

 `GetConfigurationBundleVersion` 會傳回相同的欄位加上 `versionCreatedAt`，告訴您確切建立該特定版本的時間 （而不是 `createdAt`，也就是第一次建立套件本身的時間）。

## 程式碼範例
<a name="get-bundle-examples"></a>

**Example**  
檢視套件的版本歷史記錄：  

```
agentcore config-bundle versions --name myAgentConfig
```
並排比較兩個版本：  

```
agentcore config-bundle diff --name myAgentConfig \
  --from <version-1> \
  --to <version-2>
```
沒有直接的「取得套件內容」CLI 命令 — `config-bundle`子命令為 `versions`、 `diff`和 `create-branch`。若要列舉版本並擷取其 IDs，請使用 `agentcore config-bundle versions --name myAgentConfig --json`（選用搭配 `--branch <name>`、 或 `--created-by <name>`)`--latest-per-branch`，然後將版本 IDs 饋送至 `config-bundle diff`。若要擷取套件版本的完整組態內容，請使用如下所示的 SDK/REST `GetConfigurationBundleVersion`操作。
取得套件中繼資料和最新版本內容：  

```
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']}")
```

## 請求參數
<a name="get-bundle-params"></a>

### GetConfigurationBundle
<a name="get-bundle-params-latest"></a>


| 參數 | Type | 必要 | 描述 | 
| --- | --- | --- | --- | 
|  `bundleId`  | String | 是 | 組態套件的 ID。以路徑參數傳遞。 | 
|  `branchName`  | String | 否 | 要從中取得最新版本的分支名稱。如果省略， 會傳回所有分支的最新版本。 | 

### GetConfigurationBundleVersion
<a name="get-bundle-params-version"></a>


| 參數 | Type | 必要 | 描述 | 
| --- | --- | --- | --- | 
|  `bundleId`  | String | 是 | 組態套件的 ID。以路徑參數傳遞。 | 
|  `versionId`  | String | 是 | 要擷取之特定版本的 UUID。以路徑參數傳遞。 | 

## 回應
<a name="get-bundle-response"></a>

這兩個操作都會傳回相同的欄位。 `GetConfigurationBundleVersion`也會傳回 `versionCreatedAt`。


| 欄位 | Type | Description | 
| --- | --- | --- | 
|  `bundleArn`  | String | 組態套件的 ARN。 | 
|  `bundleId`  | String | 組態套件的 ID。 | 
|  `bundleName`  | String | 套件的名稱。 | 
|  `description`  | String | 套件的描述 （如果設定）。 | 
|  `versionId`  | String | 傳回的 版本的 UUID。 | 
|  `components`  | Map | 元件識別符與元件組態的映射。每個值都包含一個`configuration`物件，其中包含存放在此版本中的鍵值對。 | 
|  `lineageMetadata`  | 物件 | 版本歷程中繼資料，包括 `parentVersionIds`、`createdBy`、 `branchName`和 `commitMessage`。 | 
|  `createdAt`  | 時間戳記 | 原始建立套件的時間。 | 
|  `updatedAt`  | 時間戳記 | 套件上次更新的時間 （僅限 GetConfigurationBundle)。 | 
|  `versionCreatedAt`  | 時間戳記 | 建立此特定版本時 （僅限 GetConfigurationBundleVersion)。 | 

## 錯誤
<a name="get-bundle-errors"></a>


| 錯誤 | HTTP 狀態 | 說明 | 
| --- | --- | --- | 
|  `ValidationException`  | 400 | 無效的請求參數。 | 
|  `ResourceNotFoundException`  | 404 | 指定的 `bundleId`或 `versionId` 不存在。 | 
|  `AccessDeniedException`  | 403 | 許可不足。驗證 IAM 政策包含 `bedrock-agentcore:GetConfigurationBundle`或 `bedrock-agentcore:GetConfigurationBundleVersion`。 | 
|  `ThrottlingException`  | 429 | 超過請求率。以指數退避重試。 | 
|  `InternalServerException`  | 500 | 服務端錯誤。重試 請求。 | 