56 lines
2.1 KiB
Python
56 lines
2.1 KiB
Python
|
# -*- coding: utf-8 -*-
|
||
|
# This file is auto-generated, don't edit it. Thanks.
|
||
|
import os
|
||
|
from alibabacloud_bailian20231229.client import Client as bailian20231229Client
|
||
|
from alibabacloud_tea_openapi import models as open_api_models
|
||
|
from alibabacloud_bailian20231229 import models as bailian_20231229_models
|
||
|
from alibabacloud_tea_util import models as util_models
|
||
|
from alibabacloud_tea_util.client import Client as UtilClient
|
||
|
|
||
|
def create_client() -> bailian20231229Client:
|
||
|
"""
|
||
|
使用AK&SK初始化账号Client
|
||
|
@return: Client
|
||
|
@throws Exception
|
||
|
"""
|
||
|
config = open_api_models.Config(
|
||
|
access_key_id=os.environ['ALIBABA_CLOUD_ACCESS_KEY_ID'],
|
||
|
access_key_secret=os.environ['ALIBABA_CLOUD_ACCESS_KEY_SECRET']
|
||
|
)
|
||
|
config.endpoint = 'bailian.cn-beijing.aliyuncs.com'
|
||
|
return bailian20231229Client(config)
|
||
|
|
||
|
def delete_index(client: bailian20231229Client, workspace_id: str, index_id: str) -> None:
|
||
|
delete_index_request = bailian_20231229_models.DeleteIndexRequest(
|
||
|
index_id=index_id
|
||
|
)
|
||
|
runtime = util_models.RuntimeOptions()
|
||
|
headers = {}
|
||
|
try:
|
||
|
response = client.delete_index_with_options(workspace_id, delete_index_request, headers, runtime)
|
||
|
print("API Response:", response)
|
||
|
except Exception as error:
|
||
|
print(error.message)
|
||
|
print(error.data.get("Recommend"))
|
||
|
UtilClient.assert_as_string(error.message)
|
||
|
|
||
|
async def delete_index_async(client: bailian20231229Client, workspace_id: str, index_id: str) -> None:
|
||
|
delete_index_request = bailian_20231229_models.DeleteIndexRequest(
|
||
|
index_id=index_id
|
||
|
)
|
||
|
runtime = util_models.RuntimeOptions()
|
||
|
headers = {}
|
||
|
try:
|
||
|
response = await client.delete_index_with_options_async(workspace_id, delete_index_request, headers, runtime)
|
||
|
print("API Response:", response)
|
||
|
except Exception as error:
|
||
|
print(error.message)
|
||
|
print(error.data.get("Recommend"))
|
||
|
UtilClient.assert_as_string(error.message)
|
||
|
|
||
|
if __name__ == '__main__':
|
||
|
workspace_id = os.environ['DASHSCOPE_WORKSPACE_ID']
|
||
|
index_id = 'pg5rrsv26x'
|
||
|
client = create_client()
|
||
|
delete_index(client, workspace_id, index_id)
|