forked from Azure/azure-sdk-for-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodels.go
193 lines (183 loc) · 5.34 KB
/
models.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
package commerce
// Copyright (c) Microsoft and contributors. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
import (
"encoding/json"
"github.com/Azure/go-autorest/autorest"
"github.com/Azure/go-autorest/autorest/date"
)
// Resource base Resource Object
type Resource struct {
// ID - URI of the resource.
ID *string `json:"id,omitempty"`
// Name - Name of the resource.
Name *string `json:"name,omitempty"`
// Type - Type of resource.
Type *string `json:"type,omitempty"`
// Location - Location where resource is location.
Location *string `json:"location,omitempty"`
// Tags - List of key value pairs.
Tags map[string]*string `json:"tags"`
}
// MarshalJSON is the custom marshaler for Resource.
func (r Resource) MarshalJSON() ([]byte, error) {
objectMap := make(map[string]interface{})
if r.ID != nil {
objectMap["id"] = r.ID
}
if r.Name != nil {
objectMap["name"] = r.Name
}
if r.Type != nil {
objectMap["type"] = r.Type
}
if r.Location != nil {
objectMap["location"] = r.Location
}
if r.Tags != nil {
objectMap["tags"] = r.Tags
}
return json.Marshal(objectMap)
}
// UsageAggregate aggregate usage values for resource.
type UsageAggregate struct {
// UsageAggregateModel - Properties for aggregate usage.
*UsageAggregateModel `json:"properties,omitempty"`
// ID - URI of the resource.
ID *string `json:"id,omitempty"`
// Name - Name of the resource.
Name *string `json:"name,omitempty"`
// Type - Type of resource.
Type *string `json:"type,omitempty"`
// Location - Location where resource is location.
Location *string `json:"location,omitempty"`
// Tags - List of key value pairs.
Tags map[string]*string `json:"tags"`
}
// MarshalJSON is the custom marshaler for UsageAggregate.
func (ua UsageAggregate) MarshalJSON() ([]byte, error) {
objectMap := make(map[string]interface{})
if ua.UsageAggregateModel != nil {
objectMap["properties"] = ua.UsageAggregateModel
}
if ua.ID != nil {
objectMap["id"] = ua.ID
}
if ua.Name != nil {
objectMap["name"] = ua.Name
}
if ua.Type != nil {
objectMap["type"] = ua.Type
}
if ua.Location != nil {
objectMap["location"] = ua.Location
}
if ua.Tags != nil {
objectMap["tags"] = ua.Tags
}
return json.Marshal(objectMap)
}
// UnmarshalJSON is the custom unmarshaler for UsageAggregate struct.
func (ua *UsageAggregate) UnmarshalJSON(body []byte) error {
var m map[string]*json.RawMessage
err := json.Unmarshal(body, &m)
if err != nil {
return err
}
for k, v := range m {
switch k {
case "properties":
if v != nil {
var usageAggregateModel UsageAggregateModel
err = json.Unmarshal(*v, &usageAggregateModel)
if err != nil {
return err
}
ua.UsageAggregateModel = &usageAggregateModel
}
case "id":
if v != nil {
var ID string
err = json.Unmarshal(*v, &ID)
if err != nil {
return err
}
ua.ID = &ID
}
case "name":
if v != nil {
var name string
err = json.Unmarshal(*v, &name)
if err != nil {
return err
}
ua.Name = &name
}
case "type":
if v != nil {
var typeVar string
err = json.Unmarshal(*v, &typeVar)
if err != nil {
return err
}
ua.Type = &typeVar
}
case "location":
if v != nil {
var location string
err = json.Unmarshal(*v, &location)
if err != nil {
return err
}
ua.Location = &location
}
case "tags":
if v != nil {
var tags map[string]*string
err = json.Unmarshal(*v, &tags)
if err != nil {
return err
}
ua.Tags = tags
}
}
}
return nil
}
// UsageAggregateModel properties for aggregate usage.
type UsageAggregateModel struct {
// SubscriptionID - Subscription id of tenant using plan.
SubscriptionID *string `json:"subscriptionId,omitempty"`
// UsageStartTime - UTC start time for the usage bucket to which this usage aggregate belongs.
UsageStartTime *date.Time `json:"usageStartTime,omitempty"`
// UsageEndTime - UTC end time for the usage bucket to which this usage aggregate belongs.
UsageEndTime *date.Time `json:"usageEndTime,omitempty"`
// InstanceData - Key-value pairs of instance details represented as a string.
InstanceData *string `json:"instanceData,omitempty"`
// Quantity - The amount of the resource consumption that occurred in this time frame.
Quantity *string `json:"quantity,omitempty"`
// MeterID - Unique ID for the resource that was consumed (aka ResourceID).
MeterID *string `json:"meterId,omitempty"`
}
// UsageAggregatePage holds an array of usage aggregates and the continuation token.
type UsageAggregatePage struct {
autorest.Response `json:"-"`
// Value - Array of usage aggregates.
Value *[]UsageAggregate `json:"value,omitempty"`
// NextLink - Continuation token
NextLink *string `json:"nextLink,omitempty"`
}