metric.go raw

   1  /**
   2   * Copyright 2016-2024 IBM Corp.
   3   *
   4   * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
   5   * the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
   6   *
   7   * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
   8   * on an "AS IS" BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   9   * See the License for the specific language governing permissions and limitations under the License.
  10   */
  11  
  12  // AUTOMATICALLY GENERATED CODE - DO NOT MODIFY
  13  
  14  package services
  15  
  16  import (
  17  	"fmt"
  18  	"strings"
  19  
  20  	"github.com/softlayer/softlayer-go/datatypes"
  21  	"github.com/softlayer/softlayer-go/session"
  22  	"github.com/softlayer/softlayer-go/sl"
  23  )
  24  
  25  // 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.
  26  type Metric_Tracking_Object struct {
  27  	Session session.SLSession
  28  	Options sl.Options
  29  }
  30  
  31  // GetMetricTrackingObjectService returns an instance of the Metric_Tracking_Object SoftLayer service
  32  func GetMetricTrackingObjectService(sess session.SLSession) Metric_Tracking_Object {
  33  	return Metric_Tracking_Object{Session: sess}
  34  }
  35  
  36  func (r Metric_Tracking_Object) Id(id int) Metric_Tracking_Object {
  37  	r.Options.Id = &id
  38  	return r
  39  }
  40  
  41  func (r Metric_Tracking_Object) Mask(mask string) Metric_Tracking_Object {
  42  	if !strings.HasPrefix(mask, "mask[") && (strings.Contains(mask, "[") || strings.Contains(mask, ",")) {
  43  		mask = fmt.Sprintf("mask[%s]", mask)
  44  	}
  45  
  46  	r.Options.Mask = mask
  47  	return r
  48  }
  49  
  50  func (r Metric_Tracking_Object) Filter(filter string) Metric_Tracking_Object {
  51  	r.Options.Filter = filter
  52  	return r
  53  }
  54  
  55  func (r Metric_Tracking_Object) Limit(limit int) Metric_Tracking_Object {
  56  	r.Options.Limit = &limit
  57  	return r
  58  }
  59  
  60  func (r Metric_Tracking_Object) Offset(offset int) Metric_Tracking_Object {
  61  	r.Options.Offset = &offset
  62  	return r
  63  }
  64  
  65  // 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.
  66  func (r Metric_Tracking_Object) GetBandwidthData(startDateTime *datatypes.Time, endDateTime *datatypes.Time, typ *string, rollupSeconds *int) (resp []datatypes.Metric_Tracking_Object_Data, err error) {
  67  	params := []interface{}{
  68  		startDateTime,
  69  		endDateTime,
  70  		typ,
  71  		rollupSeconds,
  72  	}
  73  	err = r.Session.DoRequest("SoftLayer_Metric_Tracking_Object", "getBandwidthData", params, &r.Options, &resp)
  74  	return
  75  }
  76  
  77  // 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.
  78  func (r Metric_Tracking_Object) GetBandwidthTotal(startDateTime *datatypes.Time, endDateTime *datatypes.Time, direction *string, typ *string) (resp uint, err error) {
  79  	params := []interface{}{
  80  		startDateTime,
  81  		endDateTime,
  82  		direction,
  83  		typ,
  84  	}
  85  	err = r.Session.DoRequest("SoftLayer_Metric_Tracking_Object", "getBandwidthTotal", params, &r.Options, &resp)
  86  	return
  87  }
  88  
  89  // Returns a collection of metric data types that can be retrieved for a metric tracking object.
  90  func (r Metric_Tracking_Object) GetMetricDataTypes() (resp []datatypes.Container_Metric_Data_Type, err error) {
  91  	err = r.Session.DoRequest("SoftLayer_Metric_Tracking_Object", "getMetricDataTypes", nil, &r.Options, &resp)
  92  	return
  93  }
  94  
  95  // 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.
  96  func (r Metric_Tracking_Object) GetObject() (resp datatypes.Metric_Tracking_Object, err error) {
  97  	err = r.Session.DoRequest("SoftLayer_Metric_Tracking_Object", "getObject", nil, &r.Options, &resp)
  98  	return
  99  }
 100  
 101  // Returns summarized metric data for the date range, metric type and summary period provided.
 102  func (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) {
 103  	params := []interface{}{
 104  		startDateTime,
 105  		endDateTime,
 106  		validTypes,
 107  		summaryPeriod,
 108  	}
 109  	err = r.Session.DoRequest("SoftLayer_Metric_Tracking_Object", "getSummaryData", params, &r.Options, &resp)
 110  	return
 111  }
 112  
 113  // Retrieve The type of data that a tracking object polls.
 114  func (r Metric_Tracking_Object) GetType() (resp datatypes.Metric_Tracking_Object_Type, err error) {
 115  	err = r.Session.DoRequest("SoftLayer_Metric_Tracking_Object", "getType", nil, &r.Options, &resp)
 116  	return
 117  }
 118  
 119  // This data type provides commonly used bandwidth summary components for the current billing cycle.
 120  type Metric_Tracking_Object_Bandwidth_Summary struct {
 121  	Session session.SLSession
 122  	Options sl.Options
 123  }
 124  
 125  // GetMetricTrackingObjectBandwidthSummaryService returns an instance of the Metric_Tracking_Object_Bandwidth_Summary SoftLayer service
 126  func GetMetricTrackingObjectBandwidthSummaryService(sess session.SLSession) Metric_Tracking_Object_Bandwidth_Summary {
 127  	return Metric_Tracking_Object_Bandwidth_Summary{Session: sess}
 128  }
 129  
 130  func (r Metric_Tracking_Object_Bandwidth_Summary) Id(id int) Metric_Tracking_Object_Bandwidth_Summary {
 131  	r.Options.Id = &id
 132  	return r
 133  }
 134  
 135  func (r Metric_Tracking_Object_Bandwidth_Summary) Mask(mask string) Metric_Tracking_Object_Bandwidth_Summary {
 136  	if !strings.HasPrefix(mask, "mask[") && (strings.Contains(mask, "[") || strings.Contains(mask, ",")) {
 137  		mask = fmt.Sprintf("mask[%s]", mask)
 138  	}
 139  
 140  	r.Options.Mask = mask
 141  	return r
 142  }
 143  
 144  func (r Metric_Tracking_Object_Bandwidth_Summary) Filter(filter string) Metric_Tracking_Object_Bandwidth_Summary {
 145  	r.Options.Filter = filter
 146  	return r
 147  }
 148  
 149  func (r Metric_Tracking_Object_Bandwidth_Summary) Limit(limit int) Metric_Tracking_Object_Bandwidth_Summary {
 150  	r.Options.Limit = &limit
 151  	return r
 152  }
 153  
 154  func (r Metric_Tracking_Object_Bandwidth_Summary) Offset(offset int) Metric_Tracking_Object_Bandwidth_Summary {
 155  	r.Options.Offset = &offset
 156  	return r
 157  }
 158  
 159  // no documentation yet
 160  func (r Metric_Tracking_Object_Bandwidth_Summary) GetObject() (resp datatypes.Metric_Tracking_Object_Bandwidth_Summary, err error) {
 161  	err = r.Session.DoRequest("SoftLayer_Metric_Tracking_Object_Bandwidth_Summary", "getObject", nil, &r.Options, &resp)
 162  	return
 163  }
 164