使用OpenAPI管理AI 网关MCP服务

AI 网关支持通过OpenAPI管理MCP服务。本文介绍使用OpenAPI所需的准备工作(包括SDK准备和配置服务接入点等),以及管理AI 网关MCP服务的相关API,来帮助您使用OpenAPI管理AI 网关MCP服务。

前提条件

在进行本实践之前,建议您参考以下链接,以了解AI 网关的OpenAPI基本能力、相关概念及所需的准备工作:

  • SDK准备:下载并配置适合您开发环境的SDK。

  • OpenAPI查询、在线调试:您查询和调试OpenAPI接口。

  • 服务接入点:查看服务接入点,正确配置和管理服务入口。

  • API授权(RAM):查看API授权(RAM),通过阿里云访问控制服务为不同用户或应用分配API访问权限,实现安全、细粒度的资源管理与操作授权 。

  • 使用CLI:使用阿里云CLI调用API。

ListHttpApis

获取HTTP API列表。

配置RAM授权

操作

访问级别

资源类型

条件关键字

关联操作

apig:ListHttpApis

list

*HttpApi

acs:apig:{#regionId}:{#accountId}:httpapi/*

请求语法

GET /v1/http-apis HTTP/1.1

请求体

SDK示例

// This file is auto-generated, don't edit it. Thanks.
package com.aliyun.sample;

import com.aliyun.tea.*;

public class Sample {

    /**
     * <b>description</b> :
     * <p>使用凭据初始化账号Client</p>
     * @return Client
     * 
     * @throws Exception
     */
    public static com.aliyun.apig20240327.Client createClient() throws Exception {
        // 工程代码建议使用更安全的无AK方式,凭据配置方式请参见:https://help.aliyun.com/document_detail/378657.html。
        com.aliyun.credentials.Client credential = new com.aliyun.credentials.Client();
        com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config()
                .setCredential(credential);
        // Endpoint 请参考 https://api.aliyun.com/product/APIG
        config.endpoint = "apig.cn-hangzhou.aliyuncs.com";
        return new com.aliyun.apig20240327.Client(config);
    }

    public static void main(String[] args_) throws Exception {
        
        com.aliyun.apig20240327.Client client = Sample.createClient();
        com.aliyun.apig20240327.models.ListHttpApisRequest listHttpApisRequest = new com.aliyun.apig20240327.models.ListHttpApisRequest();
        com.aliyun.teautil.models.RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions();
        java.util.Map<String, String> headers = new java.util.HashMap<>();
        try {
            // 复制代码运行请自行打印 API 的返回值
            client.listHttpApisWithOptions(listHttpApisRequest, headers, runtime);
        } catch (TeaException error) {
            // 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。
            // 错误 message
            System.out.println(error.getMessage());
            // 诊断地址
            System.out.println(error.getData().get("Recommend"));
            com.aliyun.teautil.Common.assertAsString(error.message);
        } catch (Exception _error) {
            TeaException error = new TeaException(_error.getMessage(), _error);
            // 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。
            // 错误 message
            System.out.println(error.getMessage());
            // 诊断地址
            System.out.println(error.getData().get("Recommend"));
            com.aliyun.teautil.Common.assertAsString(error.message);
        }        
    }
}
'use strict';
// This file is auto-generated, don't edit it
// 依赖的模块可通过下载工程中的模块依赖文件或右上角的获取 SDK 依赖信息查看
const APIG20240327 = require('@alicloud/apig20240327');
const OpenApi = require('@alicloud/openapi-client');
const Util = require('@alicloud/tea-util');
const Credential = require('@alicloud/credentials');
const Tea = require('@alicloud/tea-typescript');

class Client {

  /**
   * 使用凭据初始化账号Client
   * @return Client
   * @throws Exception
   */
  static createClient() {
    // 工程代码建议使用更安全的无AK方式,凭据配置方式请参见:https://help.aliyun.com/document_detail/378664.html。
    let credential = new Credential.default();
    let config = new OpenApi.Config({
      credential: credential,
    });
    // Endpoint 请参考 https://api.aliyun.com/product/APIG
    config.endpoint = `apig.cn-hangzhou.aliyuncs.com`;
    return new APIG20240327.default(config);
  }

  static async main(args) {
    let client = Client.createClient();
    let listHttpApisRequest = new APIG20240327.ListHttpApisRequest({ });
    let runtime = new Util.RuntimeOptions({ });
    let headers = { };
    try {
      // 复制代码运行请自行打印 API 的返回值
      await client.listHttpApisWithOptions(listHttpApisRequest, headers, runtime);
    } catch (error) {
      // 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。
      // 错误 message
      console.log(error.message);
      // 诊断地址
      console.log(error.data["Recommend"]);
      Util.default.assertAsString(error.message);
    }    
  }

}

exports.Client = Client;
Client.main(process.argv.slice(2));
// This file is auto-generated, don't edit it. Thanks.
package main

import (
  "encoding/json"
  "strings"
  "fmt"
  "os"
  apig20240327  "github.com/alibabacloud-go/apig-20240327/v4/client"
  openapi  "github.com/alibabacloud-go/darabonba-openapi/v2/client"
  util  "github.com/alibabacloud-go/tea-utils/v2/service"
  credential  "github.com/aliyun/credentials-go/credentials"
  "github.com/alibabacloud-go/tea/tea"
)


// Description:
// 
// 使用凭据初始化账号Client
// 
// @return Client
// 
// @throws Exception
func CreateClient () (_result *apig20240327.Client, _err error) {
  // 工程代码建议使用更安全的无AK方式,凭据配置方式请参见:https://help.aliyun.com/document_detail/378661.html。
  credential, _err := credential.NewCredential(nil)
  if _err != nil {
    return _result, _err
  }

  config := &openapi.Config{
    Credential: credential,
  }
  // Endpoint 请参考 https://api.aliyun.com/product/APIG
  config.Endpoint = tea.String("apig.cn-hangzhou.aliyuncs.com")
  _result = &apig20240327.Client{}
  _result, _err = apig20240327.NewClient(config)
  return _result, _err
}

func _main (args []*string) (_err error) {
  client, _err := CreateClient()
  if _err != nil {
    return _err
  }

  listHttpApisRequest := &apig20240327.ListHttpApisRequest{}
  runtime := &util.RuntimeOptions{}
  headers := make(map[string]*string)
  tryErr := func()(_e error) {
    defer func() {
      if r := tea.Recover(recover()); r != nil {
        _e = r
      }
    }()
    // 复制代码运行请自行打印 API 的返回值
    _, _err = client.ListHttpApisWithOptions(listHttpApisRequest, headers, runtime)
    if _err != nil {
      return _err
    }

    return nil
  }()

  if tryErr != nil {
    var error = &tea.SDKError{}
    if _t, ok := tryErr.(*tea.SDKError); ok {
      error = _t
    } else {
      error.Message = tea.String(tryErr.Error())
    }
    // 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。
    // 错误 message
    fmt.Println(tea.StringValue(error.Message))
    // 诊断地址
    var data interface{}
    d := json.NewDecoder(strings.NewReader(tea.StringValue(error.Data)))
    d.Decode(&data)
    if m, ok := data.(map[string]interface{}); ok {
      recommend, _ := m["Recommend"]
      fmt.Println(recommend)
    }
    _, _err = util.AssertAsString(error.Message)
    if _err != nil {
      return _err
    }
  }
  return _err
}


func main() {
  err := _main(tea.StringSlice(os.Args[1:]))
  if err != nil {
    panic(err)
  }
}
// This file is auto-generated, don't edit it
// 依赖的模块可通过下载工程中的模块依赖文件或右上角的获取 SDK 依赖信息查看
import APIG20240327, * as $APIG20240327 from '@alicloud/apig20240327';
import OpenApi, * as $OpenApi from '@alicloud/openapi-client';
import Util, * as $Util from '@alicloud/tea-util';
import Credential from '@alicloud/credentials';
import * as $tea from '@alicloud/tea-typescript';


export default class Client {

  /**
   * @remarks
   * 使用凭据初始化账号Client
   * @returns Client
   * 
   * @throws Exception
   */
  static createClient(): APIG20240327 {
    // 工程代码建议使用更安全的无AK方式,凭据配置方式请参见:https://help.aliyun.com/document_detail/378664.html。
    let credential = new Credential();
    let config = new $OpenApi.Config({
      credential: credential,
    });
    // Endpoint 请参考 https://api.aliyun.com/product/APIG
    config.endpoint = `apig.cn-hangzhou.aliyuncs.com`;
    return new APIG20240327(config);
  }

  static async main(args: string[]): Promise<void> {
    let client = Client.createClient();
    let listHttpApisRequest = new $APIG20240327.ListHttpApisRequest({ });
    let runtime = new $Util.RuntimeOptions({ });
    let headers : {[key: string ]: string} = { };
    try {
      // 复制代码运行请自行打印 API 的返回值
      await client.listHttpApisWithOptions(listHttpApisRequest, headers, runtime);
    } catch (error) {
      // 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。
      // 错误 message
      console.log(error.message);
      // 诊断地址
      console.log(error.data["Recommend"]);
      
    }    
  }

}

Client.main(process.argv.slice(2));
<?php

// This file is auto-generated, don't edit it. Thanks.
namespace AlibabaCloud\SDK\Sample;

use AlibabaCloud\SDK\APIG\V20240327\APIG;
use AlibabaCloud\Credentials\Credential;
use \Exception;
use AlibabaCloud\Tea\Exception\TeaError;
use AlibabaCloud\Tea\Utils\Utils;

use Darabonba\OpenApi\Models\Config;
use AlibabaCloud\SDK\APIG\V20240327\Models\ListHttpApisRequest;
use AlibabaCloud\Tea\Utils\Utils\RuntimeOptions;

class Sample {

    /**
     * 使用凭据初始化账号Client
     * @return APIG Client
     */
    public static function createClient(){
        // 工程代码建议使用更安全的无AK方式,凭据配置方式请参见:https://help.aliyun.com/document_detail/311677.html。
        $credential = new Credential();
        $config = new Config([
            "credential" => $credential
        ]);
        // Endpoint 请参考 https://api.aliyun.com/product/APIG
        $config->endpoint = "apig.cn-hangzhou.aliyuncs.com";
        return new APIG($config);
    }

    /**
     * @param string[] $args
     * @return void
     */
    public static function main($args){
        $client = self::createClient();
        $listHttpApisRequest = new ListHttpApisRequest([]);
        $runtime = new RuntimeOptions([]);
        $headers = [];
        try {
            // 复制代码运行请自行打印 API 的返回值
            $client->listHttpApisWithOptions($listHttpApisRequest, $headers, $runtime);
        }
        catch (Exception $error) {
            if (!($error instanceof TeaError)) {
                $error = new TeaError([], $error->getMessage(), $error->getCode(), $error);
            }
            // 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。
            // 错误 message
            var_dump($error->message);
            // 诊断地址
            var_dump($error->data["Recommend"]);
            Utils::assertAsString($error->message);
        }
    }
}
$path = __DIR__ . \DIRECTORY_SEPARATOR . '..' . \DIRECTORY_SEPARATOR . 'vendor' . \DIRECTORY_SEPARATOR . 'autoload.php';
if (file_exists($path)) {
    require_once $path;
}
Sample::main(array_slice($argv, 1));
# -*- coding: utf-8 -*-
# This file is auto-generated, don't edit it. Thanks.
import os
import sys

from typing import List

from alibabacloud_apig20240327.client import Client as APIG20240327Client
from alibabacloud_credentials.client import Client as CredentialClient
from alibabacloud_tea_openapi import models as open_api_models
from alibabacloud_apig20240327 import models as apig20240327_models
from alibabacloud_tea_util import models as util_models
from alibabacloud_tea_util.client import Client as UtilClient


class Sample:
    def __init__(self):
        pass

    @staticmethod
    def create_client() -> APIG20240327Client:
        """
        使用凭据初始化账号Client
        @return: Client
        @throws Exception
        """
        # 工程代码建议使用更安全的无AK方式,凭据配置方式请参见:https://help.aliyun.com/document_detail/378659.html。
        credential = CredentialClient()
        config = open_api_models.Config(
            credential=credential
        )
        # Endpoint 请参考 https://api.aliyun.com/product/APIG
        config.endpoint = f'apig.cn-hangzhou.aliyuncs.com'
        return APIG20240327Client(config)

    @staticmethod
    def main(
        args: List[str],
    ) -> None:
        client = Sample.create_client()
        list_http_apis_request = apig20240327_models.ListHttpApisRequest()
        runtime = util_models.RuntimeOptions()
        headers = {}
        try:
            # 复制代码运行请自行打印 API 的返回值
            client.list_http_apis_with_options(list_http_apis_request, headers, runtime)
        except Exception as error:
            # 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。
            # 错误 message
            print(error.message)
            # 诊断地址
            print(error.data.get("Recommend"))
            UtilClient.assert_as_string(error.message)

    @staticmethod
    async def main_async(
        args: List[str],
    ) -> None:
        client = Sample.create_client()
        list_http_apis_request = apig20240327_models.ListHttpApisRequest()
        runtime = util_models.RuntimeOptions()
        headers = {}
        try:
            # 复制代码运行请自行打印 API 的返回值
            await client.list_http_apis_with_options_async(list_http_apis_request, headers, runtime)
        except Exception as error:
            # 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。
            # 错误 message
            print(error.message)
            # 诊断地址
            print(error.data.get("Recommend"))
            UtilClient.assert_as_string(error.message)


if __name__ == '__main__':
    Sample.main(sys.argv[1:])

CLI示例

aliyun apig GET /v1/http-apis --region cn-hangzhou --header "Content-Type=application/json;"

keywordstring(可选)

搜索关键词,支持 API 名称模糊搜索或 API ID 精确搜索。

pageNumberinteger(可选),默认值为1

分页页码,从1开始。

pageSizeinteger(可选),默认值为10

分页大小,有效范围[1, 100]

namestring(可选)

按照名称精确搜索。

typesstring(可选)

HTTP API 的类型。支持传入多个类型,采用,分割。取值:

  • Http。

  • Rest。

  • WebSocket。

  • HttpIngress。

gatewayIdstring(可选)

云原生 API 网关 ID。

withAuthPolicyInEnvironmentIdstring(可选)

响应中每个 API 信息携带指定环境 ID 下的消费者认证策略信息。

withConsumerInfoByIdstring(可选)

响应中每个 API 信息携带指定消费者 ID 的授权规则列表。

withEnvironmentInfoboolean(可选)

返回结果的 API 列表是否需要包含环境信息。取值:

  • true:返回包含环境信息。

  • false:返回不包含环境信息。

withPluginAttachmentByPluginIdstring(可选)

插件 ID,根据此插件 ID 获取插件发布信息。

resourceGroupIdstring(可选)

资源组 ID。

withEnvironmentInfoByIdstring(可选)

环境 ID。

withAuthPolicyListboolean(可选)

是否启用权限认证策略。取值:

  • true:开启权限认证策略。

  • false:关闭。

withIngressInfoboolean(可选)

返回结果是否需要包含 ingress 信息。取值:

  • true:返回包含 ingress 信息。

  • false:返回不包含 ingress 信息。

withPolicyConfigsboolean(可选)

返回结果是否需要包含策略信息。取值:

  • true:返回包含策略信息。

  • false:返回不包含策略信息。

gatewayTypestring(可选)

网关类型过滤,目前支持 AIAPI 两种网关类型。

响应

{
  "requestId": "585657D2-1C20-5B8A-AF17-xxxxxxxxx4",
  "code": "Ok",
  "message": "success",
  "data": {
    "pageNumber": 1,
    "pageSize": 10,
    "totalSize": 10,
    "items": [
      {
        "name": "test-api",
        "versionEnabled": true,
        "versionedHttpApis": [
          {
            "httpApiId": "api-xxx",
            "name": "test",
            "protocols": [
              "HTTP"
            ],
            "basePath": "/v1",
            "description": "测试专用API",
            "versionInfo": {
              "enable": true,
              "scheme": "Query",
              "headerName": "my-version",
              "queryName": "myVersion",
              "version": "v1"
            },
            "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"
                  }
                ]
              }
            ]
		  }
		]
	  }
    ]
  }
}

requestIdstring

请求 ID。

codestring

响应状态码。

messagestring

响应消息。

dataobject

API 列表。

属性

pageNumberinteger

分页页码。

pageSizeinteger

分页大小。

totalSizeinteger

总数量。

itemsarray

API 信息。

属性

apiInfoHttpApiInfoByName

按照 API 名进行分组的 API 信息。

常见错误码

您可以访问错误中心查看更多错误码。

ListPlugins

获取插件列表。创建AI网关后,系统会自动安装mcp-server插件。

配置RAM授权

操作

访问级别

资源类型

条件关键字

关联操作

apig:ListPlugins

none

*全部资源

*

请求语法

GET /v1/plugins HTTP/1.1

请求体

SDK示例

// This file is auto-generated, don't edit it. Thanks.

using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;

using Tea;
using Tea.Utils;


namespace AlibabaCloud.SDK.Sample
{
    public class Sample 
    {

        /// <term><b>Description:</b></term>
        /// <description>
        /// <para>使用凭据初始化账号Client</para>
        /// </description>
        /// 
        /// <returns>
        /// Client
        /// </returns>
        /// 
        /// <term><b>Exception:</b></term>
        /// Exception
        public static AlibabaCloud.SDK.APIG20240327.Client CreateClient()
        {
            // 工程代码建议使用更安全的无AK方式,凭据配置方式请参见:https://help.aliyun.com/document_detail/378671.html。
            Aliyun.Credentials.Client credential = new Aliyun.Credentials.Client();
            AlibabaCloud.OpenApiClient.Models.Config config = new AlibabaCloud.OpenApiClient.Models.Config
            {
                Credential = credential,
            };
            // Endpoint 请参考 https://api.aliyun.com/product/APIG
            config.Endpoint = "apig.cn-hangzhou.aliyuncs.com";
            return new AlibabaCloud.SDK.APIG20240327.Client(config);
        }

        public static void Main(string[] args)
        {
            AlibabaCloud.SDK.APIG20240327.Client client = CreateClient();
            AlibabaCloud.SDK.APIG20240327.Models.ListPluginsRequest listPluginsRequest = new AlibabaCloud.SDK.APIG20240327.Models.ListPluginsRequest();
            AlibabaCloud.TeaUtil.Models.RuntimeOptions runtime = new AlibabaCloud.TeaUtil.Models.RuntimeOptions();
            Dictionary<string, string> headers = new Dictionary<string, string>(){};
            try
            {
                // 复制代码运行请自行打印 API 的返回值
                client.ListPluginsWithOptions(listPluginsRequest, headers, runtime);
            }
            catch (TeaException error)
            {
                // 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。
                // 错误 message
                Console.WriteLine(error.Message);
                // 诊断地址
                Console.WriteLine(error.Data["Recommend"]);
                AlibabaCloud.TeaUtil.Common.AssertAsString(error.Message);
            }
            catch (Exception _error)
            {
                TeaException error = new TeaException(new Dictionary<string, object>
                {
                    { "message", _error.Message }
                });
                // 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。
                // 错误 message
                Console.WriteLine(error.Message);
                // 诊断地址
                Console.WriteLine(error.Data["Recommend"]);
                AlibabaCloud.TeaUtil.Common.AssertAsString(error.Message);
            }
        }


    }
}
'use strict';
// This file is auto-generated, don't edit it
// 依赖的模块可通过下载工程中的模块依赖文件或右上角的获取 SDK 依赖信息查看
const APIG20240327 = require('@alicloud/apig20240327');
const OpenApi = require('@alicloud/openapi-client');
const Util = require('@alicloud/tea-util');
const Credential = require('@alicloud/credentials');
const Tea = require('@alicloud/tea-typescript');

class Client {

  /**
   * 使用凭据初始化账号Client
   * @return Client
   * @throws Exception
   */
  static createClient() {
    // 工程代码建议使用更安全的无AK方式,凭据配置方式请参见:https://help.aliyun.com/document_detail/378664.html。
    let credential = new Credential.default();
    let config = new OpenApi.Config({
      credential: credential,
    });
    // Endpoint 请参考 https://api.aliyun.com/product/APIG
    config.endpoint = `apig.cn-hangzhou.aliyuncs.com`;
    return new APIG20240327.default(config);
  }

  static async main(args) {
    let client = Client.createClient();
    let listPluginsRequest = new APIG20240327.ListPluginsRequest({ });
    let runtime = new Util.RuntimeOptions({ });
    let headers = { };
    try {
      // 复制代码运行请自行打印 API 的返回值
      await client.listPluginsWithOptions(listPluginsRequest, headers, runtime);
    } catch (error) {
      // 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。
      // 错误 message
      console.log(error.message);
      // 诊断地址
      console.log(error.data["Recommend"]);
      Util.default.assertAsString(error.message);
    }    
  }

}

exports.Client = Client;
Client.main(process.argv.slice(2));
// This file is auto-generated, don't edit it. Thanks.
package main

import (
  "encoding/json"
  "strings"
  "fmt"
  "os"
  apig20240327  "github.com/alibabacloud-go/apig-20240327/v4/client"
  openapi  "github.com/alibabacloud-go/darabonba-openapi/v2/client"
  util  "github.com/alibabacloud-go/tea-utils/v2/service"
  credential  "github.com/aliyun/credentials-go/credentials"
  "github.com/alibabacloud-go/tea/tea"
)


// Description:
// 
// 使用凭据初始化账号Client
// 
// @return Client
// 
// @throws Exception
func CreateClient () (_result *apig20240327.Client, _err error) {
  // 工程代码建议使用更安全的无AK方式,凭据配置方式请参见:https://help.aliyun.com/document_detail/378661.html。
  credential, _err := credential.NewCredential(nil)
  if _err != nil {
    return _result, _err
  }

  config := &openapi.Config{
    Credential: credential,
  }
  // Endpoint 请参考 https://api.aliyun.com/product/APIG
  config.Endpoint = tea.String("apig.cn-hangzhou.aliyuncs.com")
  _result = &apig20240327.Client{}
  _result, _err = apig20240327.NewClient(config)
  return _result, _err
}

func _main (args []*string) (_err error) {
  client, _err := CreateClient()
  if _err != nil {
    return _err
  }

  listPluginsRequest := &apig20240327.ListPluginsRequest{}
  runtime := &util.RuntimeOptions{}
  headers := make(map[string]*string)
  tryErr := func()(_e error) {
    defer func() {
      if r := tea.Recover(recover()); r != nil {
        _e = r
      }
    }()
    // 复制代码运行请自行打印 API 的返回值
    _, _err = client.ListPluginsWithOptions(listPluginsRequest, headers, runtime)
    if _err != nil {
      return _err
    }

    return nil
  }()

  if tryErr != nil {
    var error = &tea.SDKError{}
    if _t, ok := tryErr.(*tea.SDKError); ok {
      error = _t
    } else {
      error.Message = tea.String(tryErr.Error())
    }
    // 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。
    // 错误 message
    fmt.Println(tea.StringValue(error.Message))
    // 诊断地址
    var data interface{}
    d := json.NewDecoder(strings.NewReader(tea.StringValue(error.Data)))
    d.Decode(&data)
    if m, ok := data.(map[string]interface{}); ok {
      recommend, _ := m["Recommend"]
      fmt.Println(recommend)
    }
    _, _err = util.AssertAsString(error.Message)
    if _err != nil {
      return _err
    }
  }
  return _err
}


func main() {
  err := _main(tea.StringSlice(os.Args[1:]))
  if err != nil {
    panic(err)
  }
}
<?php

// This file is auto-generated, don't edit it. Thanks.
namespace AlibabaCloud\SDK\Sample;

use AlibabaCloud\SDK\APIG\V20240327\APIG;
use AlibabaCloud\Credentials\Credential;
use \Exception;
use AlibabaCloud\Tea\Exception\TeaError;
use AlibabaCloud\Tea\Utils\Utils;

use Darabonba\OpenApi\Models\Config;
use AlibabaCloud\SDK\APIG\V20240327\Models\ListPluginsRequest;
use AlibabaCloud\Tea\Utils\Utils\RuntimeOptions;

class Sample {

    /**
     * 使用凭据初始化账号Client
     * @return APIG Client
     */
    public static function createClient(){
        // 工程代码建议使用更安全的无AK方式,凭据配置方式请参见:https://help.aliyun.com/document_detail/311677.html。
        $credential = new Credential();
        $config = new Config([
            "credential" => $credential
        ]);
        // Endpoint 请参考 https://api.aliyun.com/product/APIG
        $config->endpoint = "apig.cn-hangzhou.aliyuncs.com";
        return new APIG($config);
    }

    /**
     * @param string[] $args
     * @return void
     */
    public static function main($args){
        $client = self::createClient();
        $listPluginsRequest = new ListPluginsRequest([]);
        $runtime = new RuntimeOptions([]);
        $headers = [];
        try {
            // 复制代码运行请自行打印 API 的返回值
            $client->listPluginsWithOptions($listPluginsRequest, $headers, $runtime);
        }
        catch (Exception $error) {
            if (!($error instanceof TeaError)) {
                $error = new TeaError([], $error->getMessage(), $error->getCode(), $error);
            }
            // 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。
            // 错误 message
            var_dump($error->message);
            // 诊断地址
            var_dump($error->data["Recommend"]);
            Utils::assertAsString($error->message);
        }
    }
}
$path = __DIR__ . \DIRECTORY_SEPARATOR . '..' . \DIRECTORY_SEPARATOR . 'vendor' . \DIRECTORY_SEPARATOR . 'autoload.php';
if (file_exists($path)) {
    require_once $path;
}
Sample::main(array_slice($argv, 1));
# -*- coding: utf-8 -*-
# This file is auto-generated, don't edit it. Thanks.
import os
import sys

from typing import List

from alibabacloud_apig20240327.client import Client as APIG20240327Client
from alibabacloud_credentials.client import Client as CredentialClient
from alibabacloud_tea_openapi import models as open_api_models
from alibabacloud_apig20240327 import models as apig20240327_models
from alibabacloud_tea_util import models as util_models
from alibabacloud_tea_util.client import Client as UtilClient


class Sample:
    def __init__(self):
        pass

    @staticmethod
    def create_client() -> APIG20240327Client:
        """
        使用凭据初始化账号Client
        @return: Client
        @throws Exception
        """
        # 工程代码建议使用更安全的无AK方式,凭据配置方式请参见:https://help.aliyun.com/document_detail/378659.html。
        credential = CredentialClient()
        config = open_api_models.Config(
            credential=credential
        )
        # Endpoint 请参考 https://api.aliyun.com/product/APIG
        config.endpoint = f'apig.cn-hangzhou.aliyuncs.com'
        return APIG20240327Client(config)

    @staticmethod
    def main(
        args: List[str],
    ) -> None:
        client = Sample.create_client()
        list_plugins_request = apig20240327_models.ListPluginsRequest()
        runtime = util_models.RuntimeOptions()
        headers = {}
        try:
            # 复制代码运行请自行打印 API 的返回值
            client.list_plugins_with_options(list_plugins_request, headers, runtime)
        except Exception as error:
            # 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。
            # 错误 message
            print(error.message)
            # 诊断地址
            print(error.data.get("Recommend"))
            UtilClient.assert_as_string(error.message)

    @staticmethod
    async def main_async(
        args: List[str],
    ) -> None:
        client = Sample.create_client()
        list_plugins_request = apig20240327_models.ListPluginsRequest()
        runtime = util_models.RuntimeOptions()
        headers = {}
        try:
            # 复制代码运行请自行打印 API 的返回值
            await client.list_plugins_with_options_async(list_plugins_request, headers, runtime)
        except Exception as error:
            # 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。
            # 错误 message
            print(error.message)
            # 诊断地址
            print(error.data.get("Recommend"))
            UtilClient.assert_as_string(error.message)


if __name__ == '__main__':
    Sample.main(sys.argv[1:])

CLI示例

aliyun apig GET /v1/plugins --region cn-hangzhou --header "Content-Type=application/json;"

gatewayIdstring(可选)

网关实例 ID 过滤参数。

pluginClassIdstring(可选)

插件类型 ID 过滤参数。

pageNumberinteger(可选)

分页页码。

pageSizeinteger(可选)

分页大小。

pluginClassNamestring(可选)

插件类型名称过滤参数。

withAttachmentInfoboolean(可选)

返回结果是否需要包含attachResourceId对应的插件挂载信息。

  • true:包含attachResourceId对应插件的挂载信息。

  • false:不包含。

attachResourceIdstring(可选)

挂载资源 ID。

attachResourceTypestring(可选)

策略支持挂载点类型。取值:

  • HttpApi:HttpApi。

  • Operation:HttpApi 的 Operation。

  • GatewayRoute:网关路由。

  • GatewayService:网关服务。

  • GatewayServicePort:网关服务端口。

  • Domain:网关域名。

  • Gateway:网关。

gatewayTypestring(可选)

网关类型过滤,目前支持 AIAPI 两种网关类型。

includeBuiltinAiGatewayboolean(可选),默认值为false

返回结果是否需要包含系统内置安装的 AI 插件。取值:

  • true:包含系统内置安装的 AI 插件。

  • false:不包含。

响应

{
  "requestId": "168BA42D-F822-569D-A67F-FC59E6ABC2B1",
  "code": "Ok",
  "message": "success",
  "data": {
    "pageNumber": 1,
    "pageSize": 10,
    "totalSize": 10,
    "items": [
      {
        "pluginId": "pl-cvu6r4um1hko3b3ti0a0",
        "gatewayInfo": {
          "gatewayId": "gw-cq7og15lhtxx6qasrj60",
          "name": "apitest-gw"
        },
        "pluginClassInfo": {
          "version": "2.0.3",
          "versionDescription": "版本描述",
          "executeStage": "AUTHZ",
          "executePriority": 999,
          "name": "key-rate-limit",
          "alias": "基于 Key 限流",
          "source": "HigressOfficial",
          "pluginClassId": "pls-cqebrgh46ppatmpri"
        },
        "attachmentInfo": {
          "pluginAttachmentId": "pa-ct2irn6m1hkreaen0t40",
          "enable": false
        }
      }
    ]
  }
}

requestIdstring

请求 ID。

codestring

响应状态码。

messagestring

响应消息。

dataobject

API 列表。

属性

pageNumberinteger

分页页码。

pageSizeinteger

分页大小。

totalSizeinteger

总数量。

itemsarray<object>

插件列表信息。

属性

itemsobject

插件信息。

属性

pluginIdstring

插件 ID。

gatewayInfoobject

网关信息。

属性

gatewayIdstring

网关 ID。

namestring

网关名称。

pluginClassInfoobject

插件类型信息。

属性

versionstring

版本。

versionDescriptionstring

版本描述。

executeStagestring

执行阶段。

executePrioritystring

执行优先级。

namestring

插件名称。

aliasstring

别名。

sourcestring

插件来源。

pluginClassIdstring

插件类型 ID。

attachmentInfoobject

插件挂载信息。

属性

pluginAttachmentIdstring

插件挂载 ID。

enablestring

是否启用。

常见错误码

您可以访问错误中心查看所有错误码。

ListHttpApiRoutes

查询HTTP API的路由列表。查询MCP API下面的路由信息,每一条路由对应一个MCP Server。

配置RAM授权

操作

访问级别

资源类型

条件关键字

关联操作

apig:ListHttpApiRoutes

list

*HttpApi

acs:apig:{#regionId}:{#accountId}:httpapi/{#HttpApiId}

请求语法

GET /v1/http-apis/{httpApiId}/routes HTTP/1.1

请求体

SDK示例

// This file is auto-generated, don't edit it. Thanks.

using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;

using Tea;
using Tea.Utils;


namespace AlibabaCloud.SDK.Sample
{
    public class Sample 
    {

        /// <term><b>Description:</b></term>
        /// <description>
        /// <para>使用凭据初始化账号Client</para>
        /// </description>
        /// 
        /// <returns>
        /// Client
        /// </returns>
        /// 
        /// <term><b>Exception:</b></term>
        /// Exception
        public static AlibabaCloud.SDK.APIG20240327.Client CreateClient()
        {
            // 工程代码建议使用更安全的无AK方式,凭据配置方式请参见:https://help.aliyun.com/document_detail/378671.html。
            Aliyun.Credentials.Client credential = new Aliyun.Credentials.Client();
            AlibabaCloud.OpenApiClient.Models.Config config = new AlibabaCloud.OpenApiClient.Models.Config
            {
                Credential = credential,
            };
            // Endpoint 请参考 https://api.aliyun.com/product/APIG
            config.Endpoint = "apig.cn-hangzhou.aliyuncs.com";
            return new AlibabaCloud.SDK.APIG20240327.Client(config);
        }

        public static void Main(string[] args)
        {
            AlibabaCloud.SDK.APIG20240327.Client client = CreateClient();
            AlibabaCloud.SDK.APIG20240327.Models.ListPluginsRequest listPluginsRequest = new AlibabaCloud.SDK.APIG20240327.Models.ListPluginsRequest();
            AlibabaCloud.TeaUtil.Models.RuntimeOptions runtime = new AlibabaCloud.TeaUtil.Models.RuntimeOptions();
            Dictionary<string, string> headers = new Dictionary<string, string>(){};
            try
            {
                // 复制代码运行请自行打印 API 的返回值
                client.ListPluginsWithOptions(listPluginsRequest, headers, runtime);
            }
            catch (TeaException error)
            {
                // 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。
                // 错误 message
                Console.WriteLine(error.Message);
                // 诊断地址
                Console.WriteLine(error.Data["Recommend"]);
                AlibabaCloud.TeaUtil.Common.AssertAsString(error.Message);
            }
            catch (Exception _error)
            {
                TeaException error = new TeaException(new Dictionary<string, object>
                {
                    { "message", _error.Message }
                });
                // 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。
                // 错误 message
                Console.WriteLine(error.Message);
                // 诊断地址
                Console.WriteLine(error.Data["Recommend"]);
                AlibabaCloud.TeaUtil.Common.AssertAsString(error.Message);
            }
        }


    }
}
'use strict';
// This file is auto-generated, don't edit it
// 依赖的模块可通过下载工程中的模块依赖文件或右上角的获取 SDK 依赖信息查看
const APIG20240327 = require('@alicloud/apig20240327');
const OpenApi = require('@alicloud/openapi-client');
const Util = require('@alicloud/tea-util');
const Credential = require('@alicloud/credentials');
const Tea = require('@alicloud/tea-typescript');

class Client {

  /**
   * 使用凭据初始化账号Client
   * @return Client
   * @throws Exception
   */
  static createClient() {
    // 工程代码建议使用更安全的无AK方式,凭据配置方式请参见:https://help.aliyun.com/document_detail/378664.html。
    let credential = new Credential.default();
    let config = new OpenApi.Config({
      credential: credential,
    });
    // Endpoint 请参考 https://api.aliyun.com/product/APIG
    config.endpoint = `apig.cn-hangzhou.aliyuncs.com`;
    return new APIG20240327.default(config);
  }

  static async main(args) {
    let client = Client.createClient();
    let listPluginsRequest = new APIG20240327.ListPluginsRequest({ });
    let runtime = new Util.RuntimeOptions({ });
    let headers = { };
    try {
      // 复制代码运行请自行打印 API 的返回值
      await client.listPluginsWithOptions(listPluginsRequest, headers, runtime);
    } catch (error) {
      // 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。
      // 错误 message
      console.log(error.message);
      // 诊断地址
      console.log(error.data["Recommend"]);
      Util.default.assertAsString(error.message);
    }    
  }

}

exports.Client = Client;
Client.main(process.argv.slice(2));
// This file is auto-generated, don't edit it. Thanks.
package main

import (
  "encoding/json"
  "strings"
  "fmt"
  "os"
  apig20240327  "github.com/alibabacloud-go/apig-20240327/v4/client"
  openapi  "github.com/alibabacloud-go/darabonba-openapi/v2/client"
  util  "github.com/alibabacloud-go/tea-utils/v2/service"
  credential  "github.com/aliyun/credentials-go/credentials"
  "github.com/alibabacloud-go/tea/tea"
)


// Description:
// 
// 使用凭据初始化账号Client
// 
// @return Client
// 
// @throws Exception
func CreateClient () (_result *apig20240327.Client, _err error) {
  // 工程代码建议使用更安全的无AK方式,凭据配置方式请参见:https://help.aliyun.com/document_detail/378661.html。
  credential, _err := credential.NewCredential(nil)
  if _err != nil {
    return _result, _err
  }

  config := &openapi.Config{
    Credential: credential,
  }
  // Endpoint 请参考 https://api.aliyun.com/product/APIG
  config.Endpoint = tea.String("apig.cn-hangzhou.aliyuncs.com")
  _result = &apig20240327.Client{}
  _result, _err = apig20240327.NewClient(config)
  return _result, _err
}

func _main (args []*string) (_err error) {
  client, _err := CreateClient()
  if _err != nil {
    return _err
  }

  listPluginsRequest := &apig20240327.ListPluginsRequest{}
  runtime := &util.RuntimeOptions{}
  headers := make(map[string]*string)
  tryErr := func()(_e error) {
    defer func() {
      if r := tea.Recover(recover()); r != nil {
        _e = r
      }
    }()
    // 复制代码运行请自行打印 API 的返回值
    _, _err = client.ListPluginsWithOptions(listPluginsRequest, headers, runtime)
    if _err != nil {
      return _err
    }

    return nil
  }()

  if tryErr != nil {
    var error = &tea.SDKError{}
    if _t, ok := tryErr.(*tea.SDKError); ok {
      error = _t
    } else {
      error.Message = tea.String(tryErr.Error())
    }
    // 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。
    // 错误 message
    fmt.Println(tea.StringValue(error.Message))
    // 诊断地址
    var data interface{}
    d := json.NewDecoder(strings.NewReader(tea.StringValue(error.Data)))
    d.Decode(&data)
    if m, ok := data.(map[string]interface{}); ok {
      recommend, _ := m["Recommend"]
      fmt.Println(recommend)
    }
    _, _err = util.AssertAsString(error.Message)
    if _err != nil {
      return _err
    }
  }
  return _err
}


func main() {
  err := _main(tea.StringSlice(os.Args[1:]))
  if err != nil {
    panic(err)
  }
}
<?php

// This file is auto-generated, don't edit it. Thanks.
namespace AlibabaCloud\SDK\Sample;

use AlibabaCloud\SDK\APIG\V20240327\APIG;
use AlibabaCloud\Credentials\Credential;
use \Exception;
use AlibabaCloud\Tea\Exception\TeaError;
use AlibabaCloud\Tea\Utils\Utils;

use Darabonba\OpenApi\Models\Config;
use AlibabaCloud\SDK\APIG\V20240327\Models\ListPluginsRequest;
use AlibabaCloud\Tea\Utils\Utils\RuntimeOptions;

class Sample {

    /**
     * 使用凭据初始化账号Client
     * @return APIG Client
     */
    public static function createClient(){
        // 工程代码建议使用更安全的无AK方式,凭据配置方式请参见:https://help.aliyun.com/document_detail/311677.html。
        $credential = new Credential();
        $config = new Config([
            "credential" => $credential
        ]);
        // Endpoint 请参考 https://api.aliyun.com/product/APIG
        $config->endpoint = "apig.cn-hangzhou.aliyuncs.com";
        return new APIG($config);
    }

    /**
     * @param string[] $args
     * @return void
     */
    public static function main($args){
        $client = self::createClient();
        $listPluginsRequest = new ListPluginsRequest([]);
        $runtime = new RuntimeOptions([]);
        $headers = [];
        try {
            // 复制代码运行请自行打印 API 的返回值
            $client->listPluginsWithOptions($listPluginsRequest, $headers, $runtime);
        }
        catch (Exception $error) {
            if (!($error instanceof TeaError)) {
                $error = new TeaError([], $error->getMessage(), $error->getCode(), $error);
            }
            // 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。
            // 错误 message
            var_dump($error->message);
            // 诊断地址
            var_dump($error->data["Recommend"]);
            Utils::assertAsString($error->message);
        }
    }
}
$path = __DIR__ . \DIRECTORY_SEPARATOR . '..' . \DIRECTORY_SEPARATOR . 'vendor' . \DIRECTORY_SEPARATOR . 'autoload.php';
if (file_exists($path)) {
    require_once $path;
}
Sample::main(array_slice($argv, 1));
# -*- coding: utf-8 -*-
# This file is auto-generated, don't edit it. Thanks.
import os
import sys

from typing import List

from alibabacloud_apig20240327.client import Client as APIG20240327Client
from alibabacloud_credentials.client import Client as CredentialClient
from alibabacloud_tea_openapi import models as open_api_models
from alibabacloud_apig20240327 import models as apig20240327_models
from alibabacloud_tea_util import models as util_models
from alibabacloud_tea_util.client import Client as UtilClient


class Sample:
    def __init__(self):
        pass

    @staticmethod
    def create_client() -> APIG20240327Client:
        """
        使用凭据初始化账号Client
        @return: Client
        @throws Exception
        """
        # 工程代码建议使用更安全的无AK方式,凭据配置方式请参见:https://help.aliyun.com/document_detail/378659.html。
        credential = CredentialClient()
        config = open_api_models.Config(
            credential=credential
        )
        # Endpoint 请参考 https://api.aliyun.com/product/APIG
        config.endpoint = f'apig.cn-hangzhou.aliyuncs.com'
        return APIG20240327Client(config)

    @staticmethod
    def main(
        args: List[str],
    ) -> None:
        client = Sample.create_client()
        list_plugins_request = apig20240327_models.ListPluginsRequest()
        runtime = util_models.RuntimeOptions()
        headers = {}
        try:
            # 复制代码运行请自行打印 API 的返回值
            client.list_plugins_with_options(list_plugins_request, headers, runtime)
        except Exception as error:
            # 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。
            # 错误 message
            print(error.message)
            # 诊断地址
            print(error.data.get("Recommend"))
            UtilClient.assert_as_string(error.message)

    @staticmethod
    async def main_async(
        args: List[str],
    ) -> None:
        client = Sample.create_client()
        list_plugins_request = apig20240327_models.ListPluginsRequest()
        runtime = util_models.RuntimeOptions()
        headers = {}
        try:
            # 复制代码运行请自行打印 API 的返回值
            await client.list_plugins_with_options_async(list_plugins_request, headers, runtime)
        except Exception as error:
            # 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。
            # 错误 message
            print(error.message)
            # 诊断地址
            print(error.data.get("Recommend"))
            UtilClient.assert_as_string(error.message)


if __name__ == '__main__':
    Sample.main(sys.argv[1:])

CLI示例

aliyun apig GET /v1/plugins --region cn-hangzhou --header "Content-Type=application/json;"

httpApiIdstring(可选)

HTTP API ID。

pageNumberinteger(可选),默认值为1

分页页码,从1开始。

pageSizeinteger(可选),默认值为10

分页大小,有效范围[1, 100]

environmentIdstring(可选)

环境 ID。

deployStatusesstringstring(可选)

路由的部署状态。

枚举值

  • Deploying:发布中。

  • DeployedWithChanges:已发布但有修改。

  • Undeploying:下线中。

  • NotDeployed:未发布。

  • Deployed:已发布。

  • UndeployFailed:下线失败。

  • DeployFailed:发布失败。

namestring(可选)

路由名称。

nameLikestring(可选)

按路由名称模糊查询。

pathLikestring(可选)

按路由路径模糊查询。

gatewayIdstring(可选)

云原生 API 网关 ID。

withConsumerInfoByIdstring(可选)

响应中每个路由信息携带指定消费者 ID 的授权规则列表。

consumerAuthorizationRuleIdstring(可选)

根据特定的消费者授权规则 ID 过滤接口列表,响应中的接口列表仅包含已授权的接口。

withAuthPolicyInfoboolean(可选)

返回结果每个路由信息是否携带指定的插件 ID 的挂载信息。取值:

  • true:每个路由信息携带指定的插件 ID 的挂载信息。

  • false:不携带。

withPluginAttachmentByPluginIdstring(可选)

响应中每个路由信息携带指定的插件 ID 的挂载信息。

domainIdstring(可选)

根据域名 ID 过滤路由信息。

响应

{
  "requestId": "168BA42D-F822-569D-A67F-Fxxxxxxxxx1",
  "code": "Ok",
  "message": "success",
  "data": {
    "pageNumber": 1,
    "pageSize": 10,
    "totalSize": 10,
    "items": [
      {
        "pluginId": "pl-cvu6r4um1hko3b3ti0a0",
        "gatewayInfo": {
          "gatewayId": "gw-cq7og15lhtxx6qasrj60",
          "name": "apitest-gw"
        },
        "pluginClassInfo": {
          "version": "2.0.3",
          "versionDescription": "版本描述",
          "executeStage": "AUTHZ",
          "executePriority": 999,
          "name": "key-rate-limit",
          "alias": "基于 Key 限流",
          "source": "HigressOfficial",
          "pluginClassId": "pls-cqebrgh46ppatmpri"
        },
        "attachmentInfo": {
          "pluginAttachmentId": "pa-ct2irn6m1hkreaen0t40",
          "enable": false
        }
      }
    ]
  }
}

requestIdstring

请求 ID。

codestring

响应状态码。

messagestring

响应消息。

dataobject

响应数据。

属性

pageNumberinteger

分页页码。

pageSizeinteger

分页大小。

totalSizeinteger

总数量。

itemsarray

路由列表。

属性

HttpRouteHttpRoute

路由信息。

常见错误码

您可以访问错误中心查看所有错误码。

ListPluginAttachments

获取插件挂载列表。

配置RAM授权

操作

访问级别

资源类型

条件关键字

关联操作

apig:ListPluginAttachments

none

*全部资源

*

请求语法

GET /v1/plugin-attachments HTTP/1.1

请求体

SDK示例

// This file is auto-generated, don't edit it. Thanks.
package com.aliyun.sample;

import com.aliyun.tea.*;

public class Sample {

    /**
     * <b>description</b> :
     * <p>使用凭据初始化账号Client</p>
     * @return Client
     * 
     * @throws Exception
     */
    public static com.aliyun.apig20240327.Client createClient() throws Exception {
        // 工程代码建议使用更安全的无AK方式,凭据配置方式请参见:https://help.aliyun.com/document_detail/378657.html。
        com.aliyun.credentials.Client credential = new com.aliyun.credentials.Client();
        com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config()
                .setCredential(credential);
        // Endpoint 请参考 https://api.aliyun.com/product/APIG
        config.endpoint = "apig.cn-hangzhou.aliyuncs.com";
        return new com.aliyun.apig20240327.Client(config);
    }

    public static void main(String[] args_) throws Exception {
        
        com.aliyun.apig20240327.Client client = Sample.createClient();
        com.aliyun.apig20240327.models.ListPluginAttachmentsRequest listPluginAttachmentsRequest = new com.aliyun.apig20240327.models.ListPluginAttachmentsRequest();
        com.aliyun.teautil.models.RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions();
        java.util.Map<String, String> headers = new java.util.HashMap<>();
        try {
            // 复制代码运行请自行打印 API 的返回值
            client.listPluginAttachmentsWithOptions(listPluginAttachmentsRequest, headers, runtime);
        } catch (TeaException error) {
            // 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。
            // 错误 message
            System.out.println(error.getMessage());
            // 诊断地址
            System.out.println(error.getData().get("Recommend"));
            com.aliyun.teautil.Common.assertAsString(error.message);
        } catch (Exception _error) {
            TeaException error = new TeaException(_error.getMessage(), _error);
            // 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。
            // 错误 message
            System.out.println(error.getMessage());
            // 诊断地址
            System.out.println(error.getData().get("Recommend"));
            com.aliyun.teautil.Common.assertAsString(error.message);
        }        
    }
}
'use strict';
// This file is auto-generated, don't edit it
// 依赖的模块可通过下载工程中的模块依赖文件或右上角的获取 SDK 依赖信息查看
const APIG20240327 = require('@alicloud/apig20240327');
const OpenApi = require('@alicloud/openapi-client');
const Util = require('@alicloud/tea-util');
const Credential = require('@alicloud/credentials');
const Tea = require('@alicloud/tea-typescript');

class Client {

  /**
   * 使用凭据初始化账号Client
   * @return Client
   * @throws Exception
   */
  static createClient() {
    // 工程代码建议使用更安全的无AK方式,凭据配置方式请参见:https://help.aliyun.com/document_detail/378664.html。
    let credential = new Credential.default();
    let config = new OpenApi.Config({
      credential: credential,
    });
    // Endpoint 请参考 https://api.aliyun.com/product/APIG
    config.endpoint = `apig.cn-hangzhou.aliyuncs.com`;
    return new APIG20240327.default(config);
  }

  static async main(args) {
    let client = Client.createClient();
    let listPluginAttachmentsRequest = new APIG20240327.ListPluginAttachmentsRequest({ });
    let runtime = new Util.RuntimeOptions({ });
    let headers = { };
    try {
      // 复制代码运行请自行打印 API 的返回值
      await client.listPluginAttachmentsWithOptions(listPluginAttachmentsRequest, headers, runtime);
    } catch (error) {
      // 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。
      // 错误 message
      console.log(error.message);
      // 诊断地址
      console.log(error.data["Recommend"]);
      Util.default.assertAsString(error.message);
    }    
  }

}

exports.Client = Client;
Client.main(process.argv.slice(2));
// This file is auto-generated, don't edit it. Thanks.
package main

import (
  "encoding/json"
  "strings"
  "fmt"
  "os"
  apig20240327  "github.com/alibabacloud-go/apig-20240327/v4/client"
  openapi  "github.com/alibabacloud-go/darabonba-openapi/v2/client"
  util  "github.com/alibabacloud-go/tea-utils/v2/service"
  credential  "github.com/aliyun/credentials-go/credentials"
  "github.com/alibabacloud-go/tea/tea"
)


// Description:
// 
// 使用凭据初始化账号Client
// 
// @return Client
// 
// @throws Exception
func CreateClient () (_result *apig20240327.Client, _err error) {
  // 工程代码建议使用更安全的无AK方式,凭据配置方式请参见:https://help.aliyun.com/document_detail/378661.html。
  credential, _err := credential.NewCredential(nil)
  if _err != nil {
    return _result, _err
  }

  config := &openapi.Config{
    Credential: credential,
  }
  // Endpoint 请参考 https://api.aliyun.com/product/APIG
  config.Endpoint = tea.String("apig.cn-hangzhou.aliyuncs.com")
  _result = &apig20240327.Client{}
  _result, _err = apig20240327.NewClient(config)
  return _result, _err
}

func _main (args []*string) (_err error) {
  client, _err := CreateClient()
  if _err != nil {
    return _err
  }

  listPluginAttachmentsRequest := &apig20240327.ListPluginAttachmentsRequest{}
  runtime := &util.RuntimeOptions{}
  headers := make(map[string]*string)
  tryErr := func()(_e error) {
    defer func() {
      if r := tea.Recover(recover()); r != nil {
        _e = r
      }
    }()
    // 复制代码运行请自行打印 API 的返回值
    _, _err = client.ListPluginAttachmentsWithOptions(listPluginAttachmentsRequest, headers, runtime)
    if _err != nil {
      return _err
    }

    return nil
  }()

  if tryErr != nil {
    var error = &tea.SDKError{}
    if _t, ok := tryErr.(*tea.SDKError); ok {
      error = _t
    } else {
      error.Message = tea.String(tryErr.Error())
    }
    // 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。
    // 错误 message
    fmt.Println(tea.StringValue(error.Message))
    // 诊断地址
    var data interface{}
    d := json.NewDecoder(strings.NewReader(tea.StringValue(error.Data)))
    d.Decode(&data)
    if m, ok := data.(map[string]interface{}); ok {
      recommend, _ := m["Recommend"]
      fmt.Println(recommend)
    }
    _, _err = util.AssertAsString(error.Message)
    if _err != nil {
      return _err
    }
  }
  return _err
}


func main() {
  err := _main(tea.StringSlice(os.Args[1:]))
  if err != nil {
    panic(err)
  }
}
<?php

// This file is auto-generated, don't edit it. Thanks.
namespace AlibabaCloud\SDK\Sample;

use AlibabaCloud\SDK\APIG\V20240327\APIG;
use AlibabaCloud\Credentials\Credential;
use \Exception;
use AlibabaCloud\Tea\Exception\TeaError;
use AlibabaCloud\Tea\Utils\Utils;

use Darabonba\OpenApi\Models\Config;
use AlibabaCloud\SDK\APIG\V20240327\Models\ListPluginAttachmentsRequest;
use AlibabaCloud\Tea\Utils\Utils\RuntimeOptions;

class Sample {

    /**
     * 使用凭据初始化账号Client
     * @return APIG Client
     */
    public static function createClient(){
        // 工程代码建议使用更安全的无AK方式,凭据配置方式请参见:https://help.aliyun.com/document_detail/311677.html。
        $credential = new Credential();
        $config = new Config([
            "credential" => $credential
        ]);
        // Endpoint 请参考 https://api.aliyun.com/product/APIG
        $config->endpoint = "apig.cn-hangzhou.aliyuncs.com";
        return new APIG($config);
    }

    /**
     * @param string[] $args
     * @return void
     */
    public static function main($args){
        $client = self::createClient();
        $listPluginAttachmentsRequest = new ListPluginAttachmentsRequest([]);
        $runtime = new RuntimeOptions([]);
        $headers = [];
        try {
            // 复制代码运行请自行打印 API 的返回值
            $client->listPluginAttachmentsWithOptions($listPluginAttachmentsRequest, $headers, $runtime);
        }
        catch (Exception $error) {
            if (!($error instanceof TeaError)) {
                $error = new TeaError([], $error->getMessage(), $error->getCode(), $error);
            }
            // 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。
            // 错误 message
            var_dump($error->message);
            // 诊断地址
            var_dump($error->data["Recommend"]);
            Utils::assertAsString($error->message);
        }
    }
}
$path = __DIR__ . \DIRECTORY_SEPARATOR . '..' . \DIRECTORY_SEPARATOR . 'vendor' . \DIRECTORY_SEPARATOR . 'autoload.php';
if (file_exists($path)) {
    require_once $path;
}
Sample::main(array_slice($argv, 1));
# -*- coding: utf-8 -*-
# This file is auto-generated, don't edit it. Thanks.
import os
import sys

from typing import List

from alibabacloud_apig20240327.client import Client as APIG20240327Client
from alibabacloud_credentials.client import Client as CredentialClient
from alibabacloud_tea_openapi import models as open_api_models
from alibabacloud_apig20240327 import models as apig20240327_models
from alibabacloud_tea_util import models as util_models
from alibabacloud_tea_util.client import Client as UtilClient


class Sample:
    def __init__(self):
        pass

    @staticmethod
    def create_client() -> APIG20240327Client:
        """
        使用凭据初始化账号Client
        @return: Client
        @throws Exception
        """
        # 工程代码建议使用更安全的无AK方式,凭据配置方式请参见:https://help.aliyun.com/document_detail/378659.html。
        credential = CredentialClient()
        config = open_api_models.Config(
            credential=credential
        )
        # Endpoint 请参考 https://api.aliyun.com/product/APIG
        config.endpoint = f'apig.cn-hangzhou.aliyuncs.com'
        return APIG20240327Client(config)

    @staticmethod
    def main(
        args: List[str],
    ) -> None:
        client = Sample.create_client()
        list_plugin_attachments_request = apig20240327_models.ListPluginAttachmentsRequest()
        runtime = util_models.RuntimeOptions()
        headers = {}
        try:
            # 复制代码运行请自行打印 API 的返回值
            client.list_plugin_attachments_with_options(list_plugin_attachments_request, headers, runtime)
        except Exception as error:
            # 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。
            # 错误 message
            print(error.message)
            # 诊断地址
            print(error.data.get("Recommend"))
            UtilClient.assert_as_string(error.message)

    @staticmethod
    async def main_async(
        args: List[str],
    ) -> None:
        client = Sample.create_client()
        list_plugin_attachments_request = apig20240327_models.ListPluginAttachmentsRequest()
        runtime = util_models.RuntimeOptions()
        headers = {}
        try:
            # 复制代码运行请自行打印 API 的返回值
            await client.list_plugin_attachments_with_options_async(list_plugin_attachments_request, headers, runtime)
        except Exception as error:
            # 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。
            # 错误 message
            print(error.message)
            # 诊断地址
            print(error.data.get("Recommend"))
            UtilClient.assert_as_string(error.message)


if __name__ == '__main__':
    Sample.main(sys.argv[1:])

CLI示例

aliyun apig GET /v1/plugin-attachments --region cn-hangzhou --header "Content-Type=application/json;"

attachResourceIdstring(可选)

挂载资源 ID。

attachResourceTypestring(可选)

插件挂载点类型,暂未启用。

枚举值

  • GatewayDomain:GatewayDomain。

  • Gateway:Gateway。

  • GatewayRoute:GatewayRoute。

  • HttpApi:HttpApi。

  • Operation:Operation。

environmentIdstring(可选)

环境 ID。

pluginIdstring(可选)

插件 ID。

gatewayIdstring(可选)

网关 ID。

pageNumberinteger(可选)默认值为1

页码。

pageSizeinteger(可选)

分页大小。

attachResourceTypesstring(可选)

挂载点类型,多个以,隔开。

withParentResourceboolean(可选)

是否需要返回父级资源挂载。取值:

  • true:返回父级资源挂载。

  • false:不返回。

响应

{
  "requestId": "168BA42D-F822-569D-A67F-Fxxxxxxxxx1",
  "code": "Ok",
  "message": "success",
  "data": {
    "pageNumber": 1,
    "pageSize": 10,
    "totalSize": 10,
    "items": [
      {
        "pluginAttachmentId": "pl-cvu6r4um1xxxxxxxa0",
        "parentResourceInfo": {
          "resourceType": "Gateway",
          "apiInfo": {}
        },
        "resourceInfos": {
          "item": ""
        },
        "environmentInfo": "xxx",
        "enable": "true",
        "pluginId": "pl-xxxxx",
        "pluginConfig": "bGltaXRfYnlfaGVhZGVyOiB4LWFwaS1rZXkKbGltaXRfa2V5czoKLSBrZXk6IGV4YW1wbGUta2V5LWEKICBxdWVyeV9wZXJfc2Vjb25kOiAxMAotIGtleTogZXhhbXBsZS1rZ",
        "pluginClassInfo": "",
        "attachResourceType": "GatewayRoute"
      }
    ]
  }
}

requestIdstring

请求 ID。

codestring

响应状态码。

messagestring

响应消息。

dataobject

响应数据。

属性

pageNumberinteger

分页页码。

pageSizeinteger

分页大小。

totalSizeinteger

总数量。

itemsarray<object>

Item 详情。

属性

itemsobject

结果对象。

属性

pluginAttachmentIdstring

插件挂载 ID。

parentResourceInfoParentResourceInfo

父级资源信息。

resourceInfosarray

挂载资源信息。

属性

itemResourceInfo

挂载资源信息。

environmentInfoEnvironmentInfo

环境信息。

enableboolean

是否启用插件挂载。取值:

  • true:启用。

  • false:关闭。

pluginIdstring

插件 ID。

pluginConfigstring

插件配置原文的 base64 内容。

pluginClassInfoPluginClassInfo

插件类型信息。

attachResourceTypestring

插件挂载资源类型,GatewayRoute、Gateway、GatewayDomain、HttpApi、Operation。

常见错误码

您可以访问错误中心查看所有错误码。

UpdatePluginAttachment

更新插件挂载。

配置RAM授权

操作

访问级别

资源类型

条件关键字

关联操作

apig:UpdatePluginAttachment

none

*全部资源

*

请求语法

PUT /v1/plugin-attachments/{pluginAttachmentId} HTTP/1.1

请求体

SDK示例

// This file is auto-generated, don't edit it. Thanks.
package com.aliyun.sample;

import com.aliyun.tea.*;

public class Sample {

    /**
     * <b>description</b> :
     * <p>使用凭据初始化账号Client</p>
     * @return Client
     * 
     * @throws Exception
     */
    public static com.aliyun.apig20240327.Client createClient() throws Exception {
        // 工程代码建议使用更安全的无AK方式,凭据配置方式请参见:https://help.aliyun.com/document_detail/378657.html。
        com.aliyun.credentials.Client credential = new com.aliyun.credentials.Client();
        com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config()
                .setCredential(credential);
        // Endpoint 请参考 https://api.aliyun.com/product/APIG
        config.endpoint = "apig.cn-hangzhou.aliyuncs.com";
        return new com.aliyun.apig20240327.Client(config);
    }

    public static void main(String[] args_) throws Exception {
        
        com.aliyun.apig20240327.Client client = Sample.createClient();
        com.aliyun.apig20240327.models.UpdatePluginAttachmentRequest updatePluginAttachmentRequest = new com.aliyun.apig20240327.models.UpdatePluginAttachmentRequest();
        com.aliyun.teautil.models.RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions();
        java.util.Map<String, String> headers = new java.util.HashMap<>();
        try {
            // 复制代码运行请自行打印 API 的返回值
            client.updatePluginAttachmentWithOptions("", updatePluginAttachmentRequest, headers, runtime);
        } catch (TeaException error) {
            // 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。
            // 错误 message
            System.out.println(error.getMessage());
            // 诊断地址
            System.out.println(error.getData().get("Recommend"));
            com.aliyun.teautil.Common.assertAsString(error.message);
        } catch (Exception _error) {
            TeaException error = new TeaException(_error.getMessage(), _error);
            // 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。
            // 错误 message
            System.out.println(error.getMessage());
            // 诊断地址
            System.out.println(error.getData().get("Recommend"));
            com.aliyun.teautil.Common.assertAsString(error.message);
        }        
    }
}
'use strict';
// This file is auto-generated, don't edit it
// 依赖的模块可通过下载工程中的模块依赖文件或右上角的获取 SDK 依赖信息查看
const APIG20240327 = require('@alicloud/apig20240327');
const OpenApi = require('@alicloud/openapi-client');
const Util = require('@alicloud/tea-util');
const Credential = require('@alicloud/credentials');
const Tea = require('@alicloud/tea-typescript');

class Client {

  /**
   * 使用凭据初始化账号Client
   * @return Client
   * @throws Exception
   */
  static createClient() {
    // 工程代码建议使用更安全的无AK方式,凭据配置方式请参见:https://help.aliyun.com/document_detail/378664.html。
    let credential = new Credential.default();
    let config = new OpenApi.Config({
      credential: credential,
    });
    // Endpoint 请参考 https://api.aliyun.com/product/APIG
    config.endpoint = `apig.cn-hangzhou.aliyuncs.com`;
    return new APIG20240327.default(config);
  }

  static async main(args) {
    let client = Client.createClient();
    let updatePluginAttachmentRequest = new APIG20240327.UpdatePluginAttachmentRequest({ });
    let runtime = new Util.RuntimeOptions({ });
    let headers = { };
    try {
      // 复制代码运行请自行打印 API 的返回值
      await client.updatePluginAttachmentWithOptions('', updatePluginAttachmentRequest, headers, runtime);
    } catch (error) {
      // 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。
      // 错误 message
      console.log(error.message);
      // 诊断地址
      console.log(error.data["Recommend"]);
      Util.default.assertAsString(error.message);
    }    
  }

}

exports.Client = Client;
Client.main(process.argv.slice(2));
// This file is auto-generated, don't edit it. Thanks.
package main

import (
  "encoding/json"
  "strings"
  "fmt"
  "os"
  apig20240327  "github.com/alibabacloud-go/apig-20240327/v4/client"
  openapi  "github.com/alibabacloud-go/darabonba-openapi/v2/client"
  util  "github.com/alibabacloud-go/tea-utils/v2/service"
  credential  "github.com/aliyun/credentials-go/credentials"
  "github.com/alibabacloud-go/tea/tea"
)


// Description:
// 
// 使用凭据初始化账号Client
// 
// @return Client
// 
// @throws Exception
func CreateClient () (_result *apig20240327.Client, _err error) {
  // 工程代码建议使用更安全的无AK方式,凭据配置方式请参见:https://help.aliyun.com/document_detail/378661.html。
  credential, _err := credential.NewCredential(nil)
  if _err != nil {
    return _result, _err
  }

  config := &openapi.Config{
    Credential: credential,
  }
  // Endpoint 请参考 https://api.aliyun.com/product/APIG
  config.Endpoint = tea.String("apig.cn-hangzhou.aliyuncs.com")
  _result = &apig20240327.Client{}
  _result, _err = apig20240327.NewClient(config)
  return _result, _err
}

func _main (args []*string) (_err error) {
  client, _err := CreateClient()
  if _err != nil {
    return _err
  }

  updatePluginAttachmentRequest := &apig20240327.UpdatePluginAttachmentRequest{}
  runtime := &util.RuntimeOptions{}
  headers := make(map[string]*string)
  tryErr := func()(_e error) {
    defer func() {
      if r := tea.Recover(recover()); r != nil {
        _e = r
      }
    }()
    // 复制代码运行请自行打印 API 的返回值
    _, _err = client.UpdatePluginAttachmentWithOptions(tea.String(""), updatePluginAttachmentRequest, headers, runtime)
    if _err != nil {
      return _err
    }

    return nil
  }()

  if tryErr != nil {
    var error = &tea.SDKError{}
    if _t, ok := tryErr.(*tea.SDKError); ok {
      error = _t
    } else {
      error.Message = tea.String(tryErr.Error())
    }
    // 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。
    // 错误 message
    fmt.Println(tea.StringValue(error.Message))
    // 诊断地址
    var data interface{}
    d := json.NewDecoder(strings.NewReader(tea.StringValue(error.Data)))
    d.Decode(&data)
    if m, ok := data.(map[string]interface{}); ok {
      recommend, _ := m["Recommend"]
      fmt.Println(recommend)
    }
    _, _err = util.AssertAsString(error.Message)
    if _err != nil {
      return _err
    }
  }
  return _err
}


func main() {
  err := _main(tea.StringSlice(os.Args[1:]))
  if err != nil {
    panic(err)
  }
}
<?php

// This file is auto-generated, don't edit it. Thanks.
namespace AlibabaCloud\SDK\Sample;

use AlibabaCloud\SDK\APIG\V20240327\APIG;
use AlibabaCloud\Credentials\Credential;
use \Exception;
use AlibabaCloud\Tea\Exception\TeaError;
use AlibabaCloud\Tea\Utils\Utils;

use Darabonba\OpenApi\Models\Config;
use AlibabaCloud\SDK\APIG\V20240327\Models\UpdatePluginAttachmentRequest;
use AlibabaCloud\Tea\Utils\Utils\RuntimeOptions;

class Sample {

    /**
     * 使用凭据初始化账号Client
     * @return APIG Client
     */
    public static function createClient(){
        // 工程代码建议使用更安全的无AK方式,凭据配置方式请参见:https://help.aliyun.com/document_detail/311677.html。
        $credential = new Credential();
        $config = new Config([
            "credential" => $credential
        ]);
        // Endpoint 请参考 https://api.aliyun.com/product/APIG
        $config->endpoint = "apig.cn-hangzhou.aliyuncs.com";
        return new APIG($config);
    }

    /**
     * @param string[] $args
     * @return void
     */
    public static function main($args){
        $client = self::createClient();
        $updatePluginAttachmentRequest = new UpdatePluginAttachmentRequest([]);
        $runtime = new RuntimeOptions([]);
        $headers = [];
        try {
            // 复制代码运行请自行打印 API 的返回值
            $client->updatePluginAttachmentWithOptions("", $updatePluginAttachmentRequest, $headers, $runtime);
        }
        catch (Exception $error) {
            if (!($error instanceof TeaError)) {
                $error = new TeaError([], $error->getMessage(), $error->getCode(), $error);
            }
            // 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。
            // 错误 message
            var_dump($error->message);
            // 诊断地址
            var_dump($error->data["Recommend"]);
            Utils::assertAsString($error->message);
        }
    }
}
$path = __DIR__ . \DIRECTORY_SEPARATOR . '..' . \DIRECTORY_SEPARATOR . 'vendor' . \DIRECTORY_SEPARATOR . 'autoload.php';
if (file_exists($path)) {
    require_once $path;
}
Sample::main(array_slice($argv, 1));
# -*- coding: utf-8 -*-
# This file is auto-generated, don't edit it. Thanks.
import os
import sys

from typing import List

from alibabacloud_apig20240327.client import Client as APIG20240327Client
from alibabacloud_credentials.client import Client as CredentialClient
from alibabacloud_tea_openapi import models as open_api_models
from alibabacloud_apig20240327 import models as apig20240327_models
from alibabacloud_tea_util import models as util_models
from alibabacloud_tea_util.client import Client as UtilClient


class Sample:
    def __init__(self):
        pass

    @staticmethod
    def create_client() -> APIG20240327Client:
        """
        使用凭据初始化账号Client
        @return: Client
        @throws Exception
        """
        # 工程代码建议使用更安全的无AK方式,凭据配置方式请参见:https://help.aliyun.com/document_detail/378659.html。
        credential = CredentialClient()
        config = open_api_models.Config(
            credential=credential
        )
        # Endpoint 请参考 https://api.aliyun.com/product/APIG
        config.endpoint = f'apig.cn-hangzhou.aliyuncs.com'
        return APIG20240327Client(config)

    @staticmethod
    def main(
        args: List[str],
    ) -> None:
        client = Sample.create_client()
        update_plugin_attachment_request = apig20240327_models.UpdatePluginAttachmentRequest()
        runtime = util_models.RuntimeOptions()
        headers = {}
        try:
            # 复制代码运行请自行打印 API 的返回值
            client.update_plugin_attachment_with_options('', update_plugin_attachment_request, headers, runtime)
        except Exception as error:
            # 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。
            # 错误 message
            print(error.message)
            # 诊断地址
            print(error.data.get("Recommend"))
            UtilClient.assert_as_string(error.message)

    @staticmethod
    async def main_async(
        args: List[str],
    ) -> None:
        client = Sample.create_client()
        update_plugin_attachment_request = apig20240327_models.UpdatePluginAttachmentRequest()
        runtime = util_models.RuntimeOptions()
        headers = {}
        try:
            # 复制代码运行请自行打印 API 的返回值
            await client.update_plugin_attachment_with_options_async('', update_plugin_attachment_request, headers, runtime)
        except Exception as error:
            # 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。
            # 错误 message
            print(error.message)
            # 诊断地址
            print(error.data.get("Recommend"))
            UtilClient.assert_as_string(error.message)


if __name__ == '__main__':
    Sample.main(sys.argv[1:])

CLI示例

aliyun apig PUT /v1/plugin-attachments/{pluginAttachmentId} --region cn-hangzhou --header "Content-Type=application/json;" --body "{}"

pluginAttachmentIdstring(可选)

插件挂载 ID。

bodyobject(可选)

请求 Body。

属性

attachResourceIdsarray(可选)

挂载点 ID 列表。

属性

attachResourceIdstring(可选)

挂载点 ID。

pluginConfigstring(可选)

插件配置原文的 base64 内容。

enableboolean(可选)

是否启用插件挂载。取值:

  • true:启用。

  • false:关闭。

响应

{
  "requestId": "F330090D-80F8-557B-8610-7xxxxxxxA4",
  "code": "Ok",
  "message": "success"
}

requestIdstring

请求 ID。

codestring

响应状态码。

messagestring

响应消息。

常见错误码

您可以访问错误中心查看所有错误码。

ImportHttpApi

导入HTTP API,支持将OpenAPI 2.0和 OpenAPI 3.0.x版本的定义文件导入为REST类型的API。将OAS转化为MCP配置。

配置RAM授权

操作

访问级别

资源类型

条件关键字

关联操作

apig:ImportHttpApi

none

*全部资源

*

请求语法

POST /v1/http-apis/import HTTP/1.1

请求体

SDK示例

// This file is auto-generated, don't edit it. Thanks.
package com.aliyun.sample;

import com.aliyun.tea.*;

public class Sample {

    /**
     * <b>description</b> :
     * <p>使用凭据初始化账号Client</p>
     * @return Client
     * 
     * @throws Exception
     */
    public static com.aliyun.teaopenapi.Client createClient() throws Exception {
        // 工程代码建议使用更安全的无AK方式,凭据配置方式请参见:https://help.aliyun.com/document_detail/378657.html。
        com.aliyun.credentials.Client credential = new com.aliyun.credentials.Client();
        com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config()
                .setCredential(credential);
        // Endpoint 请参考 https://api.aliyun.com/product/APIG
        config.endpoint = "apig.cn-hangzhou.aliyuncs.com";
        return new com.aliyun.teaopenapi.Client(config);
    }

    /**
     * <b>description</b> :
     * <p>API 相关</p>
     * 
     * @param path string Path parameters
     * @return OpenApi.Params
     */
    public static com.aliyun.teaopenapi.models.Params createApiInfo() throws Exception {
        com.aliyun.teaopenapi.models.Params params = new com.aliyun.teaopenapi.models.Params()
                // 接口名称
                .setAction("ImportHttpApi")
                // 接口版本
                .setVersion("2024-03-27")
                // 接口协议
                .setProtocol("HTTPS")
                // 接口 HTTP 方法
                .setMethod("POST")
                .setAuthType("AK")
                .setStyle("ROA")
                // 接口 PATH
                .setPathname("/v1/http-apis/import")
                // 接口请求体内容格式
                .setReqBodyType("json")
                // 接口响应体内容格式
                .setBodyType("json");
        return params;
    }

    public static void main(String[] args_) throws Exception {
        
        com.aliyun.teaopenapi.Client client = Sample.createClient();
        com.aliyun.teaopenapi.models.Params params = Sample.createApiInfo();
        // runtime options
        com.aliyun.teautil.models.RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions();
        com.aliyun.teaopenapi.models.OpenApiRequest request = new com.aliyun.teaopenapi.models.OpenApiRequest();
        // 复制代码运行请自行打印 API 的返回值
        // 返回值实际为 Map 类型,可从 Map 中获得三类数据:响应体 body、响应头 headers、HTTP 返回的状态码 statusCode。
        client.callApi(params, request, runtime);
    }
}
'use strict';
// This file is auto-generated, don't edit it
// 依赖的模块可通过下载工程中的模块依赖文件或右上角的获取 SDK 依赖信息查看
const OpenApi = require('@alicloud/openapi-client');
const Util = require('@alicloud/tea-util');
const Credential = require('@alicloud/credentials');
const Tea = require('@alicloud/tea-typescript');

class Client {

  /**
   * 使用凭据初始化账号Client
   * @return Client
   * @throws Exception
   */
  static createClient() {
    // 工程代码建议使用更安全的无AK方式,凭据配置方式请参见:https://help.aliyun.com/document_detail/378664.html。
    let credential = new Credential.default();
    let config = new OpenApi.Config({
      credential: credential,
    });
    // Endpoint 请参考 https://api.aliyun.com/product/APIG
    config.endpoint = `apig.cn-hangzhou.aliyuncs.com`;
    return new OpenApi.default(config);
  }

  /**
   * API 相关
   * @param path string Path parameters
   * @return OpenApi.Params
   */
  static createApiInfo() {
    let params = new OpenApi.Params({
      // 接口名称
      action: 'ImportHttpApi',
      // 接口版本
      version: '2024-03-27',
      // 接口协议
      protocol: 'HTTPS',
      // 接口 HTTP 方法
      method: 'POST',
      authType: 'AK',
      style: 'ROA',
      // 接口 PATH
      pathname: `/v1/http-apis/import`,
      // 接口请求体内容格式
      reqBodyType: 'json',
      // 接口响应体内容格式
      bodyType: 'json',
    });
    return params;
  }

  static async main(args) {
    let client = Client.createClient();
    let params = Client.createApiInfo();
    // runtime options
    let runtime = new Util.RuntimeOptions({ });
    let request = new OpenApi.OpenApiRequest({ });
    // 复制代码运行请自行打印 API 的返回值
    // 返回值实际为 Map 类型,可从 Map 中获得三类数据:响应体 body、响应头 headers、HTTP 返回的状态码 statusCode。
    await client.callApi(params, request, runtime);
  }

}

exports.Client = Client;
Client.main(process.argv.slice(2));
// This file is auto-generated, don't edit it. Thanks.
package main

import (
  "encoding/json"
  "strings"
  "fmt"
  "os"
  openapi  "github.com/alibabacloud-go/darabonba-openapi/v2/client"
  util  "github.com/alibabacloud-go/tea-utils/v2/service"
  credential  "github.com/aliyun/credentials-go/credentials"
  "github.com/alibabacloud-go/tea/tea"
)


// Description:
// 
// 使用凭据初始化账号Client
// 
// @return Client
// 
// @throws Exception
func CreateClient () (_result *openapi.Client, _err error) {
  // 工程代码建议使用更安全的无AK方式,凭据配置方式请参见:https://help.aliyun.com/document_detail/378661.html。
  credential, _err := credential.NewCredential(nil)
  if _err != nil {
    return _result, _err
  }

  config := &openapi.Config{
    Credential: credential,
  }
  // Endpoint 请参考 https://api.aliyun.com/product/APIG
  config.Endpoint = tea.String("apig.cn-hangzhou.aliyuncs.com")
  _result = &openapi.Client{}
  _result, _err = openapi.NewClient(config)
  return _result, _err
}

// Description:
// 
// API 相关
// 
// @param path - string Path parameters
// 
// @return OpenApi.Params
func CreateApiInfo () (_result *openapi.Params) {
  params := &openapi.Params{
    // 接口名称
    Action: tea.String("ImportHttpApi"),
    // 接口版本
    Version: tea.String("2024-03-27"),
    // 接口协议
    Protocol: tea.String("HTTPS"),
    // 接口 HTTP 方法
    Method: tea.String("POST"),
    AuthType: tea.String("AK"),
    Style: tea.String("ROA"),
    // 接口 PATH
    Pathname: tea.String("/v1/http-apis/import"),
    // 接口请求体内容格式
    ReqBodyType: tea.String("json"),
    // 接口响应体内容格式
    BodyType: tea.String("json"),
  }
  _result = params
  return _result
}

func _main (args []*string) (_err error) {
  client, _err := CreateClient()
  if _err != nil {
    return _err
  }

  params := CreateApiInfo()
  // runtime options
  runtime := &util.RuntimeOptions{}
  request := &openapi.OpenApiRequest{}
  // 复制代码运行请自行打印 API 的返回值
  // 返回值实际为 Map 类型,可从 Map 中获得三类数据:响应体 body、响应头 headers、HTTP 返回的状态码 statusCode。
  _, _err = client.CallApi(params, request, runtime)
  if _err != nil {
    return _err
  }
  return _err
}


func main() {
  err := _main(tea.StringSlice(os.Args[1:]))
  if err != nil {
    panic(err)
  }
}
<?php

// This file is auto-generated, don't edit it. Thanks.
namespace AlibabaCloud\SDK\Sample;

use Darabonba\OpenApi\OpenApiClient;
use AlibabaCloud\Credentials\Credential;

use Darabonba\OpenApi\Models\Config;
use Darabonba\OpenApi\Models\Params;
use AlibabaCloud\Tea\Utils\Utils\RuntimeOptions;
use Darabonba\OpenApi\Models\OpenApiRequest;

class Sample {

    /**
     * 使用凭据初始化账号Client
     * @return OpenApiClient Client
     */
    public static function createClient(){
        // 工程代码建议使用更安全的无AK方式,凭据配置方式请参见:https://help.aliyun.com/document_detail/311677.html。
        $credential = new Credential();
        $config = new Config([
            "credential" => $credential
        ]);
        // Endpoint 请参考 https://api.aliyun.com/product/APIG
        $config->endpoint = "apig.cn-hangzhou.aliyuncs.com";
        return new OpenApiClient($config);
    }

    /**
     * API 相关
     * @return Params OpenApi.Params
     */
    public static function createApiInfo(){
        $params = new Params([
            // 接口名称
            "action" => "ImportHttpApi",
            // 接口版本
            "version" => "2024-03-27",
            // 接口协议
            "protocol" => "HTTPS",
            // 接口 HTTP 方法
            "method" => "POST",
            "authType" => "AK",
            "style" => "ROA",
            // 接口 PATH
            "pathname" => "/v1/http-apis/import",
            // 接口请求体内容格式
            "reqBodyType" => "json",
            // 接口响应体内容格式
            "bodyType" => "json"
        ]);
        return $params;
    }

    /**
     * @param string[] $args
     * @return void
     */
    public static function main($args){
        $client = self::createClient();
        $params = self::createApiInfo();
        // runtime options
        $runtime = new RuntimeOptions([]);
        $request = new OpenApiRequest([]);
        // 复制代码运行请自行打印 API 的返回值
        // 返回值实际为 Map 类型,可从 Map 中获得三类数据:响应体 body、响应头 headers、HTTP 返回的状态码 statusCode。
        $client->callApi($params, $request, $runtime);
    }
}
$path = __DIR__ . \DIRECTORY_SEPARATOR . '..' . \DIRECTORY_SEPARATOR . 'vendor' . \DIRECTORY_SEPARATOR . 'autoload.php';
if (file_exists($path)) {
    require_once $path;
}
Sample::main(array_slice($argv, 1));
# -*- coding: utf-8 -*-
# This file is auto-generated, don't edit it. Thanks.
import os
import sys

from typing import List

from alibabacloud_tea_openapi.client import Client as OpenApiClient
from alibabacloud_credentials.client import Client as CredentialClient
from alibabacloud_tea_openapi import models as open_api_models
from alibabacloud_tea_util import models as util_models


class Sample:
    def __init__(self):
        pass

    @staticmethod
    def create_client() -> OpenApiClient:
        """
        使用凭据初始化账号Client
        @return: Client
        @throws Exception
        """
        # 工程代码建议使用更安全的无AK方式,凭据配置方式请参见:https://help.aliyun.com/document_detail/378659.html。
        credential = CredentialClient()
        config = open_api_models.Config(
            credential=credential
        )
        # Endpoint 请参考 https://api.aliyun.com/product/APIG
        config.endpoint = f'apig.cn-hangzhou.aliyuncs.com'
        return OpenApiClient(config)

    @staticmethod
    def create_api_info() -> open_api_models.Params:
        """
        API 相关
        @param path: string Path parameters
        @return: OpenApi.Params
        """
        params = open_api_models.Params(
            # 接口名称,
            action='ImportHttpApi',
            # 接口版本,
            version='2024-03-27',
            # 接口协议,
            protocol='HTTPS',
            # 接口 HTTP 方法,
            method='POST',
            auth_type='AK',
            style='ROA',
            # 接口 PATH,
            pathname=f'/v1/http-apis/import',
            # 接口请求体内容格式,
            req_body_type='json',
            # 接口响应体内容格式,
            body_type='json'
        )
        return params

    @staticmethod
    def main(
        args: List[str],
    ) -> None:
        client = Sample.create_client()
        params = Sample.create_api_info()
        # runtime options
        runtime = util_models.RuntimeOptions()
        request = open_api_models.OpenApiRequest()
        # 复制代码运行请自行打印 API 的返回值
        # 返回值实际为 Map 类型,可从 Map 中获得三类数据:响应体 body、响应头 headers、HTTP 返回的状态码 statusCode。
        client.call_api(params, request, runtime)

    @staticmethod
    async def main_async(
        args: List[str],
    ) -> None:
        client = Sample.create_client()
        params = Sample.create_api_info()
        # runtime options
        runtime = util_models.RuntimeOptions()
        request = open_api_models.OpenApiRequest()
        # 复制代码运行请自行打印 API 的返回值
        # 返回值实际为 Map 类型,可从 Map 中获得三类数据:响应体 body、响应头 headers、HTTP 返回的状态码 statusCode。
        await client.call_api_async(params, request, runtime)


if __name__ == '__main__':
    Sample.main(sys.argv[1:])

CLI示例

aliyun apig POST /v1/http-apis/import --region cn-hangzhou --header "Content-Type=application/json;" --body "{}"

bodyobject(可选)

请求体参数。

属性

specContentBase64string(可选)

Bse64 编码的 API 定义,支持 OAS2.0 和 OAS3.0 规范,支持 YAML 格式和 JSON 格式。优先级高于 specFileUrl 参数。 若文件大小超过 10MB 请使用 specFileUrl 参数传递。

specFileUrlstring(可选)

API 定义文件的下载地址,需要公网可以下载或使用相同 region 的 OSS 内网下载地址。文件地址要求拥有下载权限,对于 OSS 非公开读的文件链接,请参考文档使用预签名URL下载文件,填写带有下载权限的地址。目前仅支持 OSS 上存储的 API 定义文件。

namestring(可选)

导入的 API 名称,若不填则从 API 定义文件中提取。若 API 名称与版本化配置已存在,则本次导入会根据 strategy 字段对已有 API 定义做更新。

descriptionstring(可选)

导入的 API 描述字段,若未填写则从 API 定义中提取。限制长度 255 字节。

versionConfigHttpApiVersionConfig(可选)

API 版本化配置,若开启版本化配置,则版本号 API 名称与已存在 API 相同时,本次导入将视为更新动作。若未开启版本化配置,则 API 名称与已存在 API 相同时,本次导入将视为更新动作。

dryRunboolean(可选)

导入预检,若开启则仅进行检测,不进行导入动作。取值:

  • true:仅进行检测,不进行导入操作。

  • false:执行实际导操作。

strategystring(可选)

当导入的 API 名称与版本管理与已存在 API 相同时,需要指定更新策略。

  • SpecOnly:完全以导入文件为准。

  • SpecFirst:以导入文件为优先,新增接口与更新已有接口,文件中未提及的接口保持不动。

  • ExistFirst:以存在的 API 为优先,只新增接口,不更新已有接口。 为空时默认 ExistFirst 策略。

targetHttpApiIdstring(可选)

若指定该字段,则本次导入将更新指定 API 而非导入或根据 API 名称与版本管理配置搜索已存在 API。目标 API 必须是 REST 类型。

resourceGroupIdstring(可选)

资源组 ID

specOssConfigobject(可选)

OSS 信息。

属性

regionIdstring(可选)

地域 ID。

bucketNamestring(可选)

bucket 名称。

objectKeystring(可选)

文件完整路径。

deployConfigsHttpApiDeployConfig(可选)

API 部署配置。

mcpRouteIdstring(可选)

MCP 路由 ID。

响应

{
  "requestId": "CE857A85-251D-5018-8103-A38957D71E20",
  "code": "Ok",
  "message": "success",
  "data": {
    "name": "import-test",
    "httpApiId": "api-xxx",
    "dryRunInfo": {
      "successOperations": [
        {
          "action": "Create",
          "name": "CreateUser",
          "path": "/v1/users",
          "method": "POST"
        }
      ],
      "failureOperations": [
        {
          "path": "/v1/orders",
          "method": "GET",
          "errorMessage": "缺少响应定义。"
        }
      ],
      "successComponents": [
        {
          "action": "Create",
          "name": "userDTO"
        }
      ],
      "failureComponents": [
        {
          "name": "orderDTO",
          "errorMessage": "数据结构定义有误。"
        }
      ],
      "errorMessages": [
        "OpenAPI 3.1.x 版本不支持。"
      ],
      "warningMessages": [
        "GET /v1/orders 参数定义不完整。"
      ],
      "existHttpApiInfo": {
        "httpApiId": "api-xxx",
        "name": "test",
        "protocols": [
          "HTTP"
        ],
        "basePath": "/v1",
        "description": "测试专用API",
        "versionInfo": {
          "enable": true,
          "scheme": "Query",
          "headerName": "my-version",
          "queryName": "myVersion",
          "version": "v1"
        },
        "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"
            },
            "deployStatus": "Deployed",
            "subDomains": [
              {
                "domainId": "d-xxx",
                "name": "www.example.com",
                "protocol": "HTTP",
                "networkType": "Internet"
              }
            ]
          }
        ],
        "ingressInfo": {
          "sourceId": "src-xxx",
          "ingressClass": "mse",
          "watchNamespace": "default",
          "environmentInfo": {
            "environmentId": "env-xxx"
          },
          "k8sClusterInfo": {
            "clusterId": "ca435c77cba1547cca9311957bcxxxxxx"
          },
          "overrideIngressIp": true
        },
        "type": "Rest",
        "resourceGroupId": "rg-xxx",
        "aiProtocols": [
          "OpenAI/v1"
        ],
        "deployConfigs": [
          {
            "customDomainIds": [
              "d-xxx"
            ],
            "environmentId": "env-xxx",
            "backendScene": "SingleService",
            "serviceConfigs": [
              {
                "serviceId": "svc-xxx",
                "weight": 100,
                "modelNamePattern": "qwen-*",
                "modelName": "qwen-max"
              }
            ],
            "policyConfigs": [
              {
                "type": "AiFallback",
                "enable": true,
                "aiFallbackConfig": {
                  "serviceIds": [
                    "svc-xxx"
                  ]
                }
              }
            ],
            "autoDeploy": true,
            "gatewayId": "gw-xx",
            "routeBackend": {
              "scene": "Single",
              "services": [
                {
                  "serviceId": "service-cq2bmmdlhtgj***",
                  "name": "item-service",
                  "protocol": "HTTP",
                  "port": 0,
                  "weight": 49,
                  "version": "v1"
                }
              ]
            },
            "customDomainInfos": [
              {
                "domainId": "",
                "name": "",
                "protocol": ""
              }
            ],
            "subDomains": [
              {
                "domainId": "",
                "name": "",
                "protocol": "",
                "networkType": ""
              }
            ],
            "gatewayInfo": {
              "gatewayId": "gw-cq7og15lhtgi6qasrj60",
              "name": "apitest-gw",
              "vpcInfo": {
                "vpcId": "vpc-uf664nyle5kh***",
                "name": "商品中心预发环境专有网络"
              },
              "engineVersion": "2.0.7"
            },
            "mock": {
              "enable": false,
              "responseCode": 200,
              "responseContent": "Mock测试"
            }
          }
        ],
        "enabelAuth": true,
        "authConfig": {
          "authType": "Jwt",
          "authMode": "NoAuth"
        },
        "deployCntMap": {
          "key": {
            "deployedCnt": 0,
            "Cnt": 0
          }
        },
        "gatewayId": ""
      }
    }
  }
}

requestIdstring

请求 ID。

codestring

响应状态码。

messagestring

响应消息。

dataobject

API 信息。

属性

namestring

API 名称。

httpApiIdstring

HTTP API 唯一 ID。

dryRunInfoobject

预检结果。

属性

successOperationsarray<object>

预检成功的接口列表。

属性

successOperationobject

接口信息。

属性

actionstring

预检后将执行的动作。

  • Create:创建。

  • Update: 更新。

namestring

接口名称。

pathstring

接口路径。

methodstring

接口方法。

failureOperationsarray<object>

预检失败的接口列表。

属性

failureOperationobject

接口信息。

属性

pathstring

接口路径。

methodstring

接口方法。

errorMessagestring

错误信息。

successComponentsarray<object>

预检成功的数据结构列表。

属性

successComponentobject

数据结构信息。

属性

actionstring

预检后将执行的动作。

  • Create:创建。

  • Update: 更新。

namestring

数据结构名称。

failureComponentsarray<object>

预检失败的数据结构列表。

属性

failureComponentobject

数据结构信息。

属性

namestring

数据结构名称。

errorMessagestring

错误信息。

errorMessagesarray

错误信息,若错误信息非空,则无法成功导入 API。

属性

errorMessagestring

单个错误信息。

warningMessagesarray

告警信息,告警信息非空,则部分接口/数据接口可能导入不成功。

属性

warningMessagestring

单个告警信息。

existHttpApiInfoHttpApiApiInfo

已存在的 API 信息。若该字段非空,则导入动作将更新该 API。

常见错误码

您可以访问错误中心查看所有错误码。