blob: 38253b1ffaf64e167e517b0f2c0ee49b957fb1bb [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
Alex Klein076841b2019-08-29 15:19:39 -060010from chromite.api import faux
Alex Klein54e38e32019-06-21 14:54:17 -060011from chromite.api import router as router_lib
Alex Klein231d2da2019-07-22 16:44:45 -060012from chromite.api import validate
Alex Klein54e38e32019-06-21 14:54:17 -060013
Alex Klein104b0672019-06-28 15:43:00 -060014# API version number.
15# The major version MUST be updated on breaking changes.
16VERSION_MAJOR = 1
17# The minor and bug versions are not currently utilized, but put in place
18# to simplify future requirements.
19VERSION_MINOR = 0
20VERSION_BUG = 0
21
Alex Klein54e38e32019-06-21 14:54:17 -060022
Alex Kleinf725e102021-02-19 15:48:54 -070023def _CompileProtoSuccess(_input_proto, output_proto, _config):
24 """Mock success response for CompileProto."""
25 output_proto.modified_files.add().path = '/code/chromite/api/gen/foo_pb2.py'
26
27
28@faux.success(_CompileProtoSuccess)
29@faux.empty_error
30@validate.validation_complete
31def CompileProto(_input_proto, _output_proto, _config):
32 """Compile the Build API proto, returning the list of modified files."""
33 pass
34
35
Alex Klein076841b2019-08-29 15:19:39 -060036@faux.all_empty
Alex Klein231d2da2019-07-22 16:44:45 -060037@validate.validation_complete
38def GetMethods(_input_proto, output_proto, _config):
Alex Klein54e38e32019-06-21 14:54:17 -060039 """List all of the registered methods."""
40 router = router_lib.GetRouter()
41 for method in router.ListMethods():
42 output_proto.methods.add().method = method
Alex Klein104b0672019-06-28 15:43:00 -060043
44
Alex Klein231d2da2019-07-22 16:44:45 -060045@validate.validation_complete
46def GetVersion(_input_proto, output_proto, _config):
Alex Klein104b0672019-06-28 15:43:00 -060047 """Get the Build API major version number."""
48 output_proto.version.major = VERSION_MAJOR
49 output_proto.version.minor = VERSION_MINOR
50 output_proto.version.bug = VERSION_BUG