Skip to content

Commit f986dae

Browse files
authored
Expanded testing, plus new models for AWS Config, SQS, SNS (#16)
Adds a number of improvements. Tests will need to be revisited, but I've added a decent base. Bumps to v0.1.1 ### Added - Adds support for generating a Graphviz diagram of an Organization with the new `OrganizationDataBuilder.to_dot()` function - Adds `DOT` as a supported output format for the `organization dump-all` command - Adds models for AWS Config notifications - Adds models for SQS and SNS messages - Adds methods to ModelBase to allow (de)serializing JSON or YAML strings - Adds ModelBase.from_dict() to initialize a model from a dict using dacite - Adds CodeQL analysis workflow for GitHub Actions ### Changed - breaking: Renames `organization dump-json` CLI command to `organization dump-all` - Moves buiders into the models namespace
1 parent 017f1a0 commit f986dae

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+3729
-1384
lines changed

.editorconfig

Whitespace-only changes.

.github/CODE_OF_CONDUCT.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,11 @@ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
117117
version 2.0, available at
118118
[https://www.contributor-covenant.org/version/2/0/code_of_conduct.html][v2.0].
119119

120-
Community Impact Guidelines were inspired by
120+
Community Impact Guidelines were inspired by
121121
[Mozilla's code of conduct enforcement ladder][Mozilla CoC].
122122

123123
For answers to common questions about this code of conduct, see the FAQ at
124-
[https://www.contributor-covenant.org/faq][FAQ]. Translations are available
124+
[https://www.contributor-covenant.org/faq][FAQ]. Translations are available
125125
at [https://www.contributor-covenant.org/translations][translations].
126126

127127
[homepage]: https://www.contributor-covenant.org

.github/workflows/ci.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,3 +127,41 @@ jobs:
127127

128128
- name: Run tests
129129
run: make test
130+
131+
analyze:
132+
name: Analyze
133+
runs-on: ubuntu-latest
134+
permissions:
135+
actions: read
136+
contents: read
137+
security-events: write
138+
139+
steps:
140+
- name: Checkout repository
141+
uses: actions/checkout@v2
142+
with:
143+
fetch-depth: 1
144+
145+
- name: Set up Python
146+
uses: actions/setup-python@v1
147+
with:
148+
python-version: 3.9
149+
150+
- name: Install Poetry
151+
uses: snok/[email protected]
152+
with:
153+
virtualenvs-create: false
154+
virtualenvs-in-project: true
155+
156+
- name: Restore cache venv
157+
uses: syphar/restore-virtualenv@v1
158+
id: cache-venv
159+
160+
- name: Initialize CodeQL
161+
uses: github/codeql-action/[email protected]
162+
with:
163+
languages: python
164+
setup_python_dependencies: false
165+
166+
- name: Perform CodeQL Analysis
167+
uses: github/codeql-action/[email protected]

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ dist
308308
.pnp.*
309309

310310
# -------------------------------------------------------------------------------------
311-
# Python
311+
# Python
312312
# -------------------------------------------------------------------------------------
313313

314314
# Byte-compiled / optimized / DLL files
@@ -1101,3 +1101,7 @@ $RECYCLE.BIN/
11011101

11021102
# Windows shortcuts
11031103
*.lnk
1104+
1105+
# Misc
1106+
1107+
*.bak

.pre-commit-config.yaml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
11
# pre-commit run --all-files
22
repos:
33
- repo: https://github.com/pre-commit/pre-commit-hooks
4-
rev: v3.4.0
4+
rev: v4.0.1
55
hooks:
66
- id: check-ast
77
- id: check-json
88
- id: check-merge-conflict
99
- id: check-toml
1010
- id: check-yaml
1111
- id: debug-statements
12-
- id: detect-aws-credentials
13-
args: ["--allow-missing-credentials"]
1412
- id: detect-private-key
1513
- id: end-of-file-fixer
1614
- id: mixed-line-ending
1715
- id: no-commit-to-branch
1816
- id: trailing-whitespace
1917
- repo: https://github.com/psf/black
20-
rev: 21.6b0
18+
rev: 21.11b1
2119
hooks:
2220
- id: black
2321
- repo: https://github.com/asottile/blacken-docs
24-
rev: v1.10.0
22+
rev: v1.12.0
2523
hooks:
2624
- id: blacken-docs
2725
additional_dependencies: [black==21.6b0]
28-
- repo: https://github.com/flakehell/flakehell
29-
rev: v.0.8.0
30-
hooks:
31-
- name: Run flakehell static analysis tool
32-
id: flakehell
26+
# Disable flakehell for now due to import bug with newer flake8
27+
# https://github.com/flakehell/flakehell/issues/22
28+
# - repo: https://github.com/flakehell/flakehell
29+
# rev: v.0.9.0
30+
# hooks:
31+
# - name: Run flakehell static analysis tool
32+
# id: flakehell

CHANGELOG.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,23 @@ the unreleased section to the section for the new release.
1414

1515
No unreleased changes.
1616

17+
## [0.1.1] - 2021-11-23
18+
1719
### Added
1820

1921
- Adds support for generating a Graphviz diagram of an Organization with the new
2022
`OrganizationDataBuilder.to_dot()` function
2123
- Adds `DOT` as a supported output format for the `organization dump-all` command
24+
- Adds models for AWS Config notifications
25+
- Adds models for SQS and SNS messages
26+
- Adds methods to ModelBase to allow (de)serializing JSON or YAML strings
27+
- Adds ModelBase.from_dict() to initialize a model from a dict using dacite
28+
- Adds CodeQL analysis workflow for GitHub Actions
2229

2330
### Changed
2431

2532
- breaking: Renames `organization dump-json` CLI command to `organization dump-all`
33+
- Moves buiders into the models namespace
2634

2735
## [0.1.0-beta2] - 2021-06-16
2836

@@ -78,7 +86,8 @@ Initial alpha release
7886
These Markdown anchors provide a link to the diff for each release. They should be
7987
updated any time a new release is cut.
8088
-->
81-
[Unreleased]: https://github.com/timoguin/aws-org-tools-py/compare/v0.1.0-beta-2...HEAD
89+
[Unreleased]: https://github.com/timoguin/aws-org-tools-py/compare/v0.1.1...HEAD
90+
[0.1.1]: https://github.com/timoguin/aws-org-tools-py/compare/v0.1.0-beta2...v0.1.1
8291
[0.1.0-beta2]: https://github.com/timoguin/aws-org-tools-py/compare/v0.1.0-beta1...v0.1.0-beta2
8392
[0.1.0-beta1]: https://github.com/timoguin/aws-org-tools-py/compare/v0.1.0-alpha4...v0.1.0-beta1
8493
[0.1.0-alpha4]: https://github.com/timoguin/aws-org-tools-py/releases/tag/v0.1.0-alpha4

Makefile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,9 @@ shellcmd: ${VENV_DIR}
3131
lint: ${VENV_DIR}
3232
@echo "Running the black code formatter"
3333
@poetry run black ${ARGS} .
34-
@echo "Running flakehell plugins"
35-
@poetry run flakehell lint aws_data_tools
34+
# flakehell currently disabled, see .pre-commit-config.yaml notesk
35+
# @echo "Running flakehell plugins"
36+
# @poetry run flakehell lint aws_data_tools
3637

3738
.PHONY: lint-docs
3839
lint-docs: ${VENV_DIR}
@@ -72,7 +73,7 @@ build: ${VENV_DIR}
7273
.PHONY: test ## Run the test suite
7374
test: ${VENV_DIR}
7475
@echo "Running test suite"
75-
@poetry run pytest --suppress-no-test-exit-code
76+
@poetry run pytest --cov ${OPTS} ${ARGS}
7677

7778
# Ensures the Python venv exists and has dependencies installed
7879
${VENV_DIR}:

README.md

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# AWS Data Tools
22

33
<!-- Badges -->
4-
[![Actions Status][gh-actions-badge]][gh-actions-link]
4+
[![Actions CI Status][gh-actions-ci-badge]][gh-actions-ci-link]
5+
[![Actions CodeQL Status][gh-actions-codeql-badge]][gh-actions-codeql-link]
56
[![PyPI][pypi-badge]][pypi-link]
67
[![License][license-badge]][license-link]
78

@@ -32,7 +33,7 @@ To dump a data representation of an AWS Organization, you can do the following u
3233
the builder:
3334

3435
```python
35-
from aws_data_tools.builders.organizations import OrganizationDataBuilder
36+
from aws_data_tools.models.organizations import OrganizationDataBuilder
3637

3738
odb = OrganizationDataBuilder(init_all=True)
3839
organization = odb.as_json()
@@ -41,7 +42,7 @@ organization = odb.as_json()
4142
Here is how to do the same thing with the CLI:
4243

4344
```
44-
$ awsdata organization dump-json
45+
$ awsdata organization dump-all
4546
```
4647

4748
## Usage
@@ -54,9 +55,9 @@ abstract some of these operations.
5455
### Builders
5556

5657
While it is possible to directly utilize and interact with the data models, probably
57-
the largest benefit is the [builders](aws_data_tools/builders) package. It abstracts
58-
any API operations and data transformations required to build data models. The models
59-
can then be serialized to dicts, as well as JSON or YAML strings.
58+
the largest benefit are the builders. They abstract any API operations and data
59+
transformations required to build data models. The models can then be serialized to
60+
dicts, as well as DOT, JSON, or YAML strings.
6061

6162
A full model of an AWS Organization can be constructed using the
6263
`OrganizationDataBuilder` class. It handles recursing the organizational tree and
@@ -67,9 +68,9 @@ The simplest example pulls all supported organizational data and creates the rel
6768
data models:
6869

6970
```python
70-
from aws_data_tools.builders.organizations import OrganizationDataBuilder as odb
71+
from aws_data_tools.models.organizations import OrganizationDataBuilder
7172

72-
org = odb(init_all=True)
73+
odb = OrganizationDataBuilder(init_all=True)
7374
```
7475

7576
Note that this makes many API calls to get this data. For example, every OU, policy,
@@ -84,9 +85,9 @@ requires 316 API calls! That's why this library was created.
8485
For more control over the process, you can init each set of components as desired:
8586

8687
```python
87-
from aws_data_tools.builders.organizations import OrganizationDataBuilder as odb
88+
from aws_data_tools.models.organizations import OrganizationDataBuilder
8889

89-
org = odb()
90+
org = OrganizationDataBuilder()
9091
org.init_connection()
9192
org.init_organization()
9293
org.init_root()
@@ -274,8 +275,10 @@ View the [Contributing Guide](.github/CONTRIBUTING.md) to learn about giving bac
274275

275276

276277
<!-- Markown anchors -->
277-
[gh-actions-badge]: https://github.com/timoguin/aws-data-tools-py/actions/workflows/ci.yml/badge.svg
278-
[gh-actions-link]: https://github.com/timoguin/aws-data-tools-py/actions
278+
[gh-actions-ci-badge]: https://github.com/timoguin/aws-data-tools-py/actions/workflows/ci.yml/badge.svg
279+
[gh-actions-ci-link]: https://github.com/timoguin/aws-data-tools-py/actions/workflows/ci.yml
280+
[gh-actions-codeql-badge]: https://github.com/timoguin/aws-data-tools-py/actions/workflows/codeql-analysis.yml/badge.svg
281+
[gh-actions-codeql-link]: https://github.com/timoguin/aws-data-tools-py/actions/workflows/codeql-analysis.yml
279282
[license-badge]: https://img.shields.io/github/license/timoguin/aws-data-tools-py.svg
280283
[license-link]: https://github.com/timoguin/aws-data-tools-py/blob/main/LICENSE
281284
[pypi-badge]: https://badge.fury.io/py/aws-data-tools.svg

aws_data_tools/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
"""
22
A library for working with data from AWS APIs
33
"""
4+
# flake8: noqa: F401
5+
6+
from . import client, models, utils
47

58
__VERSION__ = "0.1.0-beta2"
69

aws_data_tools/builders/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)