Get the usage statistics over the chose period

REST: GET /saas/csp2/{serviceName}/usageStatistics
@param timePeriod [required] The period to query
@param serviceName [required] The unique identifier of your Office service

API beta
544386
public ArrayList<OvhStatistics> serviceName_usageStatistics_GET(String serviceName, OvhLicensePeriodEnum timePeriod) throws IOException {
		String qPath = "/saas/csp2/{serviceName}/usageStatistics";
		StringBuilder sb = path(qPath, serviceName);
		query(sb, "timePeriod", timePeriod);
		String resp = exec(qPath, "GET", sb.toString(), null);
		return convertTo(resp, t3);
	}
140623
@Override
    public Double getLastHourInstanceNetworkIn(String instanceId,
                                               long lastUpdated) {
        long offsetInMilliseconds = Math.min(ONE_DAY_MILLI_SECOND,
                System.currentTimeMillis() - lastUpdated);
        Dimension instanceDimension = new Dimension().withName("InstanceId")
                .withValue(instanceId);
        GetMetricStatisticsRequest request = new GetMetricStatisticsRequest()
                .withMetricName("NetworkIn")
                .withNamespace("AWS/EC2")
                .withPeriod(60 * 60)
                // one hour
                .withDimensions(instanceDimension)
                // to get metrics a specific
                // instance
                .withStatistics("Average")
                .withStartTime(
                        new Date(new Date().getTime() - offsetInMilliseconds))
                .withEndTime(new Date());
        GetMetricStatisticsResult result = cloudWatchClient
                .getMetricStatistics(request);
        // to read data
        List<Datapoint> datapoints = result.getDatapoints();
        if (CollectionUtils.isEmpty(datapoints)) return 0.0;
        Datapoint datapoint = datapoints.get(0);
        return datapoint.getAverage();
    }
16388
public ArrayList<OvhRtmMemory> serviceName_statistics_memory_GET(String serviceName) throws IOException {
		String qPath = "/dedicated/server/{serviceName}/statistics/memory";
		StringBuilder sb = path(qPath, serviceName);
		String resp = exec(qPath, "GET", sb.toString(), null);
		return convertTo(resp, t9);
	}
1042204
public OvhUnitAndValue<Double> serviceName_use_GET(String serviceName, OvhVpsStatisticTypeEnum type) throws IOException {
		String qPath = "/vps/{serviceName}/use";
		StringBuilder sb = path(qPath, serviceName);
		query(sb, "type", type);
		String resp = exec(qPath, "GET", sb.toString(), null);
		return convertTo(resp, t5);
	}
962104
function getService(serviceName) {
		var serviceData = services[serviceName];

		if (serviceData) {
			if (!serviceData.instance) {
				serviceData.instance = serviceData.creator(application);
			}

			return serviceData.instance;
		}

		return null;
	}
192403
public ArrayList<OvhStatsDataType> serviceName_quota_GET(String serviceName, OvhStatsPeriodEnum period) throws IOException {
		String qPath = "/cdn/dedicated/{serviceName}/quota";
		StringBuilder sb = path(qPath, serviceName);
		query(sb, "period", period);
		String resp = exec(qPath, "GET", sb.toString(), null);
		return convertTo(resp, t3);
	}
180422
public OvhTimeCondition billingAccount_timeCondition_serviceName_condition_id_GET(String billingAccount, String serviceName, Long id) throws IOException {
		String qPath = "/telephony/{billingAccount}/timeCondition/{serviceName}/condition/{id}";
		StringBuilder sb = path(qPath, billingAccount, serviceName, id);
		String resp = exec(qPath, "GET", sb.toString(), null);
		return convertTo(resp, OvhTimeCondition.class);
	}
24569
public GetStatPvResponse getStatPv(GetStatPvRequest request) {
        InternalRequest internalRequest = this.createRequest(request, HttpMethodName.GET, STAT, "pv");
        
        if (request.getStartTime() != null) {
            internalRequest.addParameter("startTime", DateUtils.formatAlternateIso8601Date(request.getStartTime()));
        }
        
        if (request.getEndTime() != null) {
            internalRequest.addParameter("endTime", DateUtils.formatAlternateIso8601Date(request.getEndTime()));
        }
        
        if (request.getDomain() != null) {
            internalRequest.addParameter("domain", request.getDomain());
        }
        
        if (request.getPeriod() != null) {
            internalRequest.addParameter("period", String.valueOf(request.getPeriod()));
        }
        
        if (request.isWithRegion()) {
            internalRequest.addParameter("withRegion", "");
        }
        return this.invokeHttpClient(internalRequest, GetStatPvResponse.class);
    }
210348
public static servicegroup_stats[] get(nitro_service service, options option) throws Exception{
		servicegroup_stats obj = new servicegroup_stats();
		servicegroup_stats[] response = (servicegroup_stats[])obj.stat_resources(service,option);
		return response;
	}
806844
func (api *API) GetMonitoringServerUsage(ser_id string, period string, dates ...time.Time) (*MonServerUsageDetails, error) {
	if period == "" {
		return nil, errors.New("Time period must be provided.")
	}

	params := make(map[string]interface{}, len(dates)+1)
	params["period"] = period

	if len(dates) == 2 {
		if dates[0].After(dates[1]) {
			return nil, errors.New("Start date cannot be after end date.")
		}

		params["start_date"] = dates[0].Format(time.RFC3339)
		params["end_date"] = dates[1].Format(time.RFC3339)

	} else if len(dates) > 0 {
		return nil, errors.New("Start and end dates must be provided.")
	}
	url := createUrl(api, monitorCenterPathSegment, ser_id)
	url = appendQueryParams(url, params)
	result := new(MonServerUsageDetails)
	err := api.Client.Get(url, &result, http.StatusOK)
	if err != nil {
		return nil, err
	}
	result.api = api
	return result, nil
}
216489
public OvhProjectUsage project_serviceName_consumption_GET(String serviceName, Date from, Date to) throws IOException {
		String qPath = "/cloud/project/{serviceName}/consumption";
		StringBuilder sb = path(qPath, serviceName);
		query(sb, "from", from);
		query(sb, "to", to);
		String resp = exec(qPath, "GET", sb.toString(), null);
		return convertTo(resp, OvhProjectUsage.class);
	}
785886
public GetSessionStatisticsResponse getSessionStatistics(String sessionId, String startDate,
            String endDate, Boolean aggregate) {

        GetSessionStatisticsRequest request = new GetSessionStatisticsRequest();
        request.withSessionId(sessionId).withStartDate(startDate).withEndDate(endDate).withAggregate(aggregate);
        return getSessionStatistics(request);
    }
1183624
public function getTimePeriodInSeconds($timePeriod)
    {
        $timePeriod = StringUtil::deserialize($timePeriod, true);

        if (!isset($timePeriod['unit']) || !isset($timePeriod['value'])) {
            return null;
        }

        $factor = 1;

        switch ($timePeriod['unit']) {
            case 'm':
                $factor = 60;

                break;

            case 'h':
                $factor = 60 * 60;

                break;

            case 'd':
                $factor = 24 * 60 * 60;

                break;
        }

        return $timePeriod['value'] * $factor;
    }
142828
public static String createPeriodString(final ReadablePeriod period) {
    String periodStr = "null";

    if (period == null) {
      return periodStr;
    }

    if (period.get(DurationFieldType.years()) > 0) {
      final int years = period.get(DurationFieldType.years());
      periodStr = years + "y";
    } else if (period.get(DurationFieldType.months()) > 0) {
      final int months = period.get(DurationFieldType.months());
      periodStr = months + "M";
    } else if (period.get(DurationFieldType.weeks()) > 0) {
      final int weeks = period.get(DurationFieldType.weeks());
      periodStr = weeks + "w";
    } else if (period.get(DurationFieldType.days()) > 0) {
      final int days = period.get(DurationFieldType.days());
      periodStr = days + "d";
    } else if (period.get(DurationFieldType.hours()) > 0) {
      final int hours = period.get(DurationFieldType.hours());
      periodStr = hours + "h";
    } else if (period.get(DurationFieldType.minutes()) > 0) {
      final int minutes = period.get(DurationFieldType.minutes());
      periodStr = minutes + "m";
    } else if (period.get(DurationFieldType.seconds()) > 0) {
      final int seconds = period.get(DurationFieldType.seconds());
      periodStr = seconds + "s";
    }

    return periodStr;
  }
1337679
protected void parseAndSetPeriod(String attributeName) {
    String periodStr = getAttribute(attributeName);
    if (periodStr != null) {
      int period = 0;
      try {
        period = Integer.parseInt(periodStr);
      } catch (NumberFormatException nfe) {
      }
      if (period <= 0) {
        throw new MetricsException("Invalid period: " + periodStr);
      }
      setPeriod(period);
    }
  }
355656
public function getPeriod($role = null) {
        $roles = $this->_get('roles');
        if (!isset($roles[$role])) {
            if ($role === null) {
                return null;
            }
            return $this->getPeriod();
        }
        return (int) $roles[$role]['period'];
    }
231445
public function usage($start = false, $end = false, $period = null)
    {
        $params = array();

        if ($start) {
            $params['start'] = $start;
        }
        if ($end) {
            $params['end'] = $end;
        }
        if (isset($period)) {
            $params['period'] = $period;
        }

        return $this->_user->get('account/usage', $params);
    }