Call the DeleteProject API to delete a project.
Prerequisites
Prerequisites
Simple Log Service is activated.
The Simple Log Service SDK for Python is initialized. For more information, see Initialize Simple Log Service SDK for Python.
Parameter description
def delete_project(self, project_name):
Request parameters
Parameter | Type | Required | Description |
project_name | String | Yes | The name of the Simple Log Service project. For more information, see Manage a project. |
Response parameters
For more information, see DeleteProject.
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', '')
# The Simple Log Service endpoint.
endpoint = "cn-hangzhou.log.aliyuncs.com"
# Create a Simple Log Service client.
client = LogClient(endpoint, access_key_id, access_key_secret)
# Project name
project_name = "slsproject-1"
# Delete the specified project.
def main():
try:
response = client.delete_project(project_name)
response.log_print()
except Exception as error:
print(error)
if __name__ == '__main__':
main()
Sample response
DeleteProjectResponse:
headers: {'Server': 'AliyunSLS', 'Content-Length': '0', 'Connection': 'keep-alive', 'Access-Control-Allow-Origin': '*', 'Date': 'Thu, 21 Nov 2024 08:10:54 GMT', 'x-log-time': '1732176654', 'x-log-requestid': '673EEB0D6BC05B398EB6****'}
Process finished with exit code 0
References
For more information about project-related API operations, see the following topics:
For more code samples, see aliyun-log-python-sdk on GitHub.