class BaiduBcm(object):
    pass

@@ -1,33 +1,1591 @@
-class BaiduBcm(object):%0A    pass
+import logging%0Aimport time%0A%0Aimport requests%0Aimport bceauth%0A%0Alogger = logging.getLogger(__name__)%0A%0A%0Aclass BaiduBcm(object):%0A    URL_FMT = %22http://bcm.bj.baidubce.com/json-api/v1/metricdata/%7B0%7D/%7B1%7D%22%0A    TIME_FMT = %22%25Y-%25m-%25dT%25H:%25M:%25SZ%22%0A%0A    def __init__(self, user_id, scope):%0A        self._user_id = user_id%0A        self._url = self.URL_FMT.format(user_id, scope)%0A        self._session = requests.session()%0A        self._session.auth = bceauth.AuthV1(access_key, secret_key)%0A%0A    @property%0A    def url(self):%0A        return self._url%0A%0A    def get_dimensions(self, raw_dimensions):%0A        return %5B%0A            dict(name=key, value=val)%0A            for key, val in raw_dimensions.items()%0A        %5D%0A%0A    def get_metrics(self, timestamp, raw_metrics, raw_dimensions):%0A        dimensions = self.get_dimensions(raw_dimensions)%0A        metrics = %5B%0A            dict(%0A                metricName=key,%0A                value=val,%0A                timestamp=timestamp,%0A                dimensions=dimensions%0A            )%0A            for key, val, __ in raw_metrics%0A        %5D%0A        return metrics%0A%0A    def send(self, localtime, raw_metrics, raw_dimensions):%0A        gmt = time.gmtime(localtime)%0A        timestamp = time.strftime(self.TIME_FMT, gmt)%0A%0A        metrics = self.get_metrics(timestamp, raw_metrics, raw_dimensions)%0A        res = self.session.post(%0A            self.url,%0A            json=metrics%0A        )%0A        if res.ok:%0A            return True%0A        else:%0A            logger.error(%22send metrics to baidu error: %7B0%7D%22.format(%0A                res.text%0A            ))%0A            return False
 %0A

add bcm-support