查询对应版本元数据-ShowMrsVersionMetadata
功能介绍
查询指定MRS版本的元数据信息,包括版本支持的组件列表、组件版本和配置参数等。如果参数中指定集群ID,则可查询该集群更新补丁后的最新元数据。
调用方法
请参见如何调用API。
授权信息
账号具备所有API的调用权限,如果使用账号下的IAM用户调用当前API,该IAM用户需具备调用API所需的权限。
- 如果使用角色与策略授权,具体权限要求请参见权限和授权项。
- 如果使用身份策略授权,当前API调用无需身份策略权限。
URI
GET /v1.1/{project_id}/metadata/versions/{version_name}
| 参数 | 是否必选 | 参数类型 | 描述 |
|---|---|---|---|
| project_id | 是 | String | 参数解释: 项目编号。获取方法,请参见获取项目ID。 约束限制: 不涉及 取值范围: 只能由英文字母和数字组成,且长度为[1-64]个字符。 默认取值: 不涉及 |
| version_name | 是 | String | 参数解释: 集群版本,可在MRS管理控制台创建集群页面查看当前支持的版本信息。例如“MRS 3.1.0”。如果请求客户端不支持自动转义,则需要将空格转义为%20,例如“MRS%203.1.0”。 约束限制: 不涉及 取值范围: 只能由英文字母、数字、小数点、中划线及空格组成,长度为[1-64]个字符。 默认取值: 不涉及 |
| 参数 | 是否必选 | 参数类型 | 描述 |
|---|---|---|---|
| cluster_id | 否 | String | 参数解释: 集群ID。如果指定集群ID,则获取该集群已安装补丁的最新版本元数据。获取方法,请参见获取集群ID。 约束限制: 不涉及 取值范围: 只能由英文字母、数字以及“_”和“-”组成,且长度为[1-64]个字符。 默认取值: 不涉及 |
请求参数
无
响应参数
状态码:200
| 参数 | 参数类型 | 描述 |
|---|---|---|
| other | Map<String,Object> | 参数解释: 其他属性,key(String类型)表示属性名称,value(Object类型)表示对应的属性取值。 取值范围: 不涉及 |
| name | String | 参数解释: 镜像版本名称。 取值范围: 不涉及 |
| template_type | String | 参数解释: 模板类型。 取值范围: 不涉及 |
| image_id | String | 参数解释: 镜像ID。 取值范围: 不涉及 |
| status | String | 参数解释: 版本状态。 取值范围:
|
| features | Array of strings | 参数解释: 特性列表。 取值范围: 不涉及 |
| cluster_types | Array of strings | 参数解释: 集群类型列表。 取值范围: 不涉及 |
| version_type | String | 参数解释: 版本类型。 取值范围:
|
| components | Array of VersionComponent objects | 参数解释: 组件列表。 取值范围: 不涉及 |
| resource_requirement | Array of strings | 参数解释: 版本所需的IP地址等资源说明。 取值范围: 不涉及 |
| constraints | VersionConstraint object | 参数解释: 版本限制说明。 取值范围: 不涉及 |
| flavors | FlavorLists object | 参数解释: 规格列表。 取值范围: 不涉及 |
| role_deploy_meta | Array of RoleDeployMeta objects | 参数解释: 版本组件实例角色部署策略。 取值范围: 不涉及 |
| 参数 | 参数类型 | 描述 |
|---|---|---|
| other | Map<String,Object> | 参数解释: 其他属性,key(String类型)表示属性名称,value(Object类型)表示对应的属性取值。 取值范围: 不涉及 |
| name | String | 参数解释: 组件名称。 取值范围: 不涉及 |
| version | String | 参数解释: 支持版本。 取值范围: 不涉及 |
| depend_on | Array of strings | 参数解释: 组件依赖项。 取值范围: 不涉及 |
| description | String | 参数解释: 组件描述。 取值范围: 不涉及 |
| available_cluster_types | Array of strings | 参数解释: 支持该组件的集群类型。 取值范围: 不涉及 |
| external_datasources | Array of ComponentExternalDatasource objects | 参数解释: 外部数据源。 取值范围: 不涉及 |
| resource_requirement | Array of strings | 参数解释: 所需的ip等资源说明。 取值范围: 不涉及 |
| valid_roles | Array of strings | 参数解释: 有效角色。 取值范围: 不涉及 |
| visible | Boolean | 参数解释: 是否可见。 取值范围: |
| children_components | Array of strings | 参数解释: 子组件。 取值范围: 不涉及 |
| multi_az_support_status | String | 参数解释: 多AZ支持状态。 取值范围: 不涉及 |
| 参数 | 参数类型 | 描述 |
|---|---|---|
| name | String | 参数解释: 外部数据源名称。 取值范围: 不涉及 |
| types | Array of strings | 参数解释: 外部数据源类型。 取值范围: 不涉及 |
| 参数 | 参数类型 | 描述 |
|---|---|---|
| other | Map<String,Object> | 参数解释: 其他限制,key(String类型)表示属性名称,value(Object类型)表示对应的属性取值。 取值范围: 不涉及 |
| node_constraint | NodeConstraints object | 参数解释: 节点限制。 取值范围: 不涉及 |
| safe_mode_kerberos_exclude_components | Array of strings | 参数解释: 安全模式kerberos排除组件列表。 取值范围: 不涉及 |
| 参数 | 参数类型 | 描述 |
|---|---|---|
| other | Map<String,Object> | 参数解释: 其他节点限制,key(String类型)表示属性名称,value(Object类型)表示对应的属性取值。 取值范围: 不涉及 |
| master | NodeConstraint object | 参数解释: master节点限制,包括节点数,磁盘等限制。 取值范围: 不涉及 |
| core | NodeConstraint object | 参数解释: core节点限制,包括节点数,磁盘等限制。 取值范围: 不涉及 |
| task | NodeConstraint object | 参数解释: task节点限制,包括节点数,磁盘等限制。 取值范围: 不涉及 |
| core_separate | NodeConstraint object | 参数解释: core节点管控分离限制,管控分离模板下core节点的限制,包括节点数,磁盘等限制。 取值范围: 不涉及 |
| core_combine | NodeConstraint object | 参数解释: core节点管控合设限制,管控合设模板下core节点的限制,包括节点数,磁盘等限制。 取值范围: 不涉及 |
| task_separate | NodeConstraint object | 参数解释: task节点管控分离限制,管控分离模板下task节点的限制,包括节点数,磁盘等限制。 取值范围: 不涉及 |
| task_combine | NodeConstraint object | 参数解释: task节点管控合设限制,管控合设模板下task节点的限制,包括节点数,磁盘等限制。 取值范围: 不涉及 |
| node_group_task | NodeConstraint object | 参数解释: task节点组限制,包括节点数,磁盘等限制。 取值范围: 不涉及 |
| 参数 | 参数类型 | 描述 |
|---|---|---|
| other | Map<String,Object> | 参数解释: 其他限制,key(String类型)表示属性名称,value(Object类型)表示对应的属性取值。 取值范围: 不涉及 |
| min_node_num | Integer | 参数解释: 最少节点数。 取值范围: 不涉及 |
| max_node_num | Integer | 参数解释: 最多节点数。 取值范围: 不涉及 |
| min_core_num | Map<String,Integer> | 参数解释: 最少核心数,key为节点组名称,value为核心数量。 取值范围: 不涉及 |
| min_mem_size | Map<String,Integer> | 参数解释: 最小内存容量,单位为GB,key为节点组名称,value为内存容量。 取值范围: 不涉及 |
| min_disk_size | Integer | 参数解释: 最小磁盘容量,单位为GB。 取值范围: 不涉及 |
| max_node_group_num | Integer | 参数解释: 最大节点组数。 取值范围: 不涉及 |
| min_data_volume_total_size | Map<String,Integer> | 参数解释: 最小数据卷容量,key为数据卷名称,value为容量大小,单位为GB。 取值范围: 不涉及 |
| disk_type_constraint | Map<String,String> | 参数解释: 磁盘类型限制,包含当前节点组所支持的磁盘类型。key为磁盘类型名称,value为限制说明。 取值范围: 不涉及 |
| min_root_disk_size | Integer | 参数解释: 最小系统磁盘大小,单位为GB。 取值范围: 不涉及 |
| 参数 | 参数类型 | 描述 |
|---|---|---|
| master | Array of strings | 参数解释: master节点支持的规格列表。 取值范围: 不涉及 |
| core | Array of strings | 参数解释: core节点支持的规格列表。 取值范围: 不涉及 |
| task | Array of strings | 参数解释: task节点支持的规格列表。 取值范围: 不涉及 |
| 参数 | 参数类型 | 描述 |
|---|---|---|
| other | Map<String,Object> | 参数解释: 其他扩展属性,key(String类型)表示属性名称,value(Object类型)表示对应的属性取值。 取值范围: 不涉及 |
| name | String | 参数解释: 角色名称。 取值范围: 不涉及 |
| code_name | String | 参数解释: 角色简称。 取值范围: 不涉及 |
| component | String | 参数解释: 角色所属组件。 取值范围: 不涉及 |
| node_preference | String | 参数解释: 部署倾向。 取值范围: 不涉及 |
| count | String | 参数解释: 角色数量限制。 取值范围: 不涉及 |
| affinity | String | 参数解释: 亲和。 取值范围: 不涉及 |
| affinity_target | String | 参数解释: 亲和目标。 取值范围: 不涉及 |
| multi_instance | Integer | 参数解释: 多实例,部分组件支持同一集群内部署多个。 取值范围: 不涉及 |
| role_kind | String | 参数解释: 角色类型。 取值范围: 不涉及 |
| constraints | Array of strings | 参数解释: 角色限制,包含当前组件角色的一些功能限制,例如:"no_scale_in"。 取值范围: 不涉及 |
| multi_az_placement | String | 参数解释: 多az部署。 取值范围: 不涉及 |
| arbitration_deployment | Boolean | 参数解释: 仲裁部署。 取值范围: |
| support_elb | Boolean | 参数解释: 支持ELB。 取值范围: |
| multi_affinity_group_enable | Boolean | 参数解释: 启用多亲和组。 取值范围: |
| local_disks_anti_affinity | Boolean | 参数解释: 本地盘反亲和,用于控制集群调度策略,开启后调度器会规避将同一业务多实例调度至同一主机,避免多实例共用该主机本地磁盘;若关闭,则无此隔离约束,多个实例可分配到同一台机器共用本地盘。 取值范围: |
| multi_instance_name_pattern | String | 参数解释: 多实例名称模式。 取值范围: 不涉及 |
| private_ip | String | 参数解释: 私有IP。 取值范围: 不涉及 |
| weight | String | 参数解释: 权重。 取值范围: 不涉及 |
请求示例
获取MRS 3.1.0的版本元数据:
GET /v1.1/{project_id}/metadata/versions/MRS%203.1.0 响应示例
状态码:200
版本元数据详情。(该样例省略了部分内容,详细返回请调用接口查看)
{
"other" : { },
"name" : "MRS 3.1.0",
"template_type" : "clusterFusion",
"image_id" : "ECS:X86:deda7c89-6069-46d3-af7c-4afc31eec0d9,ECS:ARM:d5f0087b-9fd7-4977-b9c8-d07262f452d6,BMS:ks1ne:bf071a00-d1d6-472f-943b-22f733248f36,BMS:d2:a9a1a279-85c9-4c05-bd0a-4cb786937a09",
"status" : "GA",
"features" : [ "anti_affinity", "auto_scaling", "bootstrap_scripts", "bootstrap_support_obs", "custom_config", "custom_topology", "datasource_manager", "decouple_install", "elastic_ip", "fi_cluster", "fi_cluster_v2", "iam_user_sync", "log_collect", "log_collect_v2", "master_scale_up", "mrs_ecs_agency", "multi_disks", "multi_login_mode", "obs_integration", "obs_user_policy", "opensource_port_matrix", "ops_channel", "password_policy_v2", "random_passwd_for_install", "register_dns_server", "resize", "resources_plans", "safe_mode", "scale_scripts", "security_job_submit", "smn_alarm", "spark_sql_validation_in_executor", "support_obs_protocol", "task_node", "unified_management_ui", "sql_execution", "multi_az", "weak_multi_az_deployment_constraint", "multi_master_scale_up", "omm_random_pwd", "metric_monitor", "auth_manager", "cluster_patch", "hw_domain_name", "fi_custom_config", "force_scale_up", "skip_fi_evs_expand", "detach_node" ],
"cluster_types" : [ "analysis", "streaming", "mixed", "custom" ],
"version_type" : "basic",
"components" : [ {
"other" : { },
"name" : "Hadoop",
"version" : "3.1.1",
"depend_on" : [ "ZooKeeper", "Ranger" ],
"description" : "A framework that allows for the distributed processing of large data sets across clusters.",
"available_cluster_types" : [ "analysis", "mixed", "custom" ],
"external_datasources" : null,
"resource_requirement" : [ "privateIp:1" ],
"valid_roles" : [ "NameNode", "Zkfc", "JournalNode", "DataNode", "ResourceManager", "NodeManager", "JobHistoryServer", "TimelineServer", "HttpFS" ],
"visible" : true,
"children_components" : [ "HDFS", "Mapreduce", "Yarn" ],
"multi_az_support_status" : "multi_az_ha"
}, {
"other" : { },
"name" : "Spark2x",
"version" : "2.4.5",
"depend_on" : [ "HDFS", "Yarn", "Hive", "KrbClient", "KrbServer", "ZooKeeper" ],
"description" : "Apache Spark2x is a fast and general engine based on open source Spark2.x for large-scale data processing.",
"available_cluster_types" : [ "analysis", "mixed", "custom" ],
"external_datasources" : null,
"resource_requirement" : null,
"valid_roles" : [ "JobHistory2x", "JDBCServer2x", "SparkResource2x", "IndexServer2x" ],
"visible" : true,
"children_components" : [ "Spark2x" ],
"multi_az_support_status" : "multi_az_ha"
}, {
"other" : { },
"name" : "HBase",
"version" : "2.2.3",
"depend_on" : [ "HDFS", "Yarn", "KrbServer", "ZooKeeper" ],
"description" : "A scalable, distributed database that supports structured data storage for large tables.",
"available_cluster_types" : [ "analysis", "mixed", "custom" ],
"external_datasources" : null,
"resource_requirement" : null,
"valid_roles" : [ "HMaster", "RegionServer", "ThriftServer", "Thrift1Server", "RESTServer", "RegionServer_1" ],
"visible" : true,
"children_components" : [ "HBase" ],
"multi_az_support_status" : "multi_az_ha"
}, {
"other" : { },
"name" : "Hive",
"version" : "3.1.0",
"depend_on" : [ "HDFS", "Mapreduce", "Yarn", "DBService", "ZooKeeper" ],
"description" : "A data warehouse infrastructure that provides data summarization and ad hoc querying.",
"available_cluster_types" : [ "analysis", "mixed", "custom" ],
"external_datasources" : [ {
"name" : "hive_metastore",
"types" : [ "RDS_MYSQL", "DLCATALOG" ]
} ],
"resource_requirement" : null,
"valid_roles" : [ "MetaStore", "WebHCat", "HiveServer" ],
"visible" : true,
"children_components" : [ "Hive" ],
"multi_az_support_status" : "multi_az_ha"
}, {
"other" : { },
"name" : "ZooKeeper",
"version" : null,
"depend_on" : [ "KrbClient", "KrbServer" ],
"description" : null,
"available_cluster_types" : [ "analysis", "streaming", "mixed", "custom" ],
"external_datasources" : null,
"resource_requirement" : null,
"valid_roles" : [ "quorumpeer" ],
"visible" : true,
"children_components" : [ "ZooKeeper" ],
"multi_az_support_status" : "multi_az_ha"
} ],
"resource_requirement" : [ "privateIp:2" ],
"constraints" : {
"other" : { },
"node_constraint" : {
"other" : { },
"master" : {
"other" : { },
"min_node_num" : 2,
"max_node_num" : 9,
"min_core_num" : null,
"min_mem_size" : null,
"min_disk_size" : 600,
"max_node_group_num" : 1,
"min_data_volume_total_size" : null,
"disk_type_constraint" : null,
"min_root_disk_size" : 480
},
"core" : {
"other" : { },
"min_node_num" : 3,
"max_node_num" : 500,
"min_core_num" : null,
"min_mem_size" : null,
"min_disk_size" : 600,
"max_node_group_num" : null,
"min_data_volume_total_size" : null,
"disk_type_constraint" : null,
"min_root_disk_size" : 480
},
"task" : null,
"core_separate" : null,
"core_combine" : null,
"task_separate" : null,
"task_combine" : null,
"node_group_task" : {
"other" : { },
"min_node_num" : 2,
"max_node_num" : 10000,
"min_core_num" : null,
"min_mem_size" : null,
"min_disk_size" : 600,
"max_node_group_num" : 9,
"min_data_volume_total_size" : null,
"disk_type_constraint" : null,
"min_root_disk_size" : 480
}
},
"safe_mode_kerberos_exclude_components" : [ "Presto", "Pulsar" ]
},
"flavors" : {
"master" : [ "ac7.4xlarge.4", "ac7.8xlarge.4", "ac7.16xlarge.4", "ac7.32xlarge.4", "ac7.8xlarge.2", "ac7.16xlarge.2", "ac7.32xlarge.2", "am7.2xlarge.8", "am7.4xlarge.8", "am7.8xlarge.8", "c3ne.4xlarge.4", "c3ne.8xlarge.4", "c3ne.15xlarge.4" ],
"core" : [ "ac7.4xlarge.4", "ac7.8xlarge.4", "ac7.16xlarge.4", "ac7.32xlarge.4", "ac7.8xlarge.2", "ac7.16xlarge.2", "ac7.32xlarge.2", "am7.2xlarge.8", "am7.4xlarge.8", "am7.8xlarge.8", "c3ne.4xlarge.4", "c3ne.8xlarge.4", "c3ne.15xlarge.4", "c6.4xlarge.4", "c6.8xlarge.2", "c6.8xlarge.4", "c6.16xlarge.2" ],
"task" : [ "ac7.4xlarge.4", "ac7.8xlarge.4", "ac7.16xlarge.4", "ac7.32xlarge.4", "ac7.8xlarge.2", "ac7.16xlarge.2", "ac7.32xlarge.2", "am7.2xlarge.8", "am7.4xlarge.8", "am7.8xlarge.8", "c3ne.4xlarge.4", "c3ne.8xlarge.4", "c3ne.15xlarge.4" ]
},
"role_deploy_meta" : [ {
"other" : { },
"name" : "OMSServer",
"code_name" : "OMS",
"component" : "OMSServer",
"node_preference" : "MASTER",
"count" : "2",
"affinity" : null,
"affinity_target" : null,
"multi_instance" : null,
"role_kind" : null,
"constraints" : null,
"multi_az_placement" : "AT_LEAST_2",
"arbitration_deployment" : false,
"support_elb" : false,
"multi_affinity_group_enable" : false,
"local_disks_anti_affinity" : false,
"multi_instance_name_pattern" : null,
"private_ip" : null,
"weight" : null
}, {
"other" : { },
"name" : "NameNode",
"code_name" : "NN",
"component" : "HDFS",
"node_preference" : "MASTER",
"count" : "2",
"affinity" : null,
"affinity_target" : null,
"multi_instance" : null,
"role_kind" : null,
"constraints" : null,
"multi_az_placement" : "AT_LEAST_2",
"arbitration_deployment" : false,
"support_elb" : false,
"multi_affinity_group_enable" : false,
"local_disks_anti_affinity" : false,
"multi_instance_name_pattern" : null,
"private_ip" : null,
"weight" : null
}, {
"other" : { },
"name" : "Zkfc",
"code_name" : "ZKFC",
"component" : "HDFS",
"node_preference" : null,
"count" : null,
"affinity" : "JUST_COLOCATE",
"affinity_target" : "NameNode",
"multi_instance" : null,
"role_kind" : null,
"constraints" : null,
"multi_az_placement" : "AT_LEAST_2",
"arbitration_deployment" : false,
"support_elb" : false,
"multi_affinity_group_enable" : false,
"local_disks_anti_affinity" : false,
"multi_instance_name_pattern" : null,
"private_ip" : null,
"weight" : null
}, {
"other" : { },
"name" : "HttpFS",
"code_name" : "HFS",
"component" : "HDFS",
"node_preference" : "MASTER",
"count" : "[0-10]",
"affinity" : null,
"affinity_target" : null,
"multi_instance" : null,
"role_kind" : null,
"constraints" : null,
"multi_az_placement" : "AT_LEAST_2",
"arbitration_deployment" : false,
"support_elb" : false,
"multi_affinity_group_enable" : false,
"local_disks_anti_affinity" : false,
"multi_instance_name_pattern" : null,
"private_ip" : null,
"weight" : null
}, {
"other" : { },
"name" : "JournalNode",
"code_name" : "JN",
"component" : "HDFS",
"node_preference" : "MASTER",
"count" : "[3-60],step=2",
"affinity" : null,
"affinity_target" : null,
"multi_instance" : null,
"role_kind" : null,
"constraints" : null,
"multi_az_placement" : "QUORUM_LIKE",
"arbitration_deployment" : true,
"support_elb" : false,
"multi_affinity_group_enable" : false,
"local_disks_anti_affinity" : false,
"multi_instance_name_pattern" : null,
"private_ip" : null,
"weight" : null
}, {
"other" : { },
"name" : "DataNode",
"code_name" : "DN",
"component" : "HDFS",
"node_preference" : "NO_LIMIT",
"count" : "[3-10000]",
"affinity" : null,
"affinity_target" : null,
"multi_instance" : null,
"role_kind" : "stateful",
"constraints" : null,
"multi_az_placement" : "AT_LEAST_2",
"arbitration_deployment" : false,
"support_elb" : false,
"multi_affinity_group_enable" : false,
"local_disks_anti_affinity" : false,
"multi_instance_name_pattern" : null,
"private_ip" : null,
"weight" : null
}, {
"other" : { },
"name" : "ResourceManager",
"code_name" : "RM",
"component" : "Yarn",
"node_preference" : "MASTER",
"count" : "2",
"affinity" : null,
"affinity_target" : null,
"multi_instance" : null,
"role_kind" : null,
"constraints" : null,
"multi_az_placement" : "AT_LEAST_2",
"arbitration_deployment" : false,
"support_elb" : false,
"multi_affinity_group_enable" : false,
"local_disks_anti_affinity" : false,
"multi_instance_name_pattern" : null,
"private_ip" : null,
"weight" : null
}, {
"other" : { },
"name" : "NodeManager",
"code_name" : "NM",
"component" : "Yarn",
"node_preference" : "NO_LIMIT",
"count" : "[3-10000]",
"affinity" : null,
"affinity_target" : null,
"multi_instance" : null,
"role_kind" : "stateless",
"constraints" : null,
"multi_az_placement" : "AT_LEAST_2",
"arbitration_deployment" : false,
"support_elb" : false,
"multi_affinity_group_enable" : false,
"local_disks_anti_affinity" : false,
"multi_instance_name_pattern" : null,
"private_ip" : null,
"weight" : null
} ]
} SDK代码示例
SDK代码示例如下。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | package com.huaweicloud.sdk.test; import com.huaweicloud.sdk.core.auth.ICredential; import com.huaweicloud.sdk.core.auth.BasicCredentials; import com.huaweicloud.sdk.core.exception.ConnectionException; import com.huaweicloud.sdk.core.exception.RequestTimeoutException; import com.huaweicloud.sdk.core.exception.ServiceResponseException; import com.huaweicloud.sdk.mrs.v1.region.MrsRegion; import com.huaweicloud.sdk.mrs.v1.*; import com.huaweicloud.sdk.mrs.v1.model.*; public class ShowMrsVersionMetadataSolution { public static void main(String[] args) { // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment String ak = System.getenv("CLOUD_SDK_AK"); String sk = System.getenv("CLOUD_SDK_SK"); String projectId = "{project_id}"; ICredential auth = new BasicCredentials() .withProjectId(projectId) .withAk(ak) .withSk(sk); MrsClient client = MrsClient.newBuilder() .withCredential(auth) .withRegion(MrsRegion.valueOf("<YOUR REGION>")) .build(); ShowMrsVersionMetadataRequest request = new ShowMrsVersionMetadataRequest(); request.withVersionName("{version_name}"); try { ShowMrsVersionMetadataResponse response = client.showMrsVersionMetadata(request); System.out.println(response.toString()); } catch (ConnectionException e) { e.printStackTrace(); } catch (RequestTimeoutException e) { e.printStackTrace(); } catch (ServiceResponseException e) { e.printStackTrace(); System.out.println(e.getHttpStatusCode()); System.out.println(e.getRequestId()); System.out.println(e.getErrorCode()); System.out.println(e.getErrorMsg()); } } } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | # coding: utf-8 import os from huaweicloudsdkcore.auth.credentials import BasicCredentials from huaweicloudsdkmrs.v1.region.mrs_region import MrsRegion from huaweicloudsdkcore.exceptions import exceptions from huaweicloudsdkmrs.v1 import * if __name__ == "__main__": # The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. # In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment ak = os.environ["CLOUD_SDK_AK"] sk = os.environ["CLOUD_SDK_SK"] projectId = "{project_id}" credentials = BasicCredentials(ak, sk, projectId) client = MrsClient.new_builder() \ .with_credentials(credentials) \ .with_region(MrsRegion.value_of("<YOUR REGION>")) \ .build() try: request = ShowMrsVersionMetadataRequest() request.version_name = "{version_name}" response = client.show_mrs_version_metadata(request) print(response) except exceptions.ClientRequestException as e: print(e.status_code) print(e.request_id) print(e.error_code) print(e.error_msg) |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | package main import ( "fmt" "github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic" mrs "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/mrs/v1" "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/mrs/v1/model" region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/mrs/v1/region" ) func main() { // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment ak := os.Getenv("CLOUD_SDK_AK") sk := os.Getenv("CLOUD_SDK_SK") projectId := "{project_id}" auth := basic.NewCredentialsBuilder(). WithAk(ak). WithSk(sk). WithProjectId(projectId). Build() client := mrs.NewMrsClient( mrs.MrsClientBuilder(). WithRegion(region.ValueOf("<YOUR REGION>")). WithCredential(auth). Build()) request := &model.ShowMrsVersionMetadataRequest{} request.VersionName = "{version_name}" response, err := client.ShowMrsVersionMetadata(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) } } |
更多编程语言的SDK代码示例,请参见API Explorer的代码示例页签,可生成自动对应的SDK代码示例。
状态码
| 状态码 | 描述 |
|---|---|
| 200 | 版本元数据详情。(该样例省略了部分内容,详细返回请调用接口查看) |
错误码
请参见错误码。