

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

以下代码示例演示如何通过将 AWS Command Line Interface与 AppRegistry 结合使用，来执行操作和实现常见场景。

*操作是大型程序的代码摘录*，必须在上下文中运行。您可以通过操作了解如何调用单个服务函数，还可以通过函数相关场景的上下文查看操作。

每个示例都包含一个指向完整源代码的链接，您可以从中找到有关如何在上下文中设置和运行代码的说明。

**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)。