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