blob: 117de05ea5b8ce4d7c57b80a2567858a5bb1b464 [file] [log] [blame]
Alex Klein54e38e32019-06-21 14:54:17 -06001# -*- coding: utf-8 -*-
2# Copyright 2019 The Chromium OS Authors. All rights reserved.
3# Use of this source code is governed by a BSD-style license that can be
4# found in the LICENSE file.
5
6"""API information controller."""
7
8from __future__ import print_function
9
Mike Frysingeref94e4c2020-02-10 23:59:54 -050010import sys
11
Alex Klein076841b2019-08-29 15:19:39 -060012from chromite.api import faux
Alex Klein54e38e32019-06-21 14:54:17 -060013from chromite.api import router as router_lib
Alex Klein231d2da2019-07-22 16:44:45 -060014from chromite.api import validate
Alex Klein54e38e32019-06-21 14:54:17 -060015
Mike Frysingeref94e4c2020-02-10 23:59:54 -050016assert sys.version_info >= (3, 6), 'This module requires Python 3.6+'
17
18
Alex Klein104b0672019-06-28 15:43:00 -060019# API version number.
20# The major version MUST be updated on breaking changes.
21VERSION_MAJOR = 1
22# The minor and bug versions are not currently utilized, but put in place
23# to simplify future requirements.
24VERSION_MINOR = 0
25VERSION_BUG = 0
26
Alex Klein54e38e32019-06-21 14:54:17 -060027
Alex Klein076841b2019-08-29 15:19:39 -060028@faux.all_empty
Alex Klein231d2da2019-07-22 16:44:45 -060029@validate.validation_complete
30def GetMethods(_input_proto, output_proto, _config):
Alex Klein54e38e32019-06-21 14:54:17 -060031 """List all of the registered methods."""
32 router = router_lib.GetRouter()
33 for method in router.ListMethods():
34 output_proto.methods.add().method = method
Alex Klein104b0672019-06-28 15:43:00 -060035
36
Alex Klein231d2da2019-07-22 16:44:45 -060037@validate.validation_complete
38def GetVersion(_input_proto, output_proto, _config):
Alex Klein104b0672019-06-28 15:43:00 -060039 """Get the Build API major version number."""
40 output_proto.version.major = VERSION_MAJOR
41 output_proto.version.minor = VERSION_MINOR
42 output_proto.version.bug = VERSION_BUG