新增用户自定义URL关键字
功能介绍
新增用户自定义URL关键字
调用方法
请参见如何调用API。
URI
POST /v1/{project_id}/basic-aw
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
project_id |
是 |
String |
参数解释 项目UUID,项目唯一标识,固定长度32位字符(字母和数字)。获取方式请参见获取项目唯一标识。 约束限制 不涉及 取值范围 32个字符组成的字符串 默认取值 不涉及 |
请求参数
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
X-Auth-Token |
是 |
String |
参数解释: 用户Token。 通过调用IAM服务获取用户Token接口获取(响应消息头中X-Subject-Token的值)。 约束限制: 必传。 取值范围: 字符串长度不少于1,不超过10万。 默认取值: 不涉及。 |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
body_param_type |
否 |
String |
body请求体的类型:text(包含JSON,参数内部区分)、form |
description |
否 |
String |
描述 |
dft_check_point_list |
否 |
Array of CheckPoint objects |
默认检查点集合 |
dft_custom_header |
否 |
Array of AwParam objects |
默认请求头参数对象 |
dft_variable_list |
否 |
Array of AwVariable objects |
定义的变量信息 |
extra_info |
否 |
ExtraInfo object |
补充信息 |
group_name |
否 |
String |
组名 |
name |
否 |
String |
名称 |
param_type_and_dft_value |
否 |
Array of AwParam objects |
参数类型和参数默认值对应集合 |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
comparison |
否 |
String |
参数解释 比较符 |
description |
否 |
String |
参数解释 描述信息 |
function_arg |
否 |
String |
参数解释 类型值 |
function_type |
否 |
String |
参数解释 高级提取类型 |
property |
否 |
String |
参数解释 属性名称 |
value |
否 |
String |
参数解释 目标值 |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
childImportPackage |
否 |
Array of strings |
子级导入的包 |
document_link |
否 |
String |
文档链接 |
http_method |
否 |
String |
http请求方法 |
http_url |
否 |
String |
HTTP请求的URL |
importPackage |
否 |
Array of strings |
导入的包 |
mock |
否 |
MockInfo object |
关键字实例中的mock信息 |
outputParam |
否 |
Array of AwVariable objects |
输出参数 |
param_dependent |
否 |
String |
参数依赖 |
summary |
否 |
String |
摘要 |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
by_order |
否 |
Integer |
参数解释 节点顺序 |
currentPermission |
否 |
String |
参数解释 当前人员权限 |
description |
否 |
String |
参数解释 参数描述 |
dynamicParam |
否 |
String |
参数解释 动态参数名称 |
dynamicParamFlag |
否 |
Boolean |
参数解释 动态参数标志,默认为false. true代表动态参数; false代表非动态参数 |
functionParams |
否 |
String |
参数解释 变量参数([]:空参、[a]:一参,[a,b]:两参) |
function_arg |
否 |
String |
参数解释 提取类型的类型值 |
function_type |
否 |
String |
参数解释 高级提取类型,响应提取时要使用什么方法处理参数 |
isSensitiveInfo |
否 |
Boolean |
参数解释 是否是敏感字段 |
isSensitiveModified |
否 |
Boolean |
参数解释 敏感字段是否被修改,不敏感字段不关注此值 |
is_out_put |
否 |
Boolean |
参数解释 是否是组合关键字的输出参数,只有组合关键字下awInstance的关键字变量有该字段 |
name |
否 |
String |
参数解释 参数名称 |
node_id |
否 |
String |
参数解释 节点id |
node_type |
否 |
Integer |
参数解释 0/null-变量节点; 1-目录节点 |
oldName |
否 |
String |
参数解释 旧名称 |
parent_node_id |
否 |
String |
参数解释 父节点唯一标识 |
property |
否 |
String |
参数解释 属性 |
regex |
否 |
String |
参数解释 内置函数枚举 |
sensitiveInfoSetterTime |
否 |
String |
参数解释 敏感参数设置时间 |
sensitiveInfoSetterUser |
否 |
String |
参数解释 敏感参数设置者名称 |
type |
否 |
String |
参数解释 类型 |
variableType |
否 |
Integer |
参数解释 变量类型(0:text,10-16:分别对应7个内置函数) |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
basic_value |
否 |
AwParamBasicValue object |
参数解释 关键字参数基本类型取值类 |
basic_value_list |
否 |
Array of AwParamBasicValue objects |
参数解释 关键字参数, valueType为1时该值有效 |
custom_body |
否 |
String |
参数解释 自定义requestBody内容,inType为2且isBodyCustom为1时有效 |
defaultValue |
否 |
String |
参数解释 默认值 |
description |
否 |
String |
参数解释 关键字参数描述 |
disabled |
否 |
Boolean |
参数解释 是否禁用,只有非必需参数才能被禁用 |
drop_down_value |
否 |
String |
参数解释 用于存储下拉菜单的值 |
enum_type |
否 |
String |
参数解释 枚举类型 |
enum_type_selected |
否 |
String |
参数解释 当前选中的枚举类型 |
format |
否 |
String |
参数解释 num和String有效 |
in_type |
否 |
Integer |
参数解释 rest接口输入参数类型: 0-query 1-path 2-body 3-header 4-formdata 5-config |
isChecked |
否 |
Boolean |
参数解释 是否是被选中参数 |
is_big_field |
否 |
Boolean |
参数解释 是否是大字段参数 |
is_body_custom |
否 |
Integer |
参数解释 requestBody是否自定义,inType为2时有效。0-非自定义,用原有逻辑;1-自定义body,requestBody直接使用字段customBody |
is_contract_param |
否 |
Integer |
参数解释 是否是契约关键字 0-否;1-yes |
is_sensitive |
否 |
Boolean |
参数解释 是否敏感参数,0 是, 1 不是 |
item |
否 |
ItemParam object |
参数解释 关键字基本参数 |
maxItems |
否 |
Integer |
参数解释 Array类型最大元素数 |
maxLength |
否 |
Long |
参数解释 String类型最大长度 |
maximum |
否 |
Object |
参数解释 Number类型最大值 |
minItems |
否 |
Integer |
参数解释 Array类型最小元素数 |
minLength |
否 |
Long |
参数解释 String类型最小长度 |
minimum |
否 |
Object |
参数解释 Number类型最小值 |
mock |
否 |
MockInfo object |
参数解释 关键字实例中的mock信息 |
name |
否 |
String |
参数解释 参数名 |
object_value |
否 |
Array of AwParam objects |
参数解释 valueType为2时该值有效。valueType为3时,该值用来表示数组中单个结构体 |
object_value_list |
否 |
Array<Array<AwParam>> |
参数解释 valueType为3时该值有效 |
pattern |
否 |
String |
参数解释 num和String有效 |
required |
否 |
Boolean |
参数解释 是否必需参数 |
type |
否 |
String |
参数解释 参数类型 |
validate_rule |
否 |
ValidateRule object |
参数解释 校验规则 |
value_type |
否 |
Integer |
参数解释 参数值类型 |
xChoiceValue |
否 |
String |
参数解释 choice选择关系 |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
value |
否 |
String |
参数解释 参数默认值,用例有效 |
value_range |
否 |
String |
参数解释 参数值范围,逻辑用例有效 |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
basic_value |
否 |
AwParamBasicValue object |
参数解释 关键字参数基本类型取值类 |
defaultValue |
否 |
String |
参数解释 默认值 |
enum_type |
否 |
String |
参数解释 枚举类型 |
enum_type_selected |
否 |
String |
参数解释 当前选中的枚举类型 |
format |
否 |
String |
参数解释 num和String有效 |
is_big_field |
否 |
Boolean |
参数解释 是否是大字段参数 |
maxItems |
否 |
Integer |
参数解释 Array类型最大元素数 |
maxLength |
否 |
Long |
参数解释 String类型最大长度 |
maximum |
否 |
Object |
Number类型最大值 |
minItems |
否 |
Integer |
参数解释 Array类型最小元素数 |
minLength |
否 |
Long |
参数解释 String类型最小长度 |
minimum |
否 |
Object |
参数解释 Number类型最小值 |
pattern |
否 |
String |
参数解释 num和String有效 |
type |
否 |
String |
参数解释 参数类型 |
validate_rule |
否 |
ValidateRule object |
参数解释 校验规则 |
value_type |
否 |
Integer |
参数解释 参数值类型 |
xChoiceValue |
否 |
String |
参数解释 choice选择关系 |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
mock_id |
否 |
String |
参数解释 mock唯一标识 |
mock_switch |
否 |
Boolean |
参数解释 mock开关 |
mock_url |
否 |
String |
参数解释 mock地址 |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
dependent_info |
否 |
Array of ConditionInstance objects |
参数解释 依赖信息列表 |
enabled |
否 |
Boolean |
参数解释 是否启用的标识符 |
is_configDep |
否 |
Boolean |
参数解释 配置依赖的标识符 |
is_dependent |
否 |
Boolean |
参数解释 是否依赖的标识符 |
message |
否 |
String |
参数解释 消息 |
result |
否 |
String |
参数解释 结果 |
special_char |
否 |
String |
参数解释 特殊字符 |
special_char_valid |
否 |
String |
参数解释 特殊字符的有效性 |
x_example |
否 |
String |
参数解释 示例 |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
conditionIndex |
否 |
Integer |
参数解释 条件索引,用于标识当前处理的是哪个条件 |
conditionMap |
否 |
Map<String,Array<String>> |
参数解释 条件映射,键为整数,值为字符串列表,用于存储各个条件的信息 |
depParamMap |
否 |
Map<String,DepParamInstance> |
参数解释 依赖参数实例的映射 |
statementIndex |
否 |
Integer |
参数解释 声明索引,用于标识当前处理的是哪个声明 |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
compareValue |
否 |
String |
参数解释 比较值 |
comparison |
否 |
String |
参数解释 比较符 |
condition |
否 |
Boolean |
参数解释 条件 |
inValidValues |
否 |
Array of strings |
参数解释 无效值列表 |
name |
否 |
String |
参数解释 名称 |
nullInfo |
否 |
String |
参数解释 空值信息 |
relationMap |
否 |
Map<String,String> |
参数解释 关系映射,key为整数,value为字符串 |
relationNum |
否 |
Integer |
参数解释 关系数量 |
values |
否 |
Array of strings |
参数解释 值列表 |
响应参数
状态码:200
参数 |
参数类型 |
描述 |
---|---|---|
code |
String |
参数解释 错误码 |
error |
CommonResponseErrorObject object |
参数解释 统一错误返回 |
reason |
String |
参数解释 失败原因 |
result |
Object |
参数解释 结果 |
status |
String |
参数解释 响应状态 |
状态码:201
Created
状态码:401
参数 |
参数类型 |
描述 |
---|---|---|
error_code |
String |
参数解释 接口调用失败错误码 取值范围 12-18个字符组成的字符串 |
error_msg |
String |
参数解释 接口调用失败错误信息 取值范围 3-1000个字符组成的字符串 |
状态码:403
参数 |
参数类型 |
描述 |
---|---|---|
error_code |
String |
参数解释 接口调用失败错误码 取值范围 12-18个字符组成的字符串 |
error_msg |
String |
参数解释 接口调用失败错误信息 取值范围 3-1000个字符组成的字符串 |
状态码:404
参数 |
参数类型 |
描述 |
---|---|---|
error_code |
String |
参数解释 接口调用失败错误码 取值范围 12-18个字符组成的字符串 |
error_msg |
String |
参数解释 接口调用失败错误信息 取值范围 3-1000个字符组成的字符串 |
请求示例
post https://{endpoint}/v1/09645c1f3f954a8d9ab29174857cffc5/basic-aw
{
"name" : "baidu2",
"group_name" : "dfaba6a51f024c1f95229c1059ca34e0",
"description" : "自定义URL请求",
"extra_info" : {
"http_url" : "http://www.baidu.com",
"http_method" : "get"
},
"param_type_and_dft_value" : [ ],
"dft_check_point_list" : [ ],
"dft_variable_list" : [ ]
}
响应示例
状态码:200
OK
{
"status" : "success",
"result" : {
"id" : "37df588351464f45944580b288556d37",
"warningMsg" : null,
"name" : "baidu1",
"source" : null,
"method" : "getwww_baidu_com",
"description" : "自定义URL请求",
"nameView" : null,
"tmssCaseNumber" : null,
"region" : "{region}",
"yamlName" : null,
"create_time_string" : "2024-06-21 15:46:18 GMT+08:00",
"update_time_string" : "2024-06-21 15:46:18 GMT+08:00",
"create_time_stamp" : 1718955978000,
"update_time_stamp" : 1718955978000,
"create_user" : "devcloud_devcloud_s00314720_01",
"create_time" : "2024-06-21T03:46:18+0800",
"update_user" : "devcloud_devcloud_s00314720_01",
"update_time" : "2024-06-21T03:46:18+0800",
"param_type_and_dft_value" : [ ],
"dft_custom_header" : null,
"dft_check_point_list" : [ ],
"dft_variable_list" : [ ],
"keyword_variable_value" : null,
"dft_retry_times" : null,
"dft_retry_interval" : null,
"return_type" : "[{\"returnCode\":200}]",
"aw_type" : 1,
"aw_ins_list" : null,
"project_id" : "09645c1f3f954a8d9ab29174857cffc5",
"public_aw_lib_id" : null,
"special_type" : 90,
"has_code" : 1,
"aw_code" : "",
"group_name" : "dfaba6a51f024c1f95229c1059ca34e0",
"protocol_type" : "http/https",
"by_order" : 1,
"aw_mark" : 1,
"output_param_list" : null,
"is_favorite" : null,
"tmss_case_id" : null,
"create_user_id" : null,
"aw_description" : null,
"origin_project" : null,
"aw_uniqueid" : null,
"aw_tags" : null,
"aw_operationid" : null,
"interface_label" : null,
"import_package" : null,
"public_aw_lib" : null,
"root_id" : null,
"custom_aw_libs" : null,
"delete_time" : null,
"delete_user" : null,
"extra_info" : {
"http_method" : "get",
"http_url" : "http://www.baidu.com"
}
},
"reason" : null,
"error" : null,
"code" : null
}
SDK代码示例
SDK代码示例如下。
Java
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 49 50 51 52 53 54 55 56 57 |
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.cloudtest.v1.region.CloudtestRegion;
import com.huaweicloud.sdk.cloudtest.v1.*;
import com.huaweicloud.sdk.cloudtest.v1.model.*;
import java.util.List;
import java.util.ArrayList;
public class CreateUserDefinedUrlKeyWordSolution {
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");
ICredential auth = new BasicCredentials()
.withAk(ak)
.withSk(sk);
CloudtestClient client = CloudtestClient.newBuilder()
.withCredential(auth)
.withRegion(CloudtestRegion.valueOf("<YOUR REGION>"))
.build();
CreateUserDefinedUrlKeyWordRequest request = new CreateUserDefinedUrlKeyWordRequest();
request.withProjectId("{project_id}");
CreateBasicAwReq body = new CreateBasicAwReq();
ExtraInfo extraInfobody = new ExtraInfo();
extraInfobody.withHttpMethod("get")
.withHttpUrl("http://www.baidu.com");
body.withName("baidu2");
body.withGroupName("dfaba6a51f024c1f95229c1059ca34e0");
body.withExtraInfo(extraInfobody);
body.withDescription("自定义URL请求");
request.withBody(body);
try {
CreateUserDefinedUrlKeyWordResponse response = client.createUserDefinedUrlKeyWord(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());
}
}
}
|
Python
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 |
# coding: utf-8
import os
from huaweicloudsdkcore.auth.credentials import BasicCredentials
from huaweicloudsdkcloudtest.v1.region.cloudtest_region import CloudtestRegion
from huaweicloudsdkcore.exceptions import exceptions
from huaweicloudsdkcloudtest.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"]
credentials = BasicCredentials(ak, sk)
client = CloudtestClient.new_builder() \
.with_credentials(credentials) \
.with_region(CloudtestRegion.value_of("<YOUR REGION>")) \
.build()
try:
request = CreateUserDefinedUrlKeyWordRequest()
request.project_id = "{project_id}"
extraInfobody = ExtraInfo(
http_method="get",
http_url="http://www.baidu.com"
)
request.body = CreateBasicAwReq(
name="baidu2",
group_name="dfaba6a51f024c1f95229c1059ca34e0",
extra_info=extraInfobody,
description="自定义URL请求"
)
response = client.create_user_defined_url_key_word(request)
print(response)
except exceptions.ClientRequestException as e:
print(e.status_code)
print(e.request_id)
print(e.error_code)
print(e.error_msg)
|
Go
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 49 50 51 |
package main
import (
"fmt"
"github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic"
cloudtest "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/cloudtest/v1"
"github.com/huaweicloud/huaweicloud-sdk-go-v3/services/cloudtest/v1/model"
region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/cloudtest/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")
auth := basic.NewCredentialsBuilder().
WithAk(ak).
WithSk(sk).
Build()
client := cloudtest.NewCloudtestClient(
cloudtest.CloudtestClientBuilder().
WithRegion(region.ValueOf("<YOUR REGION>")).
WithCredential(auth).
Build())
request := &model.CreateUserDefinedUrlKeyWordRequest{}
request.ProjectId = "{project_id}"
httpMethodExtraInfo:= "get"
httpUrlExtraInfo:= "http://www.baidu.com"
extraInfobody := &model.ExtraInfo{
HttpMethod: &httpMethodExtraInfo,
HttpUrl: &httpUrlExtraInfo,
}
nameCreateBasicAwReq:= "baidu2"
groupNameCreateBasicAwReq:= "dfaba6a51f024c1f95229c1059ca34e0"
descriptionCreateBasicAwReq:= "自定义URL请求"
request.Body = &model.CreateBasicAwReq{
Name: &nameCreateBasicAwReq,
GroupName: &groupNameCreateBasicAwReq,
ExtraInfo: extraInfobody,
Description: &descriptionCreateBasicAwReq,
}
response, err := client.CreateUserDefinedUrlKeyWord(request)
if err == nil {
fmt.Printf("%+v\n", response)
} else {
fmt.Println(err)
}
}
|
更多
更多编程语言的SDK代码示例,请参见API Explorer的代码示例页签,可生成自动对应的SDK代码示例。
状态码
状态码 |
描述 |
---|---|
200 |
OK |
201 |
Created |
401 |
Unauthorized |
403 |
Forbidden |
404 |
Not Found |
错误码
请参见错误码。