Lists all projects in a specified resource group in the current region.
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 list_project(self, offset=0, size=100, project_name_pattern=None, resource_group_id=''):Request parameters
Parameter | Type | Required | Description |
offset | integer | No | The line from which the query starts. Default value: 0. |
size | integer | No | The number of entries per page. Default value: 100. Maximum: 500. |
project_name_pattern | string | No | The project name used for fuzzy matching. For example, if you specify aliyun-project, the results include projects such as aliyun-project-sls and hangzhou-aliyun-project.
|
resource_group_id | string | No | Resource group ID. If not specified, the default resource group is used. |
Response parameters
For more information about the response parameters, see ListProject.
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)
# List projects in the default resource group in the current region.
def main():
try:
response = client.list_project()
response.log_print()
except Exception as error:
print(error)
if __name__ == '__main__':
main()