Skip to content

Commit

Permalink
Update resource model format.
Browse files Browse the repository at this point in the history
This updates to the latest resource model format, which includes the following
changes:

1. `belongsTo` references are now named `has`
2. `subResources` is replaced by two-way `has` references
3. Identifier and parameter definitions are refactored:

    * `source` is now one of `name`, `path` or `value`
    * `sourceType` is now `source`
    * A new source of `input` is added for user-supplied input

Our interface remains the same, but the underlying JSON files have changed
and our factory code and documentation are somewhat simplified. The code
that handles identifiers/parameters is a bit more complex due to having
to check several keys in the dictionary based on the source.

The model still exposes subresources and references as separate concepts.
Due to circular references, resource instances now lazy-load the subresource
class when needed.

Tests and documentation have been updated to reflect these changes.
  • Loading branch information
danielgtaylor committed Jan 29, 2015
1 parent 59136a4 commit 6b6cf76
Show file tree
Hide file tree
Showing 22 changed files with 2,437 additions and 1,262 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ tests/.coverage
# Test state / virtualenvs
.tox
.coverage
cover

# Common virtualenv names
venv
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ Changelog
Unreleased
----------

* feature:Resources: Update to the latest resource JSON format.
(`issue 51 <https://github.com/boto/boto3/pull/51>`__)
* feature:Resources: Make ``resource.meta`` a proper object. This allows
you to do things like ``resource.meta.client``. This is a **backward-
incompatible** change.
Expand Down
75 changes: 55 additions & 20 deletions boto3/data/resources/cloudformation-2010-05-15.resources.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,25 @@
"resource": {
"type": "Stack",
"identifiers": [
{ "target": "Name", "sourceType": "requestParameter", "source": "StackName" }
{ "target": "Name", "source": "requestParameter", "path": "StackName" }
]
}
}
},
"has": {
"Event": {
"resource": {
"type": "Event",
"identifiers": [
{ "target": "Id", "source": "input" }
]
}
},
"Stack": {
"resource": {
"type": "Stack",
"identifiers": [
{ "target": "Name", "source": "input" }
]
}
}
Expand All @@ -17,7 +35,7 @@
"resource": {
"type": "Stack",
"identifiers": [
{ "target": "Name", "sourceType": "responsePath", "source": "Stacks[].StackName" }
{ "target": "Name", "source": "response", "path": "Stacks[].StackName" }
]
}
}
Expand All @@ -39,7 +57,7 @@
"request": {
"operation": "DescribeStacks",
"params": [
{ "target": "StackName", "sourceType": "identifier", "source": "Name" }
{ "target": "StackName", "source": "identifier", "name": "Name" }
]
},
"path": "Stacks[0]"
Expand All @@ -49,23 +67,34 @@
"request": {
"operation": "CancelUpdateStack",
"params": [
{ "target": "StackName", "sourceType": "identifier", "source": "Name" }
{ "target": "StackName", "source": "identifier", "name": "Name" }
]
}
},
"Delete": {
"request": {
"operation": "DeleteStack",
"params": [
{ "target": "StackName", "sourceType": "identifier", "source": "Name" }
{ "target": "StackName", "source": "identifier", "name": "Name" }
]
}
},
"Update": {
"request": {
"operation": "UpdateStack",
"params": [
{ "target": "StackName", "sourceType": "identifier", "source": "Name" }
{ "target": "StackName", "source": "identifier", "name": "Name" }
]
}
}
},
"has": {
"Resource": {
"resource": {
"type": "StackResource",
"identifiers": [
{ "target": "StackName", "source": "identifier", "name": "Name" },
{ "target": "StackName", "source": "input" }
]
}
}
Expand All @@ -75,13 +104,13 @@
"request": {
"operation": "DescribeStackEvents",
"params": [
{ "target": "StackName", "sourceType": "identifier", "source": "Name" }
{ "target": "StackName", "source": "identifier", "name": "Name" }
]
},
"resource": {
"type": "Event",
"identifiers": [
{ "target": "Id", "sourceType": "responsePath", "source": "StackEvents[].EventId" }
{ "target": "Id", "source": "response", "path": "StackEvents[].EventId" }
],
"path": "StackEvents[]"
}
Expand All @@ -90,22 +119,18 @@
"request": {
"operation": "ListStackResources",
"params": [
{ "target": "StackName", "sourceType": "identifier", "source": "Name" }
{ "target": "StackName", "source": "identifier", "name": "Name" }
]
},
"resource": {
"type": "StackResourceSummary",
"identifiers": [
{ "target": "LogicalId", "sourceType": "responsePath", "source": "StackResourceSummaries[].LogicalResourceId" },
{ "target": "StackName", "sourceType": "requestParameter", "source": "StackName" }
{ "target": "LogicalId", "source": "response", "path": "StackResourceSummaries[].LogicalResourceId" },
{ "target": "StackName", "source": "requestParameter", "path": "StackName" }
],
"path": "StackResourceSummaries[]"
}
}
},
"subResources": {
"resources": [ "StackResource" ],
"identifiers": { "Name": "StackName" }
}
},
"StackResource": {
Expand All @@ -118,11 +143,21 @@
"request": {
"operation": "DescribeStackResource",
"params": [
{ "target": "LogicalResourceId", "sourceType": "identifier", "source": "LogicalId" },
{ "target": "StackName", "sourceType": "identifier", "source": "StackName" }
{ "target": "LogicalResourceId", "source": "identifier", "name": "LogicalId" },
{ "target": "StackName", "source": "identifier", "name": "StackName" }
]
},
"path": "StackResourceDetail"
},
"has": {
"Stack": {
"resource": {
"type": "Stack",
"identifiers": [
{ "target": "Name", "source": "identifier", "name": "StackName" }
]
}
}
}
},
"StackResourceSummary": {
Expand All @@ -131,13 +166,13 @@
{ "name": "StackName" }
],
"shape": "StackResourceSummary",
"belongsTo": {
"has": {
"Resource": {
"resource": {
"type": "StackResource",
"identifiers": [
{ "target": "LogicalId", "sourceType": "identifier", "source": "LogicalId" },
{ "target": "StackName", "sourceType": "identifier", "source": "StackName" }
{ "target": "LogicalId", "source": "identifier", "name": "LogicalId" },
{ "target": "StackName", "source": "identifier", "name": "StackName" }
]
}
}
Expand Down
Loading

0 comments on commit 6b6cf76

Please sign in to comment.