Update a project

Updated at:

Calls the UpdateProject API operation to update the description of a project.

Prerequisites

  • Simple Log Service is activated.

  • Simple Log Service SDK for Python is initialized.

Parameter description

def update_project(self, project_name, project_des):

Request parameters

Parameter

Type

Required

Description

project_name

String

Yes

The name of the project. The name must be globally unique. You cannot change the name after you create the project.

The name must meet the following requirements:

  • The name can contain lowercase letters, digits, and hyphens (-).

  • The name must start with a lowercase letter and end with a lowercase letter or a digit.

  • The name must be 3 to 63 characters in length.

project_des

String

Yes

Response parameters

For more information, see UpdateProject.

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"

client = LogClient(endpoint, access_key_id, access_key_secret)

# Project name
project_name = "slsproject-1"
# Project description
project_des = "test project"


# Update the project description.
def main():
    try:
        res = client.update_project(project_name, project_des)
        res.log_print()
    # If an exception is thrown, the update fails. Handle the exception.
    except Exception:
        print("Update Project failed.")


if __name__ == '__main__':
    main()

Sample response

UpdateProjectResponse:
headers: {'Server': 'AliyunSLS', 'Content-Length': '0', 'Connection': 'keep-alive', 'Access-Control-Allow-Origin': '*', 'Date': 'Wed, 20 Nov 2024 06:07:30 GMT', 'x-log-time': '1732082850', 'x-log-requestid': '673D7CA1B18EF88B8201****'}

Process finished with exit code 0