Exemple #1
0
 def listAll(self):
     ''' 获取加速所有域名列表
     @rtype: ProcessResult对象 
     @return: 通过ProcessResult.getDomainSummarys()获取DomainSummary对象的实例列表
     '''
     
     url = self.HOST + "/api/domain"
     try:
         post = ''
         ret = util.httpReqeust(url, post, self.makeHeaders(url), "GET")
         if ret.status == 200:
             return xmlToDomainList(ret)
         else:
             return xmlToFailure(ret)
     except Exception, e:
         traceback.print_exc(file=sys.stdout)
         return ProcessResult(-1, str(e))
Exemple #2
0
    def listAll(self):
        ''' 获取加速所有域名列表
        @rtype: ProcessResult对象 
        @return: 通过ProcessResult.getDomainSummarys()获取DomainSummary对象的实例列表
        '''

        url = self.HOST + "/api/domain"
        try:
            post = ''
            ret = util.httpReqeust(url, post, self.makeHeaders(url), "GET")
            if ret.status == 200:
                return xmlToDomainList(ret)
            else:
                return xmlToFailure(ret)
        except Exception, e:
            traceback.print_exc(file=sys.stdout)
            return ProcessResult(-1, str(e))
Exemple #3
0
 def add(self, domain):
     ''' 创建加速域名 
     @param domain:  新增加速域名构建的Domain对象实例
     @rtype: ProcessResult对象
     @return: 通过ProcessResult.getLocation()新域名的url
     '''
     url = self.HOST + "/api/domain"
     try:
         post = domainToXml(domain)
         #print post
         ret = util.httpReqeust(url, post, self.makeHeaders(url), "POST")
         if ret.status == 202:
             return xmlToSuccess(ret)
         else:
             return xmlToFailure(ret)
     except Exception, e:
         traceback.print_exc(file=sys.stdout)
         return ProcessResult(-1, str(e))
Exemple #4
0
    def enable(self, domainId):
        ''' 启用加速域名 
        @param domainId : 指定启用的域名ID
        @rtype: ProcessResult对象
        @return: 返回ProcessResult对象
        '''

        url = self.HOST + "/api/domain/" + str(domainId)
        try:
            post = ''
            ret = util.httpReqeust(url, post, self.makeHeaders(url), "ENABLE")
            if ret.status == 202:
                return xmlToSuccess(ret)
            else:
                return xmlToFailure(ret)
        except Exception, e:
            traceback.print_exc(file=sys.stdout)
            return ProcessResult(-1, str(e))
Exemple #5
0
 def enable(self, domainId):
     ''' 启用加速域名 
     @param domainId : 指定启用的域名ID
     @rtype: ProcessResult对象
     @return: 返回ProcessResult对象
     '''
     
     url = self.HOST + "/api/domain/" + str(domainId)
     try:
         post = ''
         ret = util.httpReqeust(url, post, self.makeHeaders(url), "ENABLE")
         if ret.status == 202:
             return xmlToSuccess(ret)
         else:
             return xmlToFailure(ret) 
     except Exception, e:
         traceback.print_exc(file=sys.stdout)
         return ProcessResult(-1, str(e))
Exemple #6
0
 def add(self, domain):
     ''' 创建加速域名 
     @param domain:  新增加速域名构建的Domain对象实例
     @rtype: ProcessResult对象
     @return: 通过ProcessResult.getLocation()新域名的url
     '''
     url = self.HOST + "/api/domain"
     try:
         post = domainToXml(domain)
         #print post
         ret = util.httpReqeust(url, post, self.makeHeaders(url), "POST")
         if ret.status == 202:
             return xmlToSuccess(ret)
         else:
             return xmlToFailure(ret)
     except Exception, e:
         traceback.print_exc(file=sys.stdout)
         return ProcessResult(-1, str(e))
Exemple #7
0
 def getLog(self, reportForm, domainId):
     ''' 获取某域名的日志下载链接 
     @type reportForm: ReportForm
     @param reportForm:  请求的起止时间
     @rtype: LogProcessResult
     @return: 通过LogProcessResult.getLogs() 获得查询后的Log对象实例列表
     '''
     url = self.HOST + "/api/report/" + str(domainId) + "/log" 
     try:
         url = appendParams(url, reportForm)
         ret = util.httpReqeust(url, "", self.makeHeaders(), "GET")
         if ret.status == 200:
             return xmlToLogList(ret)
         else:
             return getLogXmlToFailure(ret)
     except Exception, e:
         traceback.print_exc(file=sys.stdout)
         return LogProcessResult(-1, str(e))
Exemple #8
0
 def getLog(self, reportForm, domainId):
     ''' 获取某域名的日志下载链接 
     @type reportForm: ReportForm
     @param reportForm:  请求的起止时间
     @rtype: LogProcessResult
     @return: 通过LogProcessResult.getLogs() 获得查询后的Log对象实例列表
     '''
     url = self.HOST + "/api/report/" + str(domainId) + "/log"
     try:
         url = appendParams(url, reportForm)
         ret = util.httpReqeust(url, "", self.makeHeaders(), "GET")
         if ret.status == 200:
             return xmlToLogList(ret)
         else:
             return getLogXmlToFailure(ret)
     except Exception, e:
         traceback.print_exc(file=sys.stdout)
         return LogProcessResult(-1, str(e))
Exemple #9
0
    def find(self, domainId):
        ''' 获取加速域名配置  
        @type domainId: str
        @param domainId : 指定查找的域名ID
        @rtype: ProcessResult对象
        @return: 通过ProcessResult.getDomain()返回指定的域名信息的Domain实例
        '''

        url = self.HOST + "/api/domain/" + str(domainId)
        try:
            post = ''
            ret = util.httpReqeust(url, post, self.makeHeaders(url), "GET")
            if ret.status == 200:
                return xmlToDomain(ret)
            else:
                return xmlToFailure(ret)
        except Exception, e:
            traceback.print_exc(file=sys.stdout)
            return ProcessResult(-1, str(e))
Exemple #10
0
 def find(self, domainId):
     ''' 获取加速域名配置  
     @type domainId: str
     @param domainId : 指定查找的域名ID
     @rtype: ProcessResult对象
     @return: 通过ProcessResult.getDomain()返回指定的域名信息的Domain实例
     '''
     
     url = self.HOST + "/api/domain/" + str(domainId)
     try:
         post = ''
         ret = util.httpReqeust(url, post, self.makeHeaders(url), "GET")
         if ret.status == 200:
             return xmlToDomain(ret)
         else:
             return xmlToFailure(ret)
     except Exception, e:
         traceback.print_exc(file=sys.stdout)
         return ProcessResult(-1, str(e))
Exemple #11
0
 def getHitReport(self, reportForm, domainId = None):
     ''' 获取某域名请求数报表 如果domainId 为None,表示 查汇总信息
     @type reportForm: ReportForm
     @param reportForm:  请求的时间和报表粒度
     @rtype: HitProcessResult
     @return: 通过HitProcessResult.getHitPoints() 获得返回的结果
     '''
     if domainId == None:
         url = self.HOST + "/api/report/hit"
     else:
         url = self.HOST + "/api/report/" + str(domainId) + "/hit" 
     try:
         url = appendParams(url, reportForm)
         ret = util.httpReqeust(url, "", self.makeHeaders(), "GET")
         if ret.status == 200:
             return xmlToHitPointList(ret, reportForm.getReportType())
         else:
             return getHitReportXmlToDefaultFailure(ret)
     except Exception, e:
         traceback.print_exc(file=sys.stdout)
         return HitProcessResult(-1, str(e))
Exemple #12
0
 def getHitReport(self, reportForm, domainId=None):
     ''' 获取某域名请求数报表 如果domainId 为None,表示 查汇总信息
     @type reportForm: ReportForm
     @param reportForm:  请求的时间和报表粒度
     @rtype: HitProcessResult
     @return: 通过HitProcessResult.getHitPoints() 获得返回的结果
     '''
     if domainId == None:
         url = self.HOST + "/api/report/hit"
     else:
         url = self.HOST + "/api/report/" + str(domainId) + "/hit"
     try:
         url = appendParams(url, reportForm)
         ret = util.httpReqeust(url, "", self.makeHeaders(), "GET")
         if ret.status == 200:
             return xmlToHitPointList(ret, reportForm.getReportType())
         else:
             return getHitReportXmlToDefaultFailure(ret)
     except Exception, e:
         traceback.print_exc(file=sys.stdout)
         return HitProcessResult(-1, str(e))
Exemple #13
0
    def modify(self, domain):
        ''' 修改加速域名配置 
        @type domain: Domain
        @param domain : 构建需要修改的域名的Domain实例, domain中必须设置domanId字段
        @rtype: ProcessResult对象
        @return: 返回ProcessResult对象
        '''

        if domain.domainId is None:
            raise '请设置domainId字段'

        url = self.HOST + "/api/domain/" + str(domain.domainId)
        try:
            post = domainToXml(domain)
            #print post
            ret = util.httpReqeust(url, post, self.makeHeaders(url), "PUT")
            if ret.status == 202:
                return xmlToSuccess(ret)
            else:
                return xmlToFailure(ret)
        except Exception, e:
            traceback.print_exc(file=sys.stdout)
            return ProcessResult(-1, str(e))
Exemple #14
0
 def modify(self, domain):
     ''' 修改加速域名配置 
     @type domain: Domain
     @param domain : 构建需要修改的域名的Domain实例, domain中必须设置domanId字段
     @rtype: ProcessResult对象
     @return: 返回ProcessResult对象
     '''
     
     if domain.domainId is None:
         raise '请设置domainId字段'
     
     url = self.HOST + "/api/domain/" + str(domain.domainId)
     try:
         post = domainToXml(domain)
         #print post
         ret = util.httpReqeust(url, post, self.makeHeaders(url), "PUT")
         if ret.status == 202:
             return xmlToSuccess(ret)
         else:
             return xmlToFailure(ret)   
     except Exception, e:
         traceback.print_exc(file=sys.stdout)
         return ProcessResult(-1, str(e))