Update public source
This commit is contained in:
@@ -42,6 +42,37 @@ class MethodService:
|
||||
|
||||
return method_id
|
||||
|
||||
def update_method(
|
||||
self,
|
||||
method_id: str,
|
||||
name: str,
|
||||
description: str | None = None,
|
||||
) -> None:
|
||||
if not method_id:
|
||||
raise MethodServiceError(
|
||||
"Method ID must not be empty"
|
||||
)
|
||||
|
||||
if not name or not name.strip():
|
||||
raise MethodServiceError(
|
||||
"Method name must not be empty"
|
||||
)
|
||||
|
||||
if self._methods.get_method(method_id) is None:
|
||||
raise MethodServiceError(
|
||||
"Method not found"
|
||||
)
|
||||
|
||||
self._methods.update_method(
|
||||
method_id=method_id,
|
||||
name=name.strip(),
|
||||
description=(
|
||||
description.strip()
|
||||
if description
|
||||
else None
|
||||
),
|
||||
)
|
||||
|
||||
def create_method_version(
|
||||
self,
|
||||
method_id: str,
|
||||
@@ -64,6 +95,39 @@ class MethodService:
|
||||
definition=definition,
|
||||
)
|
||||
|
||||
def update_method_version(
|
||||
self,
|
||||
method_id: str,
|
||||
version: int,
|
||||
definition: dict[str, Any],
|
||||
) -> None:
|
||||
if version <= 0:
|
||||
raise MethodServiceError(
|
||||
"Method version must be greater than zero"
|
||||
)
|
||||
|
||||
try:
|
||||
validate_method_definition(definition)
|
||||
except MethodDefinitionError as exc:
|
||||
raise MethodServiceError(str(exc)) from exc
|
||||
|
||||
if (
|
||||
self._methods.get_method_version(
|
||||
method_id,
|
||||
version,
|
||||
)
|
||||
is None
|
||||
):
|
||||
raise MethodServiceError(
|
||||
"Method version not found"
|
||||
)
|
||||
|
||||
self._methods.update_method_version(
|
||||
method_id=method_id,
|
||||
version=version,
|
||||
definition=definition,
|
||||
)
|
||||
|
||||
def create_next_method_version(
|
||||
self,
|
||||
method_id: str,
|
||||
|
||||
Reference in New Issue
Block a user