go: cloud.google.com/go/iot/apiv1 Index | Examples | Files

package iot

import "cloud.google.com/go/iot/apiv1"

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

NOTE: This package is in alpha. It is not stable, and is likely to change.

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

Use of Context

The ctx passed to NewClient 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 godoc.org/cloud.google.com/go.

Index

Examples

Package Files

device_manager_client.go doc.go

func DefaultAuthScopes Uses

func DefaultAuthScopes() []string

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

type DeviceIterator Uses

type DeviceIterator struct {

    // 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 Uses

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 Uses

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

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

type DeviceManagerCallOptions Uses

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.

type DeviceManagerClient Uses

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.

func NewDeviceManagerClient Uses

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

NewDeviceManagerClient creates a new device manager client.

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

Code:

ctx := context.Background()
c, err := iot.NewDeviceManagerClient(ctx)
if err != nil {
    // TODO: Handle error.
}
// TODO: Use client.
_ = c

func (*DeviceManagerClient) BindDeviceToGateway Uses

func (c *DeviceManagerClient) BindDeviceToGateway(ctx context.Context, req *iotpb.BindDeviceToGatewayRequest, opts ...gax.CallOption) (*iotpb.BindDeviceToGatewayResponse, error)

BindDeviceToGateway associates the device with the gateway.

Code:

ctx := context.Background()
c, err := iot.NewDeviceManagerClient(ctx)
if err != nil {
    // TODO: Handle error.
}

req := &iotpb.BindDeviceToGatewayRequest{
    // TODO: Fill request struct fields.
}
resp, err := c.BindDeviceToGateway(ctx, req)
if err != nil {
    // TODO: Handle error.
}
// TODO: Use resp.
_ = resp

func (*DeviceManagerClient) Close Uses

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 Uses

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

Connection returns the client's connection to the API service.

func (*DeviceManagerClient) CreateDevice Uses

func (c *DeviceManagerClient) CreateDevice(ctx context.Context, req *iotpb.CreateDeviceRequest, opts ...gax.CallOption) (*iotpb.Device, error)

CreateDevice creates a device in a device registry.

Code:

ctx := context.Background()
c, err := iot.NewDeviceManagerClient(ctx)
if err != nil {
    // TODO: Handle error.
}

req := &iotpb.CreateDeviceRequest{
    // TODO: Fill request struct fields.
}
resp, err := c.CreateDevice(ctx, req)
if err != nil {
    // TODO: Handle error.
}
// TODO: Use resp.
_ = resp

func (*DeviceManagerClient) CreateDeviceRegistry Uses

func (c *DeviceManagerClient) CreateDeviceRegistry(ctx context.Context, req *iotpb.CreateDeviceRegistryRequest, opts ...gax.CallOption) (*iotpb.DeviceRegistry, error)

CreateDeviceRegistry creates a device registry that contains devices.

Code:

ctx := context.Background()
c, err := iot.NewDeviceManagerClient(ctx)
if err != nil {
    // TODO: Handle error.
}

req := &iotpb.CreateDeviceRegistryRequest{
    // TODO: Fill request struct fields.
}
resp, err := c.CreateDeviceRegistry(ctx, req)
if err != nil {
    // TODO: Handle error.
}
// TODO: Use resp.
_ = resp

func (*DeviceManagerClient) DeleteDevice Uses

func (c *DeviceManagerClient) DeleteDevice(ctx context.Context, req *iotpb.DeleteDeviceRequest, opts ...gax.CallOption) error

DeleteDevice deletes a device.

Code:

ctx := context.Background()
c, err := iot.NewDeviceManagerClient(ctx)
if err != nil {
    // TODO: Handle error.
}

req := &iotpb.DeleteDeviceRequest{
    // TODO: Fill request struct fields.
}
err = c.DeleteDevice(ctx, req)
if err != nil {
    // TODO: Handle error.
}

func (*DeviceManagerClient) DeleteDeviceRegistry Uses

func (c *DeviceManagerClient) DeleteDeviceRegistry(ctx context.Context, req *iotpb.DeleteDeviceRegistryRequest, opts ...gax.CallOption) error

DeleteDeviceRegistry deletes a device registry configuration.

Code:

ctx := context.Background()
c, err := iot.NewDeviceManagerClient(ctx)
if err != nil {
    // TODO: Handle error.
}

req := &iotpb.DeleteDeviceRegistryRequest{
    // TODO: Fill request struct fields.
}
err = c.DeleteDeviceRegistry(ctx, req)
if err != nil {
    // TODO: Handle error.
}

func (*DeviceManagerClient) GetDevice Uses

func (c *DeviceManagerClient) GetDevice(ctx context.Context, req *iotpb.GetDeviceRequest, opts ...gax.CallOption) (*iotpb.Device, error)

GetDevice gets details about a device.

Code:

ctx := context.Background()
c, err := iot.NewDeviceManagerClient(ctx)
if err != nil {
    // TODO: Handle error.
}

req := &iotpb.GetDeviceRequest{
    // TODO: Fill request struct fields.
}
resp, err := c.GetDevice(ctx, req)
if err != nil {
    // TODO: Handle error.
}
// TODO: Use resp.
_ = resp

func (*DeviceManagerClient) GetDeviceRegistry Uses

func (c *DeviceManagerClient) GetDeviceRegistry(ctx context.Context, req *iotpb.GetDeviceRegistryRequest, opts ...gax.CallOption) (*iotpb.DeviceRegistry, error)

GetDeviceRegistry gets a device registry configuration.

Code:

ctx := context.Background()
c, err := iot.NewDeviceManagerClient(ctx)
if err != nil {
    // TODO: Handle error.
}

req := &iotpb.GetDeviceRegistryRequest{
    // TODO: Fill request struct fields.
}
resp, err := c.GetDeviceRegistry(ctx, req)
if err != nil {
    // TODO: Handle error.
}
// TODO: Use resp.
_ = resp

func (*DeviceManagerClient) GetIamPolicy Uses

func (c *DeviceManagerClient) GetIamPolicy(ctx context.Context, req *iampb.GetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error)

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

Code:

ctx := context.Background()
c, err := iot.NewDeviceManagerClient(ctx)
if err != nil {
    // TODO: Handle error.
}

req := &iampb.GetIamPolicyRequest{
    // TODO: Fill request struct fields.
}
resp, err := c.GetIamPolicy(ctx, req)
if err != nil {
    // TODO: Handle error.
}
// TODO: Use resp.
_ = resp

func (*DeviceManagerClient) ListDeviceConfigVersions Uses

func (c *DeviceManagerClient) ListDeviceConfigVersions(ctx context.Context, req *iotpb.ListDeviceConfigVersionsRequest, opts ...gax.CallOption) (*iotpb.ListDeviceConfigVersionsResponse, error)

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

Code:

ctx := context.Background()
c, err := iot.NewDeviceManagerClient(ctx)
if err != nil {
    // TODO: Handle error.
}

req := &iotpb.ListDeviceConfigVersionsRequest{
    // TODO: Fill request struct fields.
}
resp, err := c.ListDeviceConfigVersions(ctx, req)
if err != nil {
    // TODO: Handle error.
}
// TODO: Use resp.
_ = resp

func (*DeviceManagerClient) ListDeviceRegistries Uses

func (c *DeviceManagerClient) ListDeviceRegistries(ctx context.Context, req *iotpb.ListDeviceRegistriesRequest, opts ...gax.CallOption) *DeviceRegistryIterator

ListDeviceRegistries lists device registries.

Code:

ctx := context.Background()
c, err := iot.NewDeviceManagerClient(ctx)
if err != nil {
    // TODO: Handle error.
}

req := &iotpb.ListDeviceRegistriesRequest{
    // TODO: Fill request struct fields.
}
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 Uses

func (c *DeviceManagerClient) ListDeviceStates(ctx context.Context, req *iotpb.ListDeviceStatesRequest, opts ...gax.CallOption) (*iotpb.ListDeviceStatesResponse, error)

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

Code:

ctx := context.Background()
c, err := iot.NewDeviceManagerClient(ctx)
if err != nil {
    // TODO: Handle error.
}

req := &iotpb.ListDeviceStatesRequest{
    // TODO: Fill request struct fields.
}
resp, err := c.ListDeviceStates(ctx, req)
if err != nil {
    // TODO: Handle error.
}
// TODO: Use resp.
_ = resp

func (*DeviceManagerClient) ListDevices Uses

func (c *DeviceManagerClient) ListDevices(ctx context.Context, req *iotpb.ListDevicesRequest, opts ...gax.CallOption) *DeviceIterator

ListDevices list devices in a device registry.

Code:

ctx := context.Background()
c, err := iot.NewDeviceManagerClient(ctx)
if err != nil {
    // TODO: Handle error.
}

req := &iotpb.ListDevicesRequest{
    // TODO: Fill request struct fields.
}
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 Uses

func (c *DeviceManagerClient) ModifyCloudToDeviceConfig(ctx context.Context, req *iotpb.ModifyCloudToDeviceConfigRequest, opts ...gax.CallOption) (*iotpb.DeviceConfig, error)

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.

Code:

ctx := context.Background()
c, err := iot.NewDeviceManagerClient(ctx)
if err != nil {
    // TODO: Handle error.
}

req := &iotpb.ModifyCloudToDeviceConfigRequest{
    // TODO: Fill request struct fields.
}
resp, err := c.ModifyCloudToDeviceConfig(ctx, req)
if err != nil {
    // TODO: Handle error.
}
// TODO: Use resp.
_ = resp

func (*DeviceManagerClient) SendCommandToDevice Uses

func (c *DeviceManagerClient) SendCommandToDevice(ctx context.Context, req *iotpb.SendCommandToDeviceRequest, opts ...gax.CallOption) (*iotpb.SendCommandToDeviceResponse, error)

SendCommandToDevice sends a command to the specified device. In order for a device to be able to receive commands, it must: 1) be connected to Cloud IoT Core using the MQTT protocol, and 2) 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.

Code:

ctx := context.Background()
c, err := iot.NewDeviceManagerClient(ctx)
if err != nil {
    // TODO: Handle error.
}

req := &iotpb.SendCommandToDeviceRequest{
    // TODO: Fill request struct fields.
}
resp, err := c.SendCommandToDevice(ctx, req)
if err != nil {
    // TODO: Handle error.
}
// TODO: Use resp.
_ = resp

func (*DeviceManagerClient) SetIamPolicy Uses

func (c *DeviceManagerClient) SetIamPolicy(ctx context.Context, req *iampb.SetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error)

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

Code:

ctx := context.Background()
c, err := iot.NewDeviceManagerClient(ctx)
if err != nil {
    // TODO: Handle error.
}

req := &iampb.SetIamPolicyRequest{
    // TODO: Fill request struct fields.
}
resp, err := c.SetIamPolicy(ctx, req)
if err != nil {
    // TODO: Handle error.
}
// TODO: Use resp.
_ = resp

func (*DeviceManagerClient) TestIamPermissions Uses

func (c *DeviceManagerClient) TestIamPermissions(ctx context.Context, req *iampb.TestIamPermissionsRequest, opts ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error)

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.

Code:

ctx := context.Background()
c, err := iot.NewDeviceManagerClient(ctx)
if err != nil {
    // TODO: Handle error.
}

req := &iampb.TestIamPermissionsRequest{
    // TODO: Fill request struct fields.
}
resp, err := c.TestIamPermissions(ctx, req)
if err != nil {
    // TODO: Handle error.
}
// TODO: Use resp.
_ = resp

func (*DeviceManagerClient) UnbindDeviceFromGateway Uses

func (c *DeviceManagerClient) UnbindDeviceFromGateway(ctx context.Context, req *iotpb.UnbindDeviceFromGatewayRequest, opts ...gax.CallOption) (*iotpb.UnbindDeviceFromGatewayResponse, error)

UnbindDeviceFromGateway deletes the association between the device and the gateway.

Code:

ctx := context.Background()
c, err := iot.NewDeviceManagerClient(ctx)
if err != nil {
    // TODO: Handle error.
}

req := &iotpb.UnbindDeviceFromGatewayRequest{
    // TODO: Fill request struct fields.
}
resp, err := c.UnbindDeviceFromGateway(ctx, req)
if err != nil {
    // TODO: Handle error.
}
// TODO: Use resp.
_ = resp

func (*DeviceManagerClient) UpdateDevice Uses

func (c *DeviceManagerClient) UpdateDevice(ctx context.Context, req *iotpb.UpdateDeviceRequest, opts ...gax.CallOption) (*iotpb.Device, error)

UpdateDevice updates a device.

Code:

ctx := context.Background()
c, err := iot.NewDeviceManagerClient(ctx)
if err != nil {
    // TODO: Handle error.
}

req := &iotpb.UpdateDeviceRequest{
    // TODO: Fill request struct fields.
}
resp, err := c.UpdateDevice(ctx, req)
if err != nil {
    // TODO: Handle error.
}
// TODO: Use resp.
_ = resp

func (*DeviceManagerClient) UpdateDeviceRegistry Uses

func (c *DeviceManagerClient) UpdateDeviceRegistry(ctx context.Context, req *iotpb.UpdateDeviceRegistryRequest, opts ...gax.CallOption) (*iotpb.DeviceRegistry, error)

UpdateDeviceRegistry updates a device registry configuration.

Code:

ctx := context.Background()
c, err := iot.NewDeviceManagerClient(ctx)
if err != nil {
    // TODO: Handle error.
}

req := &iotpb.UpdateDeviceRegistryRequest{
    // TODO: Fill request struct fields.
}
resp, err := c.UpdateDeviceRegistry(ctx, req)
if err != nil {
    // TODO: Handle error.
}
// TODO: Use resp.
_ = resp

type DeviceRegistryIterator Uses

type DeviceRegistryIterator struct {

    // 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 Uses

func (it *DeviceRegistryIterator) Next() (*iotpb.DeviceRegistry, 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 (*DeviceRegistryIterator) PageInfo Uses

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

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

Package iot imports 18 packages (graph). Updated 2019-11-15. Refresh now. Tools for package owners.