| 1 |
Design Notes for Botocore |
| 2 |
========================= |
| 3 |
|
| 4 |
This document outlines the rationale behind various design |
| 5 |
decisions in botocore. |
| 6 |
|
| 7 |
|
| 8 |
Casing of Arguments |
| 9 |
------------------- |
| 10 |
|
| 11 |
One of the most noticeable differences between botocore and boto |
| 12 |
is that the client objects 1) require parameters to be provided |
| 13 |
as ``**kwargs`` and 2) require the arguments typically be provided as |
| 14 |
``CamelCased`` values. |
| 15 |
|
| 16 |
For example:: |
| 17 |
|
| 18 |
ddb = session.create_client('dynamodb') |
| 19 |
ddb.describe_table(TableName='mytable') |
| 20 |
|
| 21 |
In boto, the equivalent code would be:: |
| 22 |
|
| 23 |
layer1.describe_table(table_name='mytable') |
| 24 |
|
| 25 |
There are several reasons why this was changed in botocore. |
| 26 |
|
| 27 |
The first reason was because we wanted to have the same casing for |
| 28 |
inputs as well as outputs. In both boto and botocore, the response |
| 29 |
for the ``describe_table`` calls is:: |
| 30 |
|
| 31 |
{'Table': {'CreationDateTime': 1393007077.387, |
| 32 |
'ItemCount': 0, |
| 33 |
'KeySchema': {'HashKeyElement': {'AttributeName': 'foo', |
| 34 |
'AttributeType': 'S'}}, |
| 35 |
'ProvisionedThroughput': {'ReadCapacityUnits': 5, |
| 36 |
'WriteCapacityUnits': 5}, |
| 37 |
'TableName': 'testtable', |
| 38 |
'TableStatus': 'ACTIVE'}} |
| 39 |
|
| 40 |
Notice that the response is ``CamelCased``. This makes it more difficult |
| 41 |
to round trip results. In many cases you want to get the result of |
| 42 |
a ``describe*`` call and use that value as input through a corresponding |
| 43 |
``update*`` call. If the input arguments require ``snake_casing`` but |
| 44 |
the response data is ``CamelCased`` then you will need to manually convert |
| 45 |
all the response elements back to ``snake_case`` in order to properly |
| 46 |
round trip. |
| 47 |
|
| 48 |
This makes the case for having consistent casing for both input and |
| 49 |
output. Why not use ``snake_casing`` for input as well as output? |
| 50 |
|
| 51 |
We choose to use ``CamelCasing`` because this is the casing used by |
| 52 |
AWS services. As a result, we don't have to do any translation from |
| 53 |
``CamelCasing`` to ``snake_casing``. We can use the response values |
| 54 |
exactly as they are returned from AWS services. |
| 55 |
|
| 56 |
This also means that if you are reading the AWS API documentation |
| 57 |
for services, the names and casing referenced there will match |
| 58 |
what you would provide to botocore. For example, here's the |
| 59 |
corresponding API documentation for |
| 60 |
`dynamodb.describe_table |
| 61 |
<http://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_DescribeTable.html>`__. |