云服务器内容精选

  • 前提条件 已明确需要上传媒资的点播服务所在的区域信息,详见使用前必读。 已获取需要上传到对应点播服务所在区域的项目ID,具体获取方法请参见获取项目ID。 待上传的视频文件已完成二进制流分割,建议每个分段的大小不超过20M。 OBS接口列举已上传的段支持响应段的取值范围[1,10000],段大小[100KB,5GB]。默认最多响应1000段,如果用户分段数目超出1000,需参考OBS接口列举已上传的段进行处理。
  • 操作步骤 获取用户Token,用于调用直播接口时进行认证鉴权。 详细信息请参见构造请求。以“华北-北京四”为示例,若您需要调用其它区域的直播接口,请替换成对应区域的 IAM 终端节点。 POST https://iam.cn-north-4.myhuaweicloud.com/v3/auth/tokens Content-Type: application/json { "auth": { "identity": { "methods": [ "password" ], "password": { "user": { "name": "username", "password": "password", "domain": { "name": "domainname" } } } }, "scope": { "project": { "name": "projectname" } } } } 如图1所示,红框中的信息为获取用户Token。 图1 获取用户Token 选择POST请求方法,并输入请求URI。 POST https://live.cn-north-4.myhuaweicloud.com/v1/{project_id}/template/transcodings “live.cn-north-4.myhuaweicloud.com”为直播服务的终端节点,您可以在使用前必读中获取。 调用IAM接口的区域需与调用直播接口的区域一致,如调用“cn-north-4”区域的IAM接口获取用户Token,则该Token仅能用于调用“cn-north-4”区域直播接口的鉴权。 在请求消息头中增加“X-Auth-Token”,值设置为1中获取的用户Token。 在请求消息体中传入如下所示的参数,具体参数说明可参考创建直播转码模板接口。 { "domain": "play.example.com", "app_name": "live", "quality_info": [ { "templateName": "", "quality": "lsd", "hdlb": "off", "PVC": "off", "codec": "H264", "width": 854, "height": 480, "bitrate": 600, "video_frame_rate": 0, "protocol": "HLS", "iFrameInterval": 0 } ] } 请求响应成功后,无返回参数,状态码为201 Created。 若请求失败,返回如下所示的错误码及错误描述,状态码为400 Bad Request。 "error_code": "LIVE.100011001", "error_msg": "模板配置校验失败"
  • 操作场景 微服务是业务概念,某个进程提供某种服务,那它就是个微服务。每一个服务都具有自主运行的业务功能,对外开放不受语言限制的API (最常用的是HTTP)。多个微服务组成应用程序。 下面介绍如何调用创建微服务静态信息API注册微服务my-provider后,先调用注册微服务实例API注册微服务my-provider的实例,再次调用创建微服务静态信息API注册微服务微服务my-consumer,然后调用按条件查询微服务实例API,my-consumer带着自身的serviceId去服务中心查询my-provider的实例信息。 以上微服务名称均为示例。 API的调用方法请参见如何调用API。
  • 操作步骤 调用创建微服务静态信息API注册微服务my-provider,请求示例如下: curl -k -H "x-domain-name:default" -H "x-auth-token:$Token" -XPOST "https://{cse_endpoint}/v4/default/registry/microservices" -d '{ "service": { "serviceName": "my-provider", "appId": "default", "version": "1.0.0", "description": "test", "level": "MIDDLE", "status": "UP" } }' 返回结果: {"serviceId":"918282e8562dc5fdc9a8dcd4d1baabb492190aa4"} 记录加粗显示的serviceId值,用于替换后续示例中的{providerServiceId}。 调用注册微服务实例API注册微服务my-provider的实例。 实例有效期1小时,到期自动下线。假设provider实例监听的地址为127.0.0.1:8080,请求示例如下: curl -k -H "x-domain-name:default" -H "x-auth-token:$Token" -XPOST "https://{cse_endpoint}/v4/default/registry/microservices/{providerServiceId}/instances" -d '{ "instance": { "hostName": "test", "endpoints": [ "rest:127.0.0.1:8080" ], "status": "UP", "healthCheck": { "mode": "push", "interval": 900, "times": 3 } } }' 返回结果: {"instanceId":"2be605a095ed11eabcbe0255ac100fa3"} 调用创建微服务静态信息API注册微服务my-consumer,请求示例如下: curl -k -H "x-domain-name:default" -H "x-auth-token:$Token" -XPOST "https://{cse_endpoint}/v4/default/registry/microservices" -d '{ "service": { "serviceName": "my-consumer", "appId": "default", "version": "1.0.0", "description": "test", "level": "MIDDLE", "status": "UP" } }' 返回结果: {"serviceId":"9db248934c31fc754d6e922b48ede4a5c004d3c1"} 记录加粗显示的serviceId值,用于替换后续示例中的{consumerServiceId}代替。 调用按条件查询微服务实例接口,my-consumer带着自身的serviceId去服务中心查询my-provider的实例信息。请求示例如下: curl -k -H "x-domain-name:default" -H "x-auth-token:$Token" -H "X-ConsumerId:{consumerServiceId}" -XGET "https://{cse_endpoint}/v4/default/registry/instances?appId=default&serviceName=my-provider&version=0.0.0%2B" 返回结果: { "instances": [ { "instanceId": "2be605a095ed11eabcbe0255ac100fa3", "serviceId": "918282e8562dc5fdc9a8dcd4d1baabb492190aa4", "endpoints": [ "rest:127.0.0.1:8080" ], "hostName": "test", "status": "UP", "healthCheck": { "mode": "push", "interval": 150, "times": 3 }, "timestamp": "1589465646", "modTimestamp": "1589465646", "version": "1.0.0" } ] } 在实际业务中,my-consumer可从实例查询结果中的"endpoint"字段获取my-provider实例的地址,发起业务调用。 您还可以进入ServiceStage控制台,单击微服务引擎的“查看控制台”,在“服务目录”查看服务注册信息。
  • 操作步骤 指定limit与offset查询DDS实例列表。 接口相关信息 URI格式:GET https://{Endpoint}/v3/{project_id}/instances?id={id}&name={name}&mode={mode}&datastore_type={datastore_type}&vpc_id={vpc_id}&subnet_id={subnet_id}&offset={offset}&limit={limit} {Endpoint}信息请从地区和终端节点获取。 {limit}可根据DDS实例数据调整。 详情请参见查询实例列表和详情。 请求示例 根据指定limit与offset查询DDS实例列表 https://dds.cn-north-1.myhuaweicloud.com/v3/0483b6b16e954cb88930a360d2c4e663/instances?offset=0&limit=1 响应示例 根据指定limit与offset查询DDS实例列表: { "instances": [ { "id": "8436a91546294036b75931e879882200in02", "name": "dds-efa6", "status": "normal", "port": 8635, "mode": "ReplicaSet", "region": "aaa", "datastore": { "type": "DDS-Community", "version": "3.4" }, "engine": "wiredTiger", "created": "2019-01-17T07:05:52", "updated": "2019-01-17T07:05:47", "db_user_name": "rwuser", "ssl": "1", "vpc_id": "674e9b42-cd8d-4d25-a2e6-5abcc565b961", "subnet_id": "f1df08c5-71d1-406a-aff0-de435a51007b", "security_group_id": "7aa51dbf-5b63-40db-9724-dad3c4828b58", "backup_strategy": { "start_time": "16:00-17:00", "keep_days": 7 }, "pay_mode": "0", "maintenance_window": "02:00-06:00", "groups": [ { "type": "replica", "volume": { "size": "10", "used": "0.33" }, "nodes": [ { "id": "233eaac9c6f245c0bb9c2d21eea12d1bno02", "name": "dds-efa6_replica_node_2", "status": "normal", "role": "Primary", "private_ip": "192.168.0.174", "public_ip": "", "spec_code": "dds.mongodb.s2.medium.4.repset", "availability_zone": "bbb" }, { "id": "d57d76d6320a4a7b86db82c317550c4ano02", "name": "dds-efa6_replica_node_1", "status": "normal", "role": "Hidden", "private_ip": "192.168.0.39", "public_ip": "", "spec_code": "dds.mongodb.s2.medium.4.repset", "availability_zone": "bbb" }, { "id": "f46b0a1cf4d9400e9fd7af17f8742d37no02", "name": "dds-efa6_replica_node_3", "status": "normal", "role": "Secondary", "private_ip": "192.168.0.176", "public_ip": "", "spec_code": "dds.mongodb.s2.medium.4.repset", "availability_zone": "bbb" } ] } ], "enterprise_project_id": "0", "time_zone": "", "actions": [ ] } ], "total_count": 24 } 汇总查询结果。 参考1持续调用,如果查询的DDS实例列表为空,或者返回的body体中不存在instances字段,表明所有DDS实例查询完成。 汇总所有查询到的DDS实例即当前查询条件下的所有DDS实例。
  • 查询用户的所有仓库 接口信息: URI:GET v2/projects/repositories API Explorer 在线调试请参见:查询用户的所有仓库。 请求示例: GET https://codehub-ext.cn-north-1.myhuaweicloud.com/v2/projects/repositories 响应示例: { "result": { "total": 40, "repositories": [ { "star": false, "status": 5, "userRole": null, "repository_uuid": "25c88b23d4dc400fa7b3e2a152e4d53c", "repository_id": 522140, "repository_name": "1111111111111", "ssh_url": "git@codehub.test.com:testzxq00001/1111111111111.git", "https_url": "https://test.com/testzxq00001/1111111111111.git", "group_name": "testzxq00001", "web_url": "https://test.com/codehub/522140/home", "visibility_level": 0, "created_at": "2020-07-22 10:45:56", "updated_at": "2020-07-22 10:45:56", "repository_size": "0.16M", "lfs_size": "0.00M", "creator_name": "devcloud_codehub_l00314597_01", "domain_name": "devcloud_codehub_l00314597_01", "is_owner": 1, "iam_user_uuid": "a618e34bd5704be3ae3395dfede06041", "project_uuid": "a689e057c2304abfa35d4ff65630a90a", "project_is_deleted": "false" } ] }, "status": "success"}
  • 操作步骤 创建关联VPC的VPN网关。 发送“POST https://{endpoint}/v5/{project_id}/vpn-gateways”,project_id为项目ID。 在Request Header中增加“X-Auth-Token”。 在Request Body中传入参数如下。 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 { "vpn_gateway": { "vpc_id": "cb4a631d-demo-a8df-va86-ca3fa348c36c", "local_subnets": [ "192.168.0.0/24", "192.168.1.0/24" ], "connect_subnet": "f5741286-demo-a8df-va86-2c82bd9ee114", "eip1": { "id": "cff40e5e-demo-a8df-va86-7366077bf097" }, "eip2": { "id": "d290f1ee-demo-a8df-va86-d701748f0851" } } } 查看请求响应结果。 请求成功时,响应参数如下,id就是VPN网关的ID。 { "vpn_gateway": { "id": "620d99b8-demo-a8df-va86-200b868f2d7d", "name": "vpngw-3caf", "network_type": "public", "attachment_type": "vpc", "vpc_id": "cb4a631d-demo-a8df-va86-ca3fa348c36c", "local_subnets": ["192.168.0.0/24", "192.168.1.0/24"], "connect_subnet": "f5741286-demo-a8df-va86-2c82bd9ee114", "bgp_asn": 64512, "access_vpc_id": "cb4a631d-demo-a8df-va86-ca3fa348c36c", "access_subnet_id": "f5741286-demo-a8df-va86-2c82bd9ee114", "flavor": "Professional1", "used_connection_number": 0, "used_connection_group": 0, "enterprise_project_id": "0" }, "request_id": "4a739f5c-edb7-4122-b31f-b77fb1b94857" } 查询VPN网关详情。 发送“GET https://{endpoint}/v5/{project_id}/vpn-gateways/{vgw_id}”,project_id为项目ID。 在Request Header中增加“X-Auth-Token”。 查看请求响应结果。 请求成功时,响应参数如下,id就是VPN网关的ID。 { "vpn_gateway": { "id": "620d99b8-demo-a8df-va86-200b868f2d7d", "name": "vpngw-3caf", "network_type": "public", "status": "ACTIVE", "attachment_type": "vpc", "vpc_id": "cb4a631d-demo-a8df-va86-ca3fa348c36c", "local_subnets": [ "192.168.0.0/24", "192.168.1.0/24" ], "connect_subnet": "f5741286-demo-a8df-va86-2c82bd9ee114", "access_vpc_id": "cb4a631d-demo-a8df-va86-ca3fa348c36c", "access_subnet_id": "f5741286-demo-a8df-va86-2c82bd9ee114", "bgp_asn": 64512, "flavor": "Professional1", "availability_zone_ids": [ "cn-south-1f", "cn-south-1e" ], "used_connection_number": 0, "used_connection_group": 0, "enterprise_project_id": "0", "eip1": { "id": "cff40e5e-demo-a8df-va86-7366077bf097", "ip_version": 4, "type": "5_bgp", "ip_address": "88.***.***.8", "charge_mode": "bandwidth", "bandwidth_id": "593a1a79-demo-a8df-va86-64ec45fb23f6", "bandwidth_size": 300, "bandwidth_name": "vpngw-bandwidth-1391" }, "eip2": { "id": "d290f1ee-demo-a8df-va86-d701748f0851", "ip_version": 4, "type": "5_bgp", "ip_address": "88.***.***.6", "charge_mode": "bandwidth", "bandwidth_id": "0abb9d55-demo-a8df-va86-b7500ac2a338", "bandwidth_size": 300, "bandwidth_name": "vpngw-bandwidth-1392" }, "created_at": "2022-09-15T08:56:09.386Z", "updated_at": "2022-09-15T11:13:13.677Z" }, "request_id": "d099a7dc-ea71-45a6-a75b-dccbfe17d438" }
  • 前提条件 已创建VPC,具体请参见创建VPC。 您需要规划VPN网关所在的区域信息,并根据区域确定调用API的Endpoint。 当您使用Token认证方式完成认证鉴权时,需要获取用户Token并在调用接口时增加“X-Auth-Token”到业务接口请求消息头中。Token认证,具体操作请参考认证鉴权章节。 通过IAM服务获取到的Token有效期为24小时,需要使用同一个Token鉴权时,可以先将Token缓存,避免频繁调用。
  • 数据准备 表1 创建VPN网关请求关键参数 参数 说明 取值样例 vpc_id VPN网关所连接的VPC的ID。 cb4a631d-demo-a8df-va86-ca3fa348c36c local_subnets 本端网段。 192.168.0.0/24,192.168.1.0/24 connect_subnet VPN网关所使用的VPC中的子网ID。 f5741286-demo-a8df-va86-2c82bd9ee114 eip1.id VPN网关使用的第一个EIP的ID。 cff40e5e-demo-a8df-va86-7366077bf097 eip2.id VPN网关使用的第二个EIP的ID。 d290f1ee-demo-a8df-va86-d701748f0851
  • 操作步骤 调用认证鉴权接口获取用户的Token。 请求消息体: URI格式:POST https://{iam_endpoint}/v3/auth/tokens 请求消息头:Content-Type →application/json 请求Body: { "auth": { "identity": { "methods": ["password"], "password": { "user": { "name": "user_name", "password": "user_password", "domain": { "name": "domain_name" } } } }, "scope": { "project": { "name": "cn-north-1" } } } } 其中,加粗的斜体字段需要根据实际值填写: iam_endpoint为IAM的终端节点。 user_name为IAM用户名。 user_password为用户登录密码。 domain_name为用户所属的账号名。 cn-north-1为项目名,代表服务的部署区域。 返回状态码“201 Created”,在响应Header中获取“X-Subject-Token”的值即为Token,如下所示: x-subject-token →MIIZmgYJKoZIhvcNAQcCoIIZizCCGYcCAQExDTALBglghkgBZQMEAgEwgXXXXXX... 调用创建数据集接口创建一个图像分类类型的数据集。 请求消息体: URI格式:POST https://{ma_endpoint}/v2/{project_id}/datasets 请求消息头: X-auth-Token →MIIZmgYJKoZIhvcNAQcCoIIZizCCGYcCAQExDTALBglghkgBZQMEAgEwgXXXXXX... Content-Type →application/json 请求body: { "workspace_id" : "0", "dataset_name" : "dataset-f9e8", "dataset_type" : 0, "data_sources" : [ { "data_type" : 0, "data_path" : "/test-obs/classify/input/cat-dog/" } ], "description" : "", "work_path" : "/test-obs/classify/output/", "work_path_type" : 0, "labels" : [ { "name" : "Cat", "type" : 0, "property" : { "@modelarts:color" : "#3399ff" } }, { "name" : "Dog", "type" : 0, "property" : { "@modelarts:color" : "#3399ff" } } ] } 其中,加粗的斜体字段需要根据实际值填写: ma_endpoint为ModelArts的终端节点。 project_id为用户的项目ID。 X-auth-Token的值为获取到的Token值。 “dataset_name”为创建的数据集名称。 “dataset_type”为“0”表示数据集类型为图像分类。 “data_path”为数据源所在的存储路径。 “work_path”为数据集输出位置。 “labels”为数据集的标签列表,填写标签信息。 返回状态码为“201 Created”,响应Body如下: { "dataset_id": "2MCIopOFu0bOmSxFkZ4" } “dataset_id”为新建的数据集ID,记录该值用于后续步骤。 调用查询数据集详情接口根据数据集ID查询数据集的详情。 请求消息体: URI格式:GET https://{ma_endpoint}/v2/{project_id}/datasets/{dataset_id} 请求消息头:X-auth-Token →MIIZmgYJKoZIhvcNAQcCoIIZizCCGYcCAQExDTALBglghkgBZQMEAgEwgXXXXXX... 其中,加粗的斜体字段需要根据实际值填写,dataset_id为上一步记录的数据集ID。 返回状态码为“200 OK”,响应Body如下所示: { "dataset_id" : "DINKm5SUIDhhGb1eWm3", "dataset_name" : "dataset-f9e8", "dataset_type" : 0, "data_format" : "Default", "next_version_num" : 4, "status" : 1, "data_sources" : [ { "data_type" : 0, "data_path" : "/test-obs/classify/input/cat-dog/" } ], "create_time" : 1605690595404, "update_time" : 1605690595404, "description" : "", "current_version_id" : "54IXbeJhfttGpL46lbv", "current_version_name" : "V003", "total_sample_count" : 10, "annotated_sample_count" : 10, "unconfirmed_sample_count" : 0, "work_path" : "/test-obs/classify/output/", "inner_work_path" : "/test-obs/classify/output/dataset-f9e8-DINKm5SUIDhhGb1eWm3/", "inner_annotation_path" : "/test-obs/classify/output/dataset-f9e8-DINKm5SUIDhhGb1eWm3/annotation/", "inner_data_path" : "/test-obs/classify/output/dataset-f9e8-DINKm5SUIDhhGb1eWm3/data/", "inner_log_path" : "/test-obs/classify/output/dataset-f9e8-DINKm5SUIDhhGb1eWm3/logs/", "inner_temp_path" : "/test-obs/classify/output/dataset-f9e8-DINKm5SUIDhhGb1eWm3/temp/", "inner_task_path" : "/test-obs/classify/output/dataset-f9e8-DINKm5SUIDhhGb1eWm3/task/", "work_path_type" : 0, "workspace_id" : "0", "enterprise_project_id" : "0", "workforce_task_count" : 0, "feature_supports" : [ "0" ], "managed" : false, "import_data" : false, "ai_project" : "default-ai-project", "label_task_count" : 1, "dataset_format" : 0, "dataset_version_count" : 3, "dataset_version" : "v1", "content_labeling" : true, "labels" : [ { "name" : "Cat", "type" : 0, "property" : { "@modelarts:color" : "#3399ff" } }, { "name" : "Dog", "type" : 0, "property" : { "@modelarts:color" : "#3399ff" } } ] } 根据响应可以了解数据集详情,其中“status”为“1”表示数据集创建成功且状态正常。 调用查询样本列表接口根据数据集ID获取数据集的样本详情。 请求消息体: URI格式:GET https://{ma_endpoint}/v2/{project_id}/datasets/{dataset_id}/data-annotations/samples 请求消息头:X-auth-Token →MIIZmgYJKoZIhvcNAQcCoIIZizCCGYcCAQExDTALBglghkgBZQMEAgEwgXXXXXX... 其中,加粗的斜体字段需要根据实际值填写。 返回状态码为“200 OK”,响应Body如下所示: { "sample_count" : 2, "samples" : [ { "sample_id": "012f99f3cf405860130b6ed2350c2228", "sample_type": 0, "labels": [], "source": "https://test-obs.obs.{ma_endpoint}.com:443/classify/input/cat-dog/36502.jpg......", "preview": "https://test-obs.obs.{ma_endpoint}.com:443/classify/input/cat-dog/36502.jpg......", "metadata": { "@modelarts:source_image_info": "https://test-obs.obs.{ma_endpoint}.com:443/classify/input/cat-dog/36502.jpg......", "@modelarts:import_origin": 0 }, "sample_time": 1623914750831, "sample_status": "UN_ANNOTATION" }, { "sample_id": "0192f3acfb000666033a0f85c21577c7", "sample_type": 0, "labels": [], "source": "https://test-obs.obs.xxx.com:443/classify/input/cat-dog/36139.jpg......", "preview": "https://test-obs.obs.xxx.com:443/classify/input/cat-dog/36139.jpg......", "metadata": { "@modelarts:source_image_info": "https://test-obs.obs.xxx.com:443/classify/input/cat-dog/36139.jpg......", "@modelarts:import_origin": 0 }, "sample_time": 1623914751076, "sample_status": "UN_ANNOTATION" } ] } 根据响应可以了解数据集的样本数量,以及每个样本的详细信息,其中“sample_count”为“2”表示该数据集共有2个样本,记录“sample_id”(样本ID)用于后续人工标注。 调用批量更新样本标签接口根据数据集ID和样本ID给样本添加标签进行人工标注。 请求消息体: URI格式:PUT https://{ma_endpoint}/v2/{project_id}/datasets/{dataset_id}/data-annotations/samples 请求消息头: X-auth-Token →MIIZmgYJKoZIhvcNAQcCoIIZizCCGYcCAQExDTALBglghkgBZQMEAgEwgXXXXXX... Content-Type →application/json 请求body: { "samples" : [ { "sample_id" : "012f99f3cf405860130b6ed2350c2228", "labels" : [ { "name" : "Cat" } ] }, { "sample_id" : "0192f3acfb000666033a0f85c21577c7", "labels" : [ { "name" : "Dog" } ] } ] } 其中,加粗的字段需要根据实际值填写: “sample_id”为要标注的样本ID,为上一步记录的值。 “labels”为样本需要标注的标签。 返回状态码为“200 OK”表示标注成功,响应Body如下所示: { "success" : true } 调用查询数据集的统计信息接口查看数据集的标注统计信息。 消息请求体: URI格式:GET https://{ma_endpoint}/v2/{project_id}/datasets/{dataset_id}/data-annotations/stats 请求消息头:X-auth-Token →MIIZmgYJKoZIhvcNAQcCoIIZizCCGYcCAQExDTALBglghkgBZQMEAgEwgXXXXXX... 其中,加粗的斜体字段需要根据实际值填写。 返回状态码为“200 OK”,响应Body如下所示: { "label_stats": [ { "name": "Cat", "type": 0, "property": { "@modelarts:color": "#3399ff" }, "count": 5, "sample_count": 2 }, { "name": "Dog", "type": 0, "property": { "@modelarts:color": "", "@modelarts:shortcut": "" }, "count": 4, "sample_count": 3 } ], "sample_stats": { "un_annotation": 10, "all": 15, "total": 15, "deleted": 0, "manual_annotation": 5, "auto_annotation": 0, "lefted": 15 }, "key_sample_stats": { "total": 15, "non_key_sample": 15, "key_sample": 0 }, "deletion_stats": {}, "metadata_stats": {}, "data_spliting_enable": true } 根据响应可以了解数据集的标签统计信息、样本状态统计信息等。 当数据集使用完成或不再使用时,调用删除数据集接口删除数据集。 请求消息体: URI格式:DELETE https://{ma_endpoint}/v2/{project_id}/datasets/{dataset_id} 请求消息头: X-auth-Token →MIIZmgYJKoZIhvcNAQcCoIIZizCCGYcCAQExDTALBglghkgBZQMEAgEwgXXXXXX... Content-Type →application/json 其中,加粗的斜体字段需要根据实际值填写。 返回状态码“204 No Content”表示数据集删除成功。
  • 概述 创建数据集并进行标注的流程如下: 调用认证鉴权接口获取用户Token,在后续的请求中需要将Token放到请求消息头中作为认证。 调用创建数据集接口创建一个图像分类类型的数据集。 调用查询数据集详情接口根据数据集ID查询数据集的详情。 调用查询样本列表接口根据数据集ID获取数据集的样本详情。 调用批量更新样本标签接口根据数据集ID和样本ID给样本添加标签进行人工标注。 调用查询数据集的统计信息接口查看数据集的标注统计信息。 当数据集使用完成或不再使用时,调用删除数据集接口删除数据集。
  • 操作步骤 请求示例 GET https://projectman-ext.cn-north-4.myhuaweicloud.com/v4/projects?project_type=scrum&search=ProjectTestCase&offset=0&limit=1 响应示例 { "projects": [ { "project_num_id": 3844012, "project_id": "ec147b681fb64e019a6bcd73ebdf3597", "project_name": "ProjectTestCaseYRXl", "description": "fdas", "created_time": 1600417972000, "updated_time": 1600417972000, "project_type": "scrum", "creator": { "user_num_id": 4090, "user_id": "665b542eb4c14b53a15ead449f28b0ba", "user_name": "test001", "domain_id": "70d11a2d7275425689347ec104af2ad8", "domain_name": "projectman_l00382124_01", "nick_name": "英国队长" } } ], "total": 48 }
  • 操作步骤 查询密钥列表。 接口相关信息 URI格式:POST /v1.0/{project_id}/kms/list-keys 详情请参见“查询密钥列表”。 请求示例 POST: https://{endpoint}/v1.0/53d1aefc533f4ce9a59c26b01667cbcf/kms/list-keys {endpoint}信息请从地区和终端节点获取。 Body: { "limit": "2", "marker": "1" } 响应示例 { "keys": [ "0d0466b0-e727-4d9c-b35d-f84bb474a37f", "2e258389-bb1e-4568-a1d5-e1f50adf70ea" ], "key_details": [ { "key_id":"0d0466b0-e727-4d9c-b35d-f84bb474a37f", "domain_id":"00074811d5c27c4f8d48bb91e4a1dcfd", "key_alias":"caseuirpr", "realm":"aaaa", "key_description":"123", "creation_date":"1502799822000", "scheduled_deletion_date":"", "key_state":"2", "default_key_flag":"0", "key_type":"1", "expiration_time":"1501578672000", "origin":"kms" }, { "key_id":"2e258389-bb1e-4568-a1d5-e1f50adf70ea", "domain_id":"00074811d5c27c4f8d48bb91e4a1dcfd", "key_alias":"casehvniz", "realm":"aaaa", "key_description":"234", "creation_date":"1502799820000", "scheduled_deletion_date":"", "key_state":"2", "default_key_flag":"0", "key_type":"1", "expiration_time":"1501578673000", "origin":"kms" } ], "next_marker": "", "truncated": "false", "total":2 } 查询密钥信息。 接口相关信息 URI格式:POST /v1.0/{project_id}/kms/describe-key 详情请参见“查询密钥信息”。 请求示例 POST: https://{endpoint}/v1.0/53d1aefc533f4ce9a59c26b01667cbcf/kms/describe-key {endpoint}信息请从地区和终端节点获取。 您可使用查询密钥列表接口获取当前用户密钥列表,包括key_id等信息 。 Body: { "key_id": "0d0466b0-e727-4d9c-b35d-f84bb474a37f" } 响应示例 { "key_info": { "key_id": "0d0466b0-e727-4d9c-b35d-f84bb474a37f", "domain_id": "b168fe00ff56492495a7d22974df2d0b", "key_alias": "kms_test", "realm": "aaa", "key_description": "", "creation_date": "1472442386000", "scheduled_deletion_date": "", "key_state": "2", "default_key_flag": "0", "key_type": "1", "expiration_time":"1501578672000", "origin":"kms", "key_rotation_enabled":"false", "sys_enterprise_project_id ": "0", } } 查询密钥实例。 接口相关信息 URI格式:POST /v1.0/{project_id}/kms/resource_instances/action 详情请参见“查询密钥实例”。 请求示例 POST: https://{endpoint}/v1.0/53d1aefc533f4ce9a59c26b01667cbcf/kms//resource_instances/action {endpoint}信息请从地区和终端节点获取。 Body: { "offset": "100", "limit": "100", "action": "filter", "matches":[ { "key": "resource_name", "value": "resource1" } ], "tags": [ { "key": "key1", "values": [ "value1", "value2" ] } ] } 响应示例 { "resources" : [ { "resource_id" : "90c03e67-5534-4ed0-acfa-89780e47a535", "resource_detail" : [ { "key_id" : "90c03e67-5534-4ed0-acfa-89780e47a535", "domain_id" : "4B688Fb77412Aee5570E7ecdbeB5afdc", "key_alias" : "tagTest_xmdmi", "key_description" : "123", "creation_date" : 1521449277000, "scheduled_deletion_date" : "", "key_state" : 2, "default_key_flag" : 0, "key_type" : 1, "key_rotation_enabled" : false, "expiration_time" : "", "origin" : "kms", "sys_enterprise_project_id" : "0", "realm" : "cn-north-7" } ], "resource_name" : "tagTest_xmdmi", "tags" : [ { "key" : "key", "value" : "testValue!" }, { "key" : "haha", "value" : "testValue" } ] } ], "total_count" : 1 } 查询密钥标签。 接口相关信息 URI格式:GET /v1.0/{project_id}/kms/{key_id}/tags 详情请参见“查询密钥标签”。 请求示例 GET: https://{endpoint}/v1.0/53d1aefc533f4ce9a59c26b01667cbcf/kms/94752282-805e-4032-ada8-34966f70e02f/tags {endpoint}信息请从地区和终端节点获取。 Body: 无 响应示例 { "tags": [ { "key": "key1", "value": "value1" }, { "key": "key2", "value": "value3" } ], "existTagsNum":2 }
  • 操作步骤 创建云硬盘。 创建云硬盘。 接口相关信息 URI格式:POST /v2/{project_id}/volumes 详情请参见创建云硬盘。 请求示例 POST https://{endpoint}/v2/74610f3a5ad941998e91f076297ecf27/volumes {endpoint}信息请从地区和终端节点获取。 Body: { "volume": { "name": "openapi_vol02", "availability_zone":"az_test_01", "description": "create for api test", "volume_type": "SSD", "size": 40 } } 响应示例 { "volume": { "status": "creating", "user_id": "f79791beca3c48159ac2553fff22e166", "attachments": [], "links": [ { "href": "https://xxx/v2/74610f3a5ad941998e91f076297ecf27/volumes/51f45e08-1d4f-44c6-a4a9-84a488e0e8d3", "rel": "self" }, { "href": "https://xxx/74610f3a5ad941998e91f076297ecf27/volumes/51f45e08-1d4f-44c6-a4a9-84a488e0e8d3", "rel": "bookmark" } ], "availability_zone": "az_test_01", "bootable": "false", "encrypted": false, "created_at": "2018-05-16T11:19:33.992984", "description": "create for api test", "updated_at": null, "volume_type": "SSD", "name": "openapi_vol02", "replication_status": "disabled", "consistencygroup_id": null, "source_volid": null, "snapshot_id": null, "shareable": false, "multiattach": false, "metadata": { "__system__volume_name": "openapi_vol02" }, "id": "51f45e08-1d4f-44c6-a4a9-84a488e0e8d3", "size": 40 } } 记录响应中“volume”的ID。 挂载磁盘。 接口相关信息 URI格式:POST /v1/{project_id}/cloudservers/{server_id}/attachvolume 详情请参见弹性云服务器挂载磁盘。 请求示例 POST https://{endpoint}/v1/74610f3a5ad941998e91f076297ecf27/cloudservers/9f4d9281-95e7-4915-a126-1ee597101e2e/attachvolume {endpoint}信息请从地区和终端节点获取。 Body: { "volumeAttachment": { "volumeId": "51f45e08-1d4f-44c6-a4a9-84a488e0e8d3", "device": "/dev/sdb", "volume_type": "SSD", "count": 5, "hw:passthrough": "true" }, "dry_run": false } 响应示例 { "job_id": "ff80808288d41e1b018990260955686a" } 确认挂载磁盘是否成功。 接口相关信息 URI格式:GET /v1/{project_id}/cloudservers/{server_id}/os-volume_attachments 详情请参见查询弹性云服务器挂载磁盘信息。 请求示例 GET https://{endpoint}/v2.1/74610f3a5ad941998e91f076297ecf27/servers/9f4d9281-95e7-4915-a126-1ee597101e2e/os-volume_attachments GET https://{endpoint}/v1/74610f3a5ad941998e91f076297ecf27/cloudservers/9f4d9281-95e7-4915-a126-1ee597101e2e/os-volume_attachments {endpoint}信息请从地区和终端节点获取。 响应示例 { "volumeAttachments": [ { "device": "/dev/sda", "id": "a26887c6-c47b-4654-abb5-dfadf7d3f803", "serverId": "9f4d9281-95e7-4915-a126-1ee597101e2e", "volumeId": "a26887c6-c47b-4654-abb5-dfadf7d3f803" }, { "device": "/dev/sdb", "id": "51f45e08-1d4f-44c6-a4a9-84a488e0e8d3", "serverId": "9f4d9281-95e7-4915-a126-1ee597101e2e", "volumeId": "51f45e08-1d4f-44c6-a4a9-84a488e0e8d3" } ] }
  • 操作步骤 创建虚拟IP。 发送“POST https://VPC的Endpoint/v2.0/ports”。 在Request Header中增加“X-Auth-Token”。 在Request Body中传入参数如下,其中vip所在子网需与E CS 同子网。 { "port": { "network_id": "4779ab1c-7c1a-44b1-a02e-93dfc361b32d", "device_owner": "neutron:VIP_PORT", "name": "vip_port_test" } } 或者如下,可以指定IP创建: { "port": { "network_id": "4779ab1c-7c1a-44b1-a02e-93dfc361b32d", "device_owner": "neutron:VIP_PORT", "name": "vip_port_test", "fixed_ips": [ { "ip_address": "192.168.0.220" } ] } } 查看请求响应结果。 请求成功时,响应参数如下: { "port": { "id": "a7d98f3c-b42f-460b-96a1-07601e145961", "name": "port-test", "status": "DOWN", "admin_state_up": true, "fixed_ips": [{ "subnet_id": "213cb9d-3122-2ac1-1a29-91ffc1231a12", "ip_address": "192.168.0.220" }], "mac_address": "fa:16:3e:01:f7:90", "network_id": "4779ab1c-7c1a-44b1-a02e-93dfc361b32d", "tenant_id": "db82c9e1415a464ea68048baa8acc6b8", "project_id": "db82c9e1415a464ea68048baa8acc6b8", "device_id": "", "device_owner": "neutron:VIP_PORT", "security_groups": ["d0d58aa9-cda9-414c-9c52-6c3daf8534e6"], "extra_dhcp_opts": [], "allowed_address_pairs": [], "binding:vnic_type": "normal", "binding:vif_details": {}, "binding:profile": {}, "port_security_enabled": true, "created_at": "2018-09-20T01:45:26", "updated_at": "2018-09-20T01:45:26" } } 请求异常时,错误码请参见错误码。 通过云服务器的ID查询网卡信息。 发送“GET https://VPC的Endpoint/v2.0/ports?device_id={ecs_id}&network_id={network_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" }] } 请求异常时,错误码请参见错误码。 将云服务器与虚拟IP绑定。 发送“PUT https://VPC的Endpoint/v2.0/ports/{port_id}”。port_id为上面创建的虚拟IP对应的port_id。 在Request Header中增加“X-Auth-Token”。 在Request Body中传入参数如下,ip_address为2查询出的云服务器的网卡ip。 { "port": { "allowed_address_pairs": [{ "ip_address": "192.168.0.75" }] } } 查看请求响应结果。 请求成功时,响应参数如下: { "port": { "id": "a7d98f3c-b42f-460b-96a1-07601e145961", "name": "port-test", "status": "DOWN", "admin_state_up": true, "fixed_ips": [{ "subnet_id": "213cb9d-3122-2ac1-1a29-91ffc1231a12", "ip_address": "192.168.0.220" }], "mac_address": "fa:16:3e:01:f7:90", "network_id": "4779ab1c-7c1a-44b1-a02e-93dfc361b32d", "tenant_id": "db82c9e1415a464ea68048baa8acc6b8", "project_id": "db82c9e1415a464ea68048baa8acc6b8", "device_id": "", "device_owner": "neutron:VIP_PORT", "security_groups": ["d0d58aa9-cda9-414c-9c52-6c3daf8534e6"], "extra_dhcp_opts": [], "allowed_address_pairs": [{ "ip_address": "192.168.0.75" }] "binding:vnic_type": "normal", "binding:vif_details": {}, "binding:profile": {}, "port_security_enabled": true, "created_at": "2018-09-20T01:45:26", "updated_at": "2018-09-20T01:45:26" } } 请求异常时,错误码请参见错误码。 关闭云服务器网卡的源/目的检查。 发送“PUT https://VPC的Endpoint/v2.0/ports/{port_id}”。port_id为2查询到的网卡ID。 在Request Header中增加“X-Auth-Token”。 在Request Body中传入参数如下:ip_address为1.1.1.1/0查询出的云服务器的网卡ip。 { "port": { "allowed_address_pairs": [{ "ip_address": "1.1.1.1/0" }] } } 查看请求响应结果。 请求成功时,响应参数如下: { "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": ["e0598d96-9451-4f8a-8de0-b8b4d451d9e7"], "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" } } 请求异常时,错误码请参见错误码。