QueryConsumerAuthorizationRules

Updated at:

Queries consumer authorization rules.

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

The table below describes the authorization required to call this API. You can define it in a Resource Access Management (RAM) policy. The table's columns are detailed below:

  • Action: The actions can be used in the Action element of RAM permission policy statements to grant permissions to perform the operation.

  • API: The API that you can call to perform the action.

  • Access level: The predefined level of access granted for each API. Valid values: create, list, get, update, and delete.

  • Resource type: The type of the resource that supports authorization to perform the action. It indicates if the action supports resource-level permission. The specified resource must be compatible with the action. Otherwise, the policy will be ineffective.

    • For APIs with resource-level permissions, required resource types are marked with an asterisk (*). Specify the corresponding Alibaba Cloud Resource Name (ARN) in the Resource element of the policy.

    • For APIs without resource-level permissions, it is shown as All Resources. Use an asterisk (*) in the Resource element of the policy.

  • Condition key: The condition keys defined by the service. The key allows for granular control, applying to either actions alone or actions associated with specific resources. In addition to service-specific condition keys, Alibaba Cloud provides a set of common condition keys applicable across all RAM-supported services.

  • Dependent action: The dependent actions required to run the action. To complete the action, the RAM user or the RAM role must have the permissions to perform all dependent actions.

Action

Access level

Resource type

Condition key

Dependent action

apig:QueryConsumerAuthorizationRules

none

*All Resource

*

None None

Request syntax

GET /v1/authorization-rules HTTP/1.1

Request parameters

Parameter

Type

Required

Description

Example

apiNameLike

string

No

The API name.

api-xx

pageNumber

integer

No

The page number.

1

pageSize

integer

No

The number of entries per page.

10

consumerId

string

No

The consumer ID.

cs-ct21c16m1hkp64hk6qmg

resourceId

string

No

The resource ID.

ha-cn-li942gy8p03

resourceType

string

No

The resource type.

HttpApiRoute

environmentId

string

No

The environment ID.

env-cpqnr6tlhtgubc***

groupByApi

boolean

No

The API group to filter by.

true

parentResourceId

string

No

The parent resource ID.

ha-cn-li942gy8p01

consumerNameLike

string

No

The consumer name.

consumer-xxx

resourceTypes

string

No

The service source type.

K8S

Response elements

Element

Type

Description

Example

object

Schema of Response

requestId

string

Id of the request

A60EE5CA-1294-532A-9775-8D2FD1C6EFBF

code

string

The response status code.

Ok

message

string

The response message.

success

data

object

The response data.

totalSize

string

The total number of entries.

6

pageNumber

integer

The page number.

1

pageSize

integer

The number of entries per page.

10

items

array<object>

A list of consumer rules.

array<object>

The details of the consumer authentication rules.

consumerAuthorizationRuleId

string

The consumer authorization rule ID.

car-csgeka5lhtggrjcprok0

consumerId

string

The consumer ID.

cs-csheiftlhtgmp0j0hp4g

apiInfo HttpApiApiInfo

The API details.

environmentInfo EnvironmentInfo

The environment context.

gatewayInfo GatewayInfo

The gateway information.

resourceId

string

The resource ID.

2351944

resourceType

string

The resource type.

HttpApiRoute

expireStatus

string

The expiration status.

InEffect

expireMode

string

The expiration mode. Valid values: LongTerm and ShortTerm.

ShortTerm

expireTimestamp

integer

The expiration timestamp.

172086834548

createTimestamp

integer

The timestamp when the rule was created. Unit: milliseconds.

1719386834548

updateTimestamp

integer

The timestamp when the rule was last updated. Unit: milliseconds.

1719386834548

deployStatus

string

The deployment status of the API in the current environment.

{}

consumerInfo ConsumerInfo

The consumer details.

resourceInfo

object

The resource details.

route HttpRoute

The routing rule.

operationInfo HttpApiOperationInfo

The API operation information.

Examples

Success response

JSON format

{
  "requestId": "A60EE5CA-1294-532A-9775-8D2FD1C6EFBF",
  "code": "Ok",
  "message": "success",
  "data": {
    "totalSize": "6",
    "pageNumber": 1,
    "pageSize": 10,
    "items": [
      {
        "consumerAuthorizationRuleId": "car-csgeka5lhtggrjcprok0",
        "consumerId": "cs-csheiftlhtgmp0j0hp4g",
        "apiInfo": {
          "httpApiId": "api-xxx",
          "name": "test",
          "basePath": "/v1",
          "description": "测试专用API",
          "versionInfo": {
            "enable": true,
            "scheme": "Query",
            "headerName": "my-version",
            "queryName": "myVersion",
            "version": "v1"
          },
          "ingressInfo": {
            "sourceId": "src-xxx",
            "ingressClass": "mse",
            "watchNamespace": "default",
            "environmentInfo": {
              "environmentId": "env-xxx"
            },
            "k8sClusterInfo": {
              "clusterId": "ca435c77cba1547cca9311957bcxxxxxx"
            },
            "overrideIngressIp": true
          },
          "type": "Rest",
          "resourceGroupId": "rg-xxx",
          "enableAuth": false,
          "authConfig": {
            "authType": "Jwt",
            "authMode": "NoAuth"
          },
          "gatewayId": "gw-cpv4sqdl****",
          "modelCategory": "Text",
          "protocols": [
            "HTTP"
          ],
          "environments": [
            {
              "environmentId": "env-xxx",
              "backendScene": "SingleService",
              "backendType": "Service",
              "serviceConfigs": [
                {
                  "gatewayServiceId": "gs-xxx",
                  "name": "demo-service",
                  "protocol": "HTTP",
                  "port": "8080",
                  "weight": 100,
                  "version": "v1",
                  "match": {
                    "default": true,
                    "conditions": [
                      {
                        "type": "Query",
                        "key": "color",
                        "value": "gray",
                        "operator": "equal"
                      }
                    ]
                  },
                  "serviceId": "svc-xxx"
                }
              ],
              "customDomains": [
                {
                  "domainId": "d-xxx",
                  "name": "www.example.com",
                  "protocol": "HTTP"
                }
              ],
              "name": "test",
              "alias": "test",
              "gatewayInfo": {
                "gatewayId": "gw-xxx",
                "name": "test",
                "gatewayEdition": "MultiTenantServerless"
              },
              "deployStatus": "Deployed",
              "subDomains": [
                {
                  "domainId": "d-xxx",
                  "name": "www.example.com",
                  "protocol": "HTTP",
                  "networkType": "Internet"
                }
              ]
            }
          ],
          "aiProtocols": [
            "OpenAI/v1"
          ],
          "deployConfigs": [
            {
              "environmentId": "env-xxx",
              "backendScene": "SingleService",
              "autoDeploy": true,
              "gatewayId": "gw-xx",
              "routeBackend": {
                "scene": "Single",
                "services": [
                  {
                    "serviceId": "service-cq2bmmdlhtgj***",
                    "name": "item-service",
                    "protocol": "HTTP",
                    "port": 0,
                    "weight": 49,
                    "version": "v1"
                  }
                ]
              },
              "gatewayInfo": {
                "gatewayId": "gw-cq7og15lhtgi6qasrj60",
                "name": "apitest-gw",
                "vpcInfo": {
                  "vpcId": "vpc-uf664nyle5kh***",
                  "name": "商品中心预发环境专有网络"
                },
                "engineVersion": "2.0.7",
                "gatewayEdition": "MultiTenantServerless"
              },
              "mock": {
                "enable": false,
                "responseCode": 200,
                "responseContent": "Mock测试"
              },
              "gatewayType": "API",
              "customDomainIds": [
                "d-xxx"
              ],
              "envDomainIds": [
                "d-xxx"
              ],
              "serviceConfigs": [
                {
                  "serviceId": "svc-xxx",
                  "weight": 100,
                  "modelNamePattern": "qwen-*",
                  "modelName": "qwen-max",
                  "intentCode": "INQUIRY",
                  "match": {
                    "default": true,
                    "conditions": [
                      {
                        "type": "Query",
                        "key": "color",
                        "value": "gray",
                        "operator": "equal"
                      }
                    ]
                  },
                  "port": 80,
                  "protocol": "HTTP",
                  "gatewayServiceId": "gw-svc-abc123",
                  "name": "Qwen-Max-Service",
                  "version": "V2",
                  "multiServiceRouteStrategy": "ByWeight",
                  "observabilityRouteConfig": {
                    "mode": "LeastBusy",
                    "rateLimit": 0.8,
                    "queueSize": 100
                  }
                }
              ],
              "policyConfigs": [
                {
                  "type": "AiFallback",
                  "enable": true,
                  "aiFallbackConfig": {
                    "serviceConfigs": [
                      {
                        "serviceId": "svc-******",
                        "targetModelName": "gpt-4/llama3-70b"
                      }
                    ]
                  },
                  "aiSecurityGuardConfig": {
                    "serviceAddress": "https://api.example.com/v1",
                    "checkRequest": true,
                    "checkResponse": true,
                    "checkRequestImage": true,
                    "checkResponseImage": true,
                    "requestCheckService": "https://checker.example.com/validate-request",
                    "responseCheckService": "https://checker.example.com/validate-response",
                    "requestImageCheckService": "https://image-checker.example.com/scan",
                    "responseImageCheckService": "https://image-checker.example.com/scan-response",
                    "riskAlertLevel": "low/medium/high",
                    "riskConfig": [
                      {
                        "type": "K8S",
                        "level": "Critical",
                        "consumerRules": {
                          "pattern": "first",
                          "matchType": "term"
                        }
                      }
                    ],
                    "bufferLimit": 50,
                    "consumerRequestCheckService": [
                      {
                        "name": "API",
                        "requestCheckService": "https://checker.example.com/validate",
                        "requestImageCheckService": "https://image-check.example.com/scan",
                        "matchType": "exact/prefix",
                        "modalityType": "text/image"
                      }
                    ],
                    "consumerResponseCheckService": [
                      {
                        "name": "AI_API",
                        "responseCheckService": "https://checker.example.com/validate-response",
                        "responseImageCheckService": "https://image-check.example.com/scan-response",
                        "matchType": "term",
                        "modalityType": "text/image"
                      }
                    ],
                    "consumerRiskLevel": [
                      {
                        "name": "APIG-UI",
                        "matchType": "term",
                        "type": "K8S",
                        "level": "Critical"
                      }
                    ]
                  },
                  "aiTokenRateLimitConfig": {
                    "rules": [
                      {
                        "limitType": "request/token",
                        "matchKey": "user_id/api_path",
                        "matchType": "term",
                        "matchValue": "user123",
                        "limitMode": "local",
                        "limitValue": 100
                      }
                    ],
                    "globalRules": [
                      {
                        "limitType": "request",
                        "matchKey": "user_id",
                        "matchType": "term",
                        "matchValue": "user123",
                        "limitMode": "local",
                        "limitValue": 100
                      }
                    ],
                    "enableGlobalRules": true
                  },
                  "aiStatisticsConfig": {
                    "logRequestContent": false,
                    "logResponseContent": false
                  }
                }
              ],
              "customDomainInfos": [
                {
                  "domainId": "d-cshee6dlhtgk******",
                  "name": "hello-server.com",
                  "protocol": "HTTP"
                }
              ],
              "envDomainInfos": [
                {
                  "domainId": "",
                  "name": "",
                  "protocol": ""
                }
              ],
              "subDomains": [
                {
                  "domainId": "d-csmn42um******",
                  "name": "test",
                  "protocol": "HTTP",
                  "networkType": "Intranet"
                }
              ],
              "builtinRouteNames": [
                ""
              ]
            }
          ],
          "deployCntMap": {
            "key": {
              "deployedCnt": 3,
              "cnt": 0
            }
          },
          "agentProtocols": [
            "DashScope"
          ]
        },
        "environmentInfo": {
          "environmentId": "env-cq7l5s5lhtgi6qasrdc0",
          "name": "test",
          "alias": "测试环境",
          "description": "这是xxx的xx项目测试环境",
          "gatewayInfo": {
            "gatewayId": "gw-cq7og15lhtgi6qasrj60",
            "name": "apitest-gw",
            "vpcInfo": {
              "vpcId": "vpc-uf664nyle5kh***",
              "name": "商品中心预发环境专有网络"
            },
            "engineVersion": "2.0.7",
            "gatewayEdition": "MultiTenantServerless"
          },
          "subDomainInfos": [
            {
              "domainId": "d-cpudb0llhtgl2djvq2sg",
              "name": "abc.com",
              "protocol": "HTTP",
              "networkType": "Intranet"
            }
          ],
          "default": false,
          "createTimestamp": 1721116090326,
          "updateTimestamp": 1721116090326,
          "resourceGroupId": "rg-xxxx"
        },
        "gatewayInfo": {
          "gatewayId": "gw-cq7og15lhtgi6qasrj60",
          "name": "apitest-gw",
          "vpcInfo": {
            "vpcId": "vpc-uf664nyle5kh***",
            "name": "商品中心预发环境专有网络"
          },
          "engineVersion": "2.0.7",
          "gatewayEdition": "MultiTenantServerless"
        },
        "resourceId": "2351944",
        "resourceType": "HttpApiRoute",
        "expireStatus": "InEffect",
        "expireMode": "ShortTerm",
        "expireTimestamp": 172086834548,
        "createTimestamp": 1719386834548,
        "updateTimestamp": 1719386834548,
        "deployStatus": "{}",
        "consumerInfo": {
          "consumerId": "cs-ctd4l1um1hkph7ki1k80",
          "name": "test",
          "enable": false
        },
        "resourceInfo": {
          "route": {
            "routeId": "hr-crf5l7tlhtgp91t***",
            "name": "itemcenter-pre-route",
            "deployStatus": "Deployed",
            "description": "商品中心预发路由",
            "match": {
              "ignoreUriCase": true,
              "path": {
                "type": "Prefix",
                "value": "/user"
              },
              "headers": [
                {
                  "type": "Exact",
                  "name": "dev",
                  "value": "true"
                }
              ],
              "methods": [
                "GET"
              ],
              "queryParams": [
                {
                  "type": "Exact",
                  "name": "age",
                  "value": "17"
                }
              ]
            },
            "backend": {
              "scene": "Single",
              "services": [
                {
                  "serviceId": "service-cq2bmmdlhtgj***",
                  "name": "item-service",
                  "protocol": "HTTP",
                  "port": 0,
                  "weight": 49,
                  "version": "v1"
                }
              ]
            },
            "environmentInfo": {
              "environmentId": "env-crhq1u5lhtgju***",
              "name": "itemcenter-pre",
              "alias": "商品中心预发环境",
              "gatewayInfo": {
                "gatewayId": "gw-cqoohqtlh***",
                "name": "itemcenter-gateway",
                "gatewayEdition": "MultiTenantServerless"
              },
              "subDomains": [
                {
                  "domainId": "d-cqu19hdlhtgjuv4***",
                  "name": "env-crmic3llht***-cn-hangzhou-vpc.alicloudapi.com",
                  "protocol": "HTTP",
                  "networkType": "Internet"
                }
              ]
            },
            "createTimestamp": 1726649310593,
            "updateTimestamp": 1726819895636,
            "mcpServerInfo": {
              "importInstanceId": "import-001",
              "importNamespace": "default",
              "importMcpServerId": "mcp-002",
              "createFromType": "Nacos",
              "mcpServerConfig": "{\\\"config\\\":{}}",
              "mcpRouteConfig": {
                "protocol": "SSE",
                "exposedUriPath": "/mcp"
              }
            },
            "domainInfos": [
              {
                "domainId": "d-cr3v7dllhtgi9s***",
                "name": "itemcenter.dev",
                "protocol": "HTTP"
              }
            ],
            "gatewayStatus": {
              "key": "Running"
            },
            "builtin": "true"
          },
          "operationInfo": {
            "operationId": "op-xxx",
            "method": "GET",
            "name": "GetUserInfo",
            "path": "/user/123",
            "description": "获取用户信息",
            "response": {
              "contentType": "application/json",
              "items": [
                {
                  "code": 200,
                  "example": "{\"result\": \"ok\"}",
                  "description": "正常接口响应",
                  "jsonSchema": "{\n    \"type\": \"object\",\n    \"required\": [\n        \"result\"\n    ],\n    \"properties\": {\n        \"result\": {\n            \"type\": \"string\",\n            \"description\": \"操作结果,'ok' 表示成功\"\n        }\n    }\n}"
                }
              ]
            },
            "request": {
              "headerParameters": [
                {
                  "name": "userId",
                  "required": true,
                  "type": "String",
                  "defaultValue": "123",
                  "exampleValue": "123",
                  "description": "用户ID"
                }
              ],
              "queryParameters": [
                {
                  "name": "userId",
                  "required": true,
                  "type": "String",
                  "defaultValue": "123",
                  "exampleValue": "123",
                  "description": "用户ID"
                }
              ],
              "pathParameters": [
                {
                  "name": "userId",
                  "required": true,
                  "type": "String",
                  "defaultValue": "123",
                  "exampleValue": "123",
                  "description": "用户ID"
                }
              ],
              "body": {
                "description": "body参数描述",
                "example": "{\"result\":\"ok\"}",
                "contentType": "application/json",
                "jsonSchema": "{\n    \"type\": \"object\",\n    \"required\": [\n        \"result\"\n    ],\n    \"properties\": {\n        \"result\": {\n            \"type\": \"string\",\n            \"description\": \"操作结果,'ok' 表示成功\"\n        }\n    }\n}\n"
              }
            },
            "mock": {
              "enable": false,
              "responseCode": 200,
              "responseContent": "Mock测试"
            },
            "createTimestamp": 1719386834548,
            "enableAuth": true,
            "authConfig": {
              "authType": "Jwt",
              "authMode": "NoAuth"
            },
            "status": "Deployed",
            "deployConfigs": [
              {
                "environmentId": "env-xxx",
                "backendScene": "SingleService",
                "autoDeploy": true,
                "gatewayId": "gw-xx",
                "routeBackend": {
                  "scene": "Single",
                  "services": [
                    {
                      "serviceId": "service-cq2bmmdlhtgj***",
                      "name": "item-service",
                      "protocol": "HTTP",
                      "port": 0,
                      "weight": 49,
                      "version": "v1"
                    }
                  ]
                },
                "mock": {
                  "enable": false,
                  "responseCode": 200,
                  "responseContent": "Mock测试"
                },
                "gatewayType": "API",
                "customDomainIds": [
                  "d-xxx"
                ],
                "envDomainIds": [
                  "d-xxx"
                ],
                "serviceConfigs": [
                  {
                    "serviceId": "svc-xxx",
                    "weight": 100,
                    "modelNamePattern": "qwen-*",
                    "modelName": "qwen-max",
                    "intentCode": "INQUIRY",
                    "match": {
                      "default": true,
                      "conditions": [
                        {
                          "type": "Query",
                          "key": "color",
                          "value": "gray",
                          "operator": "equal"
                        }
                      ]
                    },
                    "port": 80,
                    "protocol": "HTTP",
                    "gatewayServiceId": "gw-svc-abc123",
                    "name": "Qwen-Max-Service",
                    "version": "V2",
                    "multiServiceRouteStrategy": "ByWeight",
                    "observabilityRouteConfig": {
                      "mode": "LeastBusy",
                      "rateLimit": 0.8,
                      "queueSize": 100
                    }
                  }
                ],
                "policyConfigs": [
                  {
                    "type": "AiFallback",
                    "enable": true,
                    "aiFallbackConfig": {
                      "serviceConfigs": [
                        {
                          "serviceId": "svc-******",
                          "targetModelName": "gpt-4/llama3-70b"
                        }
                      ]
                    },
                    "aiSecurityGuardConfig": {
                      "serviceAddress": "https://api.example.com/v1",
                      "checkRequest": true,
                      "checkResponse": true,
                      "checkRequestImage": true,
                      "checkResponseImage": true,
                      "requestCheckService": "https://checker.example.com/validate-request",
                      "responseCheckService": "https://checker.example.com/validate-response",
                      "requestImageCheckService": "https://image-checker.example.com/scan",
                      "responseImageCheckService": "https://image-checker.example.com/scan-response",
                      "riskAlertLevel": "low/medium/high",
                      "riskConfig": [
                        {
                          "type": "K8S",
                          "level": "Critical",
                          "consumerRules": {
                            "pattern": "first",
                            "matchType": "term"
                          }
                        }
                      ],
                      "bufferLimit": 50,
                      "consumerRequestCheckService": [
                        {
                          "name": "API",
                          "requestCheckService": "https://checker.example.com/validate",
                          "requestImageCheckService": "https://image-check.example.com/scan",
                          "matchType": "exact/prefix",
                          "modalityType": "text/image"
                        }
                      ],
                      "consumerResponseCheckService": [
                        {
                          "name": "AI_API",
                          "responseCheckService": "https://checker.example.com/validate-response",
                          "responseImageCheckService": "https://image-check.example.com/scan-response",
                          "matchType": "term",
                          "modalityType": "text/image"
                        }
                      ],
                      "consumerRiskLevel": [
                        {
                          "name": "APIG-UI",
                          "matchType": "term",
                          "type": "K8S",
                          "level": "Critical"
                        }
                      ]
                    },
                    "aiTokenRateLimitConfig": {
                      "rules": [
                        {
                          "limitType": "request/token",
                          "matchKey": "user_id/api_path",
                          "matchType": "term",
                          "matchValue": "user123",
                          "limitMode": "local",
                          "limitValue": 100
                        }
                      ],
                      "globalRules": [
                        {
                          "limitType": "request",
                          "matchKey": "user_id",
                          "matchType": "term",
                          "matchValue": "user123",
                          "limitMode": "local",
                          "limitValue": 100
                        }
                      ],
                      "enableGlobalRules": true
                    },
                    "aiStatisticsConfig": {
                      "logRequestContent": false,
                      "logResponseContent": false
                    }
                  }
                ],
                "customDomainInfos": [
                  {
                    "domainId": "d-cshee6dlhtgk******",
                    "name": "hello-server.com",
                    "protocol": "HTTP"
                  }
                ],
                "envDomainInfos": [
                  {
                    "domainId": "",
                    "name": "",
                    "protocol": ""
                  }
                ],
                "subDomains": [
                  {
                    "domainId": "d-csmn42um******",
                    "name": "test",
                    "protocol": "HTTP",
                    "networkType": "Intranet"
                  }
                ],
                "builtinRouteNames": [
                  ""
                ]
              }
            ]
          }
        }
      }
    ]
  }
}

Error codes

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.