Alex Klein | 54e38e3 | 2019-06-21 14:54:17 -0600 | [diff] [blame] | 1 | # -*- 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 | |
| 8 | from __future__ import print_function |
| 9 | |
| 10 | from chromite.api import router as router_lib |
| 11 | |
Alex Klein | 104b067 | 2019-06-28 15:43:00 -0600 | [diff] [blame] | 12 | # API version number. |
| 13 | # The major version MUST be updated on breaking changes. |
| 14 | VERSION_MAJOR = 1 |
| 15 | # The minor and bug versions are not currently utilized, but put in place |
| 16 | # to simplify future requirements. |
| 17 | VERSION_MINOR = 0 |
| 18 | VERSION_BUG = 0 |
| 19 | |
Alex Klein | 54e38e3 | 2019-06-21 14:54:17 -0600 | [diff] [blame] | 20 | |
| 21 | def GetMethods(_input_proto, output_proto): |
| 22 | """List all of the registered methods.""" |
| 23 | router = router_lib.GetRouter() |
| 24 | for method in router.ListMethods(): |
| 25 | output_proto.methods.add().method = method |
Alex Klein | 104b067 | 2019-06-28 15:43:00 -0600 | [diff] [blame] | 26 | |
| 27 | |
| 28 | def GetVersion(_input_proto, output_proto): |
| 29 | """Get the Build API major version number.""" |
| 30 | output_proto.version.major = VERSION_MAJOR |
| 31 | output_proto.version.minor = VERSION_MINOR |
| 32 | output_proto.version.bug = VERSION_BUG |