Skip to content

Commit

Permalink
fix some bugs (aliyun#200)
Browse files Browse the repository at this point in the history
* 1.fix ListResource bug
2.remove schema ext_info check

* 1.modify param desc
  • Loading branch information
zhangtiantianx authored Oct 25, 2021
1 parent 49b7b92 commit 3937805
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
10 changes: 5 additions & 5 deletions aliyun/log/logclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -3523,8 +3523,8 @@ def create_resource(self, resource):
Unsuccessful operation will cause an LogException.
resource options: resource_name resource_type [schema:List[ResourceSchemaItem],description,ext_info]
:type resource: instance:Resource
:param resource: resource obj
:type resource: Resource
:param resource: instance of Resource
"""
if not isinstance(resource, Resource):
raise TypeError("record must be instance of Resource ")
Expand Down Expand Up @@ -3560,7 +3560,7 @@ def delete_resource(self, resource_name):
:param resource_name: resource name
"""
if not isinstance(resource_name, str):
raise TypeError("resource_name type must be %s" % str)
raise TypeError("resource_name type must be str")
headers = {}
params = {}
resource = "/resources/" + resource_name
Expand All @@ -3573,7 +3573,7 @@ def update_resource(self, resource):
resource options: resource_name [schema,description,ext_info]
:type resource: Resource
:param resource: resource
:param resource: instance of Resource
"""
if not isinstance(resource, Resource):
raise TypeError("resource type must be Resource instance")
Expand Down Expand Up @@ -3603,7 +3603,7 @@ def get_resource(self, resource_name):
:param resource_name: resource name
"""
if not isinstance(resource_name, str):
raise TypeError("resource_name type must be %s" % str)
raise TypeError("resource_name type must be str")
headers = {}
params = {}
resource = "/resources/" + resource_name
Expand Down
14 changes: 6 additions & 8 deletions aliyun/log/resource_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ class ResourceSchemaItem:
}

def __init__(self, column=None, ext_info=None, schema_type=None):
check_type_for_init(column=column, ext_info=ext_info, schema_type=schema_type, instance=self)
check_type_for_init(column=column, schema_type=schema_type, instance=self)
self.column = column
self.ext_info = ext_info
self.type = schema_type
Expand All @@ -154,7 +154,6 @@ def set_column(self, column):
def get_ext_info(self):
return self.ext_info

@check_params("ext_info", str)
def set_ext_info(self, ext_info):
self.ext_info = ext_info

Expand All @@ -170,7 +169,7 @@ def to_dict(self):
if self.get_column():
schema_dict["column"] = self.get_column()
if self.get_ext_info():
schema_dict["ext_info"] = self.get_column()
schema_dict["ext_info"] = self.get_ext_info()
if self.get_schema_type():
schema_dict["type"] = self.get_schema_type()
return schema_dict
Expand Down Expand Up @@ -297,8 +296,6 @@ def to_dict(self):
result["create_time"] = self.create_time
if self.last_modify_time:
result["last_modify_time"] = self.last_modify_time
if self.last_modify_time:
result["last_modify_time"] = self.last_modify_time
if self.resource_name:
result["resource_name"] = self.resource_name
if self.resource_type:
Expand All @@ -315,9 +312,10 @@ def to_dict(self):
def from_dict(cls, dict_data):
schema_list = Util.convert_unicode_to_str(json.loads(dict_data.get("schema"))).get("schema")
schema_instance_list = []
for schema in schema_list:
schema_instance_list.append(ResourceSchemaItem(column=schema.get("column"), schema_type=schema.get("type"),
ext_info=schema.get("ext_info")))
if schema_list:
for schema in schema_list:
schema_instance_list.append(ResourceSchemaItem(column=schema.get("column"), schema_type=schema.get("type"),
ext_info=schema.get("ext_info")))
resource = Resource()
resource.set_resource_name(dict_data.get("name"))
resource.set_description(dict_data.get('description'))
Expand Down

0 comments on commit 3937805

Please sign in to comment.