

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

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

# 使用 Storage Gateway 示例 AWS CLI
<a name="cli_2_storage-gateway_code_examples"></a>

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

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

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

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

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

### `describe-gateway-information`
<a name="storage-gateway_DescribeGatewayInformation_cli_2_topic"></a>

以下代码示例演示了如何使用 `describe-gateway-information`。

**AWS CLI**  
**描述网关**  
以下 `describe-gateway-information` 命令将返回有关指定网关的元数据。在命令中使用网关的 Amazon 资源名称（ARN）指定要描述的网关。  
此示例指定账户 `123456789012` 中 ID 为 `sgw-12A3456B` 的网关：  

```
aws storagegateway describe-gateway-information --gateway-arn "arn:aws:storagegateway:us-west-2:123456789012:gateway/sgw-12A3456B"
```
此命令将输出一个 JSON 数据块，其中包含有关网关的元数据，如名称、网络接口、已配置时区和状态（网关运行与否）。  
+  有关 API 的详细信息，请参阅*AWS CLI 命令参考[DescribeGatewayInformation](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/storagegateway/describe-gateway-information.html)*中的。

### `list-file-shares`
<a name="storage-gateway_ListFileShares_cli_2_topic"></a>

以下代码示例演示了如何使用 `list-file-shares`。

**AWS CLI**  
**列出文件共享**  
以下`command-name`示例列出了您 AWS 账户中可用的微件。  

```
aws storagegateway list-file-shares \
    --gateway-arn arn:aws:storagegateway:us-east-1:209870788375:gateway/sgw-FB02E292
```
输出：  

```
{
    "FileShareInfoList": [
        {
            "FileShareType": "NFS",
            "FileShareARN": "arn:aws:storagegateway:us-east-1:111122223333:share/share-2FA12345",
            "FileShareId": "share-2FA12345",
            "FileShareStatus": "AVAILABLE",
            "GatewayARN": "arn:aws:storagegateway:us-east-1:111122223333:gateway/sgw-FB0AAAAA"
        }
    ],
    "Marker": null
}
```
有关更多信息，请参阅 *AWS Storage Gateway 服务 API 参考[ListFileShares](https://docs.aws.amazon.com/storagegateway/latest/APIReference/API_ListFileShares.html)*中的。  
+  有关 API 的详细信息，请参阅*AWS CLI 命令参考[ListFileShares](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/storagegateway/list-file-shares.html)*中的。

### `list-gateways`
<a name="storage-gateway_ListGateways_cli_2_topic"></a>

以下代码示例演示了如何使用 `list-gateways`。

**AWS CLI**  
**列出账户的网关**  
以下 `list-gateways` 命令将列出为账户定义的所有网关：  

```
aws storagegateway list-gateways
```
此命令输出一个 JSON 块，其中包含网关 Amazon 资源名称列表 (ARNs)。  
+  有关 API 的详细信息，请参阅*AWS CLI 命令参考[ListGateways](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/storagegateway/list-gateways.html)*中的。

### `list-volumes`
<a name="storage-gateway_ListVolumes_cli_2_topic"></a>

以下代码示例演示了如何使用 `list-volumes`。

**AWS CLI**  
**列出为网关配置的卷**  
以下 `list-volumes` 命令将返回为指定网关配置的卷列表。在命令中使用网关的 Amazon 资源名称（ARN）指定要描述的网关。  
此示例指定账户 `123456789012` 中 ID 为 `sgw-12A3456B` 的网关：  

```
aws storagegateway list-volumes --gateway-arn "arn:aws:storagegateway:us-west-2:123456789012:gateway/sgw-12A3456B"
```
此命令将输出一个 JSON 数据块，其中包含带有每个卷的类型和 ARN 的卷列表。  
+  有关 API 的详细信息，请参阅*AWS CLI 命令参考[ListVolumes](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/storagegateway/list-volumes.html)*中的。

### `refresh-cache`
<a name="storage-gateway_RefreshCache_cli_2_topic"></a>

以下代码示例演示了如何使用 `refresh-cache`。

**AWS CLI**  
**刷新文件共享缓存**  
以下 `refresh-cache` 示例刷新指定文件共享的缓存。  

```
aws storagegateway refresh-cache \
    --file-share-arn arn:aws:storagegateway:us-east-1:111122223333:share/share-2FA12345
```
输出：  

```
{
    "FileShareARN": "arn:aws:storagegateway:us-east-1:111122223333:share/share-2FA12345",
    "NotificationId": "4954d4b1-abcd-ef01-1234-97950a7d3483"
}
```
有关更多信息，请参阅 *AWS Storage Gateway 服务 API 参考[ListFileShares](https://docs.aws.amazon.com/storagegateway/latest/APIReference/API_RefreshCache.html)*中的。  
+  有关 API 的详细信息，请参阅*AWS CLI 命令参考[RefreshCache](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/storagegateway/refresh-cache.html)*中的。