diff --git a/obshell/__init__.py b/obshell/__init__.py index 19662f4..8ab8201 100644 --- a/obshell/__init__.py +++ b/obshell/__init__.py @@ -14,7 +14,7 @@ # limitations under the License. from .service.client_set import ClientSet -from .service.client_v1 import TaskExecuteFailedError, OBShellHandleError +from .service.client_v1 import TaskExecuteFailedError, OBShellHandleError, IllegalOperatorError from .service.client_v1 import IllegalOperatorError, ClientV1 __all__ = ('ClientSet', 'TaskExecuteFailedError', diff --git a/obshell/model/__init__.py b/obshell/model/__init__.py index e5b00a4..b0c90fd 100644 --- a/obshell/model/__init__.py +++ b/obshell/model/__init__.py @@ -12,3 +12,5 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + +from .tenant import ZoneParam,ModifyReplicaParam diff --git a/obshell/model/format.py b/obshell/model/format.py new file mode 100644 index 0000000..ff15b7c --- /dev/null +++ b/obshell/model/format.py @@ -0,0 +1,26 @@ +# coding: utf-8 +# Copyright (c) 2024 OceanBase. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +def model_str(cls): + def __convert_value(value): + if isinstance(value, list): + return [__convert_value(item) for item in value] + elif isinstance(value, dict): + return {f"{key}": __convert_value(value) for key, value in value.items()} + else: + return str(value) + members = ", ".join( + f"\"{k}\":\"{__convert_value(v)}\"" for k, v in cls.__dict__.items()) + return '{' + members.replace("'", "\"") + '}' diff --git a/obshell/model/info.py b/obshell/model/info.py index 038eecc..d6f3683 100644 --- a/obshell/model/info.py +++ b/obshell/model/info.py @@ -16,23 +16,11 @@ from typing import List from enum import Enum +from .format import model_str from obshell.model.version import Version from obshell.auth.base import AuthVersion -def model_str(cls): - def __convert_value(value): - if isinstance(value, list): - return [__convert_value(item) for item in value] - elif isinstance(value, dict): - return {f"{key}": __convert_value(value) for key, value in value.items()} - else: - return str(value) - members = ", ".join( - f"\"{k}\":\"{__convert_value(v)}\"" for k, v in cls.__dict__.items()) - return '{' + members.replace("'", "\"") + '}' - - class AgentInfo: def __init__(self, diff --git a/obshell/model/ob.py b/obshell/model/ob.py index 2d01a58..bc7ff66 100644 --- a/obshell/model/ob.py +++ b/obshell/model/ob.py @@ -13,7 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -from .info import model_str +from .format import model_str class UpgradePkgInfo: diff --git a/obshell/model/recyclebin.py b/obshell/model/recyclebin.py index 249a052..f351044 100644 --- a/obshell/model/recyclebin.py +++ b/obshell/model/recyclebin.py @@ -13,7 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -from .info import model_str +from .format import model_str class RecyclebinTenantInfo: diff --git a/obshell/model/resource_pool.py b/obshell/model/resource_pool.py index a22f7d8..bd59e7c 100644 --- a/obshell/model/resource_pool.py +++ b/obshell/model/resource_pool.py @@ -13,7 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -from .info import model_str +from .format import model_str from .unit import UnitConfig diff --git a/obshell/model/task.py b/obshell/model/task.py index eb491b6..3a04b69 100644 --- a/obshell/model/task.py +++ b/obshell/model/task.py @@ -15,7 +15,7 @@ import json from enum import Enum -from .info import model_str +from .format import model_str class State(Enum): diff --git a/obshell/model/tenant.py b/obshell/model/tenant.py index 298356c..52abe37 100644 --- a/obshell/model/tenant.py +++ b/obshell/model/tenant.py @@ -13,7 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -from .info import model_str +from .format import model_str from .resource_pool import ResourcePoolWithUnit diff --git a/obshell/model/unit.py b/obshell/model/unit.py index 96c583f..308cbc9 100644 --- a/obshell/model/unit.py +++ b/obshell/model/unit.py @@ -13,7 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -from .info import model_str +from .format import model_str class UnitConfig: diff --git a/setup.py b/setup.py index d7dc2fb..5fc85be 100644 --- a/setup.py +++ b/setup.py @@ -17,7 +17,7 @@ setup( name='obshell', - version='0.0.1', + version='0.0.2', packages=find_packages(), description='OBShell SDK is a powerful and easy-to-use Python library that provides developers with simple method calls to interact with the OBShell. OBShell SDK allows for quick integration, enabling developers to efficiently implement features and focus on creating value in their applications.', long_description=open('README.md').read(),