homegraph.proto 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395
  1. // Copyright 2020 Google LLC
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. syntax = "proto3";
  15. package google.home.graph.v1;
  16. import "google/api/annotations.proto";
  17. import "google/api/client.proto";
  18. import "google/api/field_behavior.proto";
  19. import "google/api/resource.proto";
  20. import "google/home/graph/v1/device.proto";
  21. import "google/protobuf/empty.proto";
  22. import "google/protobuf/struct.proto";
  23. option go_package = "google.golang.org/genproto/googleapis/home/graph/v1;graph";
  24. option java_outer_classname = "HomeGraphApiServiceProto";
  25. option java_package = "com.google.home.graph.v1";
  26. option php_namespace = "Google\\Home\\Graph\\V1";
  27. option (google.api.resource_definition) = {
  28. type: "homegraph.googleapis.com/AgentUserPath"
  29. pattern: "agentUsers/{agent_user_path}"
  30. };
  31. // Google Home Graph API service. The Home Graph service provides support for
  32. // accessing first-party and third-party devices stored in Google's Home Graph.
  33. // The Home Graph database provides contextual data about the relationships
  34. // between devices and the home.
  35. //
  36. // For more details, see the [Home Graph developer
  37. // guide](https://developers.google.com/assistant/smarthome/concepts/homegraph).
  38. service HomeGraphApiService {
  39. option (google.api.default_host) = "homegraph.googleapis.com";
  40. // Requests Google to send an `action.devices.SYNC`
  41. // [intent](https://developers.google.com/assistant/smarthome/reference/intent/sync)
  42. // to your smart home Action to update device metadata for the given user.
  43. //
  44. //
  45. // The third-party user's identity is passed via the `agent_user_id`
  46. // (see
  47. // [RequestSyncDevicesRequest][google.home.graph.v1.RequestSyncDevicesRequest]).
  48. // This request must be authorized using service account credentials from your
  49. // Actions console project.
  50. rpc RequestSyncDevices(RequestSyncDevicesRequest)
  51. returns (RequestSyncDevicesResponse) {
  52. option (google.api.http) = {
  53. post: "/v1/devices:requestSync"
  54. body: "*"
  55. };
  56. option (google.api.method_signature) = "agent_user_id";
  57. }
  58. // Reports device state and optionally sends device notifications.
  59. // Called by your smart home Action when the state of a third-party device
  60. // changes or you need to send a notification about the device.
  61. // See [Implement Report
  62. // State](https://developers.google.com/assistant/smarthome/develop/report-state)
  63. // for more information.
  64. //
  65. // This method updates the device state according to its declared
  66. // [traits](https://developers.google.com/assistant/smarthome/concepts/devices-traits).
  67. // Publishing a new state value outside of these traits will result in an
  68. // `INVALID_ARGUMENT` error response.
  69. //
  70. // The third-party user's identity is passed in via the `agent_user_id`
  71. // (see
  72. // [ReportStateAndNotificationRequest][google.home.graph.v1.ReportStateAndNotificationRequest]).
  73. // This request must be authorized using service account credentials from your
  74. // Actions console project.
  75. rpc ReportStateAndNotification(ReportStateAndNotificationRequest)
  76. returns (ReportStateAndNotificationResponse) {
  77. option (google.api.http) = {
  78. post: "/v1/devices:reportStateAndNotification"
  79. body: "*"
  80. };
  81. option (google.api.method_signature) =
  82. "request_id,event_id,agent_user_id,payload";
  83. }
  84. // Unlinks the given third-party user from your smart home Action.
  85. // All data related to this user will be deleted.
  86. //
  87. // For more details on how users link their accounts, see
  88. // [fulfillment and
  89. // authentication](https://developers.google.com/assistant/smarthome/concepts/fulfillment-authentication).
  90. //
  91. // The third-party user's identity is passed in via the `agent_user_id`
  92. // (see
  93. // [DeleteAgentUserRequest][google.home.graph.v1.DeleteAgentUserRequest]).
  94. // This request must be authorized using service account credentials from your
  95. // Actions console project.
  96. rpc DeleteAgentUser(DeleteAgentUserRequest) returns (google.protobuf.Empty) {
  97. option (google.api.http) = {
  98. delete: "/v1/{agent_user_id=agentUsers/**}"
  99. };
  100. option (google.api.method_signature) = "request_id,agent_user_id";
  101. }
  102. // Gets the current states in Home Graph for the given set of the third-party
  103. // user's devices.
  104. //
  105. // The third-party user's identity is passed in via the `agent_user_id`
  106. // (see [QueryRequest][google.home.graph.v1.QueryRequest]).
  107. // This request must be authorized using service account credentials from your
  108. // Actions console project.
  109. rpc Query(QueryRequest) returns (QueryResponse) {
  110. option (google.api.http) = {
  111. post: "/v1/devices:query"
  112. body: "*"
  113. };
  114. option (google.api.method_signature) = "request_id,agent_user_id,inputs";
  115. }
  116. // Gets all the devices associated with the given third-party user.
  117. //
  118. // The third-party user's identity is passed in via the `agent_user_id`
  119. // (see [SyncRequest][google.home.graph.v1.SyncRequest]).
  120. // This request must be authorized using service account credentials from your
  121. // Actions console project.
  122. rpc Sync(SyncRequest) returns (SyncResponse) {
  123. option (google.api.http) = {
  124. post: "/v1/devices:sync"
  125. body: "*"
  126. };
  127. option (google.api.method_signature) = "request_id,agent_user_id";
  128. }
  129. }
  130. // Request type for the
  131. // [`RequestSyncDevices`](#google.home.graph.v1.HomeGraphApiService.RequestSyncDevices)
  132. // call.
  133. message RequestSyncDevicesRequest {
  134. // Required. Third-party user ID.
  135. string agent_user_id = 1 [(google.api.field_behavior) = REQUIRED];
  136. // Optional. If set, the request will be added to a queue and a response will
  137. // be returned immediately. This enables concurrent requests for the given
  138. // `agent_user_id`, but the caller will not receive any error responses.
  139. bool async = 2 [(google.api.field_behavior) = OPTIONAL];
  140. }
  141. // Response type for the
  142. // [`RequestSyncDevices`](#google.home.graph.v1.HomeGraphApiService.RequestSyncDevices)
  143. // call.
  144. //
  145. // Intentionally empty upon success. An HTTP response code is returned
  146. // with more details upon failure.
  147. message RequestSyncDevicesResponse {}
  148. // Request type for the
  149. // [`ReportStateAndNotification`](#google.home.graph.v1.HomeGraphApiService.ReportStateAndNotification)
  150. // call. It may include states, notifications, or both. States and notifications
  151. // are defined per `device_id` (for example, "123" and "456" in the following
  152. // example).
  153. // # Example
  154. //
  155. // ```json
  156. // {
  157. // "requestId": "ff36a3cc-ec34-11e6-b1a0-64510650abcf",
  158. // "agentUserId": "1234",
  159. // "payload": {
  160. // "devices": {
  161. // "states": {
  162. // "123": {
  163. // "on": true
  164. // },
  165. // "456": {
  166. // "on": true,
  167. // "brightness": 10
  168. // }
  169. // },
  170. // }
  171. // }
  172. // }
  173. // ```
  174. message ReportStateAndNotificationRequest {
  175. // Request ID used for debugging.
  176. string request_id = 1;
  177. // Unique identifier per event (for example, a doorbell press).
  178. string event_id = 4;
  179. // Required. Third-party user ID.
  180. string agent_user_id = 2 [(google.api.field_behavior) = REQUIRED];
  181. // Deprecated.
  182. // (-- Token to maintain state in the follow up notification response. See the
  183. // notifications guide at
  184. // https://developers.google.com/assistant/smarthome/develop/notifications for
  185. // details on implementing follow up notifications --)
  186. string follow_up_token = 5 [deprecated = true];
  187. // Required. State of devices to update and notification metadata for devices.
  188. StateAndNotificationPayload payload = 3
  189. [(google.api.field_behavior) = REQUIRED];
  190. }
  191. // Response type for the
  192. // [`ReportStateAndNotification`](#google.home.graph.v1.HomeGraphApiService.ReportStateAndNotification)
  193. // call.
  194. message ReportStateAndNotificationResponse {
  195. // Request ID copied from
  196. // [ReportStateAndNotificationRequest][google.home.graph.v1.ReportStateAndNotificationRequest].
  197. string request_id = 1;
  198. }
  199. // Payload containing the state and notification information for devices.
  200. message StateAndNotificationPayload {
  201. // The devices for updating state and sending notifications.
  202. ReportStateAndNotificationDevice devices = 1;
  203. }
  204. // The states and notifications specific to a device.
  205. message ReportStateAndNotificationDevice {
  206. // States of devices to update. See the **Device STATES** section
  207. // of the individual trait [reference
  208. // guides](https://developers.google.com/assistant/smarthome/traits).
  209. google.protobuf.Struct states = 1;
  210. // Notifications metadata for devices. See the **Device NOTIFICATIONS**
  211. // section of the individual trait [reference
  212. // guides](https://developers.google.com/assistant/smarthome/traits).
  213. google.protobuf.Struct notifications = 2;
  214. }
  215. // Request type for the
  216. // [`DeleteAgentUser`](#google.home.graph.v1.HomeGraphApiService.DeleteAgentUser)
  217. // call.
  218. message DeleteAgentUserRequest {
  219. // Request ID used for debugging.
  220. string request_id = 1;
  221. // Required. Third-party user ID.
  222. string agent_user_id = 2 [
  223. (google.api.field_behavior) = REQUIRED,
  224. (google.api.resource_reference) = {
  225. type: "homegraph.googleapis.com/AgentUserPath"
  226. }
  227. ];
  228. }
  229. // Request type for the
  230. // [`Query`](#google.home.graph.v1.HomeGraphApiService.Query) call.
  231. message QueryRequest {
  232. // Request ID used for debugging.
  233. string request_id = 1;
  234. // Required. Third-party user ID.
  235. string agent_user_id = 2 [(google.api.field_behavior) = REQUIRED];
  236. // Required. Inputs containing third-party device IDs for which to
  237. // get the device states.
  238. repeated QueryRequestInput inputs = 3
  239. [(google.api.field_behavior) = REQUIRED];
  240. }
  241. // Device ID inputs to [QueryRequest][google.home.graph.v1.QueryRequest].
  242. message QueryRequestInput {
  243. // Payload containing third-party device IDs.
  244. QueryRequestPayload payload = 1;
  245. }
  246. // Payload containing device IDs.
  247. message QueryRequestPayload {
  248. // Third-party device IDs for which to get the device states.
  249. repeated AgentDeviceId devices = 1;
  250. }
  251. // Third-party device ID for one device.
  252. message AgentDeviceId {
  253. // Third-party device ID.
  254. string id = 1;
  255. }
  256. // Response type for the
  257. // [`Query`](#google.home.graph.v1.HomeGraphApiService.Query) call.
  258. // This should follow the same format as the Google smart home
  259. // `action.devices.QUERY`
  260. // [response](https://developers.google.com/assistant/smarthome/reference/intent/query).
  261. // # Example
  262. //
  263. // ```json
  264. // {
  265. // "requestId": "ff36a3cc-ec34-11e6-b1a0-64510650abcf",
  266. // "payload": {
  267. // "devices": {
  268. // "123": {
  269. // "on": true,
  270. // "online": true
  271. // },
  272. // "456": {
  273. // "on": true,
  274. // "online": true,
  275. // "brightness": 80,
  276. // "color": {
  277. // "name": "cerulean",
  278. // "spectrumRGB": 31655
  279. // }
  280. // }
  281. // }
  282. // }
  283. // }
  284. // ```
  285. message QueryResponse {
  286. // Request ID used for debugging. Copied from the request.
  287. string request_id = 1;
  288. // Device states for the devices given in the request.
  289. QueryResponsePayload payload = 2;
  290. }
  291. // Payload containing device states information.
  292. message QueryResponsePayload {
  293. // States of the devices. Map of third-party device ID to struct of device
  294. // states.
  295. map<string, google.protobuf.Struct> devices = 1;
  296. }
  297. // Request type for the [`Sync`](#google.home.graph.v1.HomeGraphApiService.Sync)
  298. // call.
  299. message SyncRequest {
  300. // Request ID used for debugging.
  301. string request_id = 1;
  302. // Required. Third-party user ID.
  303. string agent_user_id = 2 [(google.api.field_behavior) = REQUIRED];
  304. }
  305. // Response type for the
  306. // [`Sync`](#google.home.graph.v1.HomeGraphApiService.Sync) call.
  307. // This should follow the same format as the Google smart home
  308. // `action.devices.SYNC`
  309. // [response](https://developers.google.com/assistant/smarthome/reference/intent/sync).
  310. // # Example
  311. //
  312. // ```json
  313. // {
  314. // "requestId": "ff36a3cc-ec34-11e6-b1a0-64510650abcf",
  315. // "payload": {
  316. // "agentUserId": "1836.15267389",
  317. // "devices": [{
  318. // "id": "123",
  319. // "type": "action.devices.types.OUTLET",
  320. // "traits": [
  321. // "action.devices.traits.OnOff"
  322. // ],
  323. // "name": {
  324. // "defaultNames": ["My Outlet 1234"],
  325. // "name": "Night light",
  326. // "nicknames": ["wall plug"]
  327. // },
  328. // "willReportState": false,
  329. // "deviceInfo": {
  330. // "manufacturer": "lights-out-inc",
  331. // "model": "hs1234",
  332. // "hwVersion": "3.2",
  333. // "swVersion": "11.4"
  334. // },
  335. // "customData": {
  336. // "fooValue": 74,
  337. // "barValue": true,
  338. // "bazValue": "foo"
  339. // }
  340. // }]
  341. // }
  342. // }
  343. // ```
  344. message SyncResponse {
  345. // Request ID used for debugging. Copied from the request.
  346. string request_id = 1;
  347. // Devices associated with the third-party user.
  348. SyncResponsePayload payload = 2;
  349. }
  350. // Payload containing device information.
  351. message SyncResponsePayload {
  352. // Third-party user ID
  353. string agent_user_id = 1;
  354. // Devices associated with the third-party user.
  355. repeated Device devices = 2;
  356. }