创建Mock规则。
调试
您可以在OpenAPI Explorer中直接运行该接口,免去您计算签名的困扰。运行成功后,OpenAPI Explorer可以自动生成SDK代码示例。
调试
授权信息
|
操作 |
访问级别 |
资源类型 |
条件关键字 |
关联操作 |
|
mse:AddMockRule |
*全部资源
|
无 | 无 |
请求参数
|
名称 |
类型 |
必填 |
描述 |
示例值 |
| Name |
string |
是 |
规则名称。 |
agent-auto-test-sc |
| Region |
string |
是 |
地域 ID。 |
cn-hangzhou |
| Source |
string |
是 |
规则来源。 |
edasmsc |
| ProviderAppId |
string |
否 |
服务提供者应用 ID。 |
dcqtkuhnc4@66e5235415**** |
| ProviderAppName |
string |
否 |
服务提供者应用名称。 |
demo-cartservice |
| ExtraJson |
string |
是 |
描述。 |
{} |
| ScMockItems |
string |
是 |
入参数,支持 JSON 格式。 |
[] |
| DubboMockItems |
string |
是 |
回收站中的项目。 |
[] |
| ConsumerAppIds |
string |
是 |
用户自定义应用 ID。 |
[{\"appName\":\"provide\",\"appId\":\"bst8l6o735@f6d8aaf6e56e67d\"}] |
| Enable |
boolean |
否 |
报警规则的启用状态。取值:
|
true |
| MockType |
integer |
否 |
慢调用 RT。取值如下:
|
1 |
| AcceptLanguage |
string |
否 |
返回信息的语言类型:
|
zh |
返回参数
|
名称 |
类型 |
描述 |
示例值 |
|
object |
数据结构。 |
||
| HttpStatusCode |
integer |
HTTP 状态码。 |
200 |
| Message |
string |
返回信息。 |
请求处理成功 |
| RequestId |
string |
请求 ID。 |
316F5F64-F73D-42DC-8632-01E308B6**** |
| Data |
object |
数据概览。 |
|
| NamespaceId |
string |
命名空间 ID。 |
cn-shanghai |
| ScMockItemJson |
string |
HTTP 协议 Mock 规则。 |
[{"oper":"return+json","Path":"/mock","Value":"{\n \"date\": \"2021-09-10T07:45:12.357+0000\",\n \"name\": \"name\",\n \"id\": \"1\"\n}","Method":"GET","Condition":"AND","Timeout":1,"ArgumentMockItems":[{"type":"param","name":"id","value":"1","cond":"==","operator":"rawvalue"},{"type":"param","name":"name","value":"aliyun","cond":"==","operator":"rawvalue"}]}] |
| ConsumerAppName |
string |
需查询的应用名称。 |
demo-xxxx |
| ConsumerAppId |
string |
服务消费者应用 ID。 |
hkhon1po62@a000601b265xxxx |
| AccountId |
string |
账户 ID。 |
178432728867xxxx |
| ExtraJson |
string |
描述。 |
desc |
| Source |
string |
来源 |
edasmsc |
| Region |
string |
地域。 |
cn-shanghai |
| ProviderAppId |
string |
服务提供者应用 ID。 |
hkhon1po62@a000601b265xxxx |
| ProviderAppName |
string |
服务提供者应用名称。 |
demo-xxxx |
| Name |
string |
名称。 |
mse-bc1a29b0-160230875****-reg-center-0-1 |
| Id |
integer |
规则 ID。 |
275 |
| Enable |
boolean |
开启或关闭。
|
true |
| MockType |
integer |
模型类型,取值如下:
|
0 |
| Code |
integer |
返回码。 |
200 |
| Success |
boolean |
请求结果,取值如下:
|
true |
示例
正常返回示例
JSON格式
{
"HttpStatusCode": 200,
"Message": "请求处理成功",
"RequestId": "316F5F64-F73D-42DC-8632-01E308B6****",
"Data": {
"NamespaceId": "cn-shanghai",
"ScMockItemJson": "[{\"oper\":\"return+json\",\"Path\":\"/mock\",\"Value\":\"{\\n \\\"date\\\": \\\"2021-09-10T07:45:12.357+0000\\\",\\n \\\"name\\\": \\\"name\\\",\\n \\\"id\\\": \\\"1\\\"\\n}\",\"Method\":\"GET\",\"Condition\":\"AND\",\"Timeout\":1,\"ArgumentMockItems\":[{\"type\":\"param\",\"name\":\"id\",\"value\":\"1\",\"cond\":\"==\",\"operator\":\"rawvalue\"},{\"type\":\"param\",\"name\":\"name\",\"value\":\"aliyun\",\"cond\":\"==\",\"operator\":\"rawvalue\"}]}]",
"ConsumerAppName": "demo-xxxx",
"ConsumerAppId": "hkhon1po62@a000601b265xxxx",
"AccountId": "178432728867xxxx",
"ExtraJson": "desc",
"Source": "edasmsc",
"Region": "cn-shanghai",
"ProviderAppId": "hkhon1po62@a000601b265xxxx",
"ProviderAppName": "demo-xxxx",
"Name": "mse-bc1a29b0-160230875****-reg-center-0-1",
"Id": 275,
"Enable": true,
"MockType": 0
},
"Code": 200,
"Success": true
}
错误码
|
HTTP status code |
错误码 |
错误信息 |
描述 |
|---|---|---|---|
| 400 | IllegalRequest | Invalid request:%s | 非法请求: %s |
| 400 | InvalidParameter | Parameter error:%s | 请求参数错误:%s |
| 500 | InternalError | Console error. Try again later:%s | 控制台错误.稍后重试:%s |
| 403 | NoPermission | You are not authorized to perform this operation:%s | 没有权限使用此接口:%s |
| 404 | NotFound | Not found:%s | 资源不存在:%s |
访问错误中心查看更多错误码。
变更历史
更多信息,参考变更详情。