

文档 AWS SDK 示例 GitHub 存储库中还有更多 [S AWS DK 示例](https://github.com/awsdocs/aws-doc-sdk-examples)。

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

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

以下代码示例向您展示了如何使用with来执行操作和实现常见场景 AppRegistry。 AWS Command Line Interface 

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

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

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

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

### `associate-attribute-group`
<a name="service-catalog-appregistry_AssociateAttributeGroup_cli_2_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"
}
```
有关更多信息，请参阅《S *AWS ervic* e Catalog 管理员指南》中的[关联和取消关联属性组](https://docs.aws.amazon.com/servicecatalog/latest/arguide/associate-attr-groups.html)。 AppRegistry   
+  有关 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_2_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": {}
    }
}
```
有关更多信息，请参阅《S *AWS ervice 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_2_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": {}
    }
}
```
有关更多信息，请参阅《S *AWS ervice 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_2_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"
    }
}
```
有关更多信息，请参阅《S *AWS ervice 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_2_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"
    }
}
```
有关更多信息，请参阅《S *AWS ervice 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_2_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"
        }
    }
}
```
有关更多信息，请参阅《S *AWS ervice 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_2_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"
    }
}
```
有关更多信息，请参阅《S *AWS ervice 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_2_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"
        }
    ]
}
```
有关更多信息，请参阅《S *AWS ervice 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_2_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"
    ]
}
```
有关更多信息，请参阅《S *AWS ervic* e Catalog 管理员指南》中的[关联和取消关联属性组](https://https://docs.aws.amazon.com/servicecatalog/latest/arguide/associate-attr-groups.html)。 AppRegistry   
+  有关 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_2_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"
        }
    ]
}
```
有关更多信息，请参阅《S *AWS ervice 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_2_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"
        }
    ]
}
```
有关更多信息，请参阅《S *AWS ervice 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_2_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"
        }
    }
}
```
有关更多信息，请参阅《S *AWS ervice 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_2_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"
        }
    }
}
```
有关更多信息，请参阅《S *AWS ervice 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)*中的。