83dbf64aca
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>
62 lines
1.8 KiB
Python
62 lines
1.8 KiB
Python
# Copyright (c) 2015 Huawei Tech. Co., Ltd.
|
|
# 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 import root as v1_root
|
|
|
|
|
|
class RootController(object):
|
|
|
|
@pecan.expose("json")
|
|
def _lookup(self, version, *remainder):
|
|
version = str(version)
|
|
minor_version = version[-1]
|
|
major_version = version[1]
|
|
remainder = remainder + (minor_version,)
|
|
if major_version == "1":
|
|
return v1_root.Controller(), remainder
|
|
|
|
@pecan.expose(generic=True, template="json")
|
|
def index(self):
|
|
return {
|
|
"versions": [
|
|
{
|
|
"status": "CURRENT",
|
|
"links": [
|
|
{
|
|
"rel": "self",
|
|
"href": pecan.request.application_url + "/v1.0/",
|
|
}
|
|
],
|
|
"id": "v1.0",
|
|
"updated": "2018-11-20",
|
|
}
|
|
]
|
|
}
|
|
|
|
@index.when(method="POST")
|
|
@index.when(method="PUT")
|
|
@index.when(method="DELETE")
|
|
@index.when(method="HEAD")
|
|
@index.when(method="PATCH")
|
|
def not_supported(self):
|
|
pecan.abort(405)
|