1 // Copyright 2024 Google LLC. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 // Code generated file. DO NOT EDIT. 6 7 // Package homegraph provides access to the HomeGraph API. 8 // 9 // For product documentation, see: https://developers.home.google.com/cloud-to-cloud/get-started 10 // 11 // # Library status 12 // 13 // These client libraries are officially supported by Google. However, this 14 // library is considered complete and is in maintenance mode. This means 15 // that we will address critical bugs and security issues but will not add 16 // any new features. 17 // 18 // When possible, we recommend using our newer 19 // [Cloud Client Libraries for Go](https://pkg.go.dev/cloud.google.com/go) 20 // that are still actively being worked and iterated on. 21 // 22 // # Creating a client 23 // 24 // Usage example: 25 // 26 // import "google.golang.org/api/homegraph/v1" 27 // ... 28 // ctx := context.Background() 29 // homegraphService, err := homegraph.NewService(ctx) 30 // 31 // In this example, Google Application Default Credentials are used for 32 // authentication. For information on how to create and obtain Application 33 // Default Credentials, see https://developers.google.com/identity/protocols/application-default-credentials. 34 // 35 // # Other authentication options 36 // 37 // To use an API key for authentication (note: some APIs do not support API 38 // keys), use [google.golang.org/api/option.WithAPIKey]: 39 // 40 // homegraphService, err := homegraph.NewService(ctx, option.WithAPIKey("AIza...")) 41 // 42 // To use an OAuth token (e.g., a user token obtained via a three-legged OAuth 43 // flow, use [google.golang.org/api/option.WithTokenSource]: 44 // 45 // config := &oauth2.Config{...} 46 // // ... 47 // token, err := config.Exchange(ctx, ...) 48 // homegraphService, err := homegraph.NewService(ctx, option.WithTokenSource(config.TokenSource(ctx, token))) 49 // 50 // See [google.golang.org/api/option.ClientOption] for details on options. 51 package homegraph // import "google.golang.org/api/homegraph/v1" 52 53 import ( 54 "bytes" 55 "context" 56 "encoding/json" 57 "errors" 58 "fmt" 59 "io" 60 "net/http" 61 "net/url" 62 "strconv" 63 "strings" 64 65 googleapi "google.golang.org/api/googleapi" 66 internal "google.golang.org/api/internal" 67 gensupport "google.golang.org/api/internal/gensupport" 68 option "google.golang.org/api/option" 69 internaloption "google.golang.org/api/option/internaloption" 70 htransport "google.golang.org/api/transport/http" 71 ) 72 73 // Always reference these packages, just in case the auto-generated code 74 // below doesn't. 75 var _ = bytes.NewBuffer 76 var _ = strconv.Itoa 77 var _ = fmt.Sprintf 78 var _ = json.NewDecoder 79 var _ = io.Copy 80 var _ = url.Parse 81 var _ = gensupport.MarshalJSON 82 var _ = googleapi.Version 83 var _ = errors.New 84 var _ = strings.Replace 85 var _ = context.Canceled 86 var _ = internaloption.WithDefaultEndpoint 87 var _ = internal.Version 88 89 const apiId = "homegraph:v1" 90 const apiName = "homegraph" 91 const apiVersion = "v1" 92 const basePath = "https://homegraph.googleapis.com/" 93 const basePathTemplate = "https://homegraph.UNIVERSE_DOMAIN/" 94 const mtlsBasePath = "https://homegraph.mtls.googleapis.com/" 95 96 // OAuth2 scopes used by this API. 97 const ( 98 // Private Service: https://www.googleapis.com/auth/homegraph 99 HomegraphScope = "https://www.googleapis.com/auth/homegraph" 100 ) 101 102 // NewService creates a new Service. 103 func NewService(ctx context.Context, opts ...option.ClientOption) (*Service, error) { 104 scopesOption := internaloption.WithDefaultScopes( 105 "https://www.googleapis.com/auth/homegraph", 106 ) 107 // NOTE: prepend, so we don't override user-specified scopes. 108 opts = append([]option.ClientOption{scopesOption}, opts...) 109 opts = append(opts, internaloption.WithDefaultEndpoint(basePath)) 110 opts = append(opts, internaloption.WithDefaultEndpointTemplate(basePathTemplate)) 111 opts = append(opts, internaloption.WithDefaultMTLSEndpoint(mtlsBasePath)) 112 opts = append(opts, internaloption.EnableNewAuthLibrary()) 113 client, endpoint, err := htransport.NewClient(ctx, opts...) 114 if err != nil { 115 return nil, err 116 } 117 s, err := New(client) 118 if err != nil { 119 return nil, err 120 } 121 if endpoint != "" { 122 s.BasePath = endpoint 123 } 124 return s, nil 125 } 126 127 // New creates a new Service. It uses the provided http.Client for requests. 128 // 129 // Deprecated: please use NewService instead. 130 // To provide a custom HTTP client, use option.WithHTTPClient. 131 // If you are using google.golang.org/api/googleapis/transport.APIKey, use option.WithAPIKey with NewService instead. 132 func New(client *http.Client) (*Service, error) { 133 if client == nil { 134 return nil, errors.New("client is nil") 135 } 136 s := &Service{client: client, BasePath: basePath} 137 s.AgentUsers = NewAgentUsersService(s) 138 s.Devices = NewDevicesService(s) 139 return s, nil 140 } 141 142 type Service struct { 143 client *http.Client 144 BasePath string // API endpoint base URL 145 UserAgent string // optional additional User-Agent fragment 146 147 AgentUsers *AgentUsersService 148 149 Devices *DevicesService 150 } 151 152 func (s *Service) userAgent() string { 153 if s.UserAgent == "" { 154 return googleapi.UserAgent 155 } 156 return googleapi.UserAgent + " " + s.UserAgent 157 } 158 159 func NewAgentUsersService(s *Service) *AgentUsersService { 160 rs := &AgentUsersService{s: s} 161 return rs 162 } 163 164 type AgentUsersService struct { 165 s *Service 166 } 167 168 func NewDevicesService(s *Service) *DevicesService { 169 rs := &DevicesService{s: s} 170 return rs 171 } 172 173 type DevicesService struct { 174 s *Service 175 } 176 177 // AgentDeviceId: Third-party device ID for one device. 178 type AgentDeviceId struct { 179 // Id: Third-party device ID. 180 Id string `json:"id,omitempty"` 181 // ForceSendFields is a list of field names (e.g. "Id") to unconditionally 182 // include in API requests. By default, fields with empty or default values are 183 // omitted from API requests. See 184 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 185 // details. 186 ForceSendFields []string `json:"-"` 187 // NullFields is a list of field names (e.g. "Id") to include in API requests 188 // with the JSON null value. By default, fields with empty values are omitted 189 // from API requests. See 190 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 191 NullFields []string `json:"-"` 192 } 193 194 func (s *AgentDeviceId) MarshalJSON() ([]byte, error) { 195 type NoMethod AgentDeviceId 196 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 197 } 198 199 // AgentOtherDeviceId: Alternate third-party device ID. 200 type AgentOtherDeviceId struct { 201 // AgentId: Project ID for your smart home Action. 202 AgentId string `json:"agentId,omitempty"` 203 // DeviceId: Unique third-party device ID. 204 DeviceId string `json:"deviceId,omitempty"` 205 // ForceSendFields is a list of field names (e.g. "AgentId") to unconditionally 206 // include in API requests. By default, fields with empty or default values are 207 // omitted from API requests. See 208 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 209 // details. 210 ForceSendFields []string `json:"-"` 211 // NullFields is a list of field names (e.g. "AgentId") to include in API 212 // requests with the JSON null value. By default, fields with empty values are 213 // omitted from API requests. See 214 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 215 NullFields []string `json:"-"` 216 } 217 218 func (s *AgentOtherDeviceId) MarshalJSON() ([]byte, error) { 219 type NoMethod AgentOtherDeviceId 220 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 221 } 222 223 // Device: Third-party device definition. 224 type Device struct { 225 // Attributes: Attributes for the traits supported by the device. 226 Attributes googleapi.RawMessage `json:"attributes,omitempty"` 227 // CustomData: Custom device attributes stored in Home Graph and provided to 228 // your smart home Action in each QUERY 229 // (https://developers.home.google.com/cloud-to-cloud/intents/query) and 230 // EXECUTE (https://developers.home.google.com/cloud-to-cloud/intents/execute) 231 // intent. Data in this object has a few constraints: No sensitive information, 232 // including but not limited to Personally Identifiable Information. 233 CustomData googleapi.RawMessage `json:"customData,omitempty"` 234 // DeviceInfo: Device manufacturer, model, hardware version, and software 235 // version. 236 DeviceInfo *DeviceInfo `json:"deviceInfo,omitempty"` 237 // Id: Third-party device ID. 238 Id string `json:"id,omitempty"` 239 // Name: Names given to this device by your smart home Action. 240 Name *DeviceNames `json:"name,omitempty"` 241 // NotificationSupportedByAgent: Indicates whether your smart home Action will 242 // report notifications to Google for this device via 243 // ReportStateAndNotification. If your smart home Action enables users to 244 // control device notifications, you should update this field and call 245 // RequestSyncDevices. 246 NotificationSupportedByAgent bool `json:"notificationSupportedByAgent,omitempty"` 247 // OtherDeviceIds: Alternate IDs associated with this device. This is used to 248 // identify cloud synced devices enabled for local fulfillment 249 // (https://developers.home.google.com/local-home/overview). 250 OtherDeviceIds []*AgentOtherDeviceId `json:"otherDeviceIds,omitempty"` 251 // RoomHint: Suggested name for the room where this device is installed. Google 252 // attempts to use this value during user setup. 253 RoomHint string `json:"roomHint,omitempty"` 254 // StructureHint: Suggested name for the structure where this device is 255 // installed. Google attempts to use this value during user setup. 256 StructureHint string `json:"structureHint,omitempty"` 257 // Traits: Traits supported by the device. See device traits 258 // (https://developers.home.google.com/cloud-to-cloud/traits). 259 Traits []string `json:"traits,omitempty"` 260 // Type: Hardware type of the device. See device types 261 // (https://developers.home.google.com/cloud-to-cloud/guides). 262 Type string `json:"type,omitempty"` 263 // WillReportState: Indicates whether your smart home Action will report state 264 // of this device to Google via ReportStateAndNotification. 265 WillReportState bool `json:"willReportState,omitempty"` 266 // ForceSendFields is a list of field names (e.g. "Attributes") to 267 // unconditionally include in API requests. By default, fields with empty or 268 // default values are omitted from API requests. See 269 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 270 // details. 271 ForceSendFields []string `json:"-"` 272 // NullFields is a list of field names (e.g. "Attributes") to include in API 273 // requests with the JSON null value. By default, fields with empty values are 274 // omitted from API requests. See 275 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 276 NullFields []string `json:"-"` 277 } 278 279 func (s *Device) MarshalJSON() ([]byte, error) { 280 type NoMethod Device 281 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 282 } 283 284 // DeviceInfo: Device information. 285 type DeviceInfo struct { 286 // HwVersion: Device hardware version. 287 HwVersion string `json:"hwVersion,omitempty"` 288 // Manufacturer: Device manufacturer. 289 Manufacturer string `json:"manufacturer,omitempty"` 290 // Model: Device model. 291 Model string `json:"model,omitempty"` 292 // SwVersion: Device software version. 293 SwVersion string `json:"swVersion,omitempty"` 294 // ForceSendFields is a list of field names (e.g. "HwVersion") to 295 // unconditionally include in API requests. By default, fields with empty or 296 // default values are omitted from API requests. See 297 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 298 // details. 299 ForceSendFields []string `json:"-"` 300 // NullFields is a list of field names (e.g. "HwVersion") to include in API 301 // requests with the JSON null value. By default, fields with empty values are 302 // omitted from API requests. See 303 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 304 NullFields []string `json:"-"` 305 } 306 307 func (s *DeviceInfo) MarshalJSON() ([]byte, error) { 308 type NoMethod DeviceInfo 309 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 310 } 311 312 // DeviceNames: Identifiers used to describe the device. 313 type DeviceNames struct { 314 // DefaultNames: List of names provided by the manufacturer rather than the 315 // user, such as serial numbers, SKUs, etc. 316 DefaultNames []string `json:"defaultNames,omitempty"` 317 // Name: Primary name of the device, generally provided by the user. 318 Name string `json:"name,omitempty"` 319 // Nicknames: Additional names provided by the user for the device. 320 Nicknames []string `json:"nicknames,omitempty"` 321 // ForceSendFields is a list of field names (e.g. "DefaultNames") to 322 // unconditionally include in API requests. By default, fields with empty or 323 // default values are omitted from API requests. See 324 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 325 // details. 326 ForceSendFields []string `json:"-"` 327 // NullFields is a list of field names (e.g. "DefaultNames") to include in API 328 // requests with the JSON null value. By default, fields with empty values are 329 // omitted from API requests. See 330 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 331 NullFields []string `json:"-"` 332 } 333 334 func (s *DeviceNames) MarshalJSON() ([]byte, error) { 335 type NoMethod DeviceNames 336 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 337 } 338 339 // Empty: A generic empty message that you can re-use to avoid defining 340 // duplicated empty messages in your APIs. A typical example is to use it as 341 // the request or the response type of an API method. For instance: service Foo 342 // { rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty); } 343 type Empty struct { 344 // ServerResponse contains the HTTP response code and headers from the server. 345 googleapi.ServerResponse `json:"-"` 346 } 347 348 // QueryRequest: Request type for the `Query` 349 // (#google.home.graph.v1.HomeGraphApiService.Query) call. 350 type QueryRequest struct { 351 // AgentUserId: Required. Third-party user ID. 352 AgentUserId string `json:"agentUserId,omitempty"` 353 // Inputs: Required. Inputs containing third-party device IDs for which to get 354 // the device states. 355 Inputs []*QueryRequestInput `json:"inputs,omitempty"` 356 // RequestId: Request ID used for debugging. 357 RequestId string `json:"requestId,omitempty"` 358 // ForceSendFields is a list of field names (e.g. "AgentUserId") to 359 // unconditionally include in API requests. By default, fields with empty or 360 // default values are omitted from API requests. See 361 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 362 // details. 363 ForceSendFields []string `json:"-"` 364 // NullFields is a list of field names (e.g. "AgentUserId") to include in API 365 // requests with the JSON null value. By default, fields with empty values are 366 // omitted from API requests. See 367 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 368 NullFields []string `json:"-"` 369 } 370 371 func (s *QueryRequest) MarshalJSON() ([]byte, error) { 372 type NoMethod QueryRequest 373 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 374 } 375 376 // QueryRequestInput: Device ID inputs to QueryRequest. 377 type QueryRequestInput struct { 378 // Payload: Payload containing third-party device IDs. 379 Payload *QueryRequestPayload `json:"payload,omitempty"` 380 // ForceSendFields is a list of field names (e.g. "Payload") to unconditionally 381 // include in API requests. By default, fields with empty or default values are 382 // omitted from API requests. See 383 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 384 // details. 385 ForceSendFields []string `json:"-"` 386 // NullFields is a list of field names (e.g. "Payload") to include in API 387 // requests with the JSON null value. By default, fields with empty values are 388 // omitted from API requests. See 389 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 390 NullFields []string `json:"-"` 391 } 392 393 func (s *QueryRequestInput) MarshalJSON() ([]byte, error) { 394 type NoMethod QueryRequestInput 395 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 396 } 397 398 // QueryRequestPayload: Payload containing device IDs. 399 type QueryRequestPayload struct { 400 // Devices: Third-party device IDs for which to get the device states. 401 Devices []*AgentDeviceId `json:"devices,omitempty"` 402 // ForceSendFields is a list of field names (e.g. "Devices") to unconditionally 403 // include in API requests. By default, fields with empty or default values are 404 // omitted from API requests. See 405 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 406 // details. 407 ForceSendFields []string `json:"-"` 408 // NullFields is a list of field names (e.g. "Devices") to include in API 409 // requests with the JSON null value. By default, fields with empty values are 410 // omitted from API requests. See 411 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 412 NullFields []string `json:"-"` 413 } 414 415 func (s *QueryRequestPayload) MarshalJSON() ([]byte, error) { 416 type NoMethod QueryRequestPayload 417 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 418 } 419 420 // QueryResponse: Response type for the `Query` 421 // (#google.home.graph.v1.HomeGraphApiService.Query) call. This should follow 422 // the same format as the Google smart home `action.devices.QUERY` response 423 // (https://developers.home.google.com/cloud-to-cloud/intents/query). Example: 424 // ```json { "requestId": "ff36a3cc-ec34-11e6-b1a0-64510650abcf", "payload": { 425 // "devices": { "123": { "on": true, "online": true }, "456": { "on": true, 426 // "online": true, "brightness": 80, "color": { "name": "cerulean", 427 // "spectrumRGB": 31655 } } } } } ``` 428 type QueryResponse struct { 429 // Payload: Device states for the devices given in the request. 430 Payload *QueryResponsePayload `json:"payload,omitempty"` 431 // RequestId: Request ID used for debugging. Copied from the request. 432 RequestId string `json:"requestId,omitempty"` 433 434 // ServerResponse contains the HTTP response code and headers from the server. 435 googleapi.ServerResponse `json:"-"` 436 // ForceSendFields is a list of field names (e.g. "Payload") to unconditionally 437 // include in API requests. By default, fields with empty or default values are 438 // omitted from API requests. See 439 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 440 // details. 441 ForceSendFields []string `json:"-"` 442 // NullFields is a list of field names (e.g. "Payload") to include in API 443 // requests with the JSON null value. By default, fields with empty values are 444 // omitted from API requests. See 445 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 446 NullFields []string `json:"-"` 447 } 448 449 func (s *QueryResponse) MarshalJSON() ([]byte, error) { 450 type NoMethod QueryResponse 451 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 452 } 453 454 // QueryResponsePayload: Payload containing device states information. 455 type QueryResponsePayload struct { 456 // Devices: States of the devices. Map of third-party device ID to struct of 457 // device states. 458 Devices map[string]googleapi.RawMessage `json:"devices,omitempty"` 459 // ForceSendFields is a list of field names (e.g. "Devices") to unconditionally 460 // include in API requests. By default, fields with empty or default values are 461 // omitted from API requests. See 462 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 463 // details. 464 ForceSendFields []string `json:"-"` 465 // NullFields is a list of field names (e.g. "Devices") to include in API 466 // requests with the JSON null value. By default, fields with empty values are 467 // omitted from API requests. See 468 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 469 NullFields []string `json:"-"` 470 } 471 472 func (s *QueryResponsePayload) MarshalJSON() ([]byte, error) { 473 type NoMethod QueryResponsePayload 474 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 475 } 476 477 // ReportStateAndNotificationDevice: The states and notifications specific to a 478 // device. 479 type ReportStateAndNotificationDevice struct { 480 // Notifications: Notifications metadata for devices. See the **Device 481 // NOTIFICATIONS** section of the individual trait reference guides 482 // (https://developers.home.google.com/cloud-to-cloud/traits). 483 Notifications googleapi.RawMessage `json:"notifications,omitempty"` 484 // States: States of devices to update. See the **Device STATES** section of 485 // the individual trait reference guides 486 // (https://developers.home.google.com/cloud-to-cloud/traits). 487 States googleapi.RawMessage `json:"states,omitempty"` 488 // ForceSendFields is a list of field names (e.g. "Notifications") to 489 // unconditionally include in API requests. By default, fields with empty or 490 // default values are omitted from API requests. See 491 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 492 // details. 493 ForceSendFields []string `json:"-"` 494 // NullFields is a list of field names (e.g. "Notifications") to include in API 495 // requests with the JSON null value. By default, fields with empty values are 496 // omitted from API requests. See 497 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 498 NullFields []string `json:"-"` 499 } 500 501 func (s *ReportStateAndNotificationDevice) MarshalJSON() ([]byte, error) { 502 type NoMethod ReportStateAndNotificationDevice 503 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 504 } 505 506 // ReportStateAndNotificationRequest: Request type for the 507 // `ReportStateAndNotification` 508 // (#google.home.graph.v1.HomeGraphApiService.ReportStateAndNotification) call. 509 // It may include states, notifications, or both. States and notifications are 510 // defined per `device_id` (for example, "123" and "456" in the following 511 // example). Example: ```json { "requestId": 512 // "ff36a3cc-ec34-11e6-b1a0-64510650abcf", "agentUserId": "1234", "payload": { 513 // "devices": { "states": { "123": { "on": true }, "456": { "on": true, 514 // "brightness": 10 } }, } } } ``` 515 type ReportStateAndNotificationRequest struct { 516 // AgentUserId: Required. Third-party user ID. 517 AgentUserId string `json:"agentUserId,omitempty"` 518 // EventId: Unique identifier per event (for example, a doorbell press). 519 EventId string `json:"eventId,omitempty"` 520 // FollowUpToken: Deprecated. 521 FollowUpToken string `json:"followUpToken,omitempty"` 522 // Payload: Required. State of devices to update and notification metadata for 523 // devices. 524 Payload *StateAndNotificationPayload `json:"payload,omitempty"` 525 // RequestId: Request ID used for debugging. 526 RequestId string `json:"requestId,omitempty"` 527 // ForceSendFields is a list of field names (e.g. "AgentUserId") to 528 // unconditionally include in API requests. By default, fields with empty or 529 // default values are omitted from API requests. See 530 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 531 // details. 532 ForceSendFields []string `json:"-"` 533 // NullFields is a list of field names (e.g. "AgentUserId") to include in API 534 // requests with the JSON null value. By default, fields with empty values are 535 // omitted from API requests. See 536 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 537 NullFields []string `json:"-"` 538 } 539 540 func (s *ReportStateAndNotificationRequest) MarshalJSON() ([]byte, error) { 541 type NoMethod ReportStateAndNotificationRequest 542 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 543 } 544 545 // ReportStateAndNotificationResponse: Response type for the 546 // `ReportStateAndNotification` 547 // (#google.home.graph.v1.HomeGraphApiService.ReportStateAndNotification) call. 548 type ReportStateAndNotificationResponse struct { 549 // RequestId: Request ID copied from ReportStateAndNotificationRequest. 550 RequestId string `json:"requestId,omitempty"` 551 552 // ServerResponse contains the HTTP response code and headers from the server. 553 googleapi.ServerResponse `json:"-"` 554 // ForceSendFields is a list of field names (e.g. "RequestId") to 555 // unconditionally include in API requests. By default, fields with empty or 556 // default values are omitted from API requests. See 557 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 558 // details. 559 ForceSendFields []string `json:"-"` 560 // NullFields is a list of field names (e.g. "RequestId") to include in API 561 // requests with the JSON null value. By default, fields with empty values are 562 // omitted from API requests. See 563 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 564 NullFields []string `json:"-"` 565 } 566 567 func (s *ReportStateAndNotificationResponse) MarshalJSON() ([]byte, error) { 568 type NoMethod ReportStateAndNotificationResponse 569 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 570 } 571 572 // RequestSyncDevicesRequest: Request type for the `RequestSyncDevices` 573 // (#google.home.graph.v1.HomeGraphApiService.RequestSyncDevices) call. 574 type RequestSyncDevicesRequest struct { 575 // AgentUserId: Required. Third-party user ID. 576 AgentUserId string `json:"agentUserId,omitempty"` 577 // Async: Optional. If set, the request will be added to a queue and a response 578 // will be returned immediately. This enables concurrent requests for the given 579 // `agent_user_id`, but the caller will not receive any error responses. 580 Async bool `json:"async,omitempty"` 581 // ForceSendFields is a list of field names (e.g. "AgentUserId") to 582 // unconditionally include in API requests. By default, fields with empty or 583 // default values are omitted from API requests. See 584 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 585 // details. 586 ForceSendFields []string `json:"-"` 587 // NullFields is a list of field names (e.g. "AgentUserId") to include in API 588 // requests with the JSON null value. By default, fields with empty values are 589 // omitted from API requests. See 590 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 591 NullFields []string `json:"-"` 592 } 593 594 func (s *RequestSyncDevicesRequest) MarshalJSON() ([]byte, error) { 595 type NoMethod RequestSyncDevicesRequest 596 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 597 } 598 599 // RequestSyncDevicesResponse: Response type for the `RequestSyncDevices` 600 // (#google.home.graph.v1.HomeGraphApiService.RequestSyncDevices) call. 601 // Intentionally empty upon success. An HTTP response code is returned with 602 // more details upon failure. 603 type RequestSyncDevicesResponse struct { 604 // ServerResponse contains the HTTP response code and headers from the server. 605 googleapi.ServerResponse `json:"-"` 606 } 607 608 // StateAndNotificationPayload: Payload containing the state and notification 609 // information for devices. 610 type StateAndNotificationPayload struct { 611 // Devices: The devices for updating state and sending notifications. 612 Devices *ReportStateAndNotificationDevice `json:"devices,omitempty"` 613 // ForceSendFields is a list of field names (e.g. "Devices") to unconditionally 614 // include in API requests. By default, fields with empty or default values are 615 // omitted from API requests. See 616 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 617 // details. 618 ForceSendFields []string `json:"-"` 619 // NullFields is a list of field names (e.g. "Devices") to include in API 620 // requests with the JSON null value. By default, fields with empty values are 621 // omitted from API requests. See 622 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 623 NullFields []string `json:"-"` 624 } 625 626 func (s *StateAndNotificationPayload) MarshalJSON() ([]byte, error) { 627 type NoMethod StateAndNotificationPayload 628 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 629 } 630 631 // SyncRequest: Request type for the `Sync` 632 // (#google.home.graph.v1.HomeGraphApiService.Sync) call. 633 type SyncRequest struct { 634 // AgentUserId: Required. Third-party user ID. 635 AgentUserId string `json:"agentUserId,omitempty"` 636 // RequestId: Request ID used for debugging. 637 RequestId string `json:"requestId,omitempty"` 638 // ForceSendFields is a list of field names (e.g. "AgentUserId") to 639 // unconditionally include in API requests. By default, fields with empty or 640 // default values are omitted from API requests. See 641 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 642 // details. 643 ForceSendFields []string `json:"-"` 644 // NullFields is a list of field names (e.g. "AgentUserId") to include in API 645 // requests with the JSON null value. By default, fields with empty values are 646 // omitted from API requests. See 647 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 648 NullFields []string `json:"-"` 649 } 650 651 func (s *SyncRequest) MarshalJSON() ([]byte, error) { 652 type NoMethod SyncRequest 653 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 654 } 655 656 // SyncResponse: Response type for the `Sync` 657 // (#google.home.graph.v1.HomeGraphApiService.Sync) call. This should follow 658 // the same format as the Google smart home `action.devices.SYNC` response 659 // (https://developers.home.google.com/cloud-to-cloud/intents/sync). Example: 660 // ```json { "requestId": "ff36a3cc-ec34-11e6-b1a0-64510650abcf", "payload": { 661 // "agentUserId": "1836.15267389", "devices": [{ "id": "123", "type": 662 // "action.devices.types.OUTLET", "traits": [ "action.devices.traits.OnOff" ], 663 // "name": { "defaultNames": ["My Outlet 1234"], "name": "Night light", 664 // "nicknames": ["wall plug"] }, "willReportState": false, "deviceInfo": { 665 // "manufacturer": "lights-out-inc", "model": "hs1234", "hwVersion": "3.2", 666 // "swVersion": "11.4" }, "customData": { "fooValue": 74, "barValue": true, 667 // "bazValue": "foo" } }] } } ``` 668 type SyncResponse struct { 669 // Payload: Devices associated with the third-party user. 670 Payload *SyncResponsePayload `json:"payload,omitempty"` 671 // RequestId: Request ID used for debugging. Copied from the request. 672 RequestId string `json:"requestId,omitempty"` 673 674 // ServerResponse contains the HTTP response code and headers from the server. 675 googleapi.ServerResponse `json:"-"` 676 // ForceSendFields is a list of field names (e.g. "Payload") to unconditionally 677 // include in API requests. By default, fields with empty or default values are 678 // omitted from API requests. See 679 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 680 // details. 681 ForceSendFields []string `json:"-"` 682 // NullFields is a list of field names (e.g. "Payload") to include in API 683 // requests with the JSON null value. By default, fields with empty values are 684 // omitted from API requests. See 685 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 686 NullFields []string `json:"-"` 687 } 688 689 func (s *SyncResponse) MarshalJSON() ([]byte, error) { 690 type NoMethod SyncResponse 691 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 692 } 693 694 // SyncResponsePayload: Payload containing device information. 695 type SyncResponsePayload struct { 696 // AgentUserId: Third-party user ID 697 AgentUserId string `json:"agentUserId,omitempty"` 698 // Devices: Devices associated with the third-party user. 699 Devices []*Device `json:"devices,omitempty"` 700 // ForceSendFields is a list of field names (e.g. "AgentUserId") to 701 // unconditionally include in API requests. By default, fields with empty or 702 // default values are omitted from API requests. See 703 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 704 // details. 705 ForceSendFields []string `json:"-"` 706 // NullFields is a list of field names (e.g. "AgentUserId") to include in API 707 // requests with the JSON null value. By default, fields with empty values are 708 // omitted from API requests. See 709 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 710 NullFields []string `json:"-"` 711 } 712 713 func (s *SyncResponsePayload) MarshalJSON() ([]byte, error) { 714 type NoMethod SyncResponsePayload 715 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 716 } 717 718 type AgentUsersDeleteCall struct { 719 s *Service 720 agentUserId string 721 urlParams_ gensupport.URLParams 722 ctx_ context.Context 723 header_ http.Header 724 } 725 726 // Delete: Unlinks the given third-party user from your smart home Action. All 727 // data related to this user will be deleted. For more details on how users 728 // link their accounts, see fulfillment and authentication 729 // (https://developers.home.google.com/cloud-to-cloud/primer/fulfillment). The 730 // third-party user's identity is passed in via the `agent_user_id` (see 731 // DeleteAgentUserRequest). This request must be authorized using service 732 // account credentials from your Actions console project. 733 // 734 // - agentUserId: Third-party user ID. 735 func (r *AgentUsersService) Delete(agentUserId string) *AgentUsersDeleteCall { 736 c := &AgentUsersDeleteCall{s: r.s, urlParams_: make(gensupport.URLParams)} 737 c.agentUserId = agentUserId 738 return c 739 } 740 741 // RequestId sets the optional parameter "requestId": Request ID used for 742 // debugging. 743 func (c *AgentUsersDeleteCall) RequestId(requestId string) *AgentUsersDeleteCall { 744 c.urlParams_.Set("requestId", requestId) 745 return c 746 } 747 748 // Fields allows partial responses to be retrieved. See 749 // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more 750 // details. 751 func (c *AgentUsersDeleteCall) Fields(s ...googleapi.Field) *AgentUsersDeleteCall { 752 c.urlParams_.Set("fields", googleapi.CombineFields(s)) 753 return c 754 } 755 756 // Context sets the context to be used in this call's Do method. 757 func (c *AgentUsersDeleteCall) Context(ctx context.Context) *AgentUsersDeleteCall { 758 c.ctx_ = ctx 759 return c 760 } 761 762 // Header returns a http.Header that can be modified by the caller to add 763 // headers to the request. 764 func (c *AgentUsersDeleteCall) Header() http.Header { 765 if c.header_ == nil { 766 c.header_ = make(http.Header) 767 } 768 return c.header_ 769 } 770 771 func (c *AgentUsersDeleteCall) doRequest(alt string) (*http.Response, error) { 772 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_) 773 var body io.Reader = nil 774 c.urlParams_.Set("alt", alt) 775 c.urlParams_.Set("prettyPrint", "false") 776 urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+agentUserId}") 777 urls += "?" + c.urlParams_.Encode() 778 req, err := http.NewRequest("DELETE", urls, body) 779 if err != nil { 780 return nil, err 781 } 782 req.Header = reqHeaders 783 googleapi.Expand(req.URL, map[string]string{ 784 "agentUserId": c.agentUserId, 785 }) 786 return gensupport.SendRequest(c.ctx_, c.s.client, req) 787 } 788 789 // Do executes the "homegraph.agentUsers.delete" call. 790 // Any non-2xx status code is an error. Response headers are in either 791 // *Empty.ServerResponse.Header or (if a response was returned at all) in 792 // error.(*googleapi.Error).Header. Use googleapi.IsNotModified to check 793 // whether the returned error was because http.StatusNotModified was returned. 794 func (c *AgentUsersDeleteCall) Do(opts ...googleapi.CallOption) (*Empty, error) { 795 gensupport.SetOptions(c.urlParams_, opts...) 796 res, err := c.doRequest("json") 797 if res != nil && res.StatusCode == http.StatusNotModified { 798 if res.Body != nil { 799 res.Body.Close() 800 } 801 return nil, gensupport.WrapError(&googleapi.Error{ 802 Code: res.StatusCode, 803 Header: res.Header, 804 }) 805 } 806 if err != nil { 807 return nil, err 808 } 809 defer googleapi.CloseBody(res) 810 if err := googleapi.CheckResponse(res); err != nil { 811 return nil, gensupport.WrapError(err) 812 } 813 ret := &Empty{ 814 ServerResponse: googleapi.ServerResponse{ 815 Header: res.Header, 816 HTTPStatusCode: res.StatusCode, 817 }, 818 } 819 target := &ret 820 if err := gensupport.DecodeResponse(target, res); err != nil { 821 return nil, err 822 } 823 return ret, nil 824 } 825 826 type DevicesQueryCall struct { 827 s *Service 828 queryrequest *QueryRequest 829 urlParams_ gensupport.URLParams 830 ctx_ context.Context 831 header_ http.Header 832 } 833 834 // Query: Gets the current states in Home Graph for the given set of the 835 // third-party user's devices. The third-party user's identity is passed in via 836 // the `agent_user_id` (see QueryRequest). This request must be authorized 837 // using service account credentials from your Actions console project. 838 func (r *DevicesService) Query(queryrequest *QueryRequest) *DevicesQueryCall { 839 c := &DevicesQueryCall{s: r.s, urlParams_: make(gensupport.URLParams)} 840 c.queryrequest = queryrequest 841 return c 842 } 843 844 // Fields allows partial responses to be retrieved. See 845 // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more 846 // details. 847 func (c *DevicesQueryCall) Fields(s ...googleapi.Field) *DevicesQueryCall { 848 c.urlParams_.Set("fields", googleapi.CombineFields(s)) 849 return c 850 } 851 852 // Context sets the context to be used in this call's Do method. 853 func (c *DevicesQueryCall) Context(ctx context.Context) *DevicesQueryCall { 854 c.ctx_ = ctx 855 return c 856 } 857 858 // Header returns a http.Header that can be modified by the caller to add 859 // headers to the request. 860 func (c *DevicesQueryCall) Header() http.Header { 861 if c.header_ == nil { 862 c.header_ = make(http.Header) 863 } 864 return c.header_ 865 } 866 867 func (c *DevicesQueryCall) doRequest(alt string) (*http.Response, error) { 868 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "application/json", c.header_) 869 var body io.Reader = nil 870 body, err := googleapi.WithoutDataWrapper.JSONReader(c.queryrequest) 871 if err != nil { 872 return nil, err 873 } 874 c.urlParams_.Set("alt", alt) 875 c.urlParams_.Set("prettyPrint", "false") 876 urls := googleapi.ResolveRelative(c.s.BasePath, "v1/devices:query") 877 urls += "?" + c.urlParams_.Encode() 878 req, err := http.NewRequest("POST", urls, body) 879 if err != nil { 880 return nil, err 881 } 882 req.Header = reqHeaders 883 return gensupport.SendRequest(c.ctx_, c.s.client, req) 884 } 885 886 // Do executes the "homegraph.devices.query" call. 887 // Any non-2xx status code is an error. Response headers are in either 888 // *QueryResponse.ServerResponse.Header or (if a response was returned at all) 889 // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to check 890 // whether the returned error was because http.StatusNotModified was returned. 891 func (c *DevicesQueryCall) Do(opts ...googleapi.CallOption) (*QueryResponse, error) { 892 gensupport.SetOptions(c.urlParams_, opts...) 893 res, err := c.doRequest("json") 894 if res != nil && res.StatusCode == http.StatusNotModified { 895 if res.Body != nil { 896 res.Body.Close() 897 } 898 return nil, gensupport.WrapError(&googleapi.Error{ 899 Code: res.StatusCode, 900 Header: res.Header, 901 }) 902 } 903 if err != nil { 904 return nil, err 905 } 906 defer googleapi.CloseBody(res) 907 if err := googleapi.CheckResponse(res); err != nil { 908 return nil, gensupport.WrapError(err) 909 } 910 ret := &QueryResponse{ 911 ServerResponse: googleapi.ServerResponse{ 912 Header: res.Header, 913 HTTPStatusCode: res.StatusCode, 914 }, 915 } 916 target := &ret 917 if err := gensupport.DecodeResponse(target, res); err != nil { 918 return nil, err 919 } 920 return ret, nil 921 } 922 923 type DevicesReportStateAndNotificationCall struct { 924 s *Service 925 reportstateandnotificationrequest *ReportStateAndNotificationRequest 926 urlParams_ gensupport.URLParams 927 ctx_ context.Context 928 header_ http.Header 929 } 930 931 // ReportStateAndNotification: Reports device state and optionally sends device 932 // notifications. Called by your smart home Action when the state of a 933 // third-party device changes or you need to send a notification about the 934 // device. See Implement Report State 935 // (https://developers.home.google.com/cloud-to-cloud/integration/report-state) 936 // for more information. This method updates the device state according to its 937 // declared traits 938 // (https://developers.home.google.com/cloud-to-cloud/primer/device-types-and-traits). 939 // Publishing a new state value outside of these traits will result in an 940 // `INVALID_ARGUMENT` error response. The third-party user's identity is passed 941 // in via the `agent_user_id` (see ReportStateAndNotificationRequest). This 942 // request must be authorized using service account credentials from your 943 // Actions console project. 944 func (r *DevicesService) ReportStateAndNotification(reportstateandnotificationrequest *ReportStateAndNotificationRequest) *DevicesReportStateAndNotificationCall { 945 c := &DevicesReportStateAndNotificationCall{s: r.s, urlParams_: make(gensupport.URLParams)} 946 c.reportstateandnotificationrequest = reportstateandnotificationrequest 947 return c 948 } 949 950 // Fields allows partial responses to be retrieved. See 951 // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more 952 // details. 953 func (c *DevicesReportStateAndNotificationCall) Fields(s ...googleapi.Field) *DevicesReportStateAndNotificationCall { 954 c.urlParams_.Set("fields", googleapi.CombineFields(s)) 955 return c 956 } 957 958 // Context sets the context to be used in this call's Do method. 959 func (c *DevicesReportStateAndNotificationCall) Context(ctx context.Context) *DevicesReportStateAndNotificationCall { 960 c.ctx_ = ctx 961 return c 962 } 963 964 // Header returns a http.Header that can be modified by the caller to add 965 // headers to the request. 966 func (c *DevicesReportStateAndNotificationCall) Header() http.Header { 967 if c.header_ == nil { 968 c.header_ = make(http.Header) 969 } 970 return c.header_ 971 } 972 973 func (c *DevicesReportStateAndNotificationCall) doRequest(alt string) (*http.Response, error) { 974 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "application/json", c.header_) 975 var body io.Reader = nil 976 body, err := googleapi.WithoutDataWrapper.JSONReader(c.reportstateandnotificationrequest) 977 if err != nil { 978 return nil, err 979 } 980 c.urlParams_.Set("alt", alt) 981 c.urlParams_.Set("prettyPrint", "false") 982 urls := googleapi.ResolveRelative(c.s.BasePath, "v1/devices:reportStateAndNotification") 983 urls += "?" + c.urlParams_.Encode() 984 req, err := http.NewRequest("POST", urls, body) 985 if err != nil { 986 return nil, err 987 } 988 req.Header = reqHeaders 989 return gensupport.SendRequest(c.ctx_, c.s.client, req) 990 } 991 992 // Do executes the "homegraph.devices.reportStateAndNotification" call. 993 // Any non-2xx status code is an error. Response headers are in either 994 // *ReportStateAndNotificationResponse.ServerResponse.Header or (if a response 995 // was returned at all) in error.(*googleapi.Error).Header. Use 996 // googleapi.IsNotModified to check whether the returned error was because 997 // http.StatusNotModified was returned. 998 func (c *DevicesReportStateAndNotificationCall) Do(opts ...googleapi.CallOption) (*ReportStateAndNotificationResponse, error) { 999 gensupport.SetOptions(c.urlParams_, opts...) 1000 res, err := c.doRequest("json") 1001 if res != nil && res.StatusCode == http.StatusNotModified { 1002 if res.Body != nil { 1003 res.Body.Close() 1004 } 1005 return nil, gensupport.WrapError(&googleapi.Error{ 1006 Code: res.StatusCode, 1007 Header: res.Header, 1008 }) 1009 } 1010 if err != nil { 1011 return nil, err 1012 } 1013 defer googleapi.CloseBody(res) 1014 if err := googleapi.CheckResponse(res); err != nil { 1015 return nil, gensupport.WrapError(err) 1016 } 1017 ret := &ReportStateAndNotificationResponse{ 1018 ServerResponse: googleapi.ServerResponse{ 1019 Header: res.Header, 1020 HTTPStatusCode: res.StatusCode, 1021 }, 1022 } 1023 target := &ret 1024 if err := gensupport.DecodeResponse(target, res); err != nil { 1025 return nil, err 1026 } 1027 return ret, nil 1028 } 1029 1030 type DevicesRequestSyncCall struct { 1031 s *Service 1032 requestsyncdevicesrequest *RequestSyncDevicesRequest 1033 urlParams_ gensupport.URLParams 1034 ctx_ context.Context 1035 header_ http.Header 1036 } 1037 1038 // RequestSync: Requests Google to send an `action.devices.SYNC` intent 1039 // (https://developers.home.google.com/cloud-to-cloud/intents/sync) to your 1040 // smart home Action to update device metadata for the given user. The 1041 // third-party user's identity is passed via the `agent_user_id` (see 1042 // RequestSyncDevicesRequest). This request must be authorized using service 1043 // account credentials from your Actions console project. 1044 func (r *DevicesService) RequestSync(requestsyncdevicesrequest *RequestSyncDevicesRequest) *DevicesRequestSyncCall { 1045 c := &DevicesRequestSyncCall{s: r.s, urlParams_: make(gensupport.URLParams)} 1046 c.requestsyncdevicesrequest = requestsyncdevicesrequest 1047 return c 1048 } 1049 1050 // Fields allows partial responses to be retrieved. See 1051 // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more 1052 // details. 1053 func (c *DevicesRequestSyncCall) Fields(s ...googleapi.Field) *DevicesRequestSyncCall { 1054 c.urlParams_.Set("fields", googleapi.CombineFields(s)) 1055 return c 1056 } 1057 1058 // Context sets the context to be used in this call's Do method. 1059 func (c *DevicesRequestSyncCall) Context(ctx context.Context) *DevicesRequestSyncCall { 1060 c.ctx_ = ctx 1061 return c 1062 } 1063 1064 // Header returns a http.Header that can be modified by the caller to add 1065 // headers to the request. 1066 func (c *DevicesRequestSyncCall) Header() http.Header { 1067 if c.header_ == nil { 1068 c.header_ = make(http.Header) 1069 } 1070 return c.header_ 1071 } 1072 1073 func (c *DevicesRequestSyncCall) doRequest(alt string) (*http.Response, error) { 1074 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "application/json", c.header_) 1075 var body io.Reader = nil 1076 body, err := googleapi.WithoutDataWrapper.JSONReader(c.requestsyncdevicesrequest) 1077 if err != nil { 1078 return nil, err 1079 } 1080 c.urlParams_.Set("alt", alt) 1081 c.urlParams_.Set("prettyPrint", "false") 1082 urls := googleapi.ResolveRelative(c.s.BasePath, "v1/devices:requestSync") 1083 urls += "?" + c.urlParams_.Encode() 1084 req, err := http.NewRequest("POST", urls, body) 1085 if err != nil { 1086 return nil, err 1087 } 1088 req.Header = reqHeaders 1089 return gensupport.SendRequest(c.ctx_, c.s.client, req) 1090 } 1091 1092 // Do executes the "homegraph.devices.requestSync" call. 1093 // Any non-2xx status code is an error. Response headers are in either 1094 // *RequestSyncDevicesResponse.ServerResponse.Header or (if a response was 1095 // returned at all) in error.(*googleapi.Error).Header. Use 1096 // googleapi.IsNotModified to check whether the returned error was because 1097 // http.StatusNotModified was returned. 1098 func (c *DevicesRequestSyncCall) Do(opts ...googleapi.CallOption) (*RequestSyncDevicesResponse, error) { 1099 gensupport.SetOptions(c.urlParams_, opts...) 1100 res, err := c.doRequest("json") 1101 if res != nil && res.StatusCode == http.StatusNotModified { 1102 if res.Body != nil { 1103 res.Body.Close() 1104 } 1105 return nil, gensupport.WrapError(&googleapi.Error{ 1106 Code: res.StatusCode, 1107 Header: res.Header, 1108 }) 1109 } 1110 if err != nil { 1111 return nil, err 1112 } 1113 defer googleapi.CloseBody(res) 1114 if err := googleapi.CheckResponse(res); err != nil { 1115 return nil, gensupport.WrapError(err) 1116 } 1117 ret := &RequestSyncDevicesResponse{ 1118 ServerResponse: googleapi.ServerResponse{ 1119 Header: res.Header, 1120 HTTPStatusCode: res.StatusCode, 1121 }, 1122 } 1123 target := &ret 1124 if err := gensupport.DecodeResponse(target, res); err != nil { 1125 return nil, err 1126 } 1127 return ret, nil 1128 } 1129 1130 type DevicesSyncCall struct { 1131 s *Service 1132 syncrequest *SyncRequest 1133 urlParams_ gensupport.URLParams 1134 ctx_ context.Context 1135 header_ http.Header 1136 } 1137 1138 // Sync: Gets all the devices associated with the given third-party user. The 1139 // third-party user's identity is passed in via the `agent_user_id` (see 1140 // SyncRequest). This request must be authorized using service account 1141 // credentials from your Actions console project. 1142 func (r *DevicesService) Sync(syncrequest *SyncRequest) *DevicesSyncCall { 1143 c := &DevicesSyncCall{s: r.s, urlParams_: make(gensupport.URLParams)} 1144 c.syncrequest = syncrequest 1145 return c 1146 } 1147 1148 // Fields allows partial responses to be retrieved. See 1149 // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more 1150 // details. 1151 func (c *DevicesSyncCall) Fields(s ...googleapi.Field) *DevicesSyncCall { 1152 c.urlParams_.Set("fields", googleapi.CombineFields(s)) 1153 return c 1154 } 1155 1156 // Context sets the context to be used in this call's Do method. 1157 func (c *DevicesSyncCall) Context(ctx context.Context) *DevicesSyncCall { 1158 c.ctx_ = ctx 1159 return c 1160 } 1161 1162 // Header returns a http.Header that can be modified by the caller to add 1163 // headers to the request. 1164 func (c *DevicesSyncCall) Header() http.Header { 1165 if c.header_ == nil { 1166 c.header_ = make(http.Header) 1167 } 1168 return c.header_ 1169 } 1170 1171 func (c *DevicesSyncCall) doRequest(alt string) (*http.Response, error) { 1172 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "application/json", c.header_) 1173 var body io.Reader = nil 1174 body, err := googleapi.WithoutDataWrapper.JSONReader(c.syncrequest) 1175 if err != nil { 1176 return nil, err 1177 } 1178 c.urlParams_.Set("alt", alt) 1179 c.urlParams_.Set("prettyPrint", "false") 1180 urls := googleapi.ResolveRelative(c.s.BasePath, "v1/devices:sync") 1181 urls += "?" + c.urlParams_.Encode() 1182 req, err := http.NewRequest("POST", urls, body) 1183 if err != nil { 1184 return nil, err 1185 } 1186 req.Header = reqHeaders 1187 return gensupport.SendRequest(c.ctx_, c.s.client, req) 1188 } 1189 1190 // Do executes the "homegraph.devices.sync" call. 1191 // Any non-2xx status code is an error. Response headers are in either 1192 // *SyncResponse.ServerResponse.Header or (if a response was returned at all) 1193 // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to check 1194 // whether the returned error was because http.StatusNotModified was returned. 1195 func (c *DevicesSyncCall) Do(opts ...googleapi.CallOption) (*SyncResponse, error) { 1196 gensupport.SetOptions(c.urlParams_, opts...) 1197 res, err := c.doRequest("json") 1198 if res != nil && res.StatusCode == http.StatusNotModified { 1199 if res.Body != nil { 1200 res.Body.Close() 1201 } 1202 return nil, gensupport.WrapError(&googleapi.Error{ 1203 Code: res.StatusCode, 1204 Header: res.Header, 1205 }) 1206 } 1207 if err != nil { 1208 return nil, err 1209 } 1210 defer googleapi.CloseBody(res) 1211 if err := googleapi.CheckResponse(res); err != nil { 1212 return nil, gensupport.WrapError(err) 1213 } 1214 ret := &SyncResponse{ 1215 ServerResponse: googleapi.ServerResponse{ 1216 Header: res.Header, 1217 HTTPStatusCode: res.StatusCode, 1218 }, 1219 } 1220 target := &ret 1221 if err := gensupport.DecodeResponse(target, res); err != nil { 1222 return nil, err 1223 } 1224 return ret, nil 1225 } 1226