Adrià Vilanova MartÃnez | f19ea43 | 2024-01-23 20:20:52 +0100 | [diff] [blame^] | 1 | # Copyright 2016 The Chromium Authors |
| 2 | # Use of this source code is governed by a BSD-style license that can be |
| 3 | # found in the LICENSE file. |
Copybara | 854996b | 2021-09-07 19:36:02 +0000 | [diff] [blame] | 4 | |
| 5 | # This file implements a pRPC API for Monorail. |
| 6 | # |
| 7 | # See the pRPC spec here: https://godoc.org/github.com/luci/luci-go/grpc/prpc |
| 8 | # |
| 9 | # Each Servicer corresponds to a service defined in a .proto file in this |
| 10 | # directory. Each method on that Servicer corresponds to one of the rpcs |
| 11 | # defined on the service. |
| 12 | # |
| 13 | # All APIs are served under the /prpc/* path space. Each service gets its own |
| 14 | # namespace under that, and each method is an individual endpoints. For example, |
| 15 | # POST https://bugs.chromium.org/prpc/monorail.Users/GetUser |
| 16 | # would be a call to the api.users_servicer.UsersServicer.GetUser method. |
| 17 | # |
| 18 | # Note that this is not a RESTful API, although it is CRUDy. All requests are |
| 19 | # POSTs, all methods take exactly one input, and all methods return exactly |
| 20 | # one output. |
| 21 | # |
| 22 | # TODO(http://crbug.com/monorail/1703): Actually integrate the rpcexplorer. |
| 23 | # You can use the API Explorer here: https://bugs.chromium.org/rpcexplorer |
| 24 | |
| 25 | from __future__ import print_function |
| 26 | from __future__ import division |
| 27 | from __future__ import absolute_import |
| 28 | |
| 29 | from api import features_servicer |
| 30 | from api import issues_servicer |
| 31 | from api import projects_servicer |
| 32 | from api import sitewide_servicer |
| 33 | from api import users_servicer |
| 34 | |
| 35 | |
| 36 | def RegisterApiHandlers(prpc_server, services): |
| 37 | """Registers pRPC API services. And makes their routes |
| 38 | available in prpc_server.get_routes(). |
| 39 | """ |
| 40 | |
| 41 | prpc_server.add_service(features_servicer.FeaturesServicer(services)) |
| 42 | prpc_server.add_service(issues_servicer.IssuesServicer(services)) |
| 43 | prpc_server.add_service(projects_servicer.ProjectsServicer(services)) |
| 44 | prpc_server.add_service(sitewide_servicer.SitewideServicer(services)) |
| 45 | prpc_server.add_service(users_servicer.UsersServicer(services)) |