Return stats about bandwidth consumption

REST: GET /cdn/webstorage/{serviceName}/statistics
@param type [required]
@param period [required]
@param serviceName [required] The internal name of your CDN Static offer
334153
public ArrayList<OvhStatsDataType> serviceName_statistics_GET(String serviceName, OvhStatsPeriodEnum period, OvhStatsTypeEnum type) throws IOException {
		String qPath = "/cdn/webstorage/{serviceName}/statistics";
		StringBuilder sb = path(qPath, serviceName);
		query(sb, "period", period);
		query(sb, "type", type);
		String resp = exec(qPath, "GET", sb.toString(), null);
		return convertTo(resp, t1);
	}
873680
def get_stats_action(cachespec, interval):
    
    if cachespec == 'global':
        caches = get_bcache_fs()
    else:
        caches = [Bcache.fromdevice(cachespec)]
    res = dict((c.cachepath, c.get_stats(interval)) for c in caches)
    return json.dumps(res, indent=4, separators=(',', ': '))
576606
def extract_measure_period_or_default(default)
      if default
        mp_low = HQMF::Value.new('TS', nil, '201201010000', nil, nil, nil)
        mp_high = HQMF::Value.new('TS', nil, '201212312359', nil, nil, nil)
        mp_width = HQMF::Value.new('PQ', 'a', '1', nil, nil, nil)
        HQMF::EffectiveTime.new(mp_low, mp_high, mp_width)
      else
        measure_period_def = @doc.at_xpath('cda:QualityMeasureDocument/cda:controlVariable/cda:measurePeriod/cda:value',
                                           NAMESPACES)
        EffectiveTime.new(measure_period_def).to_model if measure_period_def
      end
    end
470335
def _get_metric(self, metric, tablename, index_name=None):
        
        end = time.time()
        begin = end - 3 * 60  # 3 minute window
        dimensions = [{"Name": "TableName", "Value": tablename}]
        if index_name is not None:
            dimensions.append({"Name": "GlobalSecondaryIndexName", "Value": index_name})
        period = 60
        data = self.cloudwatch_connection.get_metric_statistics(
            Period=period,
            StartTime=begin,
            EndTime=end,
            MetricName=metric,
            Namespace="AWS/DynamoDB",
            Statistics=["Sum"],
            Dimensions=dimensions,
        )
        points = data["Datapoints"]
        if not points:
            return 0
        else:
            points.sort(key=lambda r: r["Timestamp"])
            return float(points[-1]["Sum"]) / period
808434
public static <T> PluggableProviderService<T> getPluginProviderService(
        Class<T> serviceType,
        String serviceName,
        ServiceProviderLoader loader
    )
    {
        for (PluginProviderServices pluginProviderServices : pluginProviderServiceLoader) {
            if (pluginProviderServices.hasServiceFor(serviceType, serviceName)) {
                return pluginProviderServices.getServiceProviderFor(serviceType, serviceName, loader);
            }
        }
        return null;
    }
1309552
public OvhOrder hosting_web_serviceName_cdn_duration_POST(String serviceName, String duration, OvhCdnOfferEnum offer) throws IOException {
		String qPath = "/order/hosting/web/{serviceName}/cdn/{duration}";
		StringBuilder sb = path(qPath, serviceName, duration);
		HashMap<String, Object>o = new HashMap<String, Object>();
		addBody(o, "offer", offer);
		String resp = exec(qPath, "POST", sb.toString(), o);
		return convertTo(resp, OvhOrder.class);
	}
999209
def find_usage(self):
        
        logger.debug("Checking usage for service %s", self.service_name)
        self.connect()
        for lim in self.limits.values():
            lim._reset_usage()

        self.limits['Auto Scaling groups']._add_current_usage(
            len(
                paginate_dict(
                    self.conn.describe_auto_scaling_groups,
                    alc_marker_path=['NextToken'],
                    alc_data_path=['AutoScalingGroups'],
                    alc_marker_param='NextToken'
                )['AutoScalingGroups']
            ),
            aws_type='AWS::AutoScaling::AutoScalingGroup',
        )

        self.limits['Launch configurations']._add_current_usage(
            len(
                paginate_dict(
                    self.conn.describe_launch_configurations,
                    alc_marker_path=['NextToken'],
                    alc_data_path=['LaunchConfigurations'],
                    alc_marker_param='NextToken'
                )['LaunchConfigurations']
            ),
            aws_type='AWS::AutoScaling::LaunchConfiguration',
        )
        self._have_usage = True
        logger.debug("Done checking usage.")
1165021
public FutureData<Usage> usage(Usage.Period timePeriod) {
        FutureData<Usage> future = new FutureData<Usage>();
        String period;
        switch (timePeriod) {
            case HOUR:
                period = "hour";
                break;
            case CURRENT:
                period = "current";
                break;
            case DAY:
            default:
                period = "day";
        }
        URI uri = newParams().put("period", period).forURL(config.newAPIEndpointURI(USAGE));
        Request request = config.http().GET(uri, new PageReader(newRequestCallback(future, new Usage(), config)));
        performRequest(future, request);
        return future;
    }
1272172
@Override
    public String[] getAllCacheStatistics() {
        DCache cache = null;
        if (ServerCache.servletCacheEnabled) {
            cache = ServerCache.cache;
        }
        String stats[] = null;
        if (cache != null) {
            Map statistics = getCacheStatisticsMap(cache.getCacheStatistics());
            Iterator keys = statistics.keySet().iterator();
            Iterator values = statistics.values().iterator();
            stats = new String[statistics.size()];
            int i = 0;
            while (keys.hasNext()) {
                stats[i] = keys.next() + "=" + values.next();
                i++;
            }
        } else {
            stats = new String[0];
            // DYNA1059W=DYNA1059W: WebSphere Dynamic Cache instance named {0} cannot be used because of Dynamic Servlet cache service has not be started.
            Tr.error(tc, "DYNA1059W", new Object[] { DCacheBase.DEFAULT_CACHE_NAME });
        }

        return stats;
    }
651112
def _get_bucket_statistics(self, bucket_name, bucket_region, storage_type, statistic, days):
        

        cw = self.session.client('cloudwatch', region_name=bucket_region)

        # gather cw stats

        try:
            obj_stats = cw.get_metric_statistics(
                Namespace='AWS/S3',
                MetricName=statistic,
                Dimensions=[
                    {
                        'Name': 'StorageType',
                        'Value': storage_type
                    },
                    {
                        'Name': 'BucketName',
                        'Value': bucket_name
                    }
                ],
                Period=86400,
                StartTime=datetime.utcnow() - timedelta(days=days),
                EndTime=datetime.utcnow(),
                Statistics=[
                    'Average'
                ]
            )
            stat_value = obj_stats['Datapoints'][0]['Average'] if obj_stats['Datapoints'] else 'NO_DATA'

            return stat_value

        except Exception as e:
            self.log.error(
                'Could not get bucket statistic for account {} / bucket {} / {}'.format(self.account.account_name,
                                                                                        bucket_name, e))

        finally:
            del cw
1164267
public OvhConsumption serviceName_consumption_GET(String serviceName, Long duration) throws IOException {
		String qPath = "/metrics/{serviceName}/consumption";
		StringBuilder sb = path(qPath, serviceName);
		query(sb, "duration", duration);
		String resp = exec(qPath, "GET", sb.toString(), null);
		return convertTo(resp, OvhConsumption.class);
	}
162779
public GetDomainStatisticsResponse getDomainStatistics(GetDomainStatisticsRequest request) {
        checkNotNull(request, "The parameter request should NOT be null.");

        checkStringNotEmpty(request.getDomain(), "Domain should NOT be empty.");
        InternalRequest internalRequest = createRequest(HttpMethodName.GET, request, STATISTICS,
                LIVE_DOMAIN, request.getDomain());
        if (request.getStartDate() != null) {
            internalRequest.addParameter("startDate", request.getStartDate());
        }
        if (request.getEndDate() != null) {
            internalRequest.addParameter("endDate", request.getEndDate());
        }
        if (request.getAggregate() != null) {
            internalRequest.addParameter("aggregate", request.getAggregate().toString());
        }
        return invokeHttpClient(internalRequest, GetDomainStatisticsResponse.class);
    }
363175
public OvhOrder dedicatedCloud_serviceName_additionalBandwidth_duration_GET(String serviceName, String duration, OvhAdditionalBandwidthEnum bandwidth) throws IOException {
		String qPath = "/order/dedicatedCloud/{serviceName}/additionalBandwidth/{duration}";
		StringBuilder sb = path(qPath, serviceName, duration);
		query(sb, "bandwidth", bandwidth);
		String resp = exec(qPath, "GET", sb.toString(), null);
		return convertTo(resp, OvhOrder.class);
	}
1049267
public OvhOrder hosting_privateDatabase_serviceName_ram_duration_POST(String serviceName, String duration, OvhAvailableRamSizeEnum ram) throws IOException {
		String qPath = "/order/hosting/privateDatabase/{serviceName}/ram/{duration}";
		StringBuilder sb = path(qPath, serviceName, duration);
		HashMap<String, Object>o = new HashMap<String, Object>();
		addBody(o, "ram", ram);
		String resp = exec(qPath, "POST", sb.toString(), o);
		return convertTo(resp, OvhOrder.class);
	}
1104122
def _get_ptr_details(self, device, device_type):
        
        context = self.api.identity
        region = self.api.region_name
        if device_type.lower().startswith("load"):
            ep = pyrax._get_service_endpoint(context, "load_balancer", region)
            svc = "loadbalancers"
            svc_name = "cloudLoadBalancers"
        else:
            ep = pyrax._get_service_endpoint(context, "compute", region)
            svc = "servers"
            svc_name = "cloudServersOpenStack"
        href = "%s/%s/%s" % (ep, svc, utils.get_id(device))
        return (href, svc_name)
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);
	}
921553
public GetStatAvgSpeedResponse getStatAvgSpeed(GetStatAvgSpeedRequest request) {
        InternalRequest internalRequest = this.createRequest(request, HttpMethodName.GET, STAT, "avgspeed");
        
        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()));
        }
        
        return this.invokeHttpClient(internalRequest, GetStatAvgSpeedResponse.class);
    }