-
Notifications
You must be signed in to change notification settings - Fork 37
/
model_datasource.go
52 lines (44 loc) · 1.78 KB
/
model_datasource.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
package backupinstances
import (
"encoding/json"
"fmt"
)
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See NOTICE.txt in the project root for license information.
type Datasource struct {
DatasourceType *string `json:"datasourceType,omitempty"`
ObjectType *string `json:"objectType,omitempty"`
ResourceID string `json:"resourceID"`
ResourceLocation *string `json:"resourceLocation,omitempty"`
ResourceName *string `json:"resourceName,omitempty"`
ResourceProperties BaseResourceProperties `json:"resourceProperties"`
ResourceType *string `json:"resourceType,omitempty"`
ResourceUri *string `json:"resourceUri,omitempty"`
}
var _ json.Unmarshaler = &Datasource{}
func (s *Datasource) UnmarshalJSON(bytes []byte) error {
type alias Datasource
var decoded alias
if err := json.Unmarshal(bytes, &decoded); err != nil {
return fmt.Errorf("unmarshaling into Datasource: %+v", err)
}
s.DatasourceType = decoded.DatasourceType
s.ObjectType = decoded.ObjectType
s.ResourceID = decoded.ResourceID
s.ResourceLocation = decoded.ResourceLocation
s.ResourceName = decoded.ResourceName
s.ResourceType = decoded.ResourceType
s.ResourceUri = decoded.ResourceUri
var temp map[string]json.RawMessage
if err := json.Unmarshal(bytes, &temp); err != nil {
return fmt.Errorf("unmarshaling Datasource into map[string]json.RawMessage: %+v", err)
}
if v, ok := temp["resourceProperties"]; ok {
impl, err := unmarshalBaseResourcePropertiesImplementation(v)
if err != nil {
return fmt.Errorf("unmarshaling field 'ResourceProperties' for 'Datasource': %+v", err)
}
s.ResourceProperties = impl
}
return nil
}