/
zz_generated_models_serde.go
206 lines (188 loc) · 7.8 KB
/
zz_generated_models_serde.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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
//go:build go1.18
// +build go1.18
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
package armsqlvirtualmachine
import (
"encoding/json"
"fmt"
"github.com/Azure/azure-sdk-for-go/sdk/azcore"
"reflect"
)
// MarshalJSON implements the json.Marshaller interface for type AgConfiguration.
func (a AgConfiguration) MarshalJSON() ([]byte, error) {
objectMap := make(map[string]interface{})
populate(objectMap, "replicas", a.Replicas)
return json.Marshal(objectMap)
}
// MarshalJSON implements the json.Marshaller interface for type AutoBackupSettings.
func (a AutoBackupSettings) MarshalJSON() ([]byte, error) {
objectMap := make(map[string]interface{})
populate(objectMap, "backupScheduleType", a.BackupScheduleType)
populate(objectMap, "backupSystemDbs", a.BackupSystemDbs)
populate(objectMap, "daysOfWeek", a.DaysOfWeek)
populate(objectMap, "enable", a.Enable)
populate(objectMap, "enableEncryption", a.EnableEncryption)
populate(objectMap, "fullBackupFrequency", a.FullBackupFrequency)
populate(objectMap, "fullBackupStartTime", a.FullBackupStartTime)
populate(objectMap, "fullBackupWindowHours", a.FullBackupWindowHours)
populate(objectMap, "logBackupFrequency", a.LogBackupFrequency)
populate(objectMap, "password", a.Password)
populate(objectMap, "retentionPeriod", a.RetentionPeriod)
populate(objectMap, "storageAccessKey", a.StorageAccessKey)
populate(objectMap, "storageAccountUrl", a.StorageAccountURL)
populate(objectMap, "storageContainerName", a.StorageContainerName)
return json.Marshal(objectMap)
}
// MarshalJSON implements the json.Marshaller interface for type AvailabilityGroupListenerProperties.
func (a AvailabilityGroupListenerProperties) MarshalJSON() ([]byte, error) {
objectMap := make(map[string]interface{})
populate(objectMap, "availabilityGroupConfiguration", a.AvailabilityGroupConfiguration)
populate(objectMap, "availabilityGroupName", a.AvailabilityGroupName)
populate(objectMap, "createDefaultAvailabilityGroupIfNotExist", a.CreateDefaultAvailabilityGroupIfNotExist)
populate(objectMap, "loadBalancerConfigurations", a.LoadBalancerConfigurations)
populate(objectMap, "port", a.Port)
populate(objectMap, "provisioningState", a.ProvisioningState)
return json.Marshal(objectMap)
}
// MarshalJSON implements the json.Marshaller interface for type Group.
func (g Group) MarshalJSON() ([]byte, error) {
objectMap := make(map[string]interface{})
populate(objectMap, "id", g.ID)
populate(objectMap, "location", g.Location)
populate(objectMap, "name", g.Name)
populate(objectMap, "properties", g.Properties)
populate(objectMap, "systemData", g.SystemData)
populate(objectMap, "tags", g.Tags)
populate(objectMap, "type", g.Type)
return json.Marshal(objectMap)
}
// MarshalJSON implements the json.Marshaller interface for type GroupUpdate.
func (g GroupUpdate) MarshalJSON() ([]byte, error) {
objectMap := make(map[string]interface{})
populate(objectMap, "tags", g.Tags)
return json.Marshal(objectMap)
}
// MarshalJSON implements the json.Marshaller interface for type LoadBalancerConfiguration.
func (l LoadBalancerConfiguration) MarshalJSON() ([]byte, error) {
objectMap := make(map[string]interface{})
populate(objectMap, "loadBalancerResourceId", l.LoadBalancerResourceID)
populate(objectMap, "privateIpAddress", l.PrivateIPAddress)
populate(objectMap, "probePort", l.ProbePort)
populate(objectMap, "publicIpAddressResourceId", l.PublicIPAddressResourceID)
populate(objectMap, "sqlVirtualMachineInstances", l.SQLVirtualMachineInstances)
return json.Marshal(objectMap)
}
// MarshalJSON implements the json.Marshaller interface for type SQLStorageSettings.
func (s SQLStorageSettings) MarshalJSON() ([]byte, error) {
objectMap := make(map[string]interface{})
populate(objectMap, "defaultFilePath", s.DefaultFilePath)
populate(objectMap, "luns", s.Luns)
return json.Marshal(objectMap)
}
// MarshalJSON implements the json.Marshaller interface for type SQLTempDbSettings.
func (s SQLTempDbSettings) MarshalJSON() ([]byte, error) {
objectMap := make(map[string]interface{})
populate(objectMap, "dataFileCount", s.DataFileCount)
populate(objectMap, "dataFileSize", s.DataFileSize)
populate(objectMap, "dataGrowth", s.DataGrowth)
populate(objectMap, "defaultFilePath", s.DefaultFilePath)
populate(objectMap, "logFileSize", s.LogFileSize)
populate(objectMap, "logGrowth", s.LogGrowth)
populate(objectMap, "luns", s.Luns)
return json.Marshal(objectMap)
}
// MarshalJSON implements the json.Marshaller interface for type SQLVirtualMachine.
func (s SQLVirtualMachine) MarshalJSON() ([]byte, error) {
objectMap := make(map[string]interface{})
populate(objectMap, "id", s.ID)
populate(objectMap, "identity", s.Identity)
populate(objectMap, "location", s.Location)
populate(objectMap, "name", s.Name)
populate(objectMap, "properties", s.Properties)
populate(objectMap, "systemData", s.SystemData)
populate(objectMap, "tags", s.Tags)
populate(objectMap, "type", s.Type)
return json.Marshal(objectMap)
}
// MarshalJSON implements the json.Marshaller interface for type SystemData.
func (s SystemData) MarshalJSON() ([]byte, error) {
objectMap := make(map[string]interface{})
populateTimeRFC3339(objectMap, "createdAt", s.CreatedAt)
populate(objectMap, "createdBy", s.CreatedBy)
populate(objectMap, "createdByType", s.CreatedByType)
populateTimeRFC3339(objectMap, "lastModifiedAt", s.LastModifiedAt)
populate(objectMap, "lastModifiedBy", s.LastModifiedBy)
populate(objectMap, "lastModifiedByType", s.LastModifiedByType)
return json.Marshal(objectMap)
}
// UnmarshalJSON implements the json.Unmarshaller interface for type SystemData.
func (s *SystemData) UnmarshalJSON(data []byte) error {
var rawMsg map[string]json.RawMessage
if err := json.Unmarshal(data, &rawMsg); err != nil {
return fmt.Errorf("unmarshalling type %T: %v", s, err)
}
for key, val := range rawMsg {
var err error
switch key {
case "createdAt":
err = unpopulateTimeRFC3339(val, "CreatedAt", &s.CreatedAt)
delete(rawMsg, key)
case "createdBy":
err = unpopulate(val, "CreatedBy", &s.CreatedBy)
delete(rawMsg, key)
case "createdByType":
err = unpopulate(val, "CreatedByType", &s.CreatedByType)
delete(rawMsg, key)
case "lastModifiedAt":
err = unpopulateTimeRFC3339(val, "LastModifiedAt", &s.LastModifiedAt)
delete(rawMsg, key)
case "lastModifiedBy":
err = unpopulate(val, "LastModifiedBy", &s.LastModifiedBy)
delete(rawMsg, key)
case "lastModifiedByType":
err = unpopulate(val, "LastModifiedByType", &s.LastModifiedByType)
delete(rawMsg, key)
}
if err != nil {
return fmt.Errorf("unmarshalling type %T: %v", s, err)
}
}
return nil
}
// MarshalJSON implements the json.Marshaller interface for type TrackedResource.
func (t TrackedResource) MarshalJSON() ([]byte, error) {
objectMap := make(map[string]interface{})
populate(objectMap, "id", t.ID)
populate(objectMap, "location", t.Location)
populate(objectMap, "name", t.Name)
populate(objectMap, "tags", t.Tags)
populate(objectMap, "type", t.Type)
return json.Marshal(objectMap)
}
// MarshalJSON implements the json.Marshaller interface for type Update.
func (u Update) MarshalJSON() ([]byte, error) {
objectMap := make(map[string]interface{})
populate(objectMap, "tags", u.Tags)
return json.Marshal(objectMap)
}
func populate(m map[string]interface{}, k string, v interface{}) {
if v == nil {
return
} else if azcore.IsNullValue(v) {
m[k] = nil
} else if !reflect.ValueOf(v).IsNil() {
m[k] = v
}
}
func unpopulate(data json.RawMessage, fn string, v interface{}) error {
if data == nil {
return nil
}
if err := json.Unmarshal(data, v); err != nil {
return fmt.Errorf("struct field %s: %v", fn, err)
}
return nil
}