应用与数据集成平台 ROMA CONNECT-创建API:请求示例

时间:2023-11-29 17:31:17

请求示例

  • 创建一个API,认证方式为自定义认证,匹配方式为绝对匹配,后端类型为Web后端,并自定义前端请求参数和后端请求参数

    {
      "group_id" : "c77f5e81d9cb4424bf704ef2b0ac7600",
      "match_mode" : "NORMAL",
      "name" : "Api_http",
      "auth_type" : "AUTHORIZER",
      "authorizer_id" : "0d982c1ac3da493dae47627b6439fc5c",
      "backend_type" : "HTTP",
      "backend_api" : {
        "url_domain" : "10.10.10.156:12346",
        "req_protocol" : "HTTP",
        "req_method" : "GET",
        "req_uri" : "/test/benchmark",
        "timeout" : 5000
      },
      "req_protocol" : "HTTPS",
      "req_uri" : "/test/http",
      "remark" : "Web backend API",
      "type" : 1,
      "req_method" : "GET",
      "result_normal_sample" : "Normal response example",
      "result_failure_sample" : "Failure response example",
      "tags" : [ "webApi" ],
      "req_params" : [ {
        "name" : "query_demo",
        "location" : "QUERY",
        "type" : "STRING",
        "required" : 1
      }, {
        "name" : "header-demo",
        "location" : "HEADER",
        "type" : "STRING",
        "required" : 2
      } ],
      "backend_params" : [ {
        "name" : "backHeader",
        "value" : "header-demo",
        "location" : "HEADER",
        "origin" : "REQUEST"
      }, {
        "name" : "backQuery",
        "value" : "query_demo",
        "location" : "QUERY",
        "origin" : "REQUEST"
      }, {
        "name" : "X-CONSTANT-HEADER",
        "value" : "demo",
        "location" : "HEADER",
        "origin" : "CONSTANT",
        "remark" : "constant_demo"
      }, {
        "name" : "app-id",
        "value" : "$context.appId",
        "location" : "HEADER",
        "origin" : "SYSTEM",
        "remark" : "Application ID of the invoker."
      } ]
    }
  • 创建一个API,认证方式为APP认证,匹配方式为绝对匹配,后端类型为函数工作流

    {
      "group_id" : "c77f5e81d9cb4424bf704ef2b0ac7600",
      "match_mode" : "NORMAL",
      "name" : "Api_function",
      "auth_type" : "APP",
      "backend_type" : "FUNCTION",
      "func_info" : {
        "authorizer_id" : "5b8cd3f06f004115aec69c58f57272c9",
        "function_urn" : "'urn:fss:region01:73d69ae0cfcf460190522d06b60f05ad:function:default:auto_testfunc93749'",
        "network_type" : "V1",
        "invocation_type" : "sync",
        "timeout" : 5000,
        "version" : "latest",
        "alias_urn" : "urn:fss:region01:73d69ae0cfcf460190522d06b60f05ad:function:default:auto_testfunc93749:!a1"
      },
      "req_protocol" : "HTTPS",
      "req_uri" : "/test/function",
      "remark" : "FunctionGraph backend API",
      "type" : 1,
      "req_method" : "GET",
      "result_normal_sample" : "Normal response example",
      "result_failure_sample" : "Failure response example",
      "tags" : [ "functionApi" ]
    }
  • 创建一个API,认证方式为APP认证,匹配方式为前缀匹配,后端类型为MOCK后端

    {
      "group_id" : "c77f5e81d9cb4424bf704ef2b0ac7600",
      "match_mode" : "SWA",
      "name" : "Api_mock",
      "auth_type" : "APP",
      "backend_type" : "MOCK",
      "mock_info" : {
        "result_content" : "mock success"
      },
      "req_protocol" : "HTTPS",
      "req_uri" : "/test/mock",
      "remark" : "Mock backend API",
      "type" : 1,
      "req_method" : "GET",
      "result_normal_sample" : "Normal response example",
      "result_failure_sample" : "Failure response example",
      "tags" : [ "mockApi" ]
    }
support.huaweicloud.com/api-roma/CreateApiV2.html