@@ -47,7 +47,8 @@ func (t *Time) UnmarshalJSON(data []byte) error {
47
47
type Device struct {
48
48
Addresses []string `json:"addresses"`
49
49
Name string `json:"name"`
50
- ID string `json:"id"`
50
+ ID string `json:"id"` // The legacy identifier for a device. Use NodeId instead.
51
+ NodeID string `json:"nodeId"` // The preferred identifier for a device.
51
52
Authorized bool `json:"authorized"`
52
53
User string `json:"user"`
53
54
Tags []string `json:"tags"`
@@ -79,6 +80,8 @@ type DevicePostureAttributeRequest struct {
79
80
}
80
81
81
82
// Get gets the [Device] identified by deviceID.
83
+ //
84
+ // Using the device `NodeID` is preferred, but its numeric `ID` value can also be used.
82
85
func (dr * DevicesResource ) Get (ctx context.Context , deviceID string ) (* Device , error ) {
83
86
req , err := dr .buildRequest (ctx , http .MethodGet , dr .buildURL ("device" , deviceID ))
84
87
if err != nil {
@@ -89,6 +92,8 @@ func (dr *DevicesResource) Get(ctx context.Context, deviceID string) (*Device, e
89
92
}
90
93
91
94
// GetPostureAttributes retrieves the posture attributes of the device identified by deviceID.
95
+ //
96
+ // Using the device `NodeID` is preferred, but its numeric `ID` value can also be used.
92
97
func (dr * DevicesResource ) GetPostureAttributes (ctx context.Context , deviceID string ) (* DevicePostureAttributes , error ) {
93
98
req , err := dr .buildRequest (ctx , http .MethodGet , dr .buildURL ("device" , deviceID , "attributes" ))
94
99
if err != nil {
@@ -99,6 +104,8 @@ func (dr *DevicesResource) GetPostureAttributes(ctx context.Context, deviceID st
99
104
}
100
105
101
106
// SetPostureAttribute sets the posture attribute of the device identified by deviceID.
107
+ //
108
+ // Using the device `NodeID` is preferred, but its numeric `ID` value can also be used.
102
109
func (dr * DevicesResource ) SetPostureAttribute (ctx context.Context , deviceID , attributeKey string , request DevicePostureAttributeRequest ) error {
103
110
req , err := dr .buildRequest (ctx , http .MethodPost , dr .buildURL ("device" , deviceID , "attributes" , attributeKey ), requestBody (request ))
104
111
if err != nil {
@@ -125,6 +132,8 @@ func (dr *DevicesResource) List(ctx context.Context) ([]Device, error) {
125
132
}
126
133
127
134
// SetAuthorized marks the specified device as authorized or not.
135
+ //
136
+ // Using the device `NodeID` is preferred, but its numeric `ID` value can also be used.
128
137
func (dr * DevicesResource ) SetAuthorized (ctx context.Context , deviceID string , authorized bool ) error {
129
138
req , err := dr .buildRequest (ctx , http .MethodPost , dr .buildURL ("device" , deviceID , "authorized" ), requestBody (map [string ]bool {
130
139
"authorized" : authorized ,
@@ -137,6 +146,8 @@ func (dr *DevicesResource) SetAuthorized(ctx context.Context, deviceID string, a
137
146
}
138
147
139
148
// Delete deletes the device identified by deviceID.
149
+ //
150
+ // Using the device `NodeID` is preferred, but its numeric `ID` value can also be used.
140
151
func (dr * DevicesResource ) Delete (ctx context.Context , deviceID string ) error {
141
152
req , err := dr .buildRequest (ctx , http .MethodDelete , dr .buildURL ("device" , deviceID ))
142
153
if err != nil {
@@ -147,6 +158,8 @@ func (dr *DevicesResource) Delete(ctx context.Context, deviceID string) error {
147
158
}
148
159
149
160
// SetName updates the name of the device identified by deviceID.
161
+ //
162
+ // Using the device `NodeID` is preferred, but its numeric `ID` value can also be used.
150
163
func (dr * DevicesResource ) SetName (ctx context.Context , deviceID , name string ) error {
151
164
req , err := dr .buildRequest (ctx , http .MethodPost , dr .buildURL ("device" , deviceID , "name" ), requestBody (map [string ]string {
152
165
"name" : name ,
@@ -159,6 +172,8 @@ func (dr *DevicesResource) SetName(ctx context.Context, deviceID, name string) e
159
172
}
160
173
161
174
// SetTags updates the tags of the device identified by deviceID.
175
+ //
176
+ // Using the device `NodeID` is preferred, but its numeric `ID` value can also be used.
162
177
func (dr * DevicesResource ) SetTags (ctx context.Context , deviceID string , tags []string ) error {
163
178
req , err := dr .buildRequest (ctx , http .MethodPost , dr .buildURL ("device" , deviceID , "tags" ), requestBody (map [string ][]string {
164
179
"tags" : tags ,
@@ -177,6 +192,8 @@ type DeviceKey struct {
177
192
}
178
193
179
194
// SetKey updates the properties of a device's key.
195
+ //
196
+ // Using the device `NodeID` is preferred, but its numeric `ID` value can also be used.
180
197
func (dr * DevicesResource ) SetKey (ctx context.Context , deviceID string , key DeviceKey ) error {
181
198
req , err := dr .buildRequest (ctx , http .MethodPost , dr .buildURL ("device" , deviceID , "key" ), requestBody (key ))
182
199
if err != nil {
@@ -187,6 +204,8 @@ func (dr *DevicesResource) SetKey(ctx context.Context, deviceID string, key Devi
187
204
}
188
205
189
206
// SetDeviceIPv4Address sets the Tailscale IPv4 address of the device.
207
+ //
208
+ // Using the device `NodeID` is preferred, but its numeric `ID` value can also be used.
190
209
func (dr * DevicesResource ) SetIPv4Address (ctx context.Context , deviceID string , ipv4Address string ) error {
191
210
req , err := dr .buildRequest (ctx , http .MethodPost , dr .buildURL ("device" , deviceID , "ip" ), requestBody (map [string ]string {
192
211
"ipv4" : ipv4Address ,
@@ -200,6 +219,8 @@ func (dr *DevicesResource) SetIPv4Address(ctx context.Context, deviceID string,
200
219
201
220
// SetSubnetRoutes sets which subnet routes are enabled to be routed by a device by replacing the existing list
202
221
// of subnet routes with the supplied routes. Routes can be enabled without a device advertising them (e.g. for preauth).
222
+ //
223
+ // Using the device `NodeID` is preferred, but its numeric `ID` value can also be used.
203
224
func (dr * DevicesResource ) SetSubnetRoutes (ctx context.Context , deviceID string , routes []string ) error {
204
225
req , err := dr .buildRequest (ctx , http .MethodPost , dr .buildURL ("device" , deviceID , "routes" ), requestBody (map [string ][]string {
205
226
"routes" : routes ,
@@ -214,6 +235,8 @@ func (dr *DevicesResource) SetSubnetRoutes(ctx context.Context, deviceID string,
214
235
// SubnetRoutes Retrieves the list of subnet routes that a device is advertising, as well as those that are
215
236
// enabled for it. Enabled routes are not necessarily advertised (e.g. for pre-enabling), and likewise, advertised
216
237
// routes are not necessarily enabled.
238
+ //
239
+ // Using the device `NodeID` is preferred, but its numeric `ID` value can also be used.
217
240
func (dr * DevicesResource ) SubnetRoutes (ctx context.Context , deviceID string ) (* DeviceRoutes , error ) {
218
241
req , err := dr .buildRequest (ctx , http .MethodGet , dr .buildURL ("device" , deviceID , "routes" ))
219
242
if err != nil {
0 commit comments