Files
distcloud/distributedcloud/dcdbsync/api/controllers/v1/root.py
Hugo Brito 83dbf64aca Apply black formatter to dcdbsync/api
This commit applies the Black format to the `dcdbsync/api`
files to ensure that it adheres to the Black code style guidelines.

Test Plan:
PASS: Success in stx-distcloud-tox-black

Story: 2011149
Task: 50443

Change-Id: Iedeaf1eced6dad414b3ef538798c7dd14b0249d6
Signed-off-by: Hugo Brito <hugo.brito@windriver.com>
2024-06-28 13:38:23 +00:00

60 lines
1.6 KiB
Python

# Copyright (c) 2017 Ericsson AB.
# All Rights Reserved.
#
# 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.
#
# Copyright (c) 2019, 2024 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
import pecan
from dcdbsync.api.controllers.v1.identity import root
class Controller(object):
def _get_sub_controller(self, remainder):
if not remainder:
pecan.abort(404)
return
minor_version = remainder[-1]
remainder = remainder[:-1]
sub_controllers = dict()
if minor_version == "0":
sub_controllers["identity"] = root.IdentityController
for name, ctrl in sub_controllers.items():
setattr(self, name, ctrl)
try:
sub_controller = remainder[0]
except IndexError:
pecan.abort(404)
return
if sub_controller not in sub_controllers:
pecan.abort(404)
return
remainder = remainder[1:]
return sub_controllers[sub_controller](), remainder
@pecan.expose()
def _lookup(self, *remainder):
return self._get_sub_controller(remainder)