云服务器内容精选

  • 步骤1:创建下载文件的函数 URI:POST /v2/{project_id}/fgs/functions API文档详情请参见:创建函数 请求示例 POST https://{Endpoint}/v2/{project_id}/fgs/functions { "code_filename": "index.zip", "code_type": "inline", "func_code": { "file": "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" }, "func_name": "download_file_from_obs", "handler": "index.handler", "memory_size": 256, "package": "default", "runtime": "Python2.7", "timeout": 30 } 响应示例 { "func_urn": "urn:fss:{project_name}:{project_id}:function:default:download_file_from_obs:latest", "func_name": "download_file_from_obs", "domain_id": "89fexxxd636", "namespace": "{project_id}", "project_name": "xxx", "package": "default", "runtime": "Python2.7", "timeout": 30, "handler": "index.handler", "memory_size": 256, "cpu": 400, "code_type": "inline", "code_filename": "index.zip", "code_size": 1707, "digest": "68891a6778848a78bd37a8c0798c91d75a5c87aee6e901303047a52edf05bf2170aac4149d79b3f6a40efe78406a83bf6d8683e7b25da4f0c07e7493aa4ccdcd", "version": "latest", "image_name": "latest-200603162219@zr2ym", "last_modified": "2020-06-03T16:22:19+08:00", "strategy_config": { "concurrency": -1 }, "StrategyConfig": {}, "enterprise_project_id": "0" } 记录函数的URN,即响应示例中的“func_urn”信息。
  • 步骤4:创建Timer触发器,实现定时下载文件 URI:POST /v2/{project_id}/fgs/triggers/{function_urn} API文档详情请参见:创建触发器 请求示例 POST https://{Endpoint}/v2/{project_id}/fgs/triggers/{function_urn} { "event_data": { "name": "Timer-download", "schedule_type": "Rate", "schedule": "1d" }, "event_type_code": "MessageCreated", "trigger_status": "ACTIVE", "trigger_type_code": "TIMER" } function_urn为步骤1:创建下载文件的函数中记录的函数URN。 上述请求示例表示每天从OBS桶中下载文件。 响应示例 { "trigger_id": "461bbe95-c85b-4dc9-a306-9701e77f1d66", "trigger_type_code": "TIMER", "trigger_status": "ACTIVE", "event_data": { "name": "Timer-download", "schedule": "1d", "schedule_type": "Rate" }, "last_updated_time": "2020-06-04T10:33:30+08:00", "created_time": "2020-06-04T10:33:30+08:00" }
  • 步骤3:确认函数能够成功从OBS桶中下载文件 URI:POST /v2/{project_id}/fgs/functions/{function_urn}/invocations API文档详情请参见:同步执行函数 请求示例 POST https://{Endpoint}/v2/{project_id}/fgs/functions/{function_urn}/invocations { "message": "download file" } function_urn为步骤1:创建下载文件的函数中记录的函数URN。 响应示例 "The object downloaded successfully from OBS, and the size is 14 KB"
  • 步骤2:修改函数配置信息中的OBS地址、OBS桶名和文件名 URI:PUT /v2/{project_id}/fgs/functions/{function_urn}/config API文档详情请参见:修改函数的metadata信息 请求示例 PUT https://{Endpoint}/v2/{project_id}/fgs/functions/{function_urn}/config { "func_name": "download_file_from_obs", "handler": "index.handler", "memory_size": 256, "runtime": "Python2.7", "timeout": 30, "user_data": "{\"obs_address\":\"obs.example.example.com\",\"srcBucket\":\" xxx\",\"srcObjName\":\"xxx\"}", "xrole": "xxx" } function_urn为步骤1:创建下载文件的函数中记录的函数URN,obs_address为OBS地址,srcBucket为OBS桶名,srcObjName为文件名,xrole为委托名。 响应示例 { "func_urn": "urn:fss:{project_name}:{project_id}:function:default:download_file_from_obs:latest", "func_name": "download_file_from_obs", "domain_id": "89fexxxd636", "namespace": "{project_id}", "project_name": "xxx", "package": "default", "runtime": "Python2.7", "timeout": 30, "handler": "index.handler", "memory_size": 256, "cpu": 400, "code_type": "inline", "code_filename": "index.zip", "code_size": 1707, "user_data": "{\"obs_address\":\"obs.example.example.com\",\"srcBucket\":\"xxx\",\"srcObjName\":\"xxx\"}", "digest": "68891a6778848a78bd37a8c0798c91d75a5c87aee6e901303047a52edf05bf2170aac4149d79b3f6a40efe78406a83bf6d8683e7b25da4f0c07e7493aa4ccdcd", "version": "latest", "image_name": "latest-200603165355@varrp", "xrole": "xxx", "app_xrole": "xxx", "last_modified": "2020-06-03T17:25:03+08:00", "strategy_config": { "concurrency": -1 }, "StrategyConfig": {}, "enterprise_project_id": "0" }
  • 查询用户的所有仓库 接口信息: 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"}
  • 操作步骤 查询证书列表。 接口相关信息 URI格式:GET /v3/scm/certificates 详情请参见查询证书列表。 请求示例 GET: https://{endpoint}/v3/scm/certificates {endpoint}信息请从地区和终端节点获取。 Body: { "limit": "2", "offset": "0" } 响应示例 { "certificates" : [ { "id" : "scs1554192131150", "name" : "test", "domain" : "www.zx.com", "type" : "OV_SSL_CERT", "brand" : "GEOTRUST", "expire_time" : "2021-05-27 16:46:25.0", "domain_type" : "MULTI_DOMAIN", "validity_period" : 12, "status" : "ISSUED", "domain_count" : 2, "wildcard_count" : 0, "description" : null } ], "total_count" : 1 } 删除证书。 接口相关信息 URI格式:DELETE /v3/scm/certificates/{certificate_id} 详情请参见删除证书。 请求示例 DELETE: https://{endpoint}/v3/scm/certificates/scs1554192131150 {endpoint}信息请从地区和终端节点获取。 Body: { certificate_id:scs1554192131150 } 响应示例 { } 或 { "error_code" : "SCM.XXX", "error_msg" : "XXX" }
  • 操作步骤 调用导出云手机数据接口进行数据备份。 请求示例 {endpoint}信息请从地区和终端节点获取。 POST https://{endpoint}/v1/{project_id}/cloud-phone/phones/batch-storage { "storage_infos" : [ { "phone_id" : "1234567b8bab40ffb711234cb80d0234", "include_files" : [ "/data/app", "/data/local", "/data/media" ], "exclude_files" : [ "/data/app/com.xx.xx-*" ], "bucket_name" : "mybucket", "object_path" : "myimage/v1/xxxxx.tar" } ] } 您需要指定如下参数: phone_id:要导出数据的手机ID。 bucket_name:导出数据所存储的OBS桶名。 object_path:导出数据所存储的OBS路径。 include_files:需要导出数据的存储路径。 exclude_files:不能导出数据的存储路径。 文件导出打包时仅保留路径最后一级的文件权限、属主、标签等元数据,如对打包文件的上层目录权限有要求,需指定路径到该目录,该目录下如存在其他文件,可用exclude_files参数排除。 示例如下: 导出数据的路径为:/data/media/0/my_files/test.png 导出打包后仅保留test.png的文件权限等,其父目录的文件权限等均不会保留。如果需要恢复的手机中存在/data/media/0/目录而不存在my_files子目录,则恢复后目标手机的/data/media/0/my_files/test.png文件会因丢失my_files父目录的权限等元数据而无法正常使用。 解决办法:修改导出文件的路径为/data/media/0/my_files 这样导出打包后会保留my_files目录及其包含的所有文件的权限等元数据。以此类推,如果目标手机不存在media子目录,则需要将打包路径指定到media这一层级。如果my_files中包含不需要导出的数据如test.txt,则需要在导出参数exclude_files中添/data/media/0/my_files/test.txt排除即可。 响应示例 { "request_id" : "6837531fd3f54550927b930180a706bf", "jobs" : [ { "phone_id" : "1234567b8bab40ffb711234cb80d0234", "job_id" : "1564567b8bab40f34711234cb80d0123" } ] } 数据导出为异步接口,可通过查询任务执行状态接口查询导出任务的执行状态。 调用恢复云手机数据接口进行数据恢复。 请求示例 {endpoint}信息请从地区和终端节点获取。 POST https://{endpoint}/v1/{project_id}/cloud-phone/phones/batch-restore { "restore_infos" : [ { "phone_id" : "1234567b8bab40ffb711234cb80d0234", "bucket_name" : "mybucket", "object_path" : "myimage/v1/xxxx.tar" } ] } 您需要指定如下参数: phone_id、bucket_name、object_path:分别对应步骤1中的内容。 响应示例 { "request_id" : "6837531fd3f54550927b930180a706bf", "jobs" : [ { "phone_id" : "1234567b8bab40ffb711234cb80d0234", "job_id" : "1564567b8bab40f34711234cb80d0123" } ] } 数据恢复为异步接口,可通过查询任务执行状态接口查询恢复任务的执行状态。
  • 操作步骤 指定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格式 :POST /v1/{project_id}/tdis/did 请求示例 POST https://{tdis_endpoint}/v1/{project_id}/tdis/did {tdis_endpoint}信息请从表1 地区和终端节点获取。 Header: { "X-Auth-Token":"tdis-test"} 响应示例 { "did": "did:hwid:ebfeb1f712ebc6f1c276e12ec21" }
  • 操作步骤 请求示例 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 }
  • 操作步骤 调用创建Workspace接口,创建一个工作空间,记录接口返回工作空间的ID。 请求示例: POST https://{hostname}/v1/workspaces Body: { "name": "apieworkspace", "description": "apie test workspace" } 响应示例: { "id": "e935d0ef-f4eb-4b95-aff1-9d33ae9f57a6", "name": "fabric", "description": "fabric", "create_time": "2023-05-30T12:24:30.401Z", "create_domain_name": "admin", "create_user_name": "user", "metastore_id": "2180518f-42b8-4947-b20b-adfc53981a25", "access_url": "https://:test.fabric.com/", "enterprise_project_id": "01049549-82cd-4b2b-9733-ddb94350c125" } 调用创建Endpoint接口,创建推理端点,记录接口返回的终端节点ID。 请求示例: POST https://{hostname}/v1/workspaces/{workspace_id}/endpoints workspace_id:为步骤1中记录的工作空间ID。 Body: { "name": "apie_test", "description": "apie test endpoint", "type": "inference", "reserved_resource": { "mu": { "spec_code": "mu.llama3.8b", "min": 0, "max": 1 } } } 响应示例: { "visibility": "PRIVATE", "id": "0b5633ba2b904511ad514346f4d23d4b", "name": "endpoint1", "type": "inference", "status": "CREATING", "description": "description", "create_time": "2023-05-30T12:24:30.401Z", "update_time": "2023-05-30T12:24:30.401Z", "owner": { "domain_name": "string", "domain_id": "xxx", "user_name": "string", "user_id": "xxx" } "reserved_resource": { "mu": { "spec_code": "mu.llama3.8b", "min": 0, "max": 1 } } } 调用创建模型接口,创建一个用户私有的模型,并记录接口返回模型ID。 请求示例: POST https://{hostname}/v1/workspaces/{workspace_id}/models workspace_id:为步骤1中记录的工作空间ID。 Body: { "name": "LLama3-8b", "description": "this is a apie test model", "type": "LLM_MODEL", "version": { "name": "v1", "description": "test description", "config": { "llm_model_config": { "base_model_type": "", "model_path": "" } } } } 响应示例: { "id": "ac8111bf-3601-4905-8ddd-b41d3e636a4e"} } 调用创建推理服务接口,创建一个推理服务,记录接口返回推理服务的ID。 请求示例: POST https://{hostname}/v1/workspaces/{workspace_id}/services/instances workspace_id:为步骤1中记录的工作空间ID。 Body: { "source": { "id": "" }, "name": "test_serviceInstanceName", "description": "description", "endpoint_id": ""} id:为步骤3中接口返回记录的模型ID。 endpoint_id:为步骤2中接口返回记录的推理端点ID。 响应示例: { "id": "b935d0ef-f4eb-4b95-aff1-9d33ae9f57b6" } 调用推理请求接口,发起推理请求。 请求示例: POST https://{hostname}/v1/workspaces/{workspace_id}/services/instances/{instance_id}/invocations workspace_id:为步骤1中记录的工作空间ID。 instance_id:为步骤4中记录的推理服务的ID。 Body: { "messages": [ { "role": "user", "content": "hello" } ] } 响应示例:推理请求接口为流式返回。 { "id": "chatcmpl-62dda7304f53451c9477e0", "object": "chat.completion.chunk", "created": 1730120529, "model": "ada1d67d-f2a1-4e77-838f-0d8688d756f4", "choices": [ { "index": 0, "delta": { "role": "assistant", "content": "\n\nHello! LLM stands for Large Language Model. It refers to artificial intelligence models, like myself," }, "finish_reason": null } ], "system_fingerprint": null, "usage": null }
  • 操作步骤 调用认证鉴权接口获取用户的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给样本添加标签进行人工标注。 调用查询数据集的统计信息接口查看数据集的标注统计信息。 当数据集使用完成或不再使用时,调用删除数据集接口删除数据集。
  • 操作步骤 获取IAM用户Token。 接口相关信息 URI格式:POST /v3/auth/tokens 详情请参见获取IAM用户Token(使用密码)。 请求示例 POST: https://{iam_endpoint}/v3/auth/tokens {endpoint}信息请从地区和终端节点获取。 Body: { "auth": { "identity": { "methods": [ "password" ], "password": { "user": { "name": "username", "domain": { "name": "domainname" }, "password": "****" } } }, "scope": { "project": { "id": "****" } } } } 响应Header中“X-Subject-Token”的值即为Token: X-Subject-Token:MIIDkgYJKoZIhvcNAQcCoIIDgzCCA38CAQExDTALBglghkgBZQMEAgEwgXXXXX... 上传附件。 接口相关信息 URI格式: POST /v2/servicerequest/accessorys/json-format-content 详情请参见上传附件接口。 请求示例 POST https://osm.cn-south-1.myhuaweicloud.com/v2/servicerequest/accessorys/json-format-content Header: Content-Type: application/json X-Auth-Token: "Token" Body: { "accessory_name": "filename", "accessory_from": "incident", "upload_type": 0, "accessory_data": "Base64 XXXXX" } 响应示例 { "accessory_id": "accessory_id" } 调用创建工单接口创建工单。 接口相关信息 URI格式: POST /v2/servicerequest/cases 详情请参见创建工单。 请求示例 POST https://osm.cn-south-1.myhuaweicloud.com/v2/servicerequest/cases Header: Content-Type: application/json X-Auth-Token: "Token" Body: { "business_type_id": "business_type_id", "product_category_id": "product_category_id", "incident_sub_type_id": "1", "source_id": "83aeb0f2834c4df49826c781d32a963e", "simple_description": "test", "remind_time": "0", "region_id": "cn-test-1", "area_code": "86", "extends_map": { }, "extension_map": { }, "accessory_ids": [ "accessory_id" // 这里的id用第三步上传附件返回的id,//如果没有附件,不要传accessory_ids这个参数 ] } 响应示例 { "incident_id": "TS-123456" } 调用查询接口,查看工单的详情和进展。 接口相关信息 URI格式: GET /v2/servicerequest/cases/{case_id} 详情请参见查询工单详情接口。 请求示例 GET https://osm.cn-south-1.myhuaweicloud.com/v2/servicerequest/cases/TT-123456 Header: Content-Type: application/json X-Auth-Token: “Token” 响应示例 { "incident_detail_info": { "xcustomer_name": "test", "status": 0, "incident_id": "TT-123456", "business_type_name": "活动规则咨询", "customer_id": "customer_id", "dc_name": "华南-广州", "simple_description": "123", "source_name": "用户中心", "create_time": "2020-12-25T09:24:18Z", "message_list": [ { "type": 0, "replier": "", "content": "123", "message_id": "", "replier_name": "", "create_time": "2020-12-25T09:24:18Z", "is_first_message": 0, "accessory_list": [ { "accessory_id": "", "file_actual_name": "test.jpg" } ] } ], "incident_satisfaction": [ ], "is_authorized": 0, "resolve_time": 0, "business_ownership": 0, "ext_info": { "area_code": "", "remind_mobile": "", "remind_mail": "", "contact_type": "0,1,2", "remind_time": "0", "cc_email": "" } } } Status 0表示待受理。
  • 操作步骤 获取用户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}/ott/channels “live.cn-north-4.myhuaweicloud.com”为媒体直播服务的终端节点,您可以在终端节点中获取。 调用IAM接口的区域需与调用媒体直播接口的区域一致,如调用“cn-north-4”区域的IAM接口获取用户Token,则该Token仅能用于调用“cn-north-4”区域媒体直播接口的鉴权。 在请求消息头中增加“X-Auth-Token”,值设置为1中获取的用户Token。 在请求消息体中传入如下所示的参数,具体参数说明可参考新建OTT频道接口。 { "domain": "push.domain.com", "app_name": "ott", "id": "testChannel", "name": "testChannel", "input": { "input_protocol": "FLV_PULL", "sources": [ { "url": "http://push.domain.com/ott/testChannel/index.flv", "bitrate": 2048, "width": 2096, "height": 1024 } ] }, "record_settings": { "rollingbuffer_duration": 3600 }, "encoder_settings": [ { "template_id": "hd" } ], "endpoints": [ { "hls_package": [ { "url": "pull.domain.com/ott/testChannel/index.m3u8", "stream_selection": [ { "key": "bitrate=900000-1800000", "max_bandwidth": 1800000, "min_bandwidth": 900000 } ], "segment_duration_seconds": 4, "encryption": { "level": "content", "resource_id": "test", "system_ids": [ "FairPlay" ], "url": "http://IP:Port/tkm/v1/owner/Data", "speke_version": "1.0", "request_mode": "direct_http", "http_headers": [ { "key": "Authorization", "value": "Basic aHVhd2VpY********************XM1Qjd6" } ] } } ] } ], "state": "ON" } 请求响应成功后,无返回参数,状态码为201 Created。 若请求失败,返回如下所示的错误码及错误描述,状态码为400 Bad Request。 "result_code": "LIVE.100011001", "result_msg": "Request parameters is invalid"