调用AddMockRule接口创建Mock规则。
调试
您可以在OpenAPI Explorer中直接运行该接口,免去您计算签名的困扰。运行成功后,OpenAPI Explorer可以自动生成SDK代码示例。
授权信息
下表是API对应的授权信息,可以在RAM权限策略语句的Action
元素中使用,用来给RAM用户或RAM角色授予调用此API的权限。具体说明如下:
- 操作:是指具体的权限点。
- 访问级别:是指每个操作的访问级别,取值为写入(Write)、读取(Read)或列出(List)。
- 资源类型:是指操作中支持授权的资源类型。具体说明如下:
- 对于必选的资源类型,用背景高亮的方式表示。
- 对于不支持资源级授权的操作,用
全部资源
表示。
- 条件关键字:是指云产品自身定义的条件关键字。
- 关联操作:是指成功执行操作所需要的其他权限。操作者必须同时具备关联操作的权限,操作才能成功。
操作 | 访问级别 | 资源类型 | 条件关键字 | 关联操作 |
---|---|---|---|---|
mse:AddMockRule | Read |
|
|
无 |
请求参数
名称 | 类型 | 必填 | 描述 | 示例值 |
---|---|---|---|---|
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 | long | 否 |
慢调用RT。取值如下:
|
1 |
AcceptLanguage | string | 否 |
返回信息的语言类型:
|
zh |
返回参数
示例
正常返回示例
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 code | 错误码 | 错误信息 | 描述 |
---|---|---|---|
400 | duplicatedClusterAliasName | duplicated cluster alias name | 实例名称已重复,请换一个 |
400 | illegalRequest | illegal request:%s | 非法请求:%s |
400 | invalidParameter | parameter error:%s | 请求入参异常:%s |
403 | NoPermission | You are not authorized to perform this operation. | 没有权限使用此接口 |
404 | clusterNotFound | cluster not found | 找不到此集群 |
500 | systemError | system error | 系统开小差了,请稍后重试 |
500 | regcenterError | register center error:%s | 注册配置中心请求错误:%s |
访问错误中心查看更多错误码。