服務(wù)數(shù)據(jù)刪除API
更新時(shí)間:
1. 根據(jù)ids刪除
1.1. 參數(shù)3
1.1.1. 入?yún)?/b>
參數(shù) | 類型 | 是否必傳 | 說(shuō)明 |
serviceId | Long | 是 | 服務(wù)id |
ids | List | 是 | 待刪除數(shù)據(jù)的主鍵id |
{
"serviceId": 1,
"ids": [1]
}
1.1.2. 出參
參數(shù)名稱 | 參數(shù)類型 | 參數(shù)描述 | ||
code | Integer | 錯(cuò)誤碼 | ||
success | Boolean | 是否成功 | ||
requestId | String | 請(qǐng)求id | ||
data | Object | 響應(yīng)內(nèi)容 | ||
msg | String | 響應(yīng)信息 |
{
"code":200,
"data": null,
"msg": null,
"requestId":"326F95A0-720A-5293-BDA7-4B91B09E636B",
"success":true
}
1.2. SDK調(diào)用
1.2.1. Java SDK
1.2.1.1. Maven依賴
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>aliyun-java-sdk-core</artifactId>
<version>4.6.0</version>
</dependency>
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>alinlp20200629</artifactId>
<version>2.2.0</version>
</dependency>
1.2.1.2. 調(diào)用示例
/**
* 使用AK&SK初始化賬號(hào)Client
* @param accessKeyId
* @param accessKeySecret
* @return Client
* @throws Exception
*/
public static Client createClient(String accessKeyId, String accessKeySecret) throws Exception {
Config config = new Config()
// 必填,您的 AccessKey ID
.setAccessKeyId(accessKeyId)
// 必填,您的 AccessKey Secret
.setAccessKeySecret(accessKeySecret);
// Endpoint 請(qǐng)參考 https://api.aliyun.com/product/alinlp
config.endpoint = "alinlp.cn-beijing.aliyuncs.com";
return new Client(config);
}
public static void main(String[] args_) throws Exception {
DeleteServiceDataByIds();
}
public static void DeleteServiceDataByIds() throws Exception {
// 工程代碼泄露可能會(huì)導(dǎo)致 AccessKey 泄露,并威脅賬號(hào)下所有資源的安全性。以下代碼示例僅供參考,建議使用更安全的 STS 方式,更多鑒權(quán)訪問(wèn)方式請(qǐng)參見(jiàn):http://bestwisewords.com/document_detail/378657.html
Client client = createClient(AccessConstant.AK3, AccessConstant.SK3);
DeleteServiceDataByIdsRequest requset = new DeleteServiceDataByIdsRequest()
.setServiceId(1L).setIds(Arrays.asList("1"));
try {
DeleteServiceDataByIdsResponse response = client.deleteServiceDataByIds(requset);
System.out.println(JSON.toJSONString(response.getBody(), SerializerFeature.PrettyFormat));
} catch (Exception e) {
e.printStackTrace();
}
}
1.2.2. Python SDK
1.2.2.1. pip源
pip install aliyun-python-sdk-alinlp==1.0.23
pip install aliyun-python-sdk-core
1.2.2.2. 調(diào)用示例
from aliyunsdkalinlp.request.v20200629 import DeleteServiceDataByIdsRequest
from aliyunsdkcore.client import AcsClient
from aliyunsdkcore.auth.credentials import AccessKeyCredential
import os
os.environ['ALIBABA_CLOUD_ACCESS_KEY_ID'] = 'xxxx'
os.environ['ALIBABA_CLOUD_ACCESS_KEY_SECRET'] = 'xxxx'
def delete_service_data():
credentials = AccessKeyCredential(os.environ['ALIBABA_CLOUD_ACCESS_KEY_ID'],
os.environ['ALIBABA_CLOUD_ACCESS_KEY_SECRET'])
client = AcsClient(region_id='cn-beijing', credential=credentials)
request = DeleteServiceDataByIdsRequest.DeleteServiceDataByIdsRequest()
request.set_ServiceId(1)
request.set_Ids([1])
request.set_accept_format('json')
response = client.do_action_with_exception(request)
# python2: print(response)
print(str(response, encoding='utf-8'))
if __name__ == '__main__':
delete_service_data()
2. 根據(jù)條件刪除
2.1. 參數(shù)
2.1.1. 入?yún)?/b>
參數(shù) | 類型 | 是否必傳 | 說(shuō)明 |
serviceId | Long | 是 | 服務(wù)id |
conditions | Object | 是 | 刪除條件,相當(dāng)于es刪除api的body,符合es的參數(shù)格式 |
{
"serviceId": 1,
"conditions": {
"query": {
"term": {
"id": 1
}
}
}
}
2.1.2. 出參
參數(shù)名稱 | 參數(shù)類型 | 參數(shù)描述 | ||
code | Integer | 錯(cuò)誤碼 | ||
success | Boolean | 是否成功 | ||
requestId | String | 請(qǐng)求id | ||
data | Object | 響應(yīng)內(nèi)容 | ||
msg | String | 響應(yīng)信息 |
{
"code":200,
"data": null,
"msg": null,
"requestId":"326F95A0-720A-5293-BDA7-4B91B09E636B",
"success":true
}
2.2. SDK調(diào)用
2.2.1. Java SDK
2.2.1.1. Maven依賴
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>aliyun-java-sdk-core</artifactId>
<version>4.6.0</version>
</dependency>
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>alinlp20200629</artifactId>
<version>2.2.0</version>
</dependency>
2.2.1.2. 調(diào)用示例
/**
* 使用AK&SK初始化賬號(hào)Client
* @param accessKeyId
* @param accessKeySecret
* @return Client
* @throws Exception
*/
public static Client createClient(String accessKeyId, String accessKeySecret) throws Exception {
Config config = new Config()
// 必填,您的 AccessKey ID
.setAccessKeyId(accessKeyId)
// 必填,您的 AccessKey Secret
.setAccessKeySecret(accessKeySecret);
// Endpoint 請(qǐng)參考 https://api.aliyun.com/product/alinlp
config.endpoint = "alinlp.cn-beijing.aliyuncs.com";
return new Client(config);
}
public static void main(String[] args_) throws Exception {
DeleteServiceDataByConditions();
}
public static void DeleteServiceDataByConditions() throws Exception {
// 工程代碼泄露可能會(huì)導(dǎo)致 AccessKey 泄露,并威脅賬號(hào)下所有資源的安全性。以下代碼示例僅供參考,建議使用更安全的 STS 方式,更多鑒權(quán)訪問(wèn)方式請(qǐng)參見(jiàn):http://bestwisewords.com/document_detail/378657.html
Client client = createClient(AccessConstant.AK3, AccessConstant.SK3);
Map<String, JSONObject> conditions = new HashMap<>();
conditions.put("query", JSON.parseObject("{\"term\":{\"id\":1}}"));
DeleteServiceDataByConditionsRequest requset = new DeleteServiceDataByConditionsRequest()
.setServiceId(1L).setConditions(conditions);
try {
DeleteServiceDataByConditionsResponse response = client.deleteServiceDataByConditions(requset);
System.out.println(JSON.toJSONString(response.getBody(), SerializerFeature.PrettyFormat));
} catch (Exception e) {
e.printStackTrace();
}
}
2.2.2. Python SDK
2.2.2.1. pip源
pip install aliyun-python-sdk-alinlp==1.0.23
pip install aliyun-python-sdk-core
2.2.2.2. 調(diào)用示例
from aliyunsdkalinlp.request.v20200629 import DeleteServiceDataByConditionsRequest
from aliyunsdkcore.client import AcsClient
from aliyunsdkcore.auth.credentials import AccessKeyCredential
import os
os.environ['ALIBABA_CLOUD_ACCESS_KEY_ID'] = 'xxxx'
os.environ['ALIBABA_CLOUD_ACCESS_KEY_SECRET'] = 'xxxx'
def delete_service_data():
credentials = AccessKeyCredential(os.environ['ALIBABA_CLOUD_ACCESS_KEY_ID'],
os.environ['ALIBABA_CLOUD_ACCESS_KEY_SECRET'])
client = AcsClient(region_id='cn-beijing', credential=credentials)
request = DeleteServiceDataByConditionsRequest.DeleteServiceDataByConditionsRequest()
request.set_ServiceId(1)
request.set_Conditions(json.loads("{\"serviceId\":1,\"conditions\":{\"query\":{\"term\":{\"id\":1}}}}"))
request.set_accept_format('json')
response = client.do_action_with_exception(request)
# python2: print(response)
print(str(response, encoding='utf-8'))
if __name__ == '__main__':
delete_service_data()
文檔內(nèi)容是否對(duì)您有幫助?