All Products
Search
Document Center

Simple Log Service:Update a project

Last Updated:Dec 02, 2024

Call the UpdateProject API to modify the project's description.

Prerequisites

Parameter description

def update_project(self, project_name, project_des):

Request parameters

Parameter

Type

Required

Description

project_name

String

Yes

The project name must be globally unique within an Alibaba Cloud region and cannot be modified after creation. The naming conventions are as follows:

  • The project name must be globally unique.

  • It can contain only lowercase letters, digits, and hyphens (-).

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

  • It must be 3 to 63 characters in length.

project_des

String

Yes

Description of the project. The description must not contain angle brackets (<>), apostrophes ('), backslashes (\), double quotes ("), or double backslashes (\\). It can contain up to 64 characters.

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

References