Cloud IoT API v1 - Package cloud.google.com/go/iot/apiv1 (v1.4.0)

Package iot is an auto-generated package for the Cloud IoT API.

Registers and manages IoT (Internet of Things) devices that connect to the Google Cloud Platform.

Example usage

To get started with this package, create a client.

 ctx 
  
 := 
  
 context 
 . 
 Background 
 () 
 // This snippet has been automatically generated and should be regarded as a code template only. 
 // It will require modifications to work: 
 // - It may require correct/in-range values for request initialization. 
 // - It may require specifying regional endpoints when creating the service client as shown in: 
 //   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 
 c 
 , 
  
 err 
  
 := 
  
 iot 
 . 
 NewDeviceManagerClient 
 ( 
 ctx 
 ) 
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
 } 
 defer 
  
 c 
 . 
 Close 
 () 

The client will use your default application credentials. Clients should be reused instead of created as needed. The methods of Client are safe for concurrent use by multiple goroutines. The returned client must be Closed when it is done being used.

Using the Client

The following is an example of making an API call with the newly created client.

 ctx 
  
 := 
  
 context 
 . 
 Background 
 () 
 // This snippet has been automatically generated and should be regarded as a code template only. 
 // It will require modifications to work: 
 // - It may require correct/in-range values for request initialization. 
 // - It may require specifying regional endpoints when creating the service client as shown in: 
 //   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 
 c 
 , 
  
 err 
  
 := 
  
 iot 
 . 
 NewDeviceManagerClient 
 ( 
 ctx 
 ) 
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
 } 
 defer 
  
 c 
 . 
 Close 
 () 
 req 
  
 := 
  
& iotpb 
 . 
 CreateDeviceRegistryRequest 
 { 
  
 // TODO: Fill request struct fields. 
  
 // See https://pkg.go.dev/cloud.google.com/go/iot/apiv1/iotpb#CreateDeviceRegistryRequest. 
 } 
 resp 
 , 
  
 err 
  
 := 
  
 c 
 . 
 CreateDeviceRegistry 
 ( 
 ctx 
 , 
  
 req 
 ) 
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
 } 
 // TODO: Use resp. 
 _ 
  
 = 
  
 resp 

Use of Context

The ctx passed to NewDeviceManagerClient is used for authentication requests and for creating the underlying connection, but is not used for subsequent calls. Individual methods on the client use the ctx given to them.

To close the open connection, use the Close() method.

For information about setting deadlines, reusing contexts, and more please visit https://pkg.go.dev/cloud.google.com/go .

Functions

func DefaultAuthScopes

  func 
  
 DefaultAuthScopes 
 () 
  
 [] 
  string 
 
 

DefaultAuthScopes reports the default set of authentication scopes to use with this package.

DeviceIterator

  type 
  
 DeviceIterator 
  
 struct 
  
 { 
  
 // Response is the raw response for the current page. 
  
 // It must be cast to the RPC response type. 
  
 // Calling Next() or InternalFetch() updates this value. 
  
 Response 
  
 interface 
 {} 
  
 // InternalFetch is for use by the Google Cloud Libraries only. 
  
 // It is not part of the stable interface of this package. 
  
 // 
  
 // InternalFetch returns results from a single call to the underlying RPC. 
  
 // The number of results is no greater than pageSize. 
  
 // If there are no more results, nextPageToken is empty and err is nil. 
  
 InternalFetch 
  
 func 
 ( 
 pageSize 
  
  int 
 
 , 
  
 pageToken 
  
  string 
 
 ) 
  
 ( 
 results 
  
 [] 
 * 
  iotpb 
 
 . 
  Device 
 
 , 
  
 nextPageToken 
  
  string 
 
 , 
  
 err 
  
  error 
 
 ) 
  
 // contains filtered or unexported fields 
 } 
 

DeviceIterator manages a stream of *iotpb.Device.

func (*DeviceIterator) Next

  func 
  
 ( 
 it 
  
 * 
  DeviceIterator 
 
 ) 
  
 Next 
 () 
  
 ( 
 * 
  iotpb 
 
 . 
  Device 
 
 , 
  
  error 
 
 ) 
 

Next returns the next result. Its second return value is iterator.Done if there are no more results. Once Next returns Done, all subsequent calls will return Done.

func (*DeviceIterator) PageInfo

  func 
  
 ( 
 it 
  
 * 
  DeviceIterator 
 
 ) 
  
 PageInfo 
 () 
  
 * 
 iterator 
 . 
 PageInfo 
 

PageInfo supports pagination. See the google.golang.org/api/iterator package for details.

DeviceManagerCallOptions

  type 
  
 DeviceManagerCallOptions 
  
 struct 
  
 { 
  
 CreateDeviceRegistry 
  
 [] 
  gax 
 
 . 
  CallOption 
 
  
 GetDeviceRegistry 
  
 [] 
  gax 
 
 . 
  CallOption 
 
  
 UpdateDeviceRegistry 
  
 [] 
  gax 
 
 . 
  CallOption 
 
  
 DeleteDeviceRegistry 
  
 [] 
  gax 
 
 . 
  CallOption 
 
  
 ListDeviceRegistries 
  
 [] 
  gax 
 
 . 
  CallOption 
 
  
 CreateDevice 
  
 [] 
  gax 
 
 . 
  CallOption 
 
  
 GetDevice 
  
 [] 
  gax 
 
 . 
  CallOption 
 
  
 UpdateDevice 
  
 [] 
  gax 
 
 . 
  CallOption 
 
  
 DeleteDevice 
  
 [] 
  gax 
 
 . 
  CallOption 
 
  
 ListDevices 
  
 [] 
  gax 
 
 . 
  CallOption 
 
  
 ModifyCloudToDeviceConfig 
  
 [] 
  gax 
 
 . 
  CallOption 
 
  
 ListDeviceConfigVersions 
  
 [] 
  gax 
 
 . 
  CallOption 
 
  
 ListDeviceStates 
  
 [] 
  gax 
 
 . 
  CallOption 
 
  
 SetIamPolicy 
  
 [] 
  gax 
 
 . 
  CallOption 
 
  
 GetIamPolicy 
  
 [] 
  gax 
 
 . 
  CallOption 
 
  
 TestIamPermissions 
  
 [] 
  gax 
 
 . 
  CallOption 
 
  
 SendCommandToDevice 
  
 [] 
  gax 
 
 . 
  CallOption 
 
  
 BindDeviceToGateway 
  
 [] 
  gax 
 
 . 
  CallOption 
 
  
 UnbindDeviceFromGateway 
  
 [] 
  gax 
 
 . 
  CallOption 
 
 } 
 

DeviceManagerCallOptions contains the retry settings for each method of DeviceManagerClient.

DeviceManagerClient

  type 
  
 DeviceManagerClient 
  
 struct 
  
 { 
  
 // The call options for this service. 
  
 CallOptions 
  
 * 
  DeviceManagerCallOptions 
 
  
 // contains filtered or unexported fields 
 } 
 

DeviceManagerClient is a client for interacting with Cloud IoT API. Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.

Internet of Things (IoT) service. Securely connect and manage IoT devices.

func NewDeviceManagerClient

  func 
  
 NewDeviceManagerClient 
 ( 
 ctx 
  
  context 
 
 . 
  Context 
 
 , 
  
 opts 
  
 ... 
 option 
 . 
 ClientOption 
 ) 
  
 ( 
 * 
  DeviceManagerClient 
 
 , 
  
  error 
 
 ) 
 

NewDeviceManagerClient creates a new device manager client based on gRPC. The returned client must be Closed when it is done being used to clean up its underlying connections.

Internet of Things (IoT) service. Securely connect and manage IoT devices.

Example

  package 
  
 main 
 import 
  
 ( 
  
 "context" 
  
 iot 
  
 "cloud.google.com/go/iot/apiv1" 
 ) 
 func 
  
 main 
 () 
  
 { 
  
 ctx 
  
 := 
  
 context 
 . 
 Background 
 () 
  
 // This snippet has been automatically generated and should be regarded as a code template only. 
  
 // It will require modifications to work: 
  
 // - It may require correct/in-range values for request initialization. 
  
 // - It may require specifying regional endpoints when creating the service client as shown in: 
  
 //   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 
  
 c 
 , 
  
 err 
  
 := 
  
 iot 
 . 
 NewDeviceManagerClient 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 defer 
  
 c 
 . 
  Close 
 
 () 
  
 // TODO: Use client. 
  
 _ 
  
 = 
  
 c 
 } 
 

func (*DeviceManagerClient) BindDeviceToGateway

BindDeviceToGateway associates the device with the gateway.

Example

  package 
  
 main 
 import 
  
 ( 
  
 "context" 
  
 iot 
  
 "cloud.google.com/go/iot/apiv1" 
  
 iotpb 
  
 "cloud.google.com/go/iot/apiv1/iotpb" 
 ) 
 func 
  
 main 
 () 
  
 { 
  
 ctx 
  
 := 
  
 context 
 . 
 Background 
 () 
  
 // This snippet has been automatically generated and should be regarded as a code template only. 
  
 // It will require modifications to work: 
  
 // - It may require correct/in-range values for request initialization. 
  
 // - It may require specifying regional endpoints when creating the service client as shown in: 
  
 //   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 
  
 c 
 , 
  
 err 
  
 := 
  
 iot 
 . 
 NewDeviceManagerClient 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 defer 
  
 c 
 . 
  Close 
 
 () 
  
 req 
  
 := 
  
& iotpb 
 . 
 BindDeviceToGatewayRequest 
 { 
  
 // TODO: Fill request struct fields. 
  
 // See https://pkg.go.dev/cloud.google.com/go/iot/apiv1/iotpb#BindDeviceToGatewayRequest. 
  
 } 
  
 resp 
 , 
  
 err 
  
 := 
  
 c 
 . 
 BindDeviceToGateway 
 ( 
 ctx 
 , 
  
 req 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 // TODO: Use resp. 
  
 _ 
  
 = 
  
 resp 
 } 
 

func (*DeviceManagerClient) Close

  func 
  
 ( 
 c 
  
 * 
  DeviceManagerClient 
 
 ) 
  
 Close 
 () 
  
  error 
 
 

Close closes the connection to the API service. The user should invoke this when the client is no longer required.

func (*DeviceManagerClient) Connection (deprecated)

  func 
  
 ( 
 c 
  
 * 
  DeviceManagerClient 
 
 ) 
  
 Connection 
 () 
  
 * 
 grpc 
 . 
 ClientConn 
 

Connection returns a connection to the API service.

Deprecated: Connections are now pooled so this method does not always return the same resource.

func (*DeviceManagerClient) CreateDevice

CreateDevice creates a device in a device registry.

Example

  package 
  
 main 
 import 
  
 ( 
  
 "context" 
  
 iot 
  
 "cloud.google.com/go/iot/apiv1" 
  
 iotpb 
  
 "cloud.google.com/go/iot/apiv1/iotpb" 
 ) 
 func 
  
 main 
 () 
  
 { 
  
 ctx 
  
 := 
  
 context 
 . 
 Background 
 () 
  
 // This snippet has been automatically generated and should be regarded as a code template only. 
  
 // It will require modifications to work: 
  
 // - It may require correct/in-range values for request initialization. 
  
 // - It may require specifying regional endpoints when creating the service client as shown in: 
  
 //   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 
  
 c 
 , 
  
 err 
  
 := 
  
 iot 
 . 
 NewDeviceManagerClient 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 defer 
  
 c 
 . 
  Close 
 
 () 
  
 req 
  
 := 
  
& iotpb 
 . 
 CreateDeviceRequest 
 { 
  
 // TODO: Fill request struct fields. 
  
 // See https://pkg.go.dev/cloud.google.com/go/iot/apiv1/iotpb#CreateDeviceRequest. 
  
 } 
  
 resp 
 , 
  
 err 
  
 := 
  
 c 
 . 
 CreateDevice 
 ( 
 ctx 
 , 
  
 req 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 // TODO: Use resp. 
  
 _ 
  
 = 
  
 resp 
 } 
 

func (*DeviceManagerClient) CreateDeviceRegistry

CreateDeviceRegistry creates a device registry that contains devices.

Example

  package 
  
 main 
 import 
  
 ( 
  
 "context" 
  
 iot 
  
 "cloud.google.com/go/iot/apiv1" 
  
 iotpb 
  
 "cloud.google.com/go/iot/apiv1/iotpb" 
 ) 
 func 
  
 main 
 () 
  
 { 
  
 ctx 
  
 := 
  
 context 
 . 
 Background 
 () 
  
 // This snippet has been automatically generated and should be regarded as a code template only. 
  
 // It will require modifications to work: 
  
 // - It may require correct/in-range values for request initialization. 
  
 // - It may require specifying regional endpoints when creating the service client as shown in: 
  
 //   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 
  
 c 
 , 
  
 err 
  
 := 
  
 iot 
 . 
 NewDeviceManagerClient 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 defer 
  
 c 
 . 
  Close 
 
 () 
  
 req 
  
 := 
  
& iotpb 
 . 
 CreateDeviceRegistryRequest 
 { 
  
 // TODO: Fill request struct fields. 
  
 // See https://pkg.go.dev/cloud.google.com/go/iot/apiv1/iotpb#CreateDeviceRegistryRequest. 
  
 } 
  
 resp 
 , 
  
 err 
  
 := 
  
 c 
 . 
 CreateDeviceRegistry 
 ( 
 ctx 
 , 
  
 req 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 // TODO: Use resp. 
  
 _ 
  
 = 
  
 resp 
 } 
 

func (*DeviceManagerClient) DeleteDevice

DeleteDevice deletes a device.

Example

  package 
  
 main 
 import 
  
 ( 
  
 "context" 
  
 iot 
  
 "cloud.google.com/go/iot/apiv1" 
  
 iotpb 
  
 "cloud.google.com/go/iot/apiv1/iotpb" 
 ) 
 func 
  
 main 
 () 
  
 { 
  
 ctx 
  
 := 
  
 context 
 . 
 Background 
 () 
  
 // This snippet has been automatically generated and should be regarded as a code template only. 
  
 // It will require modifications to work: 
  
 // - It may require correct/in-range values for request initialization. 
  
 // - It may require specifying regional endpoints when creating the service client as shown in: 
  
 //   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 
  
 c 
 , 
  
 err 
  
 := 
  
 iot 
 . 
 NewDeviceManagerClient 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 defer 
  
 c 
 . 
  Close 
 
 () 
  
 req 
  
 := 
  
& iotpb 
 . 
 DeleteDeviceRequest 
 { 
  
 // TODO: Fill request struct fields. 
  
 // See https://pkg.go.dev/cloud.google.com/go/iot/apiv1/iotpb#DeleteDeviceRequest. 
  
 } 
  
 err 
  
 = 
  
 c 
 . 
 DeleteDevice 
 ( 
 ctx 
 , 
  
 req 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
 } 
 

func (*DeviceManagerClient) DeleteDeviceRegistry

DeleteDeviceRegistry deletes a device registry configuration.

Example

  package 
  
 main 
 import 
  
 ( 
  
 "context" 
  
 iot 
  
 "cloud.google.com/go/iot/apiv1" 
  
 iotpb 
  
 "cloud.google.com/go/iot/apiv1/iotpb" 
 ) 
 func 
  
 main 
 () 
  
 { 
  
 ctx 
  
 := 
  
 context 
 . 
 Background 
 () 
  
 // This snippet has been automatically generated and should be regarded as a code template only. 
  
 // It will require modifications to work: 
  
 // - It may require correct/in-range values for request initialization. 
  
 // - It may require specifying regional endpoints when creating the service client as shown in: 
  
 //   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 
  
 c 
 , 
  
 err 
  
 := 
  
 iot 
 . 
 NewDeviceManagerClient 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 defer 
  
 c 
 . 
  Close 
 
 () 
  
 req 
  
 := 
  
& iotpb 
 . 
 DeleteDeviceRegistryRequest 
 { 
  
 // TODO: Fill request struct fields. 
  
 // See https://pkg.go.dev/cloud.google.com/go/iot/apiv1/iotpb#DeleteDeviceRegistryRequest. 
  
 } 
  
 err 
  
 = 
  
 c 
 . 
 DeleteDeviceRegistry 
 ( 
 ctx 
 , 
  
 req 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
 } 
 

func (*DeviceManagerClient) GetDevice

GetDevice gets details about a device.

Example

  package 
  
 main 
 import 
  
 ( 
  
 "context" 
  
 iot 
  
 "cloud.google.com/go/iot/apiv1" 
  
 iotpb 
  
 "cloud.google.com/go/iot/apiv1/iotpb" 
 ) 
 func 
  
 main 
 () 
  
 { 
  
 ctx 
  
 := 
  
 context 
 . 
 Background 
 () 
  
 // This snippet has been automatically generated and should be regarded as a code template only. 
  
 // It will require modifications to work: 
  
 // - It may require correct/in-range values for request initialization. 
  
 // - It may require specifying regional endpoints when creating the service client as shown in: 
  
 //   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 
  
 c 
 , 
  
 err 
  
 := 
  
 iot 
 . 
 NewDeviceManagerClient 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 defer 
  
 c 
 . 
  Close 
 
 () 
  
 req 
  
 := 
  
& iotpb 
 . 
 GetDeviceRequest 
 { 
  
 // TODO: Fill request struct fields. 
  
 // See https://pkg.go.dev/cloud.google.com/go/iot/apiv1/iotpb#GetDeviceRequest. 
  
 } 
  
 resp 
 , 
  
 err 
  
 := 
  
 c 
 . 
 GetDevice 
 ( 
 ctx 
 , 
  
 req 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 // TODO: Use resp. 
  
 _ 
  
 = 
  
 resp 
 } 
 

func (*DeviceManagerClient) GetDeviceRegistry

GetDeviceRegistry gets a device registry configuration.

Example

  package 
  
 main 
 import 
  
 ( 
  
 "context" 
  
 iot 
  
 "cloud.google.com/go/iot/apiv1" 
  
 iotpb 
  
 "cloud.google.com/go/iot/apiv1/iotpb" 
 ) 
 func 
  
 main 
 () 
  
 { 
  
 ctx 
  
 := 
  
 context 
 . 
 Background 
 () 
  
 // This snippet has been automatically generated and should be regarded as a code template only. 
  
 // It will require modifications to work: 
  
 // - It may require correct/in-range values for request initialization. 
  
 // - It may require specifying regional endpoints when creating the service client as shown in: 
  
 //   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 
  
 c 
 , 
  
 err 
  
 := 
  
 iot 
 . 
 NewDeviceManagerClient 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 defer 
  
 c 
 . 
  Close 
 
 () 
  
 req 
  
 := 
  
& iotpb 
 . 
 GetDeviceRegistryRequest 
 { 
  
 // TODO: Fill request struct fields. 
  
 // See https://pkg.go.dev/cloud.google.com/go/iot/apiv1/iotpb#GetDeviceRegistryRequest. 
  
 } 
  
 resp 
 , 
  
 err 
  
 := 
  
 c 
 . 
 GetDeviceRegistry 
 ( 
 ctx 
 , 
  
 req 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 // TODO: Use resp. 
  
 _ 
  
 = 
  
 resp 
 } 
 

func (*DeviceManagerClient) GetIamPolicy

GetIamPolicy gets the access control policy for a resource. Returns an empty policy if the resource exists and does not have a policy set.

Example

  package 
  
 main 
 import 
  
 ( 
  
 "context" 
  
 iot 
  
 "cloud.google.com/go/iot/apiv1" 
  
 iampb 
  
 "google.golang.org/genproto/googleapis/iam/v1" 
 ) 
 func 
  
 main 
 () 
  
 { 
  
 ctx 
  
 := 
  
 context 
 . 
 Background 
 () 
  
 // This snippet has been automatically generated and should be regarded as a code template only. 
  
 // It will require modifications to work: 
  
 // - It may require correct/in-range values for request initialization. 
  
 // - It may require specifying regional endpoints when creating the service client as shown in: 
  
 //   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 
  
 c 
 , 
  
 err 
  
 := 
  
 iot 
 . 
 NewDeviceManagerClient 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 defer 
  
 c 
 . 
  Close 
 
 () 
  
 req 
  
 := 
  
& iampb 
 . 
 GetIamPolicyRequest 
 { 
  
 // TODO: Fill request struct fields. 
  
 // See https://pkg.go.dev/google.golang.org/genproto/googleapis/iam/v1#GetIamPolicyRequest. 
  
 } 
  
 resp 
 , 
  
 err 
  
 := 
  
 c 
 . 
 GetIamPolicy 
 ( 
 ctx 
 , 
  
 req 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 // TODO: Use resp. 
  
 _ 
  
 = 
  
 resp 
 } 
 

func (*DeviceManagerClient) ListDeviceConfigVersions

ListDeviceConfigVersions lists the last few versions of the device configuration in descending order (i.e.: newest first).

Example

  package 
  
 main 
 import 
  
 ( 
  
 "context" 
  
 iot 
  
 "cloud.google.com/go/iot/apiv1" 
  
 iotpb 
  
 "cloud.google.com/go/iot/apiv1/iotpb" 
 ) 
 func 
  
 main 
 () 
  
 { 
  
 ctx 
  
 := 
  
 context 
 . 
 Background 
 () 
  
 // This snippet has been automatically generated and should be regarded as a code template only. 
  
 // It will require modifications to work: 
  
 // - It may require correct/in-range values for request initialization. 
  
 // - It may require specifying regional endpoints when creating the service client as shown in: 
  
 //   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 
  
 c 
 , 
  
 err 
  
 := 
  
 iot 
 . 
 NewDeviceManagerClient 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 defer 
  
 c 
 . 
  Close 
 
 () 
  
 req 
  
 := 
  
& iotpb 
 . 
 ListDeviceConfigVersionsRequest 
 { 
  
 // TODO: Fill request struct fields. 
  
 // See https://pkg.go.dev/cloud.google.com/go/iot/apiv1/iotpb#ListDeviceConfigVersionsRequest. 
  
 } 
  
 resp 
 , 
  
 err 
  
 := 
  
 c 
 . 
 ListDeviceConfigVersions 
 ( 
 ctx 
 , 
  
 req 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 // TODO: Use resp. 
  
 _ 
  
 = 
  
 resp 
 } 
 

func (*DeviceManagerClient) ListDeviceRegistries

ListDeviceRegistries lists device registries.

Example

  package 
  
 main 
 import 
  
 ( 
  
 "context" 
  
 iot 
  
 "cloud.google.com/go/iot/apiv1" 
  
 iotpb 
  
 "cloud.google.com/go/iot/apiv1/iotpb" 
  
 "google.golang.org/api/iterator" 
 ) 
 func 
  
 main 
 () 
  
 { 
  
 ctx 
  
 := 
  
 context 
 . 
 Background 
 () 
  
 // This snippet has been automatically generated and should be regarded as a code template only. 
  
 // It will require modifications to work: 
  
 // - It may require correct/in-range values for request initialization. 
  
 // - It may require specifying regional endpoints when creating the service client as shown in: 
  
 //   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 
  
 c 
 , 
  
 err 
  
 := 
  
 iot 
 . 
 NewDeviceManagerClient 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 defer 
  
 c 
 . 
  Close 
 
 () 
  
 req 
  
 := 
  
& iotpb 
 . 
 ListDeviceRegistriesRequest 
 { 
  
 // TODO: Fill request struct fields. 
  
 // See https://pkg.go.dev/cloud.google.com/go/iot/apiv1/iotpb#ListDeviceRegistriesRequest. 
  
 } 
  
 it 
  
 := 
  
 c 
 . 
 ListDeviceRegistries 
 ( 
 ctx 
 , 
  
 req 
 ) 
  
 for 
  
 { 
  
 resp 
 , 
  
 err 
  
 := 
  
 it 
 . 
 Next 
 () 
  
 if 
  
 err 
  
 == 
  
 iterator 
 . 
 Done 
  
 { 
  
 break 
  
 } 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 // TODO: Use resp. 
  
 _ 
  
 = 
  
 resp 
  
 } 
 } 
 

func (*DeviceManagerClient) ListDeviceStates

ListDeviceStates lists the last few versions of the device state in descending order (i.e.: newest first).

Example

  package 
  
 main 
 import 
  
 ( 
  
 "context" 
  
 iot 
  
 "cloud.google.com/go/iot/apiv1" 
  
 iotpb 
  
 "cloud.google.com/go/iot/apiv1/iotpb" 
 ) 
 func 
  
 main 
 () 
  
 { 
  
 ctx 
  
 := 
  
 context 
 . 
 Background 
 () 
  
 // This snippet has been automatically generated and should be regarded as a code template only. 
  
 // It will require modifications to work: 
  
 // - It may require correct/in-range values for request initialization. 
  
 // - It may require specifying regional endpoints when creating the service client as shown in: 
  
 //   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 
  
 c 
 , 
  
 err 
  
 := 
  
 iot 
 . 
 NewDeviceManagerClient 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 defer 
  
 c 
 . 
  Close 
 
 () 
  
 req 
  
 := 
  
& iotpb 
 . 
 ListDeviceStatesRequest 
 { 
  
 // TODO: Fill request struct fields. 
  
 // See https://pkg.go.dev/cloud.google.com/go/iot/apiv1/iotpb#ListDeviceStatesRequest. 
  
 } 
  
 resp 
 , 
  
 err 
  
 := 
  
 c 
 . 
 ListDeviceStates 
 ( 
 ctx 
 , 
  
 req 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 // TODO: Use resp. 
  
 _ 
  
 = 
  
 resp 
 } 
 

func (*DeviceManagerClient) ListDevices

ListDevices list devices in a device registry.

Example

  package 
  
 main 
 import 
  
 ( 
  
 "context" 
  
 iot 
  
 "cloud.google.com/go/iot/apiv1" 
  
 iotpb 
  
 "cloud.google.com/go/iot/apiv1/iotpb" 
  
 "google.golang.org/api/iterator" 
 ) 
 func 
  
 main 
 () 
  
 { 
  
 ctx 
  
 := 
  
 context 
 . 
 Background 
 () 
  
 // This snippet has been automatically generated and should be regarded as a code template only. 
  
 // It will require modifications to work: 
  
 // - It may require correct/in-range values for request initialization. 
  
 // - It may require specifying regional endpoints when creating the service client as shown in: 
  
 //   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 
  
 c 
 , 
  
 err 
  
 := 
  
 iot 
 . 
 NewDeviceManagerClient 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 defer 
  
 c 
 . 
  Close 
 
 () 
  
 req 
  
 := 
  
& iotpb 
 . 
 ListDevicesRequest 
 { 
  
 // TODO: Fill request struct fields. 
  
 // See https://pkg.go.dev/cloud.google.com/go/iot/apiv1/iotpb#ListDevicesRequest. 
  
 } 
  
 it 
  
 := 
  
 c 
 . 
 ListDevices 
 ( 
 ctx 
 , 
  
 req 
 ) 
  
 for 
  
 { 
  
 resp 
 , 
  
 err 
  
 := 
  
 it 
 . 
 Next 
 () 
  
 if 
  
 err 
  
 == 
  
 iterator 
 . 
 Done 
  
 { 
  
 break 
  
 } 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 // TODO: Use resp. 
  
 _ 
  
 = 
  
 resp 
  
 } 
 } 
 

func (*DeviceManagerClient) ModifyCloudToDeviceConfig

ModifyCloudToDeviceConfig modifies the configuration for the device, which is eventually sent from the Cloud IoT Core servers. Returns the modified configuration version and its metadata.

Example

  package 
  
 main 
 import 
  
 ( 
  
 "context" 
  
 iot 
  
 "cloud.google.com/go/iot/apiv1" 
  
 iotpb 
  
 "cloud.google.com/go/iot/apiv1/iotpb" 
 ) 
 func 
  
 main 
 () 
  
 { 
  
 ctx 
  
 := 
  
 context 
 . 
 Background 
 () 
  
 // This snippet has been automatically generated and should be regarded as a code template only. 
  
 // It will require modifications to work: 
  
 // - It may require correct/in-range values for request initialization. 
  
 // - It may require specifying regional endpoints when creating the service client as shown in: 
  
 //   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 
  
 c 
 , 
  
 err 
  
 := 
  
 iot 
 . 
 NewDeviceManagerClient 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 defer 
  
 c 
 . 
  Close 
 
 () 
  
 req 
  
 := 
  
& iotpb 
 . 
 ModifyCloudToDeviceConfigRequest 
 { 
  
 // TODO: Fill request struct fields. 
  
 // See https://pkg.go.dev/cloud.google.com/go/iot/apiv1/iotpb#ModifyCloudToDeviceConfigRequest. 
  
 } 
  
 resp 
 , 
  
 err 
  
 := 
  
 c 
 . 
 ModifyCloudToDeviceConfig 
 ( 
 ctx 
 , 
  
 req 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 // TODO: Use resp. 
  
 _ 
  
 = 
  
 resp 
 } 
 

func (*DeviceManagerClient) SendCommandToDevice

SendCommandToDevice sends a command to the specified device. In order for a device to be able to receive commands, it must:

be connected to Cloud IoT Core using the MQTT protocol, and

be subscribed to the group of MQTT topics specified by /devices/{device-id}/commands/#. This subscription will receive commands at the top-level topic /devices/{device-id}/commands as well as commands for subfolders, like /devices/{device-id}/commands/subfolder. Note that subscribing to specific subfolders is not supported. If the command could not be delivered to the device, this method will return an error; in particular, if the device is not subscribed, this method will return FAILED_PRECONDITION. Otherwise, this method will return OK. If the subscription is QoS 1, at least once delivery will be guaranteed; for QoS 0, no acknowledgment will be expected from the device.

Example

  package 
  
 main 
 import 
  
 ( 
  
 "context" 
  
 iot 
  
 "cloud.google.com/go/iot/apiv1" 
  
 iotpb 
  
 "cloud.google.com/go/iot/apiv1/iotpb" 
 ) 
 func 
  
 main 
 () 
  
 { 
  
 ctx 
  
 := 
  
 context 
 . 
 Background 
 () 
  
 // This snippet has been automatically generated and should be regarded as a code template only. 
  
 // It will require modifications to work: 
  
 // - It may require correct/in-range values for request initialization. 
  
 // - It may require specifying regional endpoints when creating the service client as shown in: 
  
 //   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 
  
 c 
 , 
  
 err 
  
 := 
  
 iot 
 . 
 NewDeviceManagerClient 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 defer 
  
 c 
 . 
  Close 
 
 () 
  
 req 
  
 := 
  
& iotpb 
 . 
 SendCommandToDeviceRequest 
 { 
  
 // TODO: Fill request struct fields. 
  
 // See https://pkg.go.dev/cloud.google.com/go/iot/apiv1/iotpb#SendCommandToDeviceRequest. 
  
 } 
  
 resp 
 , 
  
 err 
  
 := 
  
 c 
 . 
 SendCommandToDevice 
 ( 
 ctx 
 , 
  
 req 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 // TODO: Use resp. 
  
 _ 
  
 = 
  
 resp 
 } 
 

func (*DeviceManagerClient) SetIamPolicy

SetIamPolicy sets the access control policy on the specified resource. Replaces any existing policy.

Example

  package 
  
 main 
 import 
  
 ( 
  
 "context" 
  
 iot 
  
 "cloud.google.com/go/iot/apiv1" 
  
 iampb 
  
 "google.golang.org/genproto/googleapis/iam/v1" 
 ) 
 func 
  
 main 
 () 
  
 { 
  
 ctx 
  
 := 
  
 context 
 . 
 Background 
 () 
  
 // This snippet has been automatically generated and should be regarded as a code template only. 
  
 // It will require modifications to work: 
  
 // - It may require correct/in-range values for request initialization. 
  
 // - It may require specifying regional endpoints when creating the service client as shown in: 
  
 //   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 
  
 c 
 , 
  
 err 
  
 := 
  
 iot 
 . 
 NewDeviceManagerClient 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 defer 
  
 c 
 . 
  Close 
 
 () 
  
 req 
  
 := 
  
& iampb 
 . 
 SetIamPolicyRequest 
 { 
  
 // TODO: Fill request struct fields. 
  
 // See https://pkg.go.dev/google.golang.org/genproto/googleapis/iam/v1#SetIamPolicyRequest. 
  
 } 
  
 resp 
 , 
  
 err 
  
 := 
  
 c 
 . 
 SetIamPolicy 
 ( 
 ctx 
 , 
  
 req 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 // TODO: Use resp. 
  
 _ 
  
 = 
  
 resp 
 } 
 

func (*DeviceManagerClient) TestIamPermissions

TestIamPermissions returns permissions that a caller has on the specified resource. If the resource does not exist, this will return an empty set of permissions, not a NOT_FOUND error.

Example

  package 
  
 main 
 import 
  
 ( 
  
 "context" 
  
 iot 
  
 "cloud.google.com/go/iot/apiv1" 
  
 iampb 
  
 "google.golang.org/genproto/googleapis/iam/v1" 
 ) 
 func 
  
 main 
 () 
  
 { 
  
 ctx 
  
 := 
  
 context 
 . 
 Background 
 () 
  
 // This snippet has been automatically generated and should be regarded as a code template only. 
  
 // It will require modifications to work: 
  
 // - It may require correct/in-range values for request initialization. 
  
 // - It may require specifying regional endpoints when creating the service client as shown in: 
  
 //   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 
  
 c 
 , 
  
 err 
  
 := 
  
 iot 
 . 
 NewDeviceManagerClient 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 defer 
  
 c 
 . 
  Close 
 
 () 
  
 req 
  
 := 
  
& iampb 
 . 
 TestIamPermissionsRequest 
 { 
  
 // TODO: Fill request struct fields. 
  
 // See https://pkg.go.dev/google.golang.org/genproto/googleapis/iam/v1#TestIamPermissionsRequest. 
  
 } 
  
 resp 
 , 
  
 err 
  
 := 
  
 c 
 . 
 TestIamPermissions 
 ( 
 ctx 
 , 
  
 req 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 // TODO: Use resp. 
  
 _ 
  
 = 
  
 resp 
 } 
 

func (*DeviceManagerClient) UnbindDeviceFromGateway

UnbindDeviceFromGateway deletes the association between the device and the gateway.

Example

  package 
  
 main 
 import 
  
 ( 
  
 "context" 
  
 iot 
  
 "cloud.google.com/go/iot/apiv1" 
  
 iotpb 
  
 "cloud.google.com/go/iot/apiv1/iotpb" 
 ) 
 func 
  
 main 
 () 
  
 { 
  
 ctx 
  
 := 
  
 context 
 . 
 Background 
 () 
  
 // This snippet has been automatically generated and should be regarded as a code template only. 
  
 // It will require modifications to work: 
  
 // - It may require correct/in-range values for request initialization. 
  
 // - It may require specifying regional endpoints when creating the service client as shown in: 
  
 //   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 
  
 c 
 , 
  
 err 
  
 := 
  
 iot 
 . 
 NewDeviceManagerClient 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 defer 
  
 c 
 . 
  Close 
 
 () 
  
 req 
  
 := 
  
& iotpb 
 . 
 UnbindDeviceFromGatewayRequest 
 { 
  
 // TODO: Fill request struct fields. 
  
 // See https://pkg.go.dev/cloud.google.com/go/iot/apiv1/iotpb#UnbindDeviceFromGatewayRequest. 
  
 } 
  
 resp 
 , 
  
 err 
  
 := 
  
 c 
 . 
 UnbindDeviceFromGateway 
 ( 
 ctx 
 , 
  
 req 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 // TODO: Use resp. 
  
 _ 
  
 = 
  
 resp 
 } 
 

func (*DeviceManagerClient) UpdateDevice

UpdateDevice updates a device.

Example

  package 
  
 main 
 import 
  
 ( 
  
 "context" 
  
 iot 
  
 "cloud.google.com/go/iot/apiv1" 
  
 iotpb 
  
 "cloud.google.com/go/iot/apiv1/iotpb" 
 ) 
 func 
  
 main 
 () 
  
 { 
  
 ctx 
  
 := 
  
 context 
 . 
 Background 
 () 
  
 // This snippet has been automatically generated and should be regarded as a code template only. 
  
 // It will require modifications to work: 
  
 // - It may require correct/in-range values for request initialization. 
  
 // - It may require specifying regional endpoints when creating the service client as shown in: 
  
 //   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 
  
 c 
 , 
  
 err 
  
 := 
  
 iot 
 . 
 NewDeviceManagerClient 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 defer 
  
 c 
 . 
  Close 
 
 () 
  
 req 
  
 := 
  
& iotpb 
 . 
 UpdateDeviceRequest 
 { 
  
 // TODO: Fill request struct fields. 
  
 // See https://pkg.go.dev/cloud.google.com/go/iot/apiv1/iotpb#UpdateDeviceRequest. 
  
 } 
  
 resp 
 , 
  
 err 
  
 := 
  
 c 
 . 
 UpdateDevice 
 ( 
 ctx 
 , 
  
 req 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 // TODO: Use resp. 
  
 _ 
  
 = 
  
 resp 
 } 
 

func (*DeviceManagerClient) UpdateDeviceRegistry

UpdateDeviceRegistry updates a device registry configuration.

Example

  package 
  
 main 
 import 
  
 ( 
  
 "context" 
  
 iot 
  
 "cloud.google.com/go/iot/apiv1" 
  
 iotpb 
  
 "cloud.google.com/go/iot/apiv1/iotpb" 
 ) 
 func 
  
 main 
 () 
  
 { 
  
 ctx 
  
 := 
  
 context 
 . 
 Background 
 () 
  
 // This snippet has been automatically generated and should be regarded as a code template only. 
  
 // It will require modifications to work: 
  
 // - It may require correct/in-range values for request initialization. 
  
 // - It may require specifying regional endpoints when creating the service client as shown in: 
  
 //   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 
  
 c 
 , 
  
 err 
  
 := 
  
 iot 
 . 
 NewDeviceManagerClient 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 defer 
  
 c 
 . 
  Close 
 
 () 
  
 req 
  
 := 
  
& iotpb 
 . 
 UpdateDeviceRegistryRequest 
 { 
  
 // TODO: Fill request struct fields. 
  
 // See https://pkg.go.dev/cloud.google.com/go/iot/apiv1/iotpb#UpdateDeviceRegistryRequest. 
  
 } 
  
 resp 
 , 
  
 err 
  
 := 
  
 c 
 . 
 UpdateDeviceRegistry 
 ( 
 ctx 
 , 
  
 req 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 // TODO: Use resp. 
  
 _ 
  
 = 
  
 resp 
 } 
 

DeviceRegistryIterator

  type 
  
 DeviceRegistryIterator 
  
 struct 
  
 { 
  
 // Response is the raw response for the current page. 
  
 // It must be cast to the RPC response type. 
  
 // Calling Next() or InternalFetch() updates this value. 
  
 Response 
  
 interface 
 {} 
  
 // InternalFetch is for use by the Google Cloud Libraries only. 
  
 // It is not part of the stable interface of this package. 
  
 // 
  
 // InternalFetch returns results from a single call to the underlying RPC. 
  
 // The number of results is no greater than pageSize. 
  
 // If there are no more results, nextPageToken is empty and err is nil. 
  
 InternalFetch 
  
 func 
 ( 
 pageSize 
  
  int 
 
 , 
  
 pageToken 
  
  string 
 
 ) 
  
 ( 
 results 
  
 [] 
 * 
  iotpb 
 
 . 
  DeviceRegistry 
 
 , 
  
 nextPageToken 
  
  string 
 
 , 
  
 err 
  
  error 
 
 ) 
  
 // contains filtered or unexported fields 
 } 
 

DeviceRegistryIterator manages a stream of *iotpb.DeviceRegistry.

func (*DeviceRegistryIterator) Next

Next returns the next result. Its second return value is iterator.Done if there are no more results. Once Next returns Done, all subsequent calls will return Done.

func (*DeviceRegistryIterator) PageInfo

  func 
  
 ( 
 it 
  
 * 
  DeviceRegistryIterator 
 
 ) 
  
 PageInfo 
 () 
  
 * 
 iterator 
 . 
 PageInfo 
 

PageInfo supports pagination. See the google.golang.org/api/iterator package for details.

Design a Mobile Site
View Site in Mobile | Classic
Share by: