@@ -227,17 +227,8 @@ func ParseConstantOnlyID(input string) (*ConstantOnlyId, error) {
227
227
}
228
228
229
229
id := ConstantOnlyId{}
230
-
231
- if v, ok := parsed.Parsed["thingId"]; true {
232
- if !ok {
233
- return nil, resourceids.NewSegmentNotSpecifiedError(id, "thingId", *parsed)
234
- }
235
-
236
- thingId, err := parseThing(v)
237
- if err != nil {
238
- return nil, fmt.Errorf("parsing %q: %+v", v, err)
239
- }
240
- id.ThingId = *thingId
230
+ if err := id.FromParseResult(*parsed); err != nil {
231
+ return nil, err
241
232
}
242
233
243
234
return &id, nil
@@ -253,22 +244,27 @@ func ParseConstantOnlyIDInsensitively(input string) (*ConstantOnlyId, error) {
253
244
}
254
245
255
246
id := ConstantOnlyId{}
256
-
257
- if v, ok := parsed.Parsed["thingId"]; true {
258
- if !ok {
259
- return nil, resourceids.NewSegmentNotSpecifiedError(id, "thingId", *parsed)
260
- }
261
-
262
- thingId, err := parseThing(v)
263
- if err != nil {
264
- return nil, fmt.Errorf("parsing %q: %+v", v, err)
265
- }
266
- id.ThingId = *thingId
247
+ if err := id.FromParseResult(*parsed); err != nil {
248
+ return nil, err
267
249
}
268
250
269
251
return &id, nil
270
252
}
271
253
254
+ func (id *ConstantOnlyId) FromParseResult(input resourceids.ParseResult) error {
255
+ if v, ok := input.Parsed["thingId"]; true {
256
+ if !ok {
257
+ return resourceids.NewSegmentNotSpecifiedError(id, "thingId", input)
258
+ }
259
+ thingId, err := parseThing(v)
260
+ if err != nil {
261
+ return fmt.Errorf("parsing %q: %+v", v, err)
262
+ }
263
+ id.ThingId = *thingId
264
+ }
265
+ return nil
266
+ }
267
+
272
268
// ValidateConstantOnlyID checks that 'input' can be parsed as a Constant Only ID
273
269
func ValidateConstantOnlyID(input interface{}, key string) (warnings []string, errors []error) {
274
270
v, ok := input.(string)
0 commit comments