Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Situation Awareness
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive

Updating an API

Function

Update the API.

Calling Method

For details, see Calling APIs.

URI

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

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Project ID. For details about how to obtain the project ID, see Project ID and Account ID.

api_id

Yes

String

API ID.

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

User token. This parameter is mandatory when token authentication is used. You can obtain it from the value of X-Subject-Token in the response message header returned by the "Obtaining a User Token" API of the IAM service.

workspace

Yes

String

Workspace ID. For details about how to obtain the workspace ID, see Instance ID and Workspace ID.

Dlm-Type

No

String

Specifies the version type of the data service. The value can be SHARED or EXCLUSIVE.

Content-Type

Yes

String

Type (format) of the message body. This parameter is mandatory if the message body exists. If the message body does not exist, leave this parameter blank. If the request body contains Chinese characters, use charset=utf8 to specify the Chinese character set, for example, application/json;charset=utf8.

Table 3 Request body parameters

Parameter

Mandatory

Type

Description

catalog_id

No

String

Catalog ID.

name

No

String

API name

description

No

String

API description

log_flag

No

Boolean

Indicates whether to enable the access log function.

api_type

No

String

API type

Enumerated values:

  • API_SPECIFIC_TYPE_CONFIGURATION: configuration API

  • API_SPECIFIC_TYPE_SCRIPT: script API

  • API_SPECIFIC_TYPE_MYBATIS: MyBatis API

  • API_SPECIFIC_TYPE_GROOVY: Groovy API

  • API_SPECIFIC_TYPE_REGISTER: registered API

  • API_SPECIFIC_TYPE_ORCHESTRATE: orchestrated API

  • API_TYPE_CREATE: created API (obsolete)

  • API_TYPE_REGISTER: registered API (obsolete)

auth_type

No

String

Authentication mode

Enumerated values:

  • APP: app secret

  • IAM: IAM token

  • NONE: authentication disabled

retention_period

No

Integer

Minimum retention period in hours

manager

No

String

API reviewer

path

No

String

API path

protocol

No

String

API request protocol type.

Enumerated values:

  • PROTOCOL_TYPE_HTTP: HTTP

  • PROTOCOL_TYPE_HTTPS: HTTPS

request_type

No

String

Request type

Enumerated values:

  • REQUEST_TYPE_POST: POST

  • REQUEST_TYPE_GET: GET

tags

No

Array of strings

Tag

visibility

No

String

API visibility

Enumerated values:

  • WORKSPACE: visible to a workspace

  • PROJECT: visible to a project

  • DOMAIN: visible to a tenant

publish_type

No

String

Publishing type (obsolete)

Enumerated values:

  • PUBLISH_TYPE_PUBLIC: public

  • PUBLISH_TYPE_PRIVATE: private

data_mask_switch

No

Boolean

Whether to enable data masking

data_mask_paras

No

Array of DataMaskParas objects

Data masking poarameters

body

No

String

Request body description. It is available for registration APIs only.

datasource_config_list

No

Array of DatasourceConfig objects

Configuration of multiple data sources. It is available for Groovy APIs only.

groovy_content

No

String

Groovy text. It is available for Groovy APIs only.

request_paras

No

Array of RequestPara objects

List of API request parameters.

datasource_config

No

DatasourceConfig object

API data source configuration.

backend_config

No

BackendConfig object

API backend configuration. It is available for registration APIs only.

Table 4 DataMaskParas

Parameter

Mandatory

Type

Description

column_name

No

String

Sensitive field

algorithm_name

No

String

Algorithm name

algorithm_type

No

String

Algorithm type

en_name

No

String

Algorithm name

algorithm_parameters

No

String

Parameter

failure_policy

No

String

Failure policy

Enumerated values:

  • SKIP

  • INTERRUPT_AND_EXCEPTION

  • SET_NULL

  • DEFAULT_VALUE

Table 5 DatasourceConfig

Parameter

Mandatory

Type

Description

type

No

String

Data source type.

Enumerated values:

  • MYSQL

  • DLI

  • DWS

  • HIVE

  • HBASE

connection_name

No

String

Name of a data connection.

connection_id

No

String

Data connection ID.

database

No

String

Indicates the database name.

datatable

No

String

Name of a data table.

table_id

No

String

Data table ID.

queue

No

String

Queue name of DLI.

access_mode

No

String

Mode for obtaining data

Enumerated values:

  • SQL: SQL

  • ROW_KEY: ROW_KEY, available only for HBase

  • PREFIX_FILTER: PREFIX_FILTER, available only for HBase

access_type

No

String

Mode for obtaining data (obsolete)

Enumerated values:

  • SCRIPT: script

  • CONFIGURAITON: configuration

pagination

No

String

Pagination mode

Enumerated values:

  • DEFAULT: default

  • CUSTOM: custom

sql

No

String

SQL statement in script mode

backend_paras

No

Array of ApiRequestPara objects

API backend parameter.

response_paras

No

Array of ApiResponsePara objects

Return parameters of configuration APIs.

order_paras

No

Array of DatasourceOrderPara objects

Sorting parameter.

total_size_sql

No

String

SQL script for calculating the total number of records

Table 6 RequestPara

Parameter

Mandatory

Type

Description

name

No

String

Parameter name

position

No

String

Parameter position

Enumerated values:

  • REQUEST_PARAMETER_POSITION_PATH: request path

  • REQUEST_PARAMETER_POSITION_HEADER: request header

  • REQUEST_PARAMETER_POSITION_QUERY: request query

type

No

String

Constant parameter type

Enumerated values:

  • REQUEST_PARAMETER_TYPE_NUMBER: number

  • REQUEST_PARAMETER_TYPE_STRING: string

description

No

String

Parameter description.

necessary

No

Boolean

Indicates whether a parameter is mandatory.

example_value

No

String

Example value

default_value

No

String

Default value.

support_null

No

Boolean

Null supported

Table 7 ApiRequestPara

Parameter

Mandatory

Type

Description

name

No

String

Parameter name

mapping

No

String

Mapping field.

condition

No

String

Operator

Enumerated values:

  • CONDITION_TYPE_EQ: equal to

  • CONDITION_TYPE_NE: not equal to

  • CONDITION_TYPE_GT: greater than

  • CONDITION_TYPE_GE: greater than or equal to

  • CONDITION_TYPE_LT: less than

  • CONDITION_TYPE_LE: less than or equal to

  • CONDITION_TYPE_LIKE: fuzzy search, such as %like%

  • CONDITION_TYPE_LIKE_L: fuzzy search, such as %like

  • CONDITION_TYPE_LIKE_R: fuzzy search, such as like%

Table 8 ApiResponsePara

Parameter

Mandatory

Type

Description

name

No

String

Parameter name

field

No

String

Bound table field.

type

No

String

Constant parameter type

Enumerated values:

  • REQUEST_PARAMETER_TYPE_NUMBER: number

  • REQUEST_PARAMETER_TYPE_STRING: string

description

No

String

Parameter description.

example_value

No

String

Example value of a parameter.

Table 9 DatasourceOrderPara

Parameter

Mandatory

Type

Description

name

No

String

Name of a sorting parameter.

field

No

String

Indicates the corresponding parameter field.

optional

No

Boolean

Indicates whether the parameter is optional.

sort

No

String

Sorting method

Enumerated values:

  • ASC: ascending order

  • DESC: descending order

  • CUSTOM: custom order

order

No

Integer

Sequence of sorting parameters.

description

No

String

Sorting parameter description

Table 10 BackendConfig

Parameter

Mandatory

Type

Description

type

No

String

Request type

  • REQUEST_TYPE_POST: POST request

  • REQUEST_TYPE_GET: GET request

protocol

No

String

API request protocol type

  • PROTOCOL_TYPE_HTTP: HTTP

  • PROTOCOL_TYPE_HTTPS: HTTPS

host

No

String

Backend host

timeout

No

Integer

Backend timeout interval.

path

No

String

Backend request path

backend_paras

No

Array of BackendRequestPara objects

API backend parameter.

constant_paras

No

Array of BackendConstant objects

Backend constant parameter.

Table 11 BackendRequestPara

Parameter

Mandatory

Type

Description

name

No

String

API request parameter name

position

No

String

Parameter position

Enumerated values:

  • REQUEST_PARAMETER_POSITION_PATH: request path

  • REQUEST_PARAMETER_POSITION_HEADER: request header

  • REQUEST_PARAMETER_POSITION_QUERY: request query

backend_para_name

No

String

Backend parameter.

Table 12 BackendConstant

Parameter

Mandatory

Type

Description

name

No

String

Name of a constant parameter.

type

No

String

Constant parameter type

Enumerated values:

  • REQUEST_PARAMETER_TYPE_NUMBER: number

  • REQUEST_PARAMETER_TYPE_STRING: string

position

No

String

Parameter position

Enumerated values:

  • REQUEST_PARAMETER_POSITION_PATH: request path

  • REQUEST_PARAMETER_POSITION_HEADER: request header

  • REQUEST_PARAMETER_POSITION_QUERY: request query

description

No

String

Constant parameter description.

value

No

String

Constant parameter value.

Response Parameters

Status code: 400

Table 13 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

error_msg

String

Error message.

Example Requests

Update the API whose ID is 10e3a4b67f59a9efe64e6bb31859221f.

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

{
  "catalog_id" : "0",
  "name" : "creat_test0010001",
  "description" : "dws",
  "log_flag" : false,
  "auth_type" : "APP",
  "retention_period" : 0,
  "publish_type" : "PUBLISH_TYPE_PRIVATE",
  "manager" : "user",
  "path" : "/creat_test001/{p}",
  "api_type" : "API_SPECIFIC_TYPE_SCRIPT",
  "protocol" : "PROTOCOL_TYPE_HTTPS",
  "request_type" : "REQUEST_TYPE_GET",
  "request_paras" : [ {
    "name" : "p",
    "position" : "REQUEST_PARAMETER_POSITION_PATH",
    "type" : "REQUEST_PARAMETER_TYPE_NUMBER",
    "description" : "test",
    "necessary" : true,
    "example_value" : null,
    "support_null" : true,
    "default_value" : null
  } ],
  "datasource_config" : {
    "type" : "CLICKHOUSE",
    "connection_name" : "clickhouse_ywx1119238_safe",
    "connection_id" : "3d0d5941f2cb4ef08abecc01e33eabec",
    "database" : "system",
    "queue" : "dayu",
    "access_type" : "CONNECTION_TYPE_SCRIPT",
    "access_mode" : "SQL",
    "sql" : "c2VsZWN0IDEgYXMgbnVtOw==",
    "backend_paras" : [ ],
    "order_paras" : [ ],
    "pagination" : "DEFAULT"
  },
  "visibility" : "WORKSPACE"
}

Example Responses

None

SDK Sample Code

The SDK sample code is as follows.

Update the API whose ID is 10e3a4b67f59a9efe64e6bb31859221f.

 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
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.*;

import java.util.List;
import java.util.ArrayList;

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();
        DatasourceConfig datasourceConfigbody = new DatasourceConfig();
        datasourceConfigbody.withType(DatasourceConfig.TypeEnum.fromValue("CLICKHOUSE"))
            .withConnectionName("clickhouse_ywx1119238_safe")
            .withConnectionId("3d0d5941f2cb4ef08abecc01e33eabec")
            .withDatabase("system")
            .withQueue("dayu")
            .withAccessType(DatasourceConfig.AccessTypeEnum.fromValue("CONNECTION_TYPE_SCRIPT"))
            .withAccessMode(DatasourceConfig.AccessModeEnum.fromValue("SQL"))
            .withPagination(DatasourceConfig.PaginationEnum.fromValue("DEFAULT"))
            .withSql("c2VsZWN0IDEgYXMgbnVtOw==");
        List<RequestPara> listbodyRequestParas = new ArrayList<>();
        listbodyRequestParas.add(
            new RequestPara()
                .withName("p")
                .withPosition(RequestPara.PositionEnum.fromValue("REQUEST_PARAMETER_POSITION_PATH"))
                .withType(RequestPara.TypeEnum.fromValue("REQUEST_PARAMETER_TYPE_NUMBER"))
                .withDescription("test")
                .withNecessary(true)
        );
        body.withDatasourceConfig(datasourceConfigbody);
        body.withRequestParas(listbodyRequestParas);
        body.withVisibility(Api.VisibilityEnum.fromValue("WORKSPACE"));
        body.withRequestType(Api.RequestTypeEnum.fromValue("REQUEST_TYPE_GET"));
        body.withProtocol(Api.ProtocolEnum.fromValue("PROTOCOL_TYPE_HTTPS"));
        body.withPath("/creat_test001/{p}");
        body.withManager("user");
        body.withPublishType(Api.PublishTypeEnum.fromValue("PUBLISH_TYPE_PRIVATE"));
        body.withAuthType(Api.AuthTypeEnum.fromValue("APP"));
        body.withApiType(Api.ApiTypeEnum.fromValue("API_SPECIFIC_TYPE_SCRIPT"));
        body.withLogFlag(false);
        body.withDescription("dws");
        body.withName("creat_test0010001");
        body.withCatalogId("0");
        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());
        }
    }
}

Update the API whose ID is 10e3a4b67f59a9efe64e6bb31859221f.

 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# 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}"
        datasourceConfigbody = DatasourceConfig(
            type="CLICKHOUSE",
            connection_name="clickhouse_ywx1119238_safe",
            connection_id="3d0d5941f2cb4ef08abecc01e33eabec",
            database="system",
            queue="dayu",
            access_type="CONNECTION_TYPE_SCRIPT",
            access_mode="SQL",
            pagination="DEFAULT",
            sql="c2VsZWN0IDEgYXMgbnVtOw=="
        )
        listRequestParasbody = [
            RequestPara(
                name="p",
                position="REQUEST_PARAMETER_POSITION_PATH",
                type="REQUEST_PARAMETER_TYPE_NUMBER",
                description="test",
                necessary=True
            )
        ]
        request.body = Api(
            datasource_config=datasourceConfigbody,
            request_paras=listRequestParasbody,
            visibility="WORKSPACE",
            request_type="REQUEST_TYPE_GET",
            protocol="PROTOCOL_TYPE_HTTPS",
            path="/creat_test001/{p}",
            manager="user",
            publish_type="PUBLISH_TYPE_PRIVATE",
            auth_type="APP",
            api_type="API_SPECIFIC_TYPE_SCRIPT",
            log_flag=False,
            description="dws",
            name="creat_test0010001",
            catalog_id="0"
        )
        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)

Update the API whose ID is 10e3a4b67f59a9efe64e6bb31859221f.

  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
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
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}"
	typeDatasourceConfig:= model.GetDatasourceConfigTypeEnum().CLICKHOUSE
	connectionNameDatasourceConfig:= "clickhouse_ywx1119238_safe"
	connectionIdDatasourceConfig:= "3d0d5941f2cb4ef08abecc01e33eabec"
	databaseDatasourceConfig:= "system"
	queueDatasourceConfig:= "dayu"
	accessTypeDatasourceConfig:= model.GetDatasourceConfigAccessTypeEnum().CONNECTION_TYPE_SCRIPT
	accessModeDatasourceConfig:= model.GetDatasourceConfigAccessModeEnum().SQL
	paginationDatasourceConfig:= model.GetDatasourceConfigPaginationEnum().DEFAULT
	sqlDatasourceConfig:= "c2VsZWN0IDEgYXMgbnVtOw=="
	datasourceConfigbody := &model.DatasourceConfig{
		Type: &typeDatasourceConfig,
		ConnectionName: &connectionNameDatasourceConfig,
		ConnectionId: &connectionIdDatasourceConfig,
		Database: &databaseDatasourceConfig,
		Queue: &queueDatasourceConfig,
		AccessType: &accessTypeDatasourceConfig,
		AccessMode: &accessModeDatasourceConfig,
		Pagination: &paginationDatasourceConfig,
		Sql: &sqlDatasourceConfig,
	}
	nameRequestParas:= "p"
	positionRequestParas:= model.GetRequestParaPositionEnum().REQUEST_PARAMETER_POSITION_PATH
	typeRequestParas:= model.GetRequestParaTypeEnum().REQUEST_PARAMETER_TYPE_NUMBER
	descriptionRequestParas:= "test"
	necessaryRequestParas:= true
	var listRequestParasbody = []model.RequestPara{
        {
            Name: &nameRequestParas,
            Position: &positionRequestParas,
            Type: &typeRequestParas,
            Description: &descriptionRequestParas,
            Necessary: &necessaryRequestParas,
        },
    }
	visibilityApi:= model.GetApiVisibilityEnum().WORKSPACE
	requestTypeApi:= model.GetApiRequestTypeEnum().REQUEST_TYPE_GET
	protocolApi:= model.GetApiProtocolEnum().PROTOCOL_TYPE_HTTPS
	pathApi:= "/creat_test001/{p}"
	managerApi:= "user"
	publishTypeApi:= model.GetApiPublishTypeEnum().PUBLISH_TYPE_PRIVATE
	authTypeApi:= model.GetApiAuthTypeEnum().APP
	apiTypeApi:= model.GetApiApiTypeEnum().API_SPECIFIC_TYPE_SCRIPT
	logFlagApi:= false
	descriptionApi:= "dws"
	nameApi:= "creat_test0010001"
	catalogIdApi:= "0"
	request.Body = &model.Api{
		DatasourceConfig: datasourceConfigbody,
		RequestParas: &listRequestParasbody,
		Visibility: &visibilityApi,
		RequestType: &requestTypeApi,
		Protocol: &protocolApi,
		Path: &pathApi,
		Manager: &managerApi,
		PublishType: &publishTypeApi,
		AuthType: &authTypeApi,
		ApiType: &apiTypeApi,
		LogFlag: &logFlagApi,
		Description: &descriptionApi,
		Name: &nameApi,
		CatalogId: &catalogIdApi,
	}
	response, err := client.UpdateApi(request)
	if err == nil {
        fmt.Printf("%+v\n", response)
    } else {
        fmt.Println(err)
    }
}

For SDK sample code of more programming languages, see the Sample Code tab in API Explorer. SDK sample code can be automatically generated.

Update the API whose ID is 10e3a4b67f59a9efe64e6bb31859221f.

 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
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.*;

import java.util.List;
import java.util.ArrayList;

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();
        DatasourceConfig datasourceConfigbody = new DatasourceConfig();
        datasourceConfigbody.withType(DatasourceConfig.TypeEnum.fromValue("CLICKHOUSE"))
            .withConnectionName("clickhouse_ywx1119238_safe")
            .withConnectionId("3d0d5941f2cb4ef08abecc01e33eabec")
            .withDatabase("system")
            .withQueue("dayu")
            .withAccessType(DatasourceConfig.AccessTypeEnum.fromValue("CONNECTION_TYPE_SCRIPT"))
            .withAccessMode(DatasourceConfig.AccessModeEnum.fromValue("SQL"))
            .withPagination(DatasourceConfig.PaginationEnum.fromValue("DEFAULT"))
            .withSql("c2VsZWN0IDEgYXMgbnVtOw==");
        List<RequestPara> listbodyRequestParas = new ArrayList<>();
        listbodyRequestParas.add(
            new RequestPara()
                .withName("p")
                .withPosition(RequestPara.PositionEnum.fromValue("REQUEST_PARAMETER_POSITION_PATH"))
                .withType(RequestPara.TypeEnum.fromValue("REQUEST_PARAMETER_TYPE_NUMBER"))
                .withDescription("test")
                .withNecessary(true)
        );
        body.withDatasourceConfig(datasourceConfigbody);
        body.withRequestParas(listbodyRequestParas);
        body.withVisibility(Api.VisibilityEnum.fromValue("WORKSPACE"));
        body.withRequestType(Api.RequestTypeEnum.fromValue("REQUEST_TYPE_GET"));
        body.withProtocol(Api.ProtocolEnum.fromValue("PROTOCOL_TYPE_HTTPS"));
        body.withPath("/creat_test001/{p}");
        body.withManager("user");
        body.withPublishType(Api.PublishTypeEnum.fromValue("PUBLISH_TYPE_PRIVATE"));
        body.withAuthType(Api.AuthTypeEnum.fromValue("APP"));
        body.withApiType(Api.ApiTypeEnum.fromValue("API_SPECIFIC_TYPE_SCRIPT"));
        body.withLogFlag(false);
        body.withDescription("dws");
        body.withName("creat_test0010001");
        body.withCatalogId("0");
        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());
        }
    }
}

Update the API whose ID is 10e3a4b67f59a9efe64e6bb31859221f.

 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# 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}"
        datasourceConfigbody = DatasourceConfig(
            type="CLICKHOUSE",
            connection_name="clickhouse_ywx1119238_safe",
            connection_id="3d0d5941f2cb4ef08abecc01e33eabec",
            database="system",
            queue="dayu",
            access_type="CONNECTION_TYPE_SCRIPT",
            access_mode="SQL",
            pagination="DEFAULT",
            sql="c2VsZWN0IDEgYXMgbnVtOw=="
        )
        listRequestParasbody = [
            RequestPara(
                name="p",
                position="REQUEST_PARAMETER_POSITION_PATH",
                type="REQUEST_PARAMETER_TYPE_NUMBER",
                description="test",
                necessary=True
            )
        ]
        request.body = Api(
            datasource_config=datasourceConfigbody,
            request_paras=listRequestParasbody,
            visibility="WORKSPACE",
            request_type="REQUEST_TYPE_GET",
            protocol="PROTOCOL_TYPE_HTTPS",
            path="/creat_test001/{p}",
            manager="user",
            publish_type="PUBLISH_TYPE_PRIVATE",
            auth_type="APP",
            api_type="API_SPECIFIC_TYPE_SCRIPT",
            log_flag=False,
            description="dws",
            name="creat_test0010001",
            catalog_id="0"
        )
        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)

Update the API whose ID is 10e3a4b67f59a9efe64e6bb31859221f.

  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
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
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}"
	typeDatasourceConfig:= model.GetDatasourceConfigTypeEnum().CLICKHOUSE
	connectionNameDatasourceConfig:= "clickhouse_ywx1119238_safe"
	connectionIdDatasourceConfig:= "3d0d5941f2cb4ef08abecc01e33eabec"
	databaseDatasourceConfig:= "system"
	queueDatasourceConfig:= "dayu"
	accessTypeDatasourceConfig:= model.GetDatasourceConfigAccessTypeEnum().CONNECTION_TYPE_SCRIPT
	accessModeDatasourceConfig:= model.GetDatasourceConfigAccessModeEnum().SQL
	paginationDatasourceConfig:= model.GetDatasourceConfigPaginationEnum().DEFAULT
	sqlDatasourceConfig:= "c2VsZWN0IDEgYXMgbnVtOw=="
	datasourceConfigbody := &model.DatasourceConfig{
		Type: &typeDatasourceConfig,
		ConnectionName: &connectionNameDatasourceConfig,
		ConnectionId: &connectionIdDatasourceConfig,
		Database: &databaseDatasourceConfig,
		Queue: &queueDatasourceConfig,
		AccessType: &accessTypeDatasourceConfig,
		AccessMode: &accessModeDatasourceConfig,
		Pagination: &paginationDatasourceConfig,
		Sql: &sqlDatasourceConfig,
	}
	nameRequestParas:= "p"
	positionRequestParas:= model.GetRequestParaPositionEnum().REQUEST_PARAMETER_POSITION_PATH
	typeRequestParas:= model.GetRequestParaTypeEnum().REQUEST_PARAMETER_TYPE_NUMBER
	descriptionRequestParas:= "test"
	necessaryRequestParas:= true
	var listRequestParasbody = []model.RequestPara{
        {
            Name: &nameRequestParas,
            Position: &positionRequestParas,
            Type: &typeRequestParas,
            Description: &descriptionRequestParas,
            Necessary: &necessaryRequestParas,
        },
    }
	visibilityApi:= model.GetApiVisibilityEnum().WORKSPACE
	requestTypeApi:= model.GetApiRequestTypeEnum().REQUEST_TYPE_GET
	protocolApi:= model.GetApiProtocolEnum().PROTOCOL_TYPE_HTTPS
	pathApi:= "/creat_test001/{p}"
	managerApi:= "user"
	publishTypeApi:= model.GetApiPublishTypeEnum().PUBLISH_TYPE_PRIVATE
	authTypeApi:= model.GetApiAuthTypeEnum().APP
	apiTypeApi:= model.GetApiApiTypeEnum().API_SPECIFIC_TYPE_SCRIPT
	logFlagApi:= false
	descriptionApi:= "dws"
	nameApi:= "creat_test0010001"
	catalogIdApi:= "0"
	request.Body = &model.Api{
		DatasourceConfig: datasourceConfigbody,
		RequestParas: &listRequestParasbody,
		Visibility: &visibilityApi,
		RequestType: &requestTypeApi,
		Protocol: &protocolApi,
		Path: &pathApi,
		Manager: &managerApi,
		PublishType: &publishTypeApi,
		AuthType: &authTypeApi,
		ApiType: &apiTypeApi,
		LogFlag: &logFlagApi,
		Description: &descriptionApi,
		Name: &nameApi,
		CatalogId: &catalogIdApi,
	}
	response, err := client.UpdateApi(request)
	if err == nil {
        fmt.Printf("%+v\n", response)
    } else {
        fmt.Println(err)
    }
}

For SDK sample code of more programming languages, see the Sample Code tab in API Explorer. SDK sample code can be automatically generated.

Status Codes

Status Code

Description

204

Success

400

Bad request

We use cookies to improve our site and your experience. By continuing to browse our site you accept our cookie policy. Find out more

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback