當前位置: 首頁>>代碼示例>>Python>>正文


Python types.TypeDeserializer方法代碼示例

本文整理匯總了Python中boto3.dynamodb.types.TypeDeserializer方法的典型用法代碼示例。如果您正苦於以下問題:Python types.TypeDeserializer方法的具體用法?Python types.TypeDeserializer怎麽用?Python types.TypeDeserializer使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在boto3.dynamodb.types的用法示例。


在下文中一共展示了types.TypeDeserializer方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

# 需要導入模塊: from boto3.dynamodb import types [as 別名]
# 或者: from boto3.dynamodb.types import TypeDeserializer [as 別名]
def __init__(self, transformer=None, condition_builder=None,
                 serializer=None, deserializer=None):
        self._transformer = transformer
        if transformer is None:
            self._transformer = ParameterTransformer()

        self._condition_builder = condition_builder
        if condition_builder is None:
            self._condition_builder = ConditionExpressionBuilder()

        self._serializer = serializer
        if serializer is None:
            self._serializer = TypeSerializer()

        self._deserializer = deserializer
        if deserializer is None:
            self._deserializer = TypeDeserializer() 
開發者ID:skarlekar,項目名稱:faces,代碼行數:19,代碼來源:transform.py

示例2: get_account_role_map

# 需要導入模塊: from boto3.dynamodb import types [as 別名]
# 或者: from boto3.dynamodb.types import TypeDeserializer [as 別名]
def get_account_role_map(boto_session, region_name):
    """Fetch the ARNs of all the IAM Roles which people have created in other
    AWS accounts which are inserted into DynamoDB with
    http://github.com/gene1wood/cloudformation-cross-account-outputs

    :return: dict with account ID keys and IAM Role ARN values
    """

    client = boto_session.client('dynamodb', region_name=region_name)

    paginator = client.get_paginator('scan')
    service_model = client._service_model.operation_model('Scan')
    trans = TransformationInjector(deserializer=TypeDeserializer())
    items = []
    for page in paginator.paginate(TableName=DYNAMODB_TABLE_NAME):
        trans.inject_attribute_value_output(page, service_model)
        items.extend([x for x in page['Items']])

    return {x['aws-account-id']: x['GuardDutyMemberAccountIAMRoleArn']
            for x in items
            if x.get('category') == DB_CATEGORY
            and {'aws-account-id',
                 'GuardDutyMemberAccountIAMRoleArn'} <= set(x)} 
開發者ID:mozilla,項目名稱:guardduty-multi-account-manager,代碼行數:25,代碼來源:invitation_manager.py

示例3: __init__

# 需要導入模塊: from boto3.dynamodb import types [as 別名]
# 或者: from boto3.dynamodb.types import TypeDeserializer [as 別名]
def __init__(self, status_code, payload):
        self.status_code = status_code
        self.payload = payload
        Exception.__init__(
            self,
            'ES_Exception: status_code={}, payload={}'.format(
                status_code, payload))


# Subclass of boto's TypeDeserializer for DynamoDB to adjust
# for DynamoDB Stream format. 
開發者ID:aws-samples,項目名稱:accelerated-data-lake,代碼行數:13,代碼來源:sendDataCatalogUpdateToElasticsearch.py

示例4: ddb_to_dict

# 需要導入模塊: from boto3.dynamodb import types [as 別名]
# 或者: from boto3.dynamodb.types import TypeDeserializer [as 別名]
def ddb_to_dict(item):
    # type: (Dict[str, Any]) -> Dict[str, Any]
    # TODO: narrow these types down
    """Converts a raw DynamoDB item to a native Python dictionary.

    :param dict item: DynamoDB item
    :returns: Native item
    :rtype: dict
    """
    deserializer = TypeDeserializer()
    return {key: deserializer.deserialize(value) for key, value in item.items()} 
開發者ID:aws,項目名稱:aws-dynamodb-encryption-python,代碼行數:13,代碼來源:transform.py

示例5: _serialize_deserialize_cycle

# 需要導入模塊: from boto3.dynamodb import types [as 別名]
# 或者: from boto3.dynamodb.types import TypeDeserializer [as 別名]
def _serialize_deserialize_cycle(attribute):
    raw_attribute = TypeSerializer().serialize(attribute)
    serialized_attribute = serialize_attribute(raw_attribute)
    cycled_attribute = deserialize_attribute(serialized_attribute)
    deserialized_attribute = TypeDeserializer().deserialize(cycled_attribute)
    assert deserialized_attribute == attribute 
開發者ID:aws,項目名稱:aws-dynamodb-encryption-python,代碼行數:8,代碼來源:test_attribute.py

示例6: _query_specific_date

# 需要導入模塊: from boto3.dynamodb import types [as 別名]
# 或者: from boto3.dynamodb.types import TypeDeserializer [as 別名]
def _query_specific_date(self, date) -> Set[AthenaQuery]:
        """
        Private method to query for all queries
        made on a particular date with data_scanned > 0

        :param date: str date of DATE_FORMAT
        :return: Set of AthenaQuery, results of this operation
        """
        # low level client type query is used instead of resource
        # due to higher level resource query not allowing to filter
        # data_scanned > 0

        # start_timestamp is additionally queried for 'true' 24h days calculation
        # instead of a 'day' being 24h +- 11.59h
        query_finished_queries_for_days_function_call = functools.partial(
            self._dynamodb.query,
            TableName=self._config['QUERIES_TABLE'],
            ProjectionExpression='data_scanned, executing_user, start_timestamp',
            KeyConditionExpression='start_date = :date',
            ExpressionAttributeValues={':date': {'S': f'{date}'},
                                       ':num': {'N': '0'}},
            FilterExpression='#ds > :num',
            ExpressionAttributeNames={'#ds': 'data_scanned'}
        )

        response = query_finished_queries_for_days_function_call()
        data = response['Items']

        # check for paginated results
        while response.get('LastEvaluatedKey'):
            response = query_finished_queries_for_days_function_call(
                ExclusiveStartKey=response['LastEvaluatedKey'])
            data.extend(response['Items'])

        # data that comes is a list in elements of format:
        # 'start_timestamp': {'S': '2019-01-23 18:47:04'}, ..
        # so it needs to be deserialized while taking into account _dynamodb's ('S'..) types

        python_data = [{field_name: TypeDeserializer().deserialize(type_value_dict)
                       for field_name, type_value_dict in data_entry.items()}
                       for data_entry in data]

        return set(AthenaQuery(start_date=date, **item) for item in python_data) 
開發者ID:Wikia,項目名稱:discreETLy,代碼行數:45,代碼來源:query_dao.py


注:本文中的boto3.dynamodb.types.TypeDeserializer方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。