Skip to content

Commit

Permalink
feat: 🎸 Bump 0.9.11, support project data redundancy (#304)
Browse files Browse the repository at this point in the history
  • Loading branch information
crimson-gao authored Aug 19, 2024
1 parent 9552eef commit 67f74af
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 4 deletions.
10 changes: 7 additions & 3 deletions aliyun/log/logclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -2529,7 +2529,7 @@ def modify_scheduled_sql_job_instance_state(self, project, job_name, instance_id
(resp, header) = self._send("PUT", project, None, resource, params, headers)
return ModifyScheduledSqlJobStateResponse(header, resp)

def create_project(self, project_name, project_des, resource_group_id=''):
def create_project(self, project_name, project_des, resource_group_id='', data_redundancy_type=None):
""" Create a project
Unsuccessful operation will cause an LogException.
Expand All @@ -2539,17 +2539,21 @@ def create_project(self, project_name, project_des, resource_group_id=''):
:type project_des: string
:param project_des: the description of a project
type resource_group_id: string
:type resource_group_id: string
:param resource_group_id: the resource group id, the project created will put in the resource group
:type data_redundancy_type: string
:param data_redundancy_type: the data redundancy type, LRS or ZRS
:return: CreateProjectResponse
:raise: LogException
"""

params = {}
body = {"projectName": project_name, "description": project_des, "resourceGroupId": resource_group_id}

if data_redundancy_type is not None:
body["dataRedundancyType"] = data_redundancy_type
body = six.b(json.dumps(body))
headers = {'Content-Type': 'application/json', 'x-log-bodyrawsize': str(len(body))}
resource = "/"
Expand Down
5 changes: 5 additions & 0 deletions aliyun/log/project_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ def __init__(self, resp, header):
self.lastModifyTime = resp['lastModifyTime']
# resourceGroupId is optional for some old backend releases
self.resourceGroupId = resp.get('resourceGroupId', '')
self.dataRedundancyType = resp.get('dataRedundancyType')

def get_owner(self):
return self.owner
Expand All @@ -72,6 +73,9 @@ def get_last_modify_time(self):

def get_resource_group_id(self):
return self.resourceGroupId

def get_data_redundancy_type(self):
return self.dataRedundancyType

def log_print(self):
print('GetProjectResponse:')
Expand All @@ -84,6 +88,7 @@ def log_print(self):
print('create_time:' + self.get_create_time())
print('last_modify_time:' + self.get_last_modify_time())
print('resource_group_id:' + self.get_resource_group_id())
print('dataRedundancyType:' + self.get_data_redundancy_type())

class ListProjectResponse(LogResponse):
def __init__(self, resp, header):
Expand Down
2 changes: 1 addition & 1 deletion aliyun/log/version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = '0.9.10'
__version__ = '0.9.11'

import sys
OS_VERSION = str(sys.platform)
Expand Down
14 changes: 14 additions & 0 deletions tests/sample_data_redundancy.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from aliyun.log import LogClient

client = LogClient('cn-hangzhou.log.aliyuncs.com',
'your access key id',
'your access key secret')

project = 'your-project'

client.create_project(project, 'hello', data_redundancy_type='LRS') # LRS or ZRS
resp = client.get_project(project)

print(resp.get_data_redundancy_type())
assert resp.get_data_redundancy_type() == 'LRS'
client.delete_project(project)

0 comments on commit 67f74af

Please sign in to comment.