Updating an API
Function
Update the API.
Calling Method
For details, see Calling APIs.
URI
PUT /v1/{project_id}/service/apis/{api_id}
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
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. |
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:
|
auth_type |
No |
String |
Authentication mode Enumerated values:
|
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:
|
request_type |
No |
String |
Request type Enumerated values:
|
tags |
No |
Array of strings |
Tag |
visibility |
No |
String |
API visibility Enumerated values:
|
publish_type |
No |
String |
Publishing type (obsolete) Enumerated values:
|
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. |
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:
|
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
type |
No |
String |
Data source type. Enumerated values:
|
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:
|
access_type |
No |
String |
Mode for obtaining data (obsolete) Enumerated values:
|
pagination |
No |
String |
Pagination mode Enumerated values:
|
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 |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
name |
No |
String |
Parameter name |
position |
No |
String |
Parameter position Enumerated values:
|
type |
No |
String |
Constant parameter type Enumerated values:
|
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 |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
name |
No |
String |
Parameter name |
mapping |
No |
String |
Mapping field. |
condition |
No |
String |
Operator Enumerated values:
|
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
name |
No |
String |
Parameter name |
field |
No |
String |
Bound table field. |
type |
No |
String |
Constant parameter type Enumerated values:
|
description |
No |
String |
Parameter description. |
example_value |
No |
String |
Example value of a parameter. |
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:
|
order |
No |
Integer |
Sequence of sorting parameters. |
description |
No |
String |
Sorting parameter description |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
type |
No |
String |
Request type
|
protocol |
No |
String |
API request protocol type
|
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. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
name |
No |
String |
API request parameter name |
position |
No |
String |
Parameter position Enumerated values:
|
backend_para_name |
No |
String |
Backend parameter. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
name |
No |
String |
Name of a constant parameter. |
type |
No |
String |
Constant parameter type Enumerated values:
|
position |
No |
String |
Parameter position Enumerated values:
|
description |
No |
String |
Constant parameter description. |
value |
No |
String |
Constant parameter value. |
Response Parameters
Status code: 400
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.
Status Codes
Status Code |
Description |
---|---|
204 |
Success |
400 |
Bad request |
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot