示例#1
0
 def ListRoutes(self, namespace_ref):
     messages = self._messages_module
     request = messages.ServerlessNamespacesRoutesListRequest(
         parent=namespace_ref.RelativeName())
     with metrics.record_duration(metrics.LIST_ROUTES):
         response = self._client.namespaces_routes.List(request)
     return [route.Route(item, messages) for item in response.items]
示例#2
0
    def _GetRoute(self, service_ref):
        """Return the relevant Route from the server, or None if 404."""
        messages = self._messages_module
        # GET the Route
        route_name = self._registry.Parse(
            service_ref.servicesId,
            params={
                'namespacesId': service_ref.namespacesId,
            },
            collection='serverless.namespaces.routes').RelativeName()
        route_get_request = messages.ServerlessNamespacesRoutesGetRequest(
            name=route_name, )

        try:
            with metrics.record_duration(metrics.GET_ROUTE):
                route_get_response = self._client.namespaces_routes.Get(
                    route_get_request)
            return route.Route(route_get_response, messages)
        except api_exceptions.HttpNotFoundError:
            return None