コード例 #1
0
 def __init__(self, statusCode, body):
     DisResponse.__init__(self, statusCode, body)
     self.projectid = body['projectid']
     self.ak = body['ak']
     self.sk = body['sk']
     self.region = body['region']
     self.endpoint = body['endpoint']
コード例 #2
0
    def __init__(self, statusCode, body):
        DisResponse.__init__(self, statusCode, body)
        if body and type(body) != dict:
            from dis_sdk_python.com.huaweicloud.dis.sdk.python.proto import record_pb2
            target = record_pb2.PutRecordsResult()
            target.ParseFromString(body)
            records = []
            self.body = {}
            records.extend([{
                'partition_id': target.records[i].shardId,
                'sequence_number': target.records[i].sequenceNumber,
                'error_message': target.records[i].errorMessage,
                'error_code': target.records[i].errorCode
            } for i in range(len(target.records))])

            for i in records:
                if 'DIS' not in i['error_code']:
                    del i['error_code']
                    del i['error_message']

            self.body['records'] = records
            self.body['failed_record_count'] = target.failedRecordCount
        else:
            self.body = body

        self.failedRecordCount = self.body["failed_record_count"]
        self.recordResult = self.body["records"]
コード例 #3
0
    def __init__(self, status_code, body, total_number):
        app_list = []
        if 'apps' in body.keys():
            for i in body.get('apps'):
                app_list.append(i.get('app_name'))
            body.setdefault('apps_list', app_list)
            body.setdefault('total_number', total_number)

            import copy
            new_body = copy.deepcopy(body)
            if 'apps' in new_body.keys():
                del new_body['apps']
            if 'hasMoreApp' in new_body.keys():
                del new_body['hasMoreApp']

            new_body.setdefault('appinfo_list', body.get('apps'))
            new_body.setdefault('has_more_app', body.get('hasMoreApp'))

        else:
            import copy
            new_body = copy.deepcopy(body)
            if 'hasMoreApp' in new_body.keys():
                del new_body['hasMoreApp']
            new_body.setdefault('has_more_app', body.get('hasMoreApp'))

        DisResponse.__init__(self, status_code, new_body)
コード例 #4
0
 def __init__(self, statusCode, body):
     DisResponse.__init__(self, statusCode, body)
     self.streamName = body.get("stream_name","")
     self.createTime = body.get("create_time","")
     self.lastModifiedTime = body.get("last_modified_time","")
     self.retentionPeriod = body.get("retention_period","")
     self.status = body.get("status","")
     self.streamType =  body.get("stream_type","")
     self.partitions = body.get("partitions","")
     self.currentPartitionCount = len(self.partitions)
     self.hasMorePartitions = body.get("has_more_partitions","")
コード例 #5
0
 def __init__(self, statusCode, body):
     DisResponse.__init__(self, statusCode, body)
     self.createTime = body.get("create_time", "")
     self.last_transfer_timestamp = body.get("last_transfer_timestamp", "")
     self.taskName = body.get("task_name", "")
     self.partitions = body.get("partitions", "")
     self.streamName = body.get("stream_name", "")
     self.status = body.get("status", "")
     self.streamType = body.get("stream_type", "")
     self.currentPartitionCount = len(self.partitions)
     self.hasMorePartitions = body.get("has_more_partitions", "")
コード例 #6
0
 def __init__(self, statusCode, body):
     DisResponse.__init__(self, statusCode, body)
     self.recordResult = []
     self.failedRecordCount = 0
     for i in body:
         self.failedRecordCount += i['failed_record_count']
         self.recordResult.extend(i['records'])
     self.body = {
         'failed_record_count': self.failedRecordCount,
         'records': self.recordResult
     }
コード例 #7
0
 def __init__(self, statusCode, body):
     DisResponse.__init__(self, statusCode, body)
     self.partitions = body['partitions']
     self.streamName = body["stream_name"]
     self.createTime = body["create_time"]
     self.lastModifiedTime = body["last_modified_time"]
     self.retentionPeriod = body["retention_period"]
     self.status = body["status"]
     self.streamType = body["stream_type"]
     self.partitions = body["partitions"]
     self.currentPartitionCount = len(self.partitions)
     self.hasMorePartitions = body["has_more_partitions"]
     for i in self.partitions:
         self.hash_range = i.get('hash_range')
         self.sequence_number_range =i.get('sequence_number_range')
         self.partition_id = i.get('partition_id')
コード例 #8
0
    def __init__(self, statusCode, body):
        DisResponse.__init__(self, statusCode, body)
        self.body = {}
        if type(body) == dict:
            self.body['next_partition_cursor'] = body["next_partition_cursor"]
            for i in range(len(body["records"])):
                tempData = body["records"][i]["data"].encode('utf-8')
                try:
                    body["records"][i]["data"] = base64.b64decode(
                        tempData).decode('utf-8')
                except:
                    body["records"][i]["data"] = base64.b64decode(tempData)
            self.body['records'] = [{
                'data': i.get('data'),
                'sequence_number': i.get('sequence_number'),
                'partitionKey': i.get('partition_key'),
                'timestamp': i.get('timestamp'),
                'timestamp_type': i.get('timestamp_type')
            } for i in body["records"]]

        else:
            from dis_sdk_python.com.huaweicloud.dis.sdk.python.proto import record_pb2
            target = record_pb2.GetRecordsResult()
            target.ParseFromString(body)
            records = [{
                'sequence_number': i.sequenceNumber,
                'data': i.data,
                'partitionKey': i.partitionKey,
                'timestamp': i.timestamp,
                'timestamp_type': i.timestampType
            } for i in list(target.records)]
            for i in records:
                if not i['partitionKey']: i['partitionKey'] = None
            self.body['next_partition_cursor'] = target.nextShardIterator
            self.body['records'] = records

        self.nextPartitionCursor = self.body["next_partition_cursor"]
        self.recordResult = self.body["records"]
        self.recordCount = len(self.body["records"])
コード例 #9
0
 def __init__(self, status_code, body):
     DisResponse.__init__(self, status_code, body)
     self.metrics = body.get("metrics")
     self.label=self.metrics.get('label')
     self.dataPoints = self.metrics.get('dataPoints')
コード例 #10
0
 def __init__(self, status_code, body):
     DisResponse.__init__(self, status_code, body)
     self.has_more_app = body.get('has_more_app', '')
     self.apps = body.get('apps', '')
コード例 #11
0
 def __init__(self, statusCode, body):
     DisResponse.__init__(self, statusCode, body)
     self.has_more_tasks = body['has_more_tasks']
     self.total_number = body['total_number']
     self.details = body['details']
コード例 #12
0
 def __init__(self, statusCode, body):
     DisResponse.__init__(self, statusCode, body)
     self.cursor = body["partition_cursor"]
コード例 #13
0
 def __init__(self, status_code, body):
     DisResponse.__init__(self, status_code, body)
     # self.seqNumber = body["sequence_number"]
     self.seqNumber = body.get("sequence_number")
     self.metaData = body.get("metaData", '')
コード例 #14
0
 def __init__(self, statusCode, body):
     DisResponse.__init__(self, statusCode, body)
     self.body = body
コード例 #15
0
 def __init__(self, statusCode, body):
     DisResponse.__init__(self, statusCode, body)
     self.total_number = body.get("total_number",'')
     self.stream_names = body.get("stream_names",'')
     self.stream_info_list =body.get("stream_info_list",'')
コード例 #16
0
 def __init__(self, status_code, body):
     DisResponse.__init__(self, status_code, body)
     self.stream_name = body.get("stream_name", '')
     self.partition_consuming_states = body.get(
         "partition_consuming_states", '')
     self.app_name = body.get("app_name", '')
コード例 #17
0
 def __init__(self, statusCode, body):
     DisResponse.__init__(self, statusCode, body)
     self.total = body["total_number"]
     self.streams = body["stream_names"]
     self.count = len(self.streams)
     self.hasMoreStream = body["has_more_streams"]
コード例 #18
0
 def __init__(self, status_code, body):
     DisResponse.__init__(self, status_code, body)
コード例 #19
0
 def __init__(self, statusCode, body):
     DisResponse.__init__(self, statusCode, body)
     self.tasks = body.get("tasks", "")
     self.total_number = body.get("total_number", "")