#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
@Copyright (C) ansjer cop Video Technology Co.,Ltd.All rights reserved.
@AUTHOR: ASJRD018
@NAME: AnsjerFormal
@software: PyCharm
@DATE: 2019/10/9 16:17
@Version: python3.6
@MODIFY DECORD:ansjer dev
@file: DynamodbObject.py
@Contact: chanjunkai@163.com
"""
from boto3 import Session
from botocore.exceptions import ClientError
from boto3.dynamodb.conditions import Key, Attr
import logging
import json
import boto3
from var_dump import var_dump

# AWS_DynamoDB_REGION = ''
# AWS_DynamoDB_ACCESS_KEY = ''
# AWS_DynamoDB_SECRET_KEY = ''
AWS_DynamoDB_REGION = 'us-west-1'
AWS_DynamoDB_ACCESS_KEY = 'AKIA2E67UIMD4PZTYKYD'
AWS_DynamoDB_SECRET_KEY = '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'


class DynamodbObject(object):
    def __init__(self, *args, **kwargs):
        self.region = AWS_DynamoDB_REGION
        self.access_key = AWS_DynamoDB_ACCESS_KEY
        self.secret_key = AWS_DynamoDB_SECRET_KEY
        self.session = Session(aws_access_key_id=self.access_key,
                               aws_secret_access_key=self.secret_key,
                               region_name=self.region)

    def do_table_handle(self, table_name):
        dynamodb = self.session.resource('dynamodb')
        table_handle = dynamodb.Table(table_name)
        return table_handle

    def do_san(self, filter_data, table_name):
        var_dump('xjklfjl;asjl;sdf')
        table_handle = self.do_table_handle(table_name)
        response = table_handle.scan(
            ProjectionExpression="userID",
            FilterExpression=Attr('appId').eq('com.ansjer.zccloud'),
        )
        var_dump('xxloo')
        var_dump(response)
        var_dump('****************')
        items = response['Items']

        return ''


# dobj = DynamodbObject()
# res = dobj.do_san(filter_data={'appId': 'com.ansjer.zccloud'}, table_name='user_brand')

