华为云用户手册

  • 响应参数 状态码为 200 时: 表3 响应Body参数 参数 参数类型 描述 request_id String 请求ID sub_network_interfaces Integer 辅助弹性网卡数目 状态码为 400 时: 表4 响应Body参数 参数 参数类型 描述 request_id String 请求ID error_msg String 错误消息 error_code String 错误码 状态码为 401 时: 表5 响应Body参数 参数 参数类型 描述 request_id String 请求ID error_msg String 错误消息 error_code String 错误码 状态码为 403 时: 表6 响应Body参数 参数 参数类型 描述 request_id String 请求ID error_msg String 错误消息 error_code String 错误码 状态码为 500 时: 表7 响应Body参数 参数 参数类型 描述 request_id String 请求ID error_msg String 错误消息 error_code String 错误码
  • 响应参数 表2 响应参数 参数名称 类型 说明 firewall_rule firewall_rule object firewall rule对象,请参见表3。 表3 Firewall Rule对象 属性 类型 说明 id String 网络ACL规则的uuid标识。 name String 网络ACL规则名称。 description String 网络ACL规则描述。 tenant_id String 项目ID public Boolean 是否支持跨租户共享。 protocol String IP协议。 source_port String 源端口号或者一段端口范围。 destination_port String 目的端口号或者一段端口范围。 ip_version Integer IP协议版本。 source_ip_address String 源地址或者CIDR。 destination_ip_address String 目的地址或者CIDR。 action String 对通过网络ACL的流量执行的操作。 enabled Boolean 是否使能网络ACL规则。 project_id String 项目ID,请参见获取项目ID。
  • 响应示例 { "firewall_rule": { "protocol": "tcp", "description": "update check parameter", "source_ip_address": "116.66.184.0/24", "destination_ip_address": "0.0.0.0/0", "destination_port": null, "source_port": null, "id": "514e6776-162a-4b5d-ab8b-aa36b86655ef", "name": "test", "tenant_id": "a1c6f90c94334bd2953d9a61b8031a68", "project_id": "a1c6f90c94334bd2953d9a61b8031a68", "enabled": true, "action": "allow", "ip_version": 4, "public": false }}
  • 响应参数 状态码为 400 时: 表3 响应Body参数 参数 参数类型 描述 request_id String 请求ID error_msg String 错误消息 error_code String 错误码 状态码为 401 时: 表4 响应Body参数 参数 参数类型 描述 request_id String 请求ID error_msg String 错误消息 error_code String 错误码 状态码为 403 时: 表5 响应Body参数 参数 参数类型 描述 request_id String 请求ID error_msg String 错误消息 error_code String 错误码 状态码为 404 时: 表6 响应Body参数 参数 参数类型 描述 request_id String 请求ID error_msg String 错误消息 error_code String 错误码 状态码为 409 时: 表7 响应Body参数 参数 参数类型 描述 request_id String 请求ID error_msg String 错误消息 error_code String 错误码 状态码为 500 时: 表8 响应Body参数 参数 参数类型 描述 request_id String 请求ID error_msg String 错误消息 error_code String 错误码
  • 响应示例 状态码为 400 时: { "request_id" : "string", "error_msg" : "string", "error_code" : "string"} 状态码为 401 时: { "request_id" : "string", "error_msg" : "string", "error_code" : "string"} 状态码为 403 时: { "request_id" : "string", "error_msg" : "string", "error_code" : "string"} 状态码为 404 时: { "request_id" : "string", "error_msg" : "string", "error_code" : "string"} 状态码为 409 时: { "request_id" : "string", "error_msg" : "string", "error_code" : "string"} 状态码为 500 时: { "request_id" : "string", "error_msg" : "string", "error_code" : "string"}
  • 响应示例 { "firewall_rule": { "protocol": "tcp", "description": "", "source_ip_address": null, "destination_ip_address": null, "source_port": null, "destination_port": "80", "id": "b94acf06-efc2-485d-ba67-a61acf2a7e28", "name": "ALLOW_HTTP", "tenant_id": "23c8a121505047b6869edf39f3062712", "enabled": true, "action": "allow", "ip_version": 4, "public": false, "project_id": "23c8a121505047b6869edf39f3062712" }}
  • 响应参数 表3 响应参数 参数名称 类型 说明 firewall_rule firewall_rule object firewall rule对象。请参见表4。 表4 Firewall Rule对象 属性 类型 说明 id String 网络ACL规则的uuid标识。 name String 网络ACL规则名称。 description String 网络ACL规则描述。 tenant_id String 项目ID public Boolean 是否支持跨租户共享。 protocol String IP协议。 source_port String 源端口号或者一段端口范围。 destination_port String 目的端口号或者一段端口范围。 ip_version Integer IP协议版本。 source_ip_address String 源地址或者CIDR。 destination_ip_address String 目的地址或者CIDR。 action String 对通过网络ACL的流量执行的操作。 enabled Boolean 是否使能网络ACL规则。 project_id String 项目ID,请参见获取项目ID。
  • 请求参数 表1 请求参数 参数名称 是否必选 类型 说明 firewall_rule 是 firewall_rule object firewall rule对象。请参见表2。 表2 Firewall Rule对象 属性 是否必选 类型 约束 说明 name 否 String 最长255个字符 网络ACL规则名称。 使用说明:最长255个字符 description 否 String 最长255个字符 网络ACL规则描述。 使用说明:最长255个字符 protocol 否 String 支持TCP,UDP,ICMP, ICMPV6 IP协议。 取值范围:支持TCP,UDP,ICMP, ICMPV6 source_port 否 String 位于[1,65535]中一个整数或者一段端口范围a:b 源端口号或者一段端口范围。 取值范围:位于[1,65535]中一个整数或者一段端口范围a:b destination_port 否 String 位于[1,65535]中一个整数或者一段端口范围a:b 目的端口号或者一段端口范围。 取值范围:位于[1,65535]中一个整数或者一段端口范围a:b ip_version 否 Integer 4/6 IP协议版本。 取值范围:4、6,分别表示创建ipv4和ipv6。 source_ip_address 否 String N/A 源地址或者CIDR。 destination_ip_address 否 String N/A 目的地址或者CIDR。 action 否 String deny/allow 对通过网络ACL的流量执行的操作。 取值范围:deny(拒绝)/allow(允许) enabled 否 Boolean true/false 是否使能网络ACL规则。 取值范围:true/false
  • 请求示例 创建ACL规则,action为allow,IP协议为tcp,目的端口为80。 POST https://{Endpoint}/v2.0/fwaas/firewall_rules{ "firewall_rule": { "action": "allow", "enabled": true, "destination_port": "80", "protocol": "tcp", "name": "ALLOW_HTTP" }}
  • 响应参数 表2 响应参数 参数名称 类型 说明 firewall_policy firewall_policy object firewall policy对象。请参见表3。 表3 Firewall Policy对象 属性 类型 说明 id String 网络ACL策略uuid标识。 name String 网络ACL策略名称。 description String 网络ACL策略描述。 tenant_id String 项目ID firewall_rules Array of strings 策略引用的网络ACL规则链。 audited Boolean 审计标记。 public Boolean 是否支持跨租户共享。 project_id String 项目ID,请参见获取项目ID。
  • 响应示例 { "firewall_policy": { "description": "", "firewall_rules": [ "3c0e6267-73df-4d9a-87a6-e226f2db2036" ], "tenant_id": "23c8a121505047b6869edf39f3062712", "public": false, "id": "fed2d88f-d0e7-4cc5-bd7e-c495f67037b6", "audited": false, "name": "bobby_fwp1", "project_id": "23c8a121505047b6869edf39f3062712" }}
  • 响应参数 表2 响应参数 参数名称 类型 说明 firewall_rules Array of Firewall Rule objects firewall rule对象列表,参见表4。单次查询最多返回2000条数据,超过2000后会返回分页标记,分页查询请参见分页查询。 firewall_rules_links Array of firewall_rules_link Object 分页信息,参见表3 。 只有在使用limit过滤,并且资源个数超过limit或者资源个数超过2000时(limit默认值),该参数的rel和href取值才会显示为next和其对应的link。 表3 firewall_rules_link对象 参数名称 类型 说明 href String API链接 rel String API链接与该API版本的关系 表4 Firewall Rule对象 属性 类型 说明 id String 网络ACL规则的uuid标识。 name String 网络ACL规则名称。 description String 网络ACL规则描述。 tenant_id String 项目ID public Boolean 是否支持跨租户共享。 protocol String IP协议。 source_port String 源端口号或者一段端口范围。 destination_port String 目的端口号或者一段端口范围。 ip_version Integer IP协议版本。 source_ip_address String 源地址或者CIDR。 destination_ip_address String 目的地址或者CIDR。 action String 对通过网络ACL的流量执行的操作。 enabled Boolean 是否使能网络ACL规则。 project_id String 项目ID,请参见获取项目ID。
  • 响应示例 { "firewall_rules": [ { "protocol": "tcp", "description": "update check parameter", "source_ip_address": "116.66.184.0/24", "destination_ip_address": "0.0.0.0/0", "destination_port": null, "source_port": null, "id": "2a193015-4a88-4aa1-84ad-d4955adae707", "name": "crhfwruleupdate", "tenant_id": "a1c6f90c94334bd2953d9a61b8031a68", "project_id": "a1c6f90c94334bd2953d9a61b8031a68", "enabled": true, "action": "allow", "ip_version": 4, "public": false }, { "protocol": "tcp", "description": "update check parameter", "source_ip_address": null, "destination_ip_address": null, "destination_port": "40:60", "source_port": "20:50", "id": "db7a204c-9eb1-40a2-9bd6-ed5cfd3cff32", "name": "update_firewall-role-tommy", "tenant_id": "a1c6f90c94334bd2953d9a61b8031a68", "project_id": "a1c6f90c94334bd2953d9a61b8031a68", "enabled": false, "action": "deny", "ip_version": 4, "public": false } ], "firewall_rules_links": [ { "rel": "previous", "href": "https://{Endpoint}/v2.0/fwaas/firewall_rules?marker=2a193015-4a88-4aa1-84ad-d4955adae707&page_reverse=True" } ]}
  • URI GET /v2.0/fwaas/firewall_rules 样例: GET https://{Endpoint}/v2.0/fwaas/firewall_rules?name={firewall_rule_name}&tenant_id={tenant_id}&public={is_public}&protocol={protocol}&ip_version={ip_version}&action={action}&enabled={is_enabled} 分页查询样例: GET https://{Endpoint}/v2.0/fwaas/firewall_rules?limit=2&marker=2a193015-4a88-4aa1-84ad-d4955adae707&page_reverse=False 参数说明请参见表1。 表1 参数说明 名称 是否必选 参数类型 说明 id 否 String 按照网络ACL规则对应的ID过滤查询 name 否 String 按照网络ACL规则的名称过滤查询 description 否 String 按照网络ACL规则的描述过滤查询 ip_version 否 Integer 按照网络ACL规则的IP协议版本过滤查询 取值范围:4,6 action 否 String 按照网络ACL规则的行为过滤查询 取值范围:allow or deny enabled 否 Boolean 按照网络ACL规则是否使能过滤查询 取值范围:true or false tenant_id 否 String 按照网络ACL规则所属的项目ID过滤查询 marker 否 String 分页查询的起始资源ID,表示从指定资源的下一条记录开始查询。 marker需要和limit配合使用: 若不传入marker和limit参数,查询结果返回第一页全部资源记录。 若不传入marker参数,limit为10,查询结果返回第1~10条资源记录。 若marker为第10条记录的资源ID,limit为10,查询结果返回第11~20条资源记录。 若marker为第10条记录的资源ID,不传入limit参数,查询结果返回第11条及之后的所有资源记录。 limit 否 Integer 分页查询每页返回的记录个数,取值范围为0~intmax(2^31-1),默认值2000。 limit需要和marker配合使用,详细规则请见marker的参数说明。
  • 操作步骤 创建VPC。 发送“POST https://VPC的Endpoint/v1/{project_id}/vpcs”,project_id为项目ID。 在Request Header中增加“X-Auth-Token”。 在Request Body中传入参数如下,其中cidr字段需要提前进行网络规划。 { "vpc": { "name": "vpc", //虚拟私有云名称 "cidr": "192.168.0.0/16" //虚拟私有云下可用子网的范围 }} 查看请求响应结果。 请求成功时,响应参数如下,id就是vpc_id。 { "vpc": { "id": "b6684a27-b049-407d-90b4-c9551f2390e1", "name": "vpc", "cidr": "192.168.0.0/16", "status": "CREATING", "routes": [] }} 请求异常时,错误码请参见错误码。 查询VPC详情。 发送“GET https://VPC的Endpoint/v1/{project_id}/vpcs/{vpc_id}”,project_id为项目ID。 在Request Header中增加“X-Auth-Token”。 查看请求响应结果。 请求成功时,响应参数如下,id就是vpc_id。 { "vpc": { "id": "b6684a27-b049-407d-90b4-c9551f2390e1", "name": "vpc", "description": "", "cidr": "192.168.0.0/16", "status": "OK", "enterprise_project_id": "0" , "routes": [] }} 请求异常时,错误码请参见错误码。 指定VPC创建子网。 发送“POST https://VPC的Endpoint/v1/{project_id}/subnets”,project_id为项目ID。 在Request Header中增加“X-Auth-Token”。 在Request Body中传入参数如下,其中dnsList参数参见华为云提供的内网 DNS地址 是多少?,availability_zone参数可通过地区和终端节点获取。 {"subnet": {"name": "subnet","description": "","cidr": "192.168.0.0/24","gateway_ip": "192.168.0.1","dhcp_enable": true,"dnsList": ["114.xx.xx.114", "114.xx.xx.115"],"availability_zone": "aa-bb-cc","vpc_id": "b6684a27-b049-407d-90b4-c9551f2390e1"}} 查看请求响应结果。 请求成功时,响应参数如下: {"subnet": {"id": "4779ab1c-7c1a-44b1-a02e-93dfc361b32d","name": "subnet","description": "","cidr": "192.168.0.0/24","dnsList": ["114.xx.xx.114", "1114.xx.xx.115"],"status": "UNKNOWN","vpc_id": "b6684a27-b049-407d-90b4-c9551f2390e1","gateway_ip": "192.168.0.1","dhcp_enable": true,"primary_dns": "114.xx.xx.114","secondary_dns": "114.xx.xx.115","availability_zone": "aa-bb-cc","neutron_network_id": "4779ab1c-7c1a-44b1-a02e-93dfc361b32d","neutron_subnet_id": "213cb9d-3122-2ac1-1a29-91ffc1231a12","extra_dhcp_opts": []}} 请求异常时,错误码请参见错误码。 查询子网详情。 发送“GET https://VPC的Endpoint/v1/{project_id}/subnets/{subnet_id}”,project_id为项目ID。 在Request Header中增加“X-Auth-Token”。 查看请求响应结果。 {"subnet": {"id": "4779ab1c-7c1a-44b1-a02e-93dfc361b32d","name": "subnet","description": "","cidr": "192.168.20.0/24","dnsList": ["114.xx.xx.114", "114.xx.xx.115"],"status": "ACTIVE","vpc_id": "b6684a27-b049-407d-90b4-c9551f2390e1","gateway_ip": "192.168.20.1","ipv6_enable": false,"dhcp_enable": true,"primary_dns": "114.xx.xx.114","secondary_dns": "114.xx.xx.115","availability_zone": "aa-bb-cc","neutron_network_id": "4779ab1c-7c1a-44b1-a02e-93dfc361b32d","neutron_subnet_id": "213cb9d-3122-2ac1-1a29-91ffc1231a12","extra_dhcp_opts": []}}
  • 操作步骤 通过云服务器的ID查询网卡信息。 发送“GET https://VPC的Endpoint/v1/{project_id}/ports?device_id={ecs_id}”,project_id为项目ID。 在Request Header中增加“X-Auth-Token”。 查看请求响应结果。 请求成功时,响应参数如下: {"ports": [{"id": "02c72193-efec-42fb-853b-c33f2b802467","name": "","status": "ACTIVE","admin_state_up": true,"fixed_ips": [{"subnet_id": "213cb9d-3122-2ac1-1a29-91ffc1231a12","ip_address": "192.168.0.75"}],"mac_address": "fa:16:3e:47:5f:c1","network_id": "4779ab1c-7c1a-44b1-a02e-93dfc361b32d","tenant_id": "db82c9e1415a464ea68048baa8acc6b8","project_id": "db82c9e1415a464ea68048baa8acc6b8","device_id": "ea61f836-b52f-41bf-9d06-685644001d6f","device_owner": "compute:br-iaas-odin1a","security_groups": ["e0598d96-9451-4f8a-8de0-b8b4d451d9e7"],"extra_dhcp_opts": [],"allowed_address_pairs": [],"binding:vnic_type": "normal","binding:vif_details": {"primary_interface": true},"binding:profile": {},"port_security_enabled": true,"created_at": "2020-06-20T08:07:29","updated_at": "2020-06-20T08:07:29"}]} 请求异常时,错误码请参见错误码。 查询当前已有的安全组信息。 发送“GET https://VPC的Endpoint/v1/{project_id}/security-groups”,project_id为项目ID。 在Request Header中增加“X-Auth-Token”。 查看请求响应结果。 请求成功时,响应参数如下,id就是security_group_id。 {"security_groups": [{"id": "16b6e77a-08fa-42c7-aa8b-106c048884e6","name": "qq","description": "qq","vpc_id": "3ec3b33f-ac1c-4630-ad1c-7dba1ed79d85","enterprise_project_id ": "0aad99bc-f5f6-4f78-8404-c598d76b0ed2","security_group_rules": [{"direction": "egress","ethertype": "IPv4","id": "369e6499-b2cb-4126-972a-97e589692c62","description": "","security_group_id": "16b6e77a-08fa-42c7-aa8b-106c048884e6"}, {"direction": "ingress","ethertype": "IPv4","id": "0222556c-6556-40ad-8aac-9fd5d3c06171","description": "","remote_group_id": "16b6e77a-08fa-42c7-aa8b-106c048884e6","security_group_id": "16b6e77a-08fa-42c7-aa8b-106c048884e6"}]}, {"id": "9c0f56be-a9ac-438c-8c57-fce62de19419","name": "default","description": "qq","vpc_id": "13551d6b-755d-4757-b956-536f674975c0","enterprise_project_id ": "0","security_group_rules": [{"direction": "egress","ethertype": "IPv4","id": "95479e0a-e312-4844-b53d-a5e4541b783f","description": "","security_group_id": "9c0f56be-a9ac-438c-8c57-fce62de19419"}, {"direction": "ingress","ethertype": "IPv4","id": "0c4a2336-b036-4fa2-bc3c-1a291ed4c431","description": "","remote_group_id": "9c0f56be-a9ac-438c-8c57-fce62de19419","security_group_id": "9c0f56be-a9ac-438c-8c57-fce62de19419"}]}]} 请求异常时,错误码请参见错误码。 为弹性云服务器添加安全组。 发送“PUT https://VPC的Endpoint/v1/{project_id}/ports/{port_id}”,project_id为项目ID。 在Request Header中增加“X-Auth-Token”。 在Request Body中传入参数如下: { "port": { "security_groups": ["9c0f56be-a9ac-438c-8c57-fce62de19419","16b6e77a-08fa-42c7-aa8b-106c048884e6"] }} 查看请求响应结果。 请求成功时,响应参数如下,id就是port_id。 {"port": {"id": "02c72193-efec-42fb-853b-c33f2b802467","name": "","status": "ACTIVE","admin_state_up": true,"fixed_ips": [{"subnet_id": "213cb9d-3122-2ac1-1a29-91ffc1231a12","ip_address": "192.168.0.75"}],"mac_address": "fa:16:3e:47:5f:c1","network_id": "4779ab1c-7c1a-44b1-a02e-93dfc361b32d","tenant_id": "db82c9e1415a464ea68048baa8acc6b8","project_id": "db82c9e1415a464ea68048baa8acc6b8","device_id": "ea61f836-b52f-41bf-9d06-685644001d6f","device_owner": "compute:br-iaas-odin1a","security_groups": ["9c0f56be-a9ac-438c-8c57-fce62de19419", "16b6e77a-08fa-42c7-aa8b-106c048884e6"],"extra_dhcp_opts": [],"allowed_address_pairs": [{"ip_address": "1.1.1.1/0"}],"binding:vnic_type": "normal","binding:vif_details": {"primary_interface": true},"binding:profile": {},"port_security_enabled": true,"created_at": "2020-06-20T08:07:29","updated_at": "2020-06-20T08:07:29"}} 请求异常时,错误码请参见错误码。
  • 调用API获取项目ID 项目ID可以通过调用查询指定条件下的项目列表API获取。 获取项目ID的接口为“GET https://{Endpoint}/v3/projects”,其中{Endpoint}为 IAM 的终端节点,可以从地区和终端节点获取。接口的认证鉴权请参见认证鉴权。 响应示例如下,其中projects下的“id”即为项目ID。 { "projects": [ { "domain_id": "65382450e8f64ac0870cd180d14e684b", "is_domain": false, "parent_id": "65382450e8f64ac0870cd180d14e684b", "name": "project_name", "description": "", "links": { "next": null, "previous": null, "self": "https://www.example.com/v3/projects/a4a5d4098fb4474fa22cd05f897d6b99" }, "id": "a4a5d4098fb4474fa22cd05f897d6b99", "enabled": true } ], "links": { "next": null, "previous": null, "self": "https://www.example.com/v3/projects" }}
  • 两者区别 子网接口分为VPC子网接口、OpenStack Neutron子网接口两种。两者均可以正常创建、查询、更新、删除子网。 两者的区别及容易混淆的地方在于网络ID、子网ID两个参数的含义。 登录管理控制台,查看子网的基本信息,可以看到网络ID、子网ID两个字段。 图1 子网基本信息 调用VPC子网接口时,使用的子网ID为图1所示的网络ID,例如:a22724a0-b77b-44b4-b731-afd3a4839863。 调用OpenStack neutron子网接口时,使用的子网ID为图1所示的子网ID,例如:f32a3acf-2312-41d0-947c-13d377a35059。
  • 示例 以查询子网详情为例,对比两者之间的区别。 VPC子网接口 GET /v1/049d06b7f20037e12f0dc0137381822f/subnets/a22724a0-b77b-44b4-b731-afd3a4839863 { "subnet": { "id": "a22724a0-b77b-44b4-b731-afd3a4839863", //对应管理控制台上的网络ID "name": "subnet-54eb", "description": "", "cidr": "192.168.0.0/24", "dnsList": [ "100.125.1.202", "100.125.1.230" ], "status": "ACTIVE", "tags": [], "vpc_id": "f4d0ebd4-2a62-4396-980b-96e73b3386de", "ipv6_enable": false, "gateway_ip": "192.168.0.1", "dhcp_enable": true, "primary_dns": "100.125.1.202", "secondary_dns": "100.125.1.230", "availability_zone": "az1.dc1", "neutron_network_id": "a22724a0-b77b-44b4-b731-afd3a4839863", //对应管理控制台上的网络ID "neutron_subnet_id": "f32a3acf-2312-41d0-947c-13d377a35059", //对应管理控制台上的子网ID "extra_dhcp_opts": [] }} OpenStack neutron子网接口 GET /v2.0/subnets/f32a3acf-2312-41d0-947c-13d377a35059 { "subnet": { "name": "subnet-54eb", "cidr": "192.168.0.0/24", "id": "f32a3acf-2312-41d0-947c-13d377a35059", //对应管理控制台上的子网ID "enable_dhcp": true, "network_id": "a22724a0-b77b-44b4-b731-afd3a4839863", //对应管理控制台上的网络ID "tenant_id": "049d06b7f20037e12f0dc0137381822f", "project_id": "049d06b7f20037e12f0dc0137381822f", "dns_nameservers": [ "100.125.1.202", "100.125.1.230" ], "allocation_pools": [ { "start": "192.168.0.2", "end": "192.168.0.252" } ], "host_routes": [], "ip_version": 4, "gateway_ip": "192.168.0.1", "created_at": "2019-04-09T08:03:58", "updated_at": "2019-04-09T08:03:59" }}
  • 响应参数 表5 响应参数 名称 参数类型 说明 resources Array of resource objects resource对象列表,请参见表6。 total_count Integer 总记录数 表6 resource对象 名称 参数类型 说明 resource_id String 资源ID resource_detail Object 资源详情。 资源对象,用于扩展。默认为空 tags Array of tag objects 标签列表,没有标签默认为空数组,参见表7 resource_name String 资源名称,没有默认为空字符串 表7 tag字段数据结构说明 名称 是否必选 参数类型 说明 key 是 String 键。最大长度127个unicode字符。 key不能为空。(搜索时不对此参数做校验) value 是 string 值列表。每个值最大长度255个unicode字符,如果values为空列表,则表示any_value。value之间为或的关系。
  • 响应示例 action为filter { "resources": [ { "resource_detail": null, "resource_id": "cdfs_cefs_wesas_12_dsad", "resource_name": "resouece1", "tags": [ { "key": "key1", "value": "value1" }, { "key": "key2", "value": "value1" } ] } ], "total_count": 1000} action为count { "total_count": 1000}
  • 请求参数 表2 请求参数 参数名称 类型 是否必选 说明 tags Array of tag objects 否 包含标签,最多包含10个key,每个key下面的value最多10个,结构体不能缺失,key不能为空或者空字符串。Key不能重复,同一个key中values不能重复。 limit Integer 否 查询记录数(action为count时无此参数)如果action为filter默认为1000,limit最多为1000,不能为负数,最小值为1 offset Integer 否 (索引位置), 从offset指定的下一条数据开始查询。 查询第一页数据时,不需要传入此参数,查询后续页码数据时,将查询前一页数据时响应体中的值带入此参数(action为count时无此参数)如果action为filter默认为0,必须为数字,不能为负数 action String 是 操作标识(仅限于filter,count):filter(过滤),count(查询总条数) 如果是filter就是分页查询,如果是count只需按照条件将总条数返回即可。 matches Array of match objects 否 搜索字段,key为要匹配的字段,当前仅支持resource_name。value为匹配的值。此字段为固定字典值。 表3 tag字段数据结构说明 名称 是否必选 参数类型 说明 key 是 String 键。最大长度127个unicode字符。 key不能为空。(搜索时不对此参数做校验) values 是 Array of strings 值列表。每个值最大长度255个unicode字符,如果values为空列表,则表示any_value。value之间为或的关系。 表4 match字段数据结构说明 名称 是否必选 参数类型 说明 key 是 String 键。当前仅限定为resource_name value 是 String 值。每个值最大长度255个unicode字符。
  • 请求示例 过滤查询子网资源实例,action为filter,从第1条数据开始查询,单次查询最多返回100条,用matches和tags过滤查询。 POST https://{Endpoint}/v2.0/{project_id}/subnets/resource_instances/action{ "offset": "0", "limit": "100", "action": "filter", "matches": [ { "key": "resource_name", "value": "resource1" } ], "tags": [ { "key": "key1", "values": [ "*value1", "value2" ] } ]} 过滤计数子网资源实例,action为count,用matches和tags过滤计数。 POST https://{Endpoint}/v2.0/{project_id}/subnets/resource_instances/action{ "action": "count", "tags": [ { "key": "key1", "values": [ "value1", "value2" ] }, { "key": "key2", "values": [ "value1", "value2" ] } ], "matches": [ { "key": "resource_name", "value": "resource1" } ]}
  • 状态码 表1 正常返回值 正常返回码 类型 说明 200 OK GET、PUT、POST操作正常返回 201 Created OpenStack Neutron API、API V3的POST操作正常返回 204 No Content DELETE操作正常返回 表2 异常返回值 返回值 说明 400 Bad Request 服务器未能处理请求。 401 Unauthorized 被请求的页面需要用户名和密码。 403 Forbidden 对被请求页面的访问被禁止。 404 Not Found 服务器无法找到被请求的页面。 405 Method Not Allowed 请求中指定的方法不被允许。 406 Not Acceptable 服务器生成的响应无法被客户端所接受。 407 Proxy Authentication Required 用户必须首先使用代理服务器进行验证,这样请求才会被处理。 408 Request Timeout 请求超出了服务器的等待时间。 409 Conflict 由于冲突,请求无法被完成。 500 Internal Server Error 请求未完成。服务异常。 501 Not Implemented 请求未完成。服务器不支持所请求的功能。 502 Bad Gateway 请求未完成。服务器从上游服务器收到一个无效的响应。 503 Service Unavailable 请求未完成。系统暂时异常。 504 Gateway Timeout 网关超时。 父主题: 附录
  • 响应示例 { "tags": [ { "key": "key1", "values": [ "value1", "value2" ] }, { "key": "key2", "values": [ "value1", "value2" ] } ]}
  • 响应参数 表2 响应参数 参数名称 类型 说明 tags Array of tag objects tag对象列表,请参见表3。 表3 tag字段数据结构说明 名称 参数类型 说明 key String 键。 不能为空。 长度不超过36个字符。 由英文字母、数字、下划线、中划线、中文字符组成。 values Array of strings 值列表。 长度不超过43个字符。 由英文字母、数字、下划线、点、中划线、中文字符组成。
  • 基本概念 帐号 用户注册时的帐号,帐号对其所拥有的资源及云服务具有完全的访问权限,可以重置用户密码、分配用户权限等。由于帐号是付费主体,为了确保帐号安全,建议您不要直接使用帐号进行日常管理工作,而是创建用户并使用用户进行日常管理工作。 用户 由帐号在IAM中创建的用户,是云服务的使用人员,具有身份凭证(密码和访问密钥)。 在我的凭证下,您可以查看帐号ID和IAM用户ID。通常在调用API的鉴权过程中,您需要用到帐号、用户和密码等信息。 区域(Region) 从地理位置和网络时延维度划分,同一个Region内共享弹性计算、块存储、对象存储、VPC网络、弹性公网IP、镜像等公共服务。Region分为通用Region和专属Region,通用Region指面向公共租户提供通用云服务的Region;专属Region指只承载同一类业务或只面向特定租户提供业务服务的专用Region。 详情请参见区域和可用区。 可用区(AZ,Availability Zone) 一个可用区是一个或多个物理数据中心的集合,有独立的风火水电,AZ内逻辑上再将计算、网络、存储等资源划分成多个集群。一个Region中的多个AZ间通过高速光纤相连,以满足用户跨AZ构建高可用性系统的需求。 项目 区域默认对应一个项目,这个项目由系统预置,用来隔离物理区域间的资源(计算资源、存储资源和网络资源),以默认项目为单位进行授权,用户可以访问您帐号中该区域的所有资源。如果您希望进行更加精细的权限控制,可以在区域默认的项目中创建子项目,并在子项目中创建资源,然后以子项目为单位进行授权,使得用户仅能访问特定子项目中的资源,使得资源的权限控制更加精确。 图1 项目隔离模型 同样在我的凭证下,您可以查看项目ID。 企业项目 企业项目是项目的升级版,针对企业不同项目间的资源进行分组和管理,是逻辑隔离。企业项目中可以包含多个区域的资源,且项目中的资源可以迁入迁出。 关于企业项目ID的获取及企业项目特性的详细信息,请参见《企业管理用户指南》。 父主题: 使用前必读
  • 响应示例 action为filter { "resources": [ { "resource_detail": null, "resource_id": "cdfs_cefs_wesas_12_dsad", "resource_name": "resouece1", "tags": [ { "key": "key1", "value": "value1" }, { "key": "key2", "value": "value1" } ] } ], "total_count": 1000} action为count { "total_count": 1000}
  • 请求参数 表2 请求参数 参数名称 类型 是否必选 说明 tags Array of tag objects 否 包含标签,最多包含10个key,每个key下面的value最多10个,结构体不能缺失,key不能为空或者空字符串。Key不能重复,同一个key中values不能重复。 limit Integer 否 查询记录数(action为count时无此参数)如果action为filter默认为1000,limit最多为1000,不能为负数,最小值为1 offset Integer 否 (索引位置), 从offset指定的下一条数据开始查询。 查询第一页数据时,不需要传入此参数,查询后续页码数据时,将查询前一页数据时响应体中的值带入此参数(action为count时无此参数)如果action为filter默认为0,必须为数字,不能为负数 action String 是 操作标识(仅限于filter,count):filter(过滤),count(查询总条数) 如果是filter就是分页查询,如果是count只需按照条件将总条数返回即可。 matches Array of match objects 否 搜索字段,key为要匹配的字段,当前仅支持resource_name。value为匹配的值。此字段为固定字典值。 表3 tag字段数据结构说明 名称 是否必选 参数类型 说明 key 是 String 键。最大长度127个unicode字符。 key不能为空。(搜索时不对此参数做校验) values 是 Array of strings 值列表。每个值最大长度255个unicode字符,如果values为空列表,则表示any_value。 value之间为或的关系: 能查到匹配任意一个value的资源,如,资源A有val1的tag,B有val2的tag,用values={val1,val2}能过滤查询到资源A和B。 表4 match字段数据结构说明 名称 是否必选 参数类型 说明 key 是 String 键。当前仅限定为resource_name value 是 String 值。每个值最大长度255个unicode字符。
  • 响应参数 表5 响应参数 名称 参数类型 说明 resources Array of resource objects resource对象列表,请参见表6。 total_count Integer 总记录数 表6 resource对象 名称 参数类型 说明 resource_id String 资源ID resource_detail Object 资源详情。 资源对象,用于扩展。默认为空 tags Array of tag objects 标签列表,没有标签默认为空数组,参见表7 resource_name String 资源名称,没有默认为空字符串 表7 tag字段数据结构说明 名称 是否必选 参数类型 说明 key 是 String 键。最大长度127个unicode字符。 key不能为空。(搜索时不对此参数做校验) value 是 String 值列表。每个值最大长度255个unicode字符,如果values为空列表,则表示any_value。 value之间为或的关系: 能查到匹配任意一个value的资源,如,资源A有val1的tag,B有val2的tag,用values={val1,val2}能过滤查询到资源A和B。
共100000条