1/**
2 * Copyright 2016 IBM Corp.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *    http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17/**
18 * AUTOMATICALLY GENERATED CODE - DO NOT MODIFY
19 */
20
21package services
22
23import (
24	"fmt"
25	"strings"
26
27	"github.com/softlayer/softlayer-go/datatypes"
28	"github.com/softlayer/softlayer-go/session"
29	"github.com/softlayer/softlayer-go/sl"
30)
31
32// Metric tracking objects provides a common interface to all metrics provided by SoftLayer. These metrics range from network component traffic for a server to aggregated Bandwidth Pooling traffic and more. Every object within SoftLayer's range of objects that has data that can be tracked over time has an associated tracking object. Use the [[SoftLayer_Metric_Tracking_Object]] service to retrieve raw and graph data from a tracking object.
33type Metric_Tracking_Object struct {
34	Session *session.Session
35	Options sl.Options
36}
37
38// GetMetricTrackingObjectService returns an instance of the Metric_Tracking_Object SoftLayer service
39func GetMetricTrackingObjectService(sess *session.Session) Metric_Tracking_Object {
40	return Metric_Tracking_Object{Session: sess}
41}
42
43func (r Metric_Tracking_Object) Id(id int) Metric_Tracking_Object {
44	r.Options.Id = &id
45	return r
46}
47
48func (r Metric_Tracking_Object) Mask(mask string) Metric_Tracking_Object {
49	if !strings.HasPrefix(mask, "mask[") && (strings.Contains(mask, "[") || strings.Contains(mask, ",")) {
50		mask = fmt.Sprintf("mask[%s]", mask)
51	}
52
53	r.Options.Mask = mask
54	return r
55}
56
57func (r Metric_Tracking_Object) Filter(filter string) Metric_Tracking_Object {
58	r.Options.Filter = filter
59	return r
60}
61
62func (r Metric_Tracking_Object) Limit(limit int) Metric_Tracking_Object {
63	r.Options.Limit = &limit
64	return r
65}
66
67func (r Metric_Tracking_Object) Offset(offset int) Metric_Tracking_Object {
68	r.Options.Offset = &offset
69	return r
70}
71
72// Retrieve a PNG image of the last 24 hours of bandwidth usage of one of SoftLayer's network backbones.
73func (r Metric_Tracking_Object) GetBackboneBandwidthGraph(graphTitle *string) (resp datatypes.Container_Bandwidth_GraphOutputs, err error) {
74	params := []interface{}{
75		graphTitle,
76	}
77	err = r.Session.DoRequest("SoftLayer_Metric_Tracking_Object", "getBackboneBandwidthGraph", params, &r.Options, &resp)
78	return
79}
80
81// Retrieve a collection of raw bandwidth data from an individual public or private network tracking object. Raw data is ideal if you with to employ your own traffic storage and graphing systems.
82func (r Metric_Tracking_Object) GetBandwidthData(startDateTime *datatypes.Time, endDateTime *datatypes.Time, typ *string, rollupSeconds *int) (resp []datatypes.Metric_Tracking_Object_Data, err error) {
83	params := []interface{}{
84		startDateTime,
85		endDateTime,
86		typ,
87		rollupSeconds,
88	}
89	err = r.Session.DoRequest("SoftLayer_Metric_Tracking_Object", "getBandwidthData", params, &r.Options, &resp)
90	return
91}
92
93// Retrieve a PNG image of a bandwidth graph representing the bandwidth usage over time recorded by SofTLayer's bandwidth pollers.
94func (r Metric_Tracking_Object) GetBandwidthGraph(startDateTime *datatypes.Time, endDateTime *datatypes.Time, graphType *string, fontSize *int, graphWidth *int, graphHeight *int, doNotShowTimeZone *bool) (resp datatypes.Container_Bandwidth_GraphOutputs, err error) {
95	params := []interface{}{
96		startDateTime,
97		endDateTime,
98		graphType,
99		fontSize,
100		graphWidth,
101		graphHeight,
102		doNotShowTimeZone,
103	}
104	err = r.Session.DoRequest("SoftLayer_Metric_Tracking_Object", "getBandwidthGraph", params, &r.Options, &resp)
105	return
106}
107
108// Retrieve the total amount of bandwidth recorded by a tracking object within the given date range. This method will only work on SoftLayer_Metric_Tracking_Object for SoftLayer_Hardware objects, and SoftLayer_Virtual_Guest objects.
109func (r Metric_Tracking_Object) GetBandwidthTotal(startDateTime *datatypes.Time, endDateTime *datatypes.Time, direction *string, typ *string) (resp uint, err error) {
110	params := []interface{}{
111		startDateTime,
112		endDateTime,
113		direction,
114		typ,
115	}
116	err = r.Session.DoRequest("SoftLayer_Metric_Tracking_Object", "getBandwidthTotal", params, &r.Options, &resp)
117	return
118}
119
120// Returns a graph container instance that is populated with metric data for the tracking object.
121func (r Metric_Tracking_Object) GetCustomGraphData(graphContainer *datatypes.Container_Graph) (resp datatypes.Container_Graph, err error) {
122	params := []interface{}{
123		graphContainer,
124	}
125	err = r.Session.DoRequest("SoftLayer_Metric_Tracking_Object", "getCustomGraphData", params, &r.Options, &resp)
126	return
127}
128
129// Retrieve a collection of detailed metric data over a date range. Ideal if you want to employ your own graphing systems.  Note not all metrics support this method.  Those that do not return null.
130func (r Metric_Tracking_Object) GetDetailsForDateRange(startDate *datatypes.Time, endDate *datatypes.Time, graphType []string) (resp []datatypes.Container_Metric_Tracking_Object_Details, err error) {
131	params := []interface{}{
132		startDate,
133		endDate,
134		graphType,
135	}
136	err = r.Session.DoRequest("SoftLayer_Metric_Tracking_Object", "getDetailsForDateRange", params, &r.Options, &resp)
137	return
138}
139
140// Retrieve a PNG image of a metric in graph form.
141func (r Metric_Tracking_Object) GetGraph(startDateTime *datatypes.Time, endDateTime *datatypes.Time, graphType []string) (resp datatypes.Container_Bandwidth_GraphOutputs, err error) {
142	params := []interface{}{
143		startDateTime,
144		endDateTime,
145		graphType,
146	}
147	err = r.Session.DoRequest("SoftLayer_Metric_Tracking_Object", "getGraph", params, &r.Options, &resp)
148	return
149}
150
151// Returns a collection of metric data types that can be retrieved for a metric tracking object.
152func (r Metric_Tracking_Object) GetMetricDataTypes() (resp []datatypes.Container_Metric_Data_Type, err error) {
153	err = r.Session.DoRequest("SoftLayer_Metric_Tracking_Object", "getMetricDataTypes", nil, &r.Options, &resp)
154	return
155}
156
157// getObject retrieves the SoftLayer_Metric_Tracking_Object object whose ID number corresponds to the ID number of the init parameter passed to the SoftLayer_Metric_Tracking_Object service. You can only tracking objects that are associated with your SoftLayer account or services.
158func (r Metric_Tracking_Object) GetObject() (resp datatypes.Metric_Tracking_Object, err error) {
159	err = r.Session.DoRequest("SoftLayer_Metric_Tracking_Object", "getObject", nil, &r.Options, &resp)
160	return
161}
162
163// Retrieve a metric summary. Ideal if you want to employ your own graphing systems.  Note not all metric types contain a summary.  These return null.
164func (r Metric_Tracking_Object) GetSummary(graphType *string) (resp datatypes.Container_Metric_Tracking_Object_Summary, err error) {
165	params := []interface{}{
166		graphType,
167	}
168	err = r.Session.DoRequest("SoftLayer_Metric_Tracking_Object", "getSummary", params, &r.Options, &resp)
169	return
170}
171
172// Returns summarized metric data for the date range, metric type and summary period provided.
173func (r Metric_Tracking_Object) GetSummaryData(startDateTime *datatypes.Time, endDateTime *datatypes.Time, validTypes []datatypes.Container_Metric_Data_Type, summaryPeriod *int) (resp []datatypes.Metric_Tracking_Object_Data, err error) {
174	params := []interface{}{
175		startDateTime,
176		endDateTime,
177		validTypes,
178		summaryPeriod,
179	}
180	err = r.Session.DoRequest("SoftLayer_Metric_Tracking_Object", "getSummaryData", params, &r.Options, &resp)
181	return
182}
183
184// Retrieve The type of data that a tracking object polls.
185func (r Metric_Tracking_Object) GetType() (resp datatypes.Metric_Tracking_Object_Type, err error) {
186	err = r.Session.DoRequest("SoftLayer_Metric_Tracking_Object", "getType", nil, &r.Options, &resp)
187	return
188}
189
190// This data type provides commonly used bandwidth summary components for the current billing cycle.
191type Metric_Tracking_Object_Bandwidth_Summary struct {
192	Session *session.Session
193	Options sl.Options
194}
195
196// GetMetricTrackingObjectBandwidthSummaryService returns an instance of the Metric_Tracking_Object_Bandwidth_Summary SoftLayer service
197func GetMetricTrackingObjectBandwidthSummaryService(sess *session.Session) Metric_Tracking_Object_Bandwidth_Summary {
198	return Metric_Tracking_Object_Bandwidth_Summary{Session: sess}
199}
200
201func (r Metric_Tracking_Object_Bandwidth_Summary) Id(id int) Metric_Tracking_Object_Bandwidth_Summary {
202	r.Options.Id = &id
203	return r
204}
205
206func (r Metric_Tracking_Object_Bandwidth_Summary) Mask(mask string) Metric_Tracking_Object_Bandwidth_Summary {
207	if !strings.HasPrefix(mask, "mask[") && (strings.Contains(mask, "[") || strings.Contains(mask, ",")) {
208		mask = fmt.Sprintf("mask[%s]", mask)
209	}
210
211	r.Options.Mask = mask
212	return r
213}
214
215func (r Metric_Tracking_Object_Bandwidth_Summary) Filter(filter string) Metric_Tracking_Object_Bandwidth_Summary {
216	r.Options.Filter = filter
217	return r
218}
219
220func (r Metric_Tracking_Object_Bandwidth_Summary) Limit(limit int) Metric_Tracking_Object_Bandwidth_Summary {
221	r.Options.Limit = &limit
222	return r
223}
224
225func (r Metric_Tracking_Object_Bandwidth_Summary) Offset(offset int) Metric_Tracking_Object_Bandwidth_Summary {
226	r.Options.Offset = &offset
227	return r
228}
229
230// no documentation yet
231func (r Metric_Tracking_Object_Bandwidth_Summary) GetObject() (resp datatypes.Metric_Tracking_Object_Bandwidth_Summary, err error) {
232	err = r.Session.DoRequest("SoftLayer_Metric_Tracking_Object_Bandwidth_Summary", "getObject", nil, &r.Options, &resp)
233	return
234}
235