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