Modify a resource group
Call the ChangeResourceGroup API to modify the resource group associated with a project.
Prerequisites
-
Simple Log Service is activated. For more information, see Activate Simple Log Service.
-
The Simple Log Service SDK for Python is initialized. For more information, see Initialize Simple Log Service SDK for Python.
Parameter description
def change_resource_group(self, resource_id, resource_group_id, resource_type="PROJECT"):Request parameters
Parameter | Type | Required | Description | Example |
resource_id | String | Yes | The name of the project. | ali-test-project |
resource_group_id | String | Yes | The ID of the resource group. Obtain the ID by viewing the basic information about the resource group. | rg-ae******ey |
resource_type | String | No | The type of the resource. Only PROJECT is supported. | PROJECT |
Response parameters
For information about the response parameters, see ChangeResourceGroup.
Sample code
import os
from aliyun.log import LogClient
def main():
# Specify a Simple Log Service endpoint.
endpoint = "cn-hangzhou.log.aliyuncs.com"
# In this example, the AccessKey ID and AccessKey secret are obtained from environment variables.
accessKeyId = os.environ.get('ALIBABA_CLOUD_ACCESS_KEY_ID', '')
accessKey = os.environ.get('ALIBABA_CLOUD_ACCESS_KEY_SECRET', '')
project_name = "ali-test-project"
client = LogClient(endpoint, accessKeyId, accessKey, "")
project_info_res = client.get_project(project_name)
print(project_info_res.get_resource_group_id())
res = client.change_resource_group(project_name, project_info_res.get_resource_group_id(), "PROJECT")
res.log_print()
print(project_info_res.get_resource_group_id())
if __name__ == '__main__':
main()
Sample response
rg-acf******gtpfpa
header: {'Server': 'AliyunSLS', 'Content-Length': '0', 'Connection': 'keep-alive', 'Access-Control-Allow-Origin': '*', 'Date': 'Thu, 31 Oct 2024 02:47:22 GMT', 'x-log-time': '1730342842', 'x-log-requestid': '6722EFB9FB9C5E203F3DCEAD'}
rg-acf******gtpfpa
Process finished with exit code 0References
For more information, see ChangeResourceGroup.
For more sample code, see Alibaba Cloud Simple Log Service SDK for Python on GitHub.