调用CreateGateway接口在网关集群里创建一个包年包月或按量付费的网关。

使用该接口时,需要注意如下事项:

  • 请确保在使用该接口前,已充分了解混合云存储网关产品的收费方式和价格
  • 您已经注册阿里云账号,并完成实名认证。
  • 您已经开通云存储网关服务。
  • 您在需要创建云上文件网关的地域,已有可用的专有网络VPC和虚拟交换机vSwitch。
  • 您在需要创建云上文件网关的地域,已有可用的云服务器ECS,并将此云服务器ECS归属到已创建的专有网络VPC下。
  • 在创建网关前,确保您已创建网关集群,如果还未创建,可以通过CreateStorageBundle接口完成网关集群的创建。
  • 如果您的网关付费类型为包年包月,完成文件网关创建后,您需要通过接口返回的购买链接进行网关购买,完成网关的创建。

调试

您可以在OpenAPI Explorer中直接运行该接口,免去您计算签名的困扰。运行成功后,OpenAPI Explorer可以自动生成SDK代码示例。

请求参数

名称 类型 是否必选 示例值 描述
Action String CreateGateway

系统规定参数。取值:CreateGateway

StorageBundleId String sb-0001b2otnkdxrigeq***

网关集群ID。

Name String alex***

网关名称。长度限制1~60个字符,可以包含大小写字母,中文,数字,“.”,“_”或“-”,同时必须以大小写字母或者中文开头。

Description String 测试使用

网关描述。长度限制0~255个字符。

Type String File

网关类型。取值范围:

  • File:文件网关。
  • Iscsi:块网关。
Location String Cloud

网关位置。取值范围:

  • Cloud:线上网关。
  • On_Premise:线下网关。
GatewayClass String Basic

网关规格。

如果您的网关位置在本地数据中心,即线下网关,您可以忽略这个参数。

如果您的网关位置在阿里云,即线上网关,则取值范围:

  • Basic:基础型
  • Standard:标准型
  • Enhanced:增强型
  • Advanced:性能型
VSwitchId String vsw-bp1krhkglx3nahkb9s***

虚拟交换机的ID。如果您的网关位置在本地数据中心,可以忽略这个参数。

  • 必须与您需要挂载的云服务器ECS处于同一个VPC下。
  • 如果当前的虚拟交换机所在的可用区没有可以分配的网关资源,请到其他可用区创建虚拟交换机。
PostPaid Boolean true

网关付费类型。详情请参见计量项和计费项。取值范围:

  • true:按量付费,即后付费。
  • false:包年包月,即预付费。

默认:false(包年包月)。

ReleaseAfterExpiration Boolean true

是否到期释放。取值范围:

  • true:到期释放,直接收回。创建的云存储网关到期7天后,停止云存储网关服务。
  • false:创建的云存储网关到期后,转按量付费模式。
PublicNetworkBandwidth Integer 50

数据公网带宽。单位为Mbps。取值范围为5~200。

说明
  • 仅线上网关支持,线下网关请忽略此参数。
  • 传值0或不传值情况下,默认值为5。
ResourceRegionId String cn-hangzhou

资源地域ID。

返回数据

名称 类型 示例值 描述
BuyURL String https://common-buy.aliyun.com/?commodityCode=hcs_sgw_csg_pre&request={"gateway_id":"gw-0007va9bnidei3s8a***","directBuy":"false","gateway_class":"standard","cache_cloud_efficiency_size":0}&regionId=cn-hangzhou#/buy

购买链接。

RequestId String 8E69E1A1-9076-4C8C-8ADF-ACD253886E22

请求ID。

Message String successful

请求结果描述。

GatewayId String gw-0001xv7je357zm9u6***

网关ID。

Code String 200

状态码。状态码为200表示请求成功。

Success Boolean true

请求是否成功。

示例

请求示例

http(s)://[Endpoint]/?Action=CreateGateway
&Location=Cloud
&Name=alex***
&StorageBundleId=sb-0001b2otnkdxrigeq***
&Type=File
&VSwitchId=vsw-bp1krhkglx3nahkb9s***
&<公共请求参数>

正常返回示例

XML格式

HTTP/1.1 200 OK
Content-Type:application/xml

<CreateGatewayResponse>
    <Message>successful</Message>
    <RequestId>8E69E1A1-9076-4C8C-8ADF-ACD253886E22</RequestId>
    <GatewayId>gw-0001xv7je357zm9u6m0u</GatewayId>
    <BuyURL>https://common-buy.aliyun.com/?commodityCode=hcs_sgw_csg_pre&amp;request=%7B%22gateway_id%22:%22gw-0007va9bnidei3s8a09e%22,%22directBuy%22:%22false%22,%22gateway_class%22:%22standard%22,%22cache_cloud_efficiency_size%22:0%7D®ionId=cn-hangzhou#/buy</BuyURL>
    <Code>200</Code>
    <Success>true</Success>
</CreateGatewayResponse>

JSON格式

HTTP/1.1 200 OK
Content-Type:application/json

{
  "Message" : "successful",
  "RequestId" : "8E69E1A1-9076-4C8C-8ADF-ACD253886E22",
  "GatewayId" : "gw-0001xv7je357zm9u6m0u",
  "BuyURL" : "https://common-buy.aliyun.com/?commodityCode=hcs_sgw_csg_pre&request=%7B%22gateway_id%22:%22gw-0007va9bnidei3s8a09e%22,%22directBuy%22:%22false%22,%22gateway_class%22:%22standard%22,%22cache_cloud_efficiency_size%22:0%7D®ionId=cn-hangzhou#/buy",
  "Code" : "200",
  "Success" : true
}

错误码

HttpCode 错误码 错误信息 描述
400 EmptyGatewayName You must enter a valid name for the gateway. 网关名称不能为空。
400 InvalidGatewayName The specified name of the gateway is invalid. The name must be 1 to 60 characters in length and can contain letters, digits, periods (.), underscores (_), and hyphens (-). The name must start with a letter. 无效的网关名称,网关名称长度限制1~60个字符,可以包含大小写字母,中文,数字,“.”,“_”或“-”,同时必须以大小写字母或者中文开头。
400 DescriptionOverLimit The length of the specified gateway description exceeds the maximum limit. The description cannot exceed 255 characters. 网关描述超过最大长度,最大限度为255个字符。
400 EmptyStorageBundleId You must enter a valid ID for the gateway cluster. 网关集群ID不能为空。
400 InvalidGatewayClass The specified specification of the gateway is invalid. 无效的网关规格。
400 InvalidGatewayType The specified type of the gateway is invalid. 无效的网关类型。
400 InvalidVSwitchId The specified VSwitch ID does not exist. 指定的虚拟交换机ID不存在。
400 NoAvailableOnlineResource There are no cloud gateways available. We recommend that you select a different specification or VSwitch that resides in another zone. 当前没有可用的线上网关资源,请选择其他规格或者其他可用区虚拟交换机。
400 DuplicateGatewayName The specified name of the gateway already exists. You must specify a valid name. 存在同名的网关,请选用其它名称。
400 InvalidGatewayBandwidth The specified public network bandwidth for the gateway is invalid. The bandwidth ranges from 6 to 200 Mbit/s. 网关数据公网带宽不合法, 取值为6 - 200, 单位Mbps。
400 GatewayBandwidthNotSupported You cannot decrease the public network bandwidth of a On Premise Gateway. 线下网关不支持设置数据公网带宽。
400 InvalidGatewayLocation The specified location of the gateway is invalid. 无效的网关位置。
404 StorageBundleNotExist The name you specified for the gateway cluster does not exist. You must specify a valid parameter. 网关集群不存在,请确认输入参数是否正确。

访问错误中心查看更多错误码。