#!/usr/bin/env python

import uuid
from context import fossil_fuel

cust_key = str(uuid.uuid4())
de_name = 'example-v1'

props = {
    'Name': de_name,
    'Description': 'Example Data Extension Creation',
    'CustomerKey': cust_key,
    'Template': [{'CustomerKey': '12345'}],
    }

# Set the data extension columns
columns = [
    {"Name": "Name", "FieldType": "Text", "IsPrimaryKey": "false", "MaxLength": "100", "IsRequired": "false"},
    {"Name": "EmailNum", "FieldType": "Number", "IsPrimaryKey": "false", "IsRequired": "false"},
    {"Name": "ProductName", "FieldType": "Text", "IsPrimaryKey": "false", "MaxLength": "100", "IsRequired": "false"},
    {"Name": "Price", "FieldType": "Decimal", "Precision": "6", "Scale": "2", "IsPrimaryKey": "false", "MaxLength": "50", "IsRequired": "false"},
    ]

print('Creating data extension {}'.format(de_name))

results = fossil_fuel.data_extension(action='post', props=props,
                                     columns=columns)
print(results)
#!/usr/bin/env python

from context import fossil_fuel

# Limit the fields that are returned
props = ['Name', 'CustomerKey']

# Filter the list of data extenions to retrieve
# Match DE name precisely
search_filter = {'Property': 'Name',
                 'SimpleOperator': 'equals',
                 'Value': 'jpdev'}
# Find DE's containing a string, use 'like' as the SimpleOperator

print('Retrieving data extension {}'.format(''))
results = fossil_fuel.data_extension(action='get', search_filter=search_filter)
print(results)