Files
codegenerator/codegenerator/metadata/load_balancer.py
Artem Goncharov a75eb01672 Start building parts of TUI
Simplify TUI extension by generation of resource filter structure and
corresponding execute traits.

Change-Id: I35fe5c9e568c13cc35183588fe3f7bd4e1c45c72
2024-12-16 13:25:07 +00:00

60 lines
1.9 KiB
Python

# 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.
#
import typing as ty
from codegenerator.types import OperationModel
from codegenerator.types import OperationTargetParams
from codegenerator.metadata.base import MetadataBase
class LoadBalancerMetadata(MetadataBase):
@staticmethod
def get_operation_key(
operation, path: str, method: str, resource_name: str
) -> ty.Tuple[str | None, bool]:
skip: bool = False
operation_key: str | None = None
path_elements: list[str] = path.split("/")
if len(path_elements) > 1 and path_elements[-1] in [
"stats",
"status",
"failover",
"config",
]:
operation_key = path_elements[-1]
return (operation_key, skip)
@staticmethod
def post_process_operation(
resource_name: str, operation_name: str, operation
):
if resource_name in [
"healthmonitor",
"loadbalancer",
"listener",
"quota",
"pool",
"pool/member",
]:
if operation_name in ["list", "delete", "show"]:
operation.targets.setdefault(
"rust-tui",
OperationTargetParams(
module_name=operation.targets["rust-sdk"].module_name
),
)
return operation