更新时间:2024-06-06 GMT+08:00
分享

更新API

功能介绍

更新API。

调用方法

请参见如何调用API

URI

PUT /v1/{project_id}/service/apis/{api_id}

表1 路径参数

参数

是否必选

参数类型

描述

project_id

String

项目ID,获取方法请参见项目ID和账号ID

api_id

String

API ID。

请求参数

表2 请求Header参数

参数

是否必选

参数类型

描述

X-Auth-Token

String

用户Token,使用Token认证时必选。通过调用[ManageOne平台的](tag:hcs, hcs_sm)IAM服务的“获取用户Token”接口获取响应消息头中X-Subject-Token的值。

workspace

String

工作空间ID,获取方法请参见实例ID和工作空间ID

Dlm-Type

String

数据服务的版本类型,指定SHARED共享版或EXCLUSIVE专享版。

Content-Type

String

消息体的类型(格式),有Body体的情况下必选,没有Body体无需填写。如果请求消息体中含有中文字符,则需要通过charset=utf8指定中文字符集,例如取值为:application/json;charset=utf8。

表3 请求Body参数

参数

是否必选

参数类型

描述

catalog_id

String

目录ID。

name

String

API名称。

description

String

API描述。

log_flag

Boolean

是否启用访问日志。

api_type

String

API类型。

枚举值:

  • API_SPECIFIC_TYPE_CONFIGURATION: 配置类API

  • API_SPECIFIC_TYPE_SCRIPT: 脚本类API

  • API_SPECIFIC_TYPE_MYBATIS: MyBatis类API

  • API_SPECIFIC_TYPE_GROOVY: Groovy类API

  • API_SPECIFIC_TYPE_REGISTER:注册类API

  • API_SPECIFIC_TYPE_ORCHESTRATE:编排类API

  • API_TYPE_CREATE:创建类API(已弃用)

  • API_TYPE_REGISTER:注册类API(已弃用)

auth_type

String

认证类型。

枚举值:

  • APP: app secret认证

  • IAM: IAM token认证

  • NONE: 无认证

retention_period

Integer

最低保留期限,单位小时。

manager

String

API审核人。

path

String

API路径。

protocol

String

API请求协议类型。

枚举值:

  • PROTOCOL_TYPE_HTTP:HTTP协议请求

  • PROTOCOL_TYPE_HTTPS:HTTPS协议请求

request_type

String

请求类型。

枚举值:

  • REQUEST_TYPE_POST:POST请求

  • REQUEST_TYPE_GET:GET请求

tags

Array of strings

标签。

visibility

String

API可见性。

枚举值:

  • WORKSPACE: 工作空间可见

  • PROJECT: 项目可见

  • DOMAIN: 租户可见

publish_type

String

发布类型(已弃用)。

枚举值:

  • PUBLISH_TYPE_PUBLIC:公开

  • PUBLISH_TYPE_PRIVATE:私有

data_mask_switch

Boolean

数据脱敏开关。

data_mask_paras

Array of DataMaskParas objects

数据脱敏配置。

body

String

请求体内容描述,仅注册类API使用。

datasource_config_list

Array of DatasourceConfig objects

多数据源配置信息,仅Groovy类API使用。

groovy_content

String

Groovy文本,仅Groovy类API使用。

request_paras

Array of RequestPara objects

API请求参数列表。

datasource_config

DatasourceConfig object

API数据源配置。

backend_config

BackendConfig object

API后端配置。仅注册类API使用

表4 DataMaskParas

参数

是否必选

参数类型

描述

column_name

String

敏感字段。

algorithm_name

String

算法名称。

algorithm_type

String

算法类型。

en_name

String

算法名称。

algorithm_parameters

String

参数。

failure_policy

String

失败策略。

枚举值:

  • SKIP:跳过, 即不做处理

  • INTERRUPT_AND_EXCEPTION:中断并抛出异常

  • SET_NULL:置空

  • DEFAULT_VALUE:默认值

表5 DatasourceConfig

参数

是否必选

参数类型

描述

type

String

数据源的类型。

枚举值:

  • MYSQL:MYSQL数据源

  • DLI:DLI数据源

  • DWS:DWS数据源

  • HIVE:HIVE数据源

  • HBASE:HBASE数据源

connection_name

String

数据连接名称。

connection_id

String

数据连接ID。

database

String

数据库名。

datatable

String

数据表名称。

table_id

String

数据表ID。

queue

String

DLI的队列名称。

access_mode

String

获取数据的模式。

枚举值:

  • SQL:SQL取数方式

  • ROW_KEY:ROW_KEY取数方式 仅适用于HBASE

  • PREFIX_FILTER:PREFIX_FILTER取数方式仅适用于HBASE

access_type

String

取数方式(已弃用)。

枚举值:

  • SCRIPT:脚本方式

  • CONFIGURAITON:配置方式

pagination

String

分页方式。

枚举值:

  • DEFAULT:默认分页

  • CUSTOM:自定义分页

sql

String

脚本模式下的SQL语句。

backend_paras

Array of ApiRequestPara objects

API后端参数。

response_paras

Array of ApiResponsePara objects

配置类API返回参数。

order_paras

Array of DatasourceOrderPara objects

排序参数。

total_size_sql

String

总条数计算脚本SQL。

表6 RequestPara

参数

是否必选

参数类型

描述

name

String

参数名。

position

String

参数的位置。

枚举值:

  • REQUEST_PARAMETER_POSITION_PATH:请求PATH内参数

  • REQUEST_PARAMETER_POSITION_HEADER:请求HEADER内参数

  • REQUEST_PARAMETER_POSITION_QUERY:请求QUERY参数

type

String

常量参数类型。

枚举值:

  • REQUEST_PARAMETER_TYPE_NUMBER:数值类型

  • REQUEST_PARAMETER_TYPE_STRING:字符串类型

description

String

参数的描述。

necessary

Boolean

参数是否必填。

example_value

String

示例值。

default_value

String

默认值。

support_null

Boolean

支持NULL值。

表7 ApiRequestPara

参数

是否必选

参数类型

描述

name

String

参数名称。

mapping

String

映射字段。

condition

String

操作符。

枚举值:

  • CONDITION_TYPE_EQ:等于

  • CONDITION_TYPE_NE:不等于

  • CONDITION_TYPE_GT:大于

  • CONDITION_TYPE_GE:大于等于

  • CONDITION_TYPE_LT:小于

  • CONDITION_TYPE_LE:小于等于

  • CONDITION_TYPE_LIKE:模糊查询如:%like%

  • CONDITION_TYPE_LIKE_L:模糊查询如:%like

  • CONDITION_TYPE_LIKE_R:模糊查询如:like%

表8 ApiResponsePara

参数

是否必选

参数类型

描述

name

String

参数名。

field

String

绑定的表字段。

type

String

常量参数类型。

枚举值:

  • REQUEST_PARAMETER_TYPE_NUMBER:数值类型

  • REQUEST_PARAMETER_TYPE_STRING:字符串类型

description

String

参数描述。

example_value

String

参数示例值。

表9 DatasourceOrderPara

参数

是否必选

参数类型

描述

name

String

排序参数名称。

field

String

对应的参数字段。

optional

Boolean

是否可选。

sort

String

排序方式。

枚举值:

  • ASC: 升序

  • DESC: 降序

  • CUSTOM: 自定义

order

Integer

排序参数顺序。

description

String

排序参数描述信息。

表10 BackendConfig

参数

是否必选

参数类型

描述

type

String

请求类型。

  • REQUEST_TYPE_POST:POST请求

  • REQUEST_TYPE_GET:GET请求

protocol

String

API请求协议类型。

  • PROTOCOL_TYPE_HTTP:HTTP协议请求

  • PROTOCOL_TYPE_HTTPS:HTTPS协议请求

host

String

后端HOST。

timeout

Integer

后端超时时间。

path

String

后端请求PATH。

backend_paras

Array of BackendRequestPara objects

API后端参数。

constant_paras

Array of BackendConstant objects

后端常量参数。

表11 BackendRequestPara

参数

是否必选

参数类型

描述

name

String

API请求参数名称。

position

String

参数的位置。

枚举值:

  • REQUEST_PARAMETER_POSITION_PATH:请求PATH内参数

  • REQUEST_PARAMETER_POSITION_HEADER:请求HEADER内参数

  • REQUEST_PARAMETER_POSITION_QUERY:请求QUERY参数

backend_para_name

String

对应的后端参数。

表12 BackendConstant

参数

是否必选

参数类型

描述

name

String

常量参数名。

type

String

常量参数类型。

枚举值:

  • REQUEST_PARAMETER_TYPE_NUMBER:数值类型

  • REQUEST_PARAMETER_TYPE_STRING:字符串类型

position

String

参数的位置。

枚举值:

  • REQUEST_PARAMETER_POSITION_PATH:请求PATH内参数

  • REQUEST_PARAMETER_POSITION_HEADER:请求HEADER内参数

  • REQUEST_PARAMETER_POSITION_QUERY:请求QUERY参数

description

String

常量参数描述。

value

String

常量参数值。

响应参数

状态码: 400

表13 响应Body参数

参数

参数类型

描述

error_code

String

错误码。

error_msg

String

错误描述。

请求示例

更新Id为10e3a4b67f59a9efe64e6bb31859221f的API信息。

/v1/0833a5737480d53b2f250010d01a7b88/service/apis/10e3a4b67f59a9efe64e6bb31859221f

响应示例

SDK代码示例

SDK代码示例如下。

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package com.huaweicloud.sdk.test;

import com.huaweicloud.sdk.core.auth.ICredential;
import com.huaweicloud.sdk.core.auth.BasicCredentials;
import com.huaweicloud.sdk.core.exception.ConnectionException;
import com.huaweicloud.sdk.core.exception.RequestTimeoutException;
import com.huaweicloud.sdk.core.exception.ServiceResponseException;
import com.huaweicloud.sdk.dataartsstudio.v1.region.dataartsstudioRegion;
import com.huaweicloud.sdk.dataartsstudio.v1.*;
import com.huaweicloud.sdk.dataartsstudio.v1.model.*;


public class UpdateApiSolution {

    public static void main(String[] args) {
        // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
        // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
        String ak = System.getenv("CLOUD_SDK_AK");
        String sk = System.getenv("CLOUD_SDK_SK");
        String projectId = "{project_id}";

        ICredential auth = new BasicCredentials()
                .withProjectId(projectId)
                .withAk(ak)
                .withSk(sk);

        dataartsstudioClient client = dataartsstudioClient.newBuilder()
                .withCredential(auth)
                .withRegion(dataartsstudioRegion.valueOf("<YOUR REGION>"))
                .build();
        UpdateApiRequest request = new UpdateApiRequest();
        request.withApiId("{api_id}");
        Api body = new Api();
        request.withBody(body);
        try {
            UpdateApiResponse response = client.updateApi(request);
            System.out.println(response.toString());
        } catch (ConnectionException e) {
            e.printStackTrace();
        } catch (RequestTimeoutException e) {
            e.printStackTrace();
        } catch (ServiceResponseException e) {
            e.printStackTrace();
            System.out.println(e.getHttpStatusCode());
            System.out.println(e.getRequestId());
            System.out.println(e.getErrorCode());
            System.out.println(e.getErrorMsg());
        }
    }
}
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# coding: utf-8

import os
from huaweicloudsdkcore.auth.credentials import BasicCredentials
from huaweicloudsdkdataartsstudio.v1.region.dataartsstudio_region import dataartsstudioRegion
from huaweicloudsdkcore.exceptions import exceptions
from huaweicloudsdkdataartsstudio.v1 import *

if __name__ == "__main__":
    # The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
    # In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
    ak = os.environ["CLOUD_SDK_AK"]
    sk = os.environ["CLOUD_SDK_SK"]
    projectId = "{project_id}"

    credentials = BasicCredentials(ak, sk, projectId)

    client = dataartsstudioClient.new_builder() \
        .with_credentials(credentials) \
        .with_region(dataartsstudioRegion.value_of("<YOUR REGION>")) \
        .build()

    try:
        request = UpdateApiRequest()
        request.api_id = "{api_id}"
        request.body = Api(
        )
        response = client.update_api(request)
        print(response)
    except exceptions.ClientRequestException as e:
        print(e.status_code)
        print(e.request_id)
        print(e.error_code)
        print(e.error_msg)
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package main

import (
	"fmt"
	"github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic"
    dataartsstudio "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/dataartsstudio/v1"
	"github.com/huaweicloud/huaweicloud-sdk-go-v3/services/dataartsstudio/v1/model"
    region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/dataartsstudio/v1/region"
)

func main() {
    // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
    // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
    ak := os.Getenv("CLOUD_SDK_AK")
    sk := os.Getenv("CLOUD_SDK_SK")
    projectId := "{project_id}"

    auth := basic.NewCredentialsBuilder().
        WithAk(ak).
        WithSk(sk).
        WithProjectId(projectId).
        Build()

    client := dataartsstudio.NewdataartsstudioClient(
        dataartsstudio.dataartsstudioClientBuilder().
            WithRegion(region.ValueOf("<YOUR REGION>")).
            WithCredential(auth).
            Build())

    request := &model.UpdateApiRequest{}
	request.ApiId = "{api_id}"
	request.Body = &model.Api{
	}
	response, err := client.UpdateApi(request)
	if err == nil {
        fmt.Printf("%+v\n", response)
    } else {
        fmt.Println(err)
    }
}

更多编程语言的SDK代码示例,请参见API Explorer的代码示例页签,可生成自动对应的SDK代码示例。

状态码

状态码

描述

204

Success。

400

BadRequest。

分享:

    相关文档

    相关产品