/
getDevice.go
189 lines (159 loc) · 12.7 KB
/
getDevice.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
// Code generated by the Pulumi SDK Generator DO NOT EDIT.
// *** WARNING: Do not edit by hand unless you're certain you know what you are doing! ***
package v1
import (
"context"
"reflect"
"github.com/pulumi/pulumi-google-native/sdk/go/google/internal"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
// Gets details about a device.
func LookupDevice(ctx *pulumi.Context, args *LookupDeviceArgs, opts ...pulumi.InvokeOption) (*LookupDeviceResult, error) {
opts = internal.PkgInvokeDefaultOpts(opts)
var rv LookupDeviceResult
err := ctx.Invoke("google-native:cloudiot/v1:getDevice", args, &rv, opts...)
if err != nil {
return nil, err
}
return &rv, nil
}
type LookupDeviceArgs struct {
DeviceId string `pulumi:"deviceId"`
FieldMask *string `pulumi:"fieldMask"`
Location string `pulumi:"location"`
Project *string `pulumi:"project"`
RegistryId string `pulumi:"registryId"`
}
type LookupDeviceResult struct {
// If a device is blocked, connections or requests from this device will fail. Can be used to temporarily prevent the device from connecting if, for example, the sensor is generating bad data and needs maintenance.
Blocked bool `pulumi:"blocked"`
// The most recent device configuration, which is eventually sent from Cloud IoT Core to the device. If not present on creation, the configuration will be initialized with an empty payload and version value of `1`. To update this field after creation, use the `DeviceManager.ModifyCloudToDeviceConfig` method.
Config DeviceConfigResponse `pulumi:"config"`
// The credentials used to authenticate this device. To allow credential rotation without interruption, multiple device credentials can be bound to this device. No more than 3 credentials can be bound to a single device at a time. When new credentials are added to a device, they are verified against the registry credentials. For details, see the description of the `DeviceRegistry.credentials` field.
Credentials []DeviceCredentialResponse `pulumi:"credentials"`
// Gateway-related configuration and state.
GatewayConfig GatewayConfigResponse `pulumi:"gatewayConfig"`
// [Output only] The last time a cloud-to-device config version acknowledgment was received from the device. This field is only for configurations sent through MQTT.
LastConfigAckTime string `pulumi:"lastConfigAckTime"`
// [Output only] The last time a cloud-to-device config version was sent to the device.
LastConfigSendTime string `pulumi:"lastConfigSendTime"`
// [Output only] The error message of the most recent error, such as a failure to publish to Cloud Pub/Sub. 'last_error_time' is the timestamp of this field. If no errors have occurred, this field has an empty message and the status code 0 == OK. Otherwise, this field is expected to have a status code other than OK.
LastErrorStatus StatusResponse `pulumi:"lastErrorStatus"`
// [Output only] The time the most recent error occurred, such as a failure to publish to Cloud Pub/Sub. This field is the timestamp of 'last_error_status'.
LastErrorTime string `pulumi:"lastErrorTime"`
// [Output only] The last time a telemetry event was received. Timestamps are periodically collected and written to storage; they may be stale by a few minutes.
LastEventTime string `pulumi:"lastEventTime"`
// [Output only] The last time an MQTT `PINGREQ` was received. This field applies only to devices connecting through MQTT. MQTT clients usually only send `PINGREQ` messages if the connection is idle, and no other messages have been sent. Timestamps are periodically collected and written to storage; they may be stale by a few minutes.
LastHeartbeatTime string `pulumi:"lastHeartbeatTime"`
// [Output only] The last time a state event was received. Timestamps are periodically collected and written to storage; they may be stale by a few minutes.
LastStateTime string `pulumi:"lastStateTime"`
// **Beta Feature** The logging verbosity for device activity. If unspecified, DeviceRegistry.log_level will be used.
LogLevel string `pulumi:"logLevel"`
// The metadata key-value pairs assigned to the device. This metadata is not interpreted or indexed by Cloud IoT Core. It can be used to add contextual information for the device. Keys must conform to the regular expression a-zA-Z+ and be less than 128 bytes in length. Values are free-form strings. Each value must be less than or equal to 32 KB in size. The total size of all keys and values must be less than 256 KB, and the maximum number of key-value pairs is 500.
Metadata map[string]string `pulumi:"metadata"`
// The resource path name. For example, `projects/p1/locations/us-central1/registries/registry0/devices/dev0` or `projects/p1/locations/us-central1/registries/registry0/devices/{num_id}`. When `name` is populated as a response from the service, it always ends in the device numeric ID.
Name string `pulumi:"name"`
// [Output only] A server-defined unique numeric ID for the device. This is a more compact way to identify devices, and it is globally unique.
NumId string `pulumi:"numId"`
// [Output only] The state most recently received from the device. If no state has been reported, this field is not present.
State DeviceStateResponse `pulumi:"state"`
}
func LookupDeviceOutput(ctx *pulumi.Context, args LookupDeviceOutputArgs, opts ...pulumi.InvokeOption) LookupDeviceResultOutput {
return pulumi.ToOutputWithContext(context.Background(), args).
ApplyT(func(v interface{}) (LookupDeviceResult, error) {
args := v.(LookupDeviceArgs)
r, err := LookupDevice(ctx, &args, opts...)
var s LookupDeviceResult
if r != nil {
s = *r
}
return s, err
}).(LookupDeviceResultOutput)
}
type LookupDeviceOutputArgs struct {
DeviceId pulumi.StringInput `pulumi:"deviceId"`
FieldMask pulumi.StringPtrInput `pulumi:"fieldMask"`
Location pulumi.StringInput `pulumi:"location"`
Project pulumi.StringPtrInput `pulumi:"project"`
RegistryId pulumi.StringInput `pulumi:"registryId"`
}
func (LookupDeviceOutputArgs) ElementType() reflect.Type {
return reflect.TypeOf((*LookupDeviceArgs)(nil)).Elem()
}
type LookupDeviceResultOutput struct{ *pulumi.OutputState }
func (LookupDeviceResultOutput) ElementType() reflect.Type {
return reflect.TypeOf((*LookupDeviceResult)(nil)).Elem()
}
func (o LookupDeviceResultOutput) ToLookupDeviceResultOutput() LookupDeviceResultOutput {
return o
}
func (o LookupDeviceResultOutput) ToLookupDeviceResultOutputWithContext(ctx context.Context) LookupDeviceResultOutput {
return o
}
// If a device is blocked, connections or requests from this device will fail. Can be used to temporarily prevent the device from connecting if, for example, the sensor is generating bad data and needs maintenance.
func (o LookupDeviceResultOutput) Blocked() pulumi.BoolOutput {
return o.ApplyT(func(v LookupDeviceResult) bool { return v.Blocked }).(pulumi.BoolOutput)
}
// The most recent device configuration, which is eventually sent from Cloud IoT Core to the device. If not present on creation, the configuration will be initialized with an empty payload and version value of `1`. To update this field after creation, use the `DeviceManager.ModifyCloudToDeviceConfig` method.
func (o LookupDeviceResultOutput) Config() DeviceConfigResponseOutput {
return o.ApplyT(func(v LookupDeviceResult) DeviceConfigResponse { return v.Config }).(DeviceConfigResponseOutput)
}
// The credentials used to authenticate this device. To allow credential rotation without interruption, multiple device credentials can be bound to this device. No more than 3 credentials can be bound to a single device at a time. When new credentials are added to a device, they are verified against the registry credentials. For details, see the description of the `DeviceRegistry.credentials` field.
func (o LookupDeviceResultOutput) Credentials() DeviceCredentialResponseArrayOutput {
return o.ApplyT(func(v LookupDeviceResult) []DeviceCredentialResponse { return v.Credentials }).(DeviceCredentialResponseArrayOutput)
}
// Gateway-related configuration and state.
func (o LookupDeviceResultOutput) GatewayConfig() GatewayConfigResponseOutput {
return o.ApplyT(func(v LookupDeviceResult) GatewayConfigResponse { return v.GatewayConfig }).(GatewayConfigResponseOutput)
}
// [Output only] The last time a cloud-to-device config version acknowledgment was received from the device. This field is only for configurations sent through MQTT.
func (o LookupDeviceResultOutput) LastConfigAckTime() pulumi.StringOutput {
return o.ApplyT(func(v LookupDeviceResult) string { return v.LastConfigAckTime }).(pulumi.StringOutput)
}
// [Output only] The last time a cloud-to-device config version was sent to the device.
func (o LookupDeviceResultOutput) LastConfigSendTime() pulumi.StringOutput {
return o.ApplyT(func(v LookupDeviceResult) string { return v.LastConfigSendTime }).(pulumi.StringOutput)
}
// [Output only] The error message of the most recent error, such as a failure to publish to Cloud Pub/Sub. 'last_error_time' is the timestamp of this field. If no errors have occurred, this field has an empty message and the status code 0 == OK. Otherwise, this field is expected to have a status code other than OK.
func (o LookupDeviceResultOutput) LastErrorStatus() StatusResponseOutput {
return o.ApplyT(func(v LookupDeviceResult) StatusResponse { return v.LastErrorStatus }).(StatusResponseOutput)
}
// [Output only] The time the most recent error occurred, such as a failure to publish to Cloud Pub/Sub. This field is the timestamp of 'last_error_status'.
func (o LookupDeviceResultOutput) LastErrorTime() pulumi.StringOutput {
return o.ApplyT(func(v LookupDeviceResult) string { return v.LastErrorTime }).(pulumi.StringOutput)
}
// [Output only] The last time a telemetry event was received. Timestamps are periodically collected and written to storage; they may be stale by a few minutes.
func (o LookupDeviceResultOutput) LastEventTime() pulumi.StringOutput {
return o.ApplyT(func(v LookupDeviceResult) string { return v.LastEventTime }).(pulumi.StringOutput)
}
// [Output only] The last time an MQTT `PINGREQ` was received. This field applies only to devices connecting through MQTT. MQTT clients usually only send `PINGREQ` messages if the connection is idle, and no other messages have been sent. Timestamps are periodically collected and written to storage; they may be stale by a few minutes.
func (o LookupDeviceResultOutput) LastHeartbeatTime() pulumi.StringOutput {
return o.ApplyT(func(v LookupDeviceResult) string { return v.LastHeartbeatTime }).(pulumi.StringOutput)
}
// [Output only] The last time a state event was received. Timestamps are periodically collected and written to storage; they may be stale by a few minutes.
func (o LookupDeviceResultOutput) LastStateTime() pulumi.StringOutput {
return o.ApplyT(func(v LookupDeviceResult) string { return v.LastStateTime }).(pulumi.StringOutput)
}
// **Beta Feature** The logging verbosity for device activity. If unspecified, DeviceRegistry.log_level will be used.
func (o LookupDeviceResultOutput) LogLevel() pulumi.StringOutput {
return o.ApplyT(func(v LookupDeviceResult) string { return v.LogLevel }).(pulumi.StringOutput)
}
// The metadata key-value pairs assigned to the device. This metadata is not interpreted or indexed by Cloud IoT Core. It can be used to add contextual information for the device. Keys must conform to the regular expression a-zA-Z+ and be less than 128 bytes in length. Values are free-form strings. Each value must be less than or equal to 32 KB in size. The total size of all keys and values must be less than 256 KB, and the maximum number of key-value pairs is 500.
func (o LookupDeviceResultOutput) Metadata() pulumi.StringMapOutput {
return o.ApplyT(func(v LookupDeviceResult) map[string]string { return v.Metadata }).(pulumi.StringMapOutput)
}
// The resource path name. For example, `projects/p1/locations/us-central1/registries/registry0/devices/dev0` or `projects/p1/locations/us-central1/registries/registry0/devices/{num_id}`. When `name` is populated as a response from the service, it always ends in the device numeric ID.
func (o LookupDeviceResultOutput) Name() pulumi.StringOutput {
return o.ApplyT(func(v LookupDeviceResult) string { return v.Name }).(pulumi.StringOutput)
}
// [Output only] A server-defined unique numeric ID for the device. This is a more compact way to identify devices, and it is globally unique.
func (o LookupDeviceResultOutput) NumId() pulumi.StringOutput {
return o.ApplyT(func(v LookupDeviceResult) string { return v.NumId }).(pulumi.StringOutput)
}
// [Output only] The state most recently received from the device. If no state has been reported, this field is not present.
func (o LookupDeviceResultOutput) State() DeviceStateResponseOutput {
return o.ApplyT(func(v LookupDeviceResult) DeviceStateResponse { return v.State }).(DeviceStateResponseOutput)
}
func init() {
pulumi.RegisterOutputType(LookupDeviceResultOutput{})
}