villaBackendSdk

interact with villa cart and ordering endpoints


Keywords
villa, cart, orders, basket
License
Apache-2.0
Install
pip install villaBackendSdk==0.0.1

Documentation

PynamoLogger

log information into a dynamodb, with dax support

Install

pip install pynamologger

view Documentation

Usage

create a dynamodb table

indexKey

  • appName

rangeKey

  • timestamp

Sam template

put this in your template.yaml file under properties section
make sure that the table name is the same in Meta declaration

YourLogTable:
  Type: AWS::DynamoDB::Table
  Properties:
    AttributeDefinitions:
      - AttributeName: appName
        AttributeType: S
      - AttributeName: timestamp
        AttributeType: N
    BillingMode: PAY_PER_REQUEST
    TableName: <put your table name here>
    KeySchema:
      - AttributeName: appName
        KeyType: HASH
      - AttributeName: timestamp
        KeyType: RANGE

create using pynamodb api

Logger.create_table()

class meta definition

from pynamoLogger.logger import PynamoLogger
class Logger(PynamoLogger):
  class Meta:
    table_name = 'member-database-log-dev-manual' # put your table name
    region = 'ap-southeast-1' #put your region name
    billing_mode = 'PAY_PER_REQUEST'
    
# Logger.create_table()
Logger.log(appName = 'test', message = "this is crazy", responseObject = {'response': 'null response'})
{'logId': 1603075789.054751,
 'saveResult': {'ConsumedCapacity': {'CapacityUnits': 1.0,
   'TableName': 'member-database-log-dev-manual'}}}
Logger.checkLog(appName = 'test', logId = '1603074235.103042')
[{'appName': None,
  'timestamp': 1603074235.103042,
  'logMessage': 'this is crazy',
  'requestObject': {'noValue': 'noValue'},
  'responseObject': {'response': 'null response'}}]