

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 使用 的 AppRegistry 範例 AWS CLI
<a name="cli_service-catalog-appregistry_code_examples"></a>

下列程式碼範例示範如何使用 AWS Command Line Interface 搭配 AppRegistry 執行動作和實作常見案例。

*Actions* 是大型程式的程式碼摘錄，必須在內容中執行。雖然動作會告訴您如何呼叫個別服務函數，但您可以在其相關情境中查看內容中的動作。

每個範例均包含完整原始碼的連結，您可在連結中找到如何設定和執行內容中程式碼的相關指示。

**Topics**
+ [動作](#actions)

## 動作
<a name="actions"></a>

### `associate-attribute-group`
<a name="service-catalog-appregistry_AssociateAttributeGroup_cli_topic"></a>

以下程式碼範例顯示如何使用 `associate-attribute-group`。

**AWS CLI**  
**建立屬性群組的關聯**  
下列`associate-attribute-group`範例會將您 AWS 帳戶中的特定屬性群組與您 AWS 帳戶中的特定應用程式建立關聯。  

```
aws servicecatalog-appregistry associate-attribute-group \
    --application "ExampleApplication" \
    --attribute-group "ExampleAttributeGroup"
```
輸出：  

```
{
    "applicationArn": "arn:aws:servicecatalog:us-west-2:813737243517:/applications/0ars38r6btoohvpvd9gqrptt9l",
    "attributeGroupArn": "arn:aws:servicecatalog:us-west-2:813737243517:/attribute-groups/01sj5xdwhbw54kejwnt09fnpcl"
}
```
如需詳細資訊，請參閱《*AWS Service Catalog AppRegistry 管理員指南*》中的[關聯和取消關聯屬性群組](https://docs.aws.amazon.com/servicecatalog/latest/arguide/associate-attr-groups.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [AssociateAttributeGroup](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/servicecatalog-appregistry/associate-attribute-group.html)。

### `create-application`
<a name="service-catalog-appregistry_CreateApplication_cli_topic"></a>

以下程式碼範例顯示如何使用 `create-application`。

**AWS CLI**  
**建立應用程式**  
下列`create-application`範例會在您的帳戶中建立新的應用程式 AWS 。  

```
aws servicecatalog-appregistry create-application \
    --name "ExampleApplication"
```
輸出：  

```
{
    "application": {
        "id": "0ars38r6btoohvpvd9gqrptt9l",
        "arn": "arn:aws:servicecatalog:us-west-2:813737243517:/applications/0ars38r6btoohvpvd9gqrptt9l",
        "name": "ExampleApplication",
        "creationTime": "2023-02-28T21:10:10.820000+00:00",
        "lastUpdateTime": "2023-02-28T21:10:10.820000+00:00",
        "tags": {}
    }
}
```
如需詳細資訊，請參閱《AWS Service Catalog AppRegistry 管理員指南》**中的[建立應用程式](https://docs.aws.amazon.com/servicecatalog/latest/arguide/create-apps.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [CreateApplication](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/servicecatalog-appregistry/create-application.html)。

### `create-attribute-group`
<a name="service-catalog-appregistry_CreateAttributeGroup_cli_topic"></a>

以下程式碼範例顯示如何使用 `create-attribute-group`。

**AWS CLI**  
**建立屬性群組**  
下列`create-attribute-group`範例會在您的帳戶中建立新的屬性群組 AWS 。  

```
aws servicecatalog-appregistry create-attribute-group \
    --name "ExampleAttributeGroup" \
    --attributes '{"SomeKey1":"SomeValue1","SomeKey2":"SomeValue2"}'
```
輸出：  

```
{
    "attributeGroup": {
        "id": "01sj5xdwhbw54kejwnt09fnpcl",
        "arn": "arn:aws:servicecatalog:us-west-2:813737243517:/attribute-groups/01sj5xdwhbw54kejwnt09fnpcl",
        "name": "ExampleAttributeGroup",
        "creationTime": "2023-02-28T20:38:01.389000+00:00",
        "lastUpdateTime": "2023-02-28T20:38:01.389000+00:00",
        "tags": {}
    }
}
```
如需詳細資訊，請參閱《AWS Service Catalog AppRegistry 管理員指南》**中的[建立屬性群組](https://docs.aws.amazon.com/servicecatalog/latest/arguide/create-attr-groups.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [CreateAttributeGroup](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/servicecatalog-appregistry/create-attribute-group.html)。

### `delete-application`
<a name="service-catalog-appregistry_DeleteApplication_cli_topic"></a>

以下程式碼範例顯示如何使用 `delete-application`。

**AWS CLI**  
**如欲刪除應用程式**  
下列`delete-application`範例會刪除您 AWS 帳戶中的特定應用程式。  

```
aws servicecatalog-appregistry delete-application \
    --application "ExampleApplication3"
```
輸出：  

```
{
    "application": {
        "id": "055gw7aynr1i5mbv7kjwzx5945",
        "arn": "arn:aws:servicecatalog:us-west-2:813737243517:/applications/055gw7aynr1i5mbv7kjwzx5945",
        "name": "ExampleApplication3",
        "creationTime": "2023-02-28T22:06:28.228000+00:00",
        "lastUpdateTime": "2023-02-28T22:06:28.228000+00:00"
    }
}
```
如需詳細資訊，請參閱《AWS Service Catalog AppRegistry 管理員指南》**中的[刪除應用程式](https://docs.aws.amazon.com/servicecatalog/latest/arguide/delete-app-details.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [DeleteApplication](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/servicecatalog-appregistry/delete-application.html)。

### `delete-attribute-group`
<a name="service-catalog-appregistry_DeleteAttributeGroup_cli_topic"></a>

以下程式碼範例顯示如何使用 `delete-attribute-group`。

**AWS CLI**  
**範例 8：刪除屬性群組**  
下列`delete-attribute-group`範例會刪除您 AWS 帳戶中的特定屬性群組。  

```
aws servicecatalog-appregistry delete-attribute-group \
    --attribute-group "ExampleAttributeGroup3"
```
輸出：  

```
{
    "attributeGroup": {
        "id": "011ge6y3emyjijt8dw8jn6r0hv",
        "arn": "arn:aws:servicecatalog:us-west-2:813737243517:/attribute-groups/011ge6y3emyjijt8dw8jn6r0hv",
        "name": "ExampleAttributeGroup3",
        "creationTime": "2023-02-28T22:05:35.224000+00:00",
        "lastUpdateTime": "2023-02-28T22:05:35.224000+00:00"
    }
}
```
如需詳細資訊，請參閱《AWS Service Catalog AppRegistry 管理員指南》**中的[刪除屬性群組](https://docs.aws.amazon.com/servicecatalog/latest/arguide/delete-attr-group.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [DeleteAttributeGroup](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/servicecatalog-appregistry/delete-attribute-group.html)。

### `get-application`
<a name="service-catalog-appregistry_GetApplication_cli_topic"></a>

以下程式碼範例顯示如何使用 `get-application`。

**AWS CLI**  
**取得應用程式**  
下列`get-application`範例會擷取您 AWS 帳戶中特定應用程式的中繼資料資訊。  

```
aws servicecatalog-appregistry get-application \
    --application "ExampleApplication"
```
輸出：  

```
{
    "id": "0ars38r6btoohvpvd9gqrptt9l",
    "arn": "arn:aws:servicecatalog:us-west-2:813737243517:/applications/0ars38r6btoohvpvd9gqrptt9l",
    "name": "ExampleApplication",
    "creationTime": "2023-02-28T21:10:10.820000+00:00",
    "lastUpdateTime": "2023-02-28T21:10:10.820000+00:00",
    "associatedResourceCount": 0,
    "tags": {
        "aws:servicecatalog:applicationName": "ExampleApplication"
    },
    "integrations": {
        "resourceGroup": {
            "state": "CREATE_COMPLETE",
            "arn": "arn:aws:resource-groups:us-west-2:813737243517:group/AWS_AppRegistry_Application-ExampleApplication"
        }
    }
}
```
如需詳細資訊，請參閱《AWS Service Catalog AppRegistry 管理員指南》**中的[使用應用程式詳細資訊](https://docs.aws.amazon.com/servicecatalog/latest/arguide/access-app-details.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [GetApplication](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/servicecatalog-appregistry/get-application.html)。

### `get-attribute-group`
<a name="service-catalog-appregistry_GetAttributeGroup_cli_topic"></a>

以下程式碼範例顯示如何使用 `get-attribute-group`。

**AWS CLI**  
**取得屬性群組**  
下列`get-attribute-group`範例會擷取您 AWS 帳戶中的特定屬性群組。  

```
aws servicecatalog-appregistry get-attribute-group \
    --attribute-group "ExampleAttributeGroup"
```
輸出：  

```
{
    "id": "01sj5xdwhbw54kejwnt09fnpcl",
    "arn": "arn:aws:servicecatalog:us-west-2:813737243517:/attribute-groups/01sj5xdwhbw54kejwnt09fnpcl",
    "name": "ExampleAttributeGroup",
    "attributes": "{\"SomeKey1\":\"SomeValue1\",\"SomeKey2\":\"SomeValue2\"}",
    "creationTime": "2023-02-28T20:38:01.389000+00:00",
    "lastUpdateTime": "2023-02-28T20:38:01.389000+00:00",
    "tags": {
        "aws:servicecatalog:attributeGroupName": "ExampleAttributeGroup"
    }
}
```
如需詳細資訊，請參閱《AWS Service Catalog AppRegistry 管理員指南》**中的[管理屬性群組的中繼資料](https://docs.aws.amazon.com/servicecatalog/latest/arguide/manage-metatdata.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [GetAttributeGroup](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/servicecatalog-appregistry/get-attribute-group.html)。

### `list-applications`
<a name="service-catalog-appregistry_ListApplications_cli_topic"></a>

以下程式碼範例顯示如何使用 `list-applications`。

**AWS CLI**  
**列出應用程式**  
下列`list-applications`範例會擷取您 AWS 帳戶中所有應用程式的清單。  

```
aws servicecatalog-appregistry list-applications
```
輸出：  

```
{
    "applications": [
        {
            "id": "03axw94pjfj3uan00tcgbrxnkw",
            "arn": "arn:aws:servicecatalog:us-west-2:813737243517:/applications/03axw94pjfj3uan00tcgbrxnkw",
            "name": "ExampleApplication2",
            "creationTime": "2023-02-28T21:59:34.094000+00:00",
            "lastUpdateTime": "2023-02-28T21:59:34.094000+00:00"
        },
        {
            "id": "055gw7aynr1i5mbv7kjwzx5945",
            "arn": "arn:aws:servicecatalog:us-west-2:813737243517:/applications/055gw7aynr1i5mbv7kjwzx5945",
            "name": "ExampleApplication3",
            "creationTime": "2023-02-28T22:06:28.228000+00:00",
            "lastUpdateTime": "2023-02-28T22:06:28.228000+00:00"
        },
        {
            "id": "0ars38r6btoohvpvd9gqrptt9l",
            "arn": "arn:aws:servicecatalog:us-west-2:813737243517:/applications/0ars38r6btoohvpvd9gqrptt9l",
            "name": "ExampleApplication",
            "description": "This is an example application",
            "creationTime": "2023-02-28T21:10:10.820000+00:00",
            "lastUpdateTime": "2023-02-28T21:24:19.729000+00:00"
        }
    ]
}
```
如需詳細資訊，請參閱《AWS Service Catalog AppRegistry 管理員指南》**中的[檢戈覍應用程式詳細資訊](https://docs.aws.amazon.com/servicecatalog/latest/arguide/view-app-details.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [ListApplications](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/servicecatalog-appregistry/list-applications.html)。

### `list-associated-attribute-groups`
<a name="service-catalog-appregistry_ListAssociatedAttributeGroups_cli_topic"></a>

以下程式碼範例顯示如何使用 `list-associated-attribute-groups`。

**AWS CLI**  
**列出關聯的屬性群組**  
下列`list-associated-attribute-groups`範例會擷取您 AWS 帳戶中與 AWS 帳戶中特定應用程式相關聯的所有屬性群組清單。  

```
aws servicecatalog-appregistry list-associated-attribute-groups \
    --application "ExampleApplication"
```
輸出：  

```
{
    "attributeGroups": [
        "01sj5xdwhbw54kejwnt09fnpcl"
    ]
}
```
如需詳細資訊，請參閱《*AWS Service Catalog AppRegistry 管理員指南*》中的[關聯和取消關聯屬性群組](https://https://docs.aws.amazon.com/servicecatalog/latest/arguide/associate-attr-groups.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [ListAssociatedAttributeGroups](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/servicecatalog-appregistry/list-associated-attribute-groups.html)。

### `list-attribute-groups-for-application`
<a name="service-catalog-appregistry_ListAttributeGroupsForApplication_cli_topic"></a>

以下程式碼範例顯示如何使用 `list-attribute-groups-for-application`。

**AWS CLI**  
**列出應用程式的屬性群組**  
下列`list-attribute-groups-for-application`範例列出與您 AWS 帳戶中特定應用程式相關聯的 AWS 帳戶中所有屬性群組的詳細資訊。  

```
aws servicecatalog-appregistry list-attribute-groups-for-application \
    --application "ExampleApplication"
```
輸出：  

```
{
    "attributeGroupsDetails": [
        {
            "id": "01sj5xdwhbw54kejwnt09fnpcl",
            "arn": "arn:aws:servicecatalog:us-west-2:813737243517:/attribute-groups/01sj5xdwhbw54kejwnt09fnpcl",
            "name": "ExampleAttributeGroup"
        }
    ]
}
```
如需詳細資訊，請參閱《*AWS Service Catalog AppRegistry 管理員指南*》中的[檢視屬性群組詳細資訊](https://servicecatalog/latest/arguide/view-attr-group.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [ListAttributeGroupsForApplication](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/servicecatalog-appregistry/list-attribute-groups-for-application.html)。

### `list-attribute-groups`
<a name="service-catalog-appregistry_ListAttributeGroups_cli_topic"></a>

以下程式碼範例顯示如何使用 `list-attribute-groups`。

**AWS CLI**  
**列出屬性群組**  
下列`list-attribute-groups`範例會擷取您 AWS 帳戶中所有屬性群組的清單。  

```
aws servicecatalog-appregistry list-attribute-groups
```
輸出：  

```
{
    "attributeGroups": [
        {
            "id": "011ge6y3emyjijt8dw8jn6r0hv",
            "arn": "arn:aws:servicecatalog:us-west-2:813737243517:/attribute-groups/011ge6y3emyjijt8dw8jn6r0hv",
            "name": "ExampleAttributeGroup3",
            "creationTime": "2023-02-28T22:05:35.224000+00:00",
            "lastUpdateTime": "2023-02-28T22:05:35.224000+00:00"
        },
        {
            "id": "01sj5xdwhbw54kejwnt09fnpcl",
            "arn": "arn:aws:servicecatalog:us-west-2:813737243517:/attribute-groups/01sj5xdwhbw54kejwnt09fnpcl",
            "name": "ExampleAttributeGroup",
            "description": "This is an example attribute group",
            "creationTime": "2023-02-28T20:38:01.389000+00:00",
            "lastUpdateTime": "2023-02-28T21:02:04.559000+00:00"
        },
        {
            "id": "03n1yffgq6d18vwrzxf0c70nm3",
            "arn": "arn:aws:servicecatalog:us-west-2:813737243517:/attribute-groups/03n1yffgq6d18vwrzxf0c70nm3",
            "name": "ExampleAttributeGroup2",
            "creationTime": "2023-02-28T21:57:30.687000+00:00",
            "lastUpdateTime": "2023-02-28T21:57:30.687000+00:00"
        }
    ]
}
```
如需詳細資訊，請參閱《*AWS Service Catalog AppRegistry 管理員指南*》中的[檢視屬性群組詳細資訊](https://docs.aws.amazon.com/servicecatalog/latest/arguide/view-attr-group.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [ListAttributeGroups](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/servicecatalog-appregistry/list-attribute-groups.html)。

### `update-application`
<a name="service-catalog-appregistry_UpdateApplication_cli_topic"></a>

以下程式碼範例顯示如何使用 `update-application`。

**AWS CLI**  
**更新應用程式**  
下列`update-application`範例會更新您 AWS 帳戶中的特定應用程式，以包含描述。  

```
aws servicecatalog-appregistry update-application \
    --application "ExampleApplication" \
    --description "This is an example application"
```
輸出：  

```
{
    "application": {
        "id": "0ars38r6btoohvpvd9gqrptt9l",
        "arn": "arn:aws:servicecatalog:us-west-2:813737243517:/applications/0ars38r6btoohvpvd9gqrptt9l",
        "name": "ExampleApplication",
        "description": "This is an example application",
        "creationTime": "2023-02-28T21:10:10.820000+00:00",
        "lastUpdateTime": "2023-02-28T21:24:19.729000+00:00",
        "tags": {
            "aws:servicecatalog:applicationName": "ExampleApplication"
        }
    }
}
```
如需詳細資訊，請參閱《AWS Service Catalog AppRegistry 管理員指南》**中的[編輯應用程式](https://docs.aws.amazon.com/servicecatalog/latest/arguide/edit-apps.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [UpdateApplication](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/servicecatalog-appregistry/update-application.html)。

### `update-attribute-group`
<a name="service-catalog-appregistry_UpdateAttributeGroup_cli_topic"></a>

以下程式碼範例顯示如何使用 `update-attribute-group`。

**AWS CLI**  
**更新屬性群組**  
下列`update-attribute-group`範例會更新您 AWS 帳戶中的特定屬性群組，以包含描述。  

```
aws servicecatalog-appregistry update-attribute-group \
    --attribute-group "ExampleAttributeGroup" \
    --description "This is an example attribute group"
```
輸出：  

```
{
    "attributeGroup": {
        "id": "01sj5xdwhbw54kejwnt09fnpcl",
        "arn": "arn:aws:servicecatalog:us-west-2:813737243517:/attribute-groups/01sj5xdwhbw54kejwnt09fnpcl",
        "name": "ExampleAttributeGroup",
        "description": "This is an example attribute group",
        "creationTime": "2023-02-28T20:38:01.389000+00:00",
        "lastUpdateTime": "2023-02-28T21:02:04.559000+00:00",
        "tags": {
            "aws:servicecatalog:attributeGroupName": "ExampleAttributeGroup"
        }
    }
}
```
如需詳細資訊，請參閱《AWS Service Catalog AppRegistry 管理員指南》**中的[編輯屬性群組](https://docs.aws.amazon.com/servicecatalog/latest/arguide/edit-attr-group.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [UpdateAttributeGroup](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/servicecatalog-appregistry/update-attribute-group.html)。