【问题标题】:Google Cloud Endpoints Multi GetGoogle Cloud Endpoints 多获取
【发布时间】:2017-01-07 01:24:09
【问题描述】:

我有一个来自 Endpoints Proto Datastore API 的名为 Resource 的 EndpointsModel,我正在使用以下命令请求 10 个项目:Resource.query().fetch(10)。

问题是它返回了一个资源数组,但根据“创建端点 API”的文档,我需要返回一个消息数组。

https://cloud.google.com/appengine/docs/python/endpoints/create_api

Proto RPC messages with Google Cloud Enpoints

有没有一种标准方法可以将我的模型数组转换为消息,或者 for 循环是最有效的方法?

提前致谢!

【问题讨论】:

    标签: python-2.7 google-app-engine google-cloud-messaging google-cloud-endpoints protorpc


    【解决方案1】:

    我进行了更多挖掘,并在 GitHub (https://github.com/GoogleCloudPlatform/appengine-endpoints-tictactoe-python) 上找到了 Google Cloud Platform 的示例。 tictactoe_api.py 在返回的 NDB 值上使用 for 循环,并在 models.py 中使用自定义 to_message() 函数将它们转换为 protoRPC 消息。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-12-18
      • 2021-11-16
      • 2013-05-23
      • 1970-01-01
      • 1970-01-01
      • 2014-09-12
      • 2013-05-26
      • 1970-01-01
      相关资源
      最近更新 更多