Delete a saved search by using Simple Log Service SDK for Python
Call the DeleteSavedSearch operation by using Simple Log Service SDK for Python to delete a saved search.
Prerequisites
-
Simple Log Service is activated.
-
Simple Log Service SDK for Python is installed and initialized. For more information, see Initialize Simple Log Service SDK for Python.
Usage notes
-
This example uses the public endpoint for the Singapore region:
ap-southeast-1.log.aliyuncs.com. To access Simple Log Service from other Alibaba Cloud services in the same region as your project, use the private endpoint:ap-southeast-1-intranet.log.aliyuncs.com. For more information about endpoint-to-region mappings, see Endpoints. -
You can call the ListSavedSearch operation to query the names of existing saved searches before you delete a saved search.
Parameters
def delete_savedsearch(self, project, entity):
Request parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| project | String | Yes | The name of the project. Projects in Simple Log Service isolate resources and control access. For more information, see Manage a project. |
| entity | String | Yes | The name of the saved search. |
Response parameters
For information about the response parameters, see DeleteSavedSearch.
Sample code
from aliyun.log import LogClient
import os
# In this example, the AccessKey ID and AccessKey secret are obtained from environment variables.
access_key_id = os.environ.get('ALIBABA_CLOUD_ACCESS_KEY_ID', '')
access_key_secret = os.environ.get('ALIBABA_CLOUD_ACCESS_KEY_SECRET', '')
# Specify a Simple Log Service endpoint.
endpoint = "ap-southeast-1.log.aliyuncs.com"
# Instantiate the LogClient class.
client = LogClient(endpoint, access_key_id, access_key_secret)
project = "proj-test-1"
entity = "savedsearch-1"
def main():
# Delete the saved search.
res = client.delete_savedsearch(project, entity)
res.log_print()
if __name__ == '__main__':
main()
Sample response
header: {'Server': 'AliyunSLS', 'Content-Length': '0', 'Connection': 'keep-alive', 'Access-Control-Allow-Origin': '*', 'Date': 'Tue, 15 Oct 2024 07:18:14 GMT', 'x-log-time': '1728976694', 'x-log-requestid': '670E17368A944B829A8D****'}
Process finished with exit code 0
References
-
For more information about saved search API operations, see:
-
For more code samples, see aliyun-log-python-sdk.