reverse-diagrams 1.3.3__tar.gz → 1.3.5__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. {reverse_diagrams-1.3.3 → reverse_diagrams-1.3.5}/.github/workflows/publish-to-test-pypi.yml +6 -6
  2. {reverse_diagrams-1.3.3 → reverse_diagrams-1.3.5}/.gitignore +29 -0
  3. reverse_diagrams-1.3.5/.kiro/specs/tag-based-filtering/design.md +258 -0
  4. reverse_diagrams-1.3.5/.kiro/specs/tag-based-filtering/requirements.md +139 -0
  5. reverse_diagrams-1.3.5/.kiro/specs/tag-based-filtering/tasks.md +191 -0
  6. reverse_diagrams-1.3.5/.kiro/steering/product.md +19 -0
  7. reverse_diagrams-1.3.5/.kiro/steering/structure.md +251 -0
  8. reverse_diagrams-1.3.5/.kiro/steering/tech.md +63 -0
  9. reverse_diagrams-1.3.5/.pre-commit-config.yaml +47 -0
  10. reverse_diagrams-1.3.5/IMPLEMENTATION_GUIDE.md +388 -0
  11. reverse_diagrams-1.3.5/IMPROVEMENTS_SUMMARY.md +258 -0
  12. reverse_diagrams-1.3.5/PHASE_2_3_COMPLETION_SUMMARY.md +226 -0
  13. reverse_diagrams-1.3.5/PKG-INFO +706 -0
  14. reverse_diagrams-1.3.5/PLUGIN_MIGRATION_SUMMARY.md +202 -0
  15. reverse_diagrams-1.3.5/README.md +654 -0
  16. reverse_diagrams-1.3.5/TAG_FILTERING_SPEC_COMPLETE.md +165 -0
  17. reverse_diagrams-1.3.5/improvements_analysis.md +298 -0
  18. {reverse_diagrams-1.3.3 → reverse_diagrams-1.3.5}/pyproject.toml +32 -8
  19. reverse_diagrams-1.3.5/src/aws/client_manager.py +217 -0
  20. {reverse_diagrams-1.3.3 → reverse_diagrams-1.3.5}/src/aws/describe_identity_store.py +8 -0
  21. reverse_diagrams-1.3.5/src/aws/describe_organization.py +359 -0
  22. reverse_diagrams-1.3.5/src/aws/describe_sso.py +203 -0
  23. reverse_diagrams-1.3.5/src/aws/exceptions.py +26 -0
  24. reverse_diagrams-1.3.5/src/config.py +153 -0
  25. reverse_diagrams-1.3.5/src/models.py +242 -0
  26. reverse_diagrams-1.3.5/src/plugins/__init__.py +12 -0
  27. reverse_diagrams-1.3.5/src/plugins/base.py +292 -0
  28. reverse_diagrams-1.3.5/src/plugins/builtin/__init__.py +12 -0
  29. reverse_diagrams-1.3.5/src/plugins/builtin/ec2_plugin.py +228 -0
  30. reverse_diagrams-1.3.5/src/plugins/builtin/identity_center_plugin.py +496 -0
  31. reverse_diagrams-1.3.5/src/plugins/builtin/organizations_plugin.py +376 -0
  32. reverse_diagrams-1.3.5/src/plugins/registry.py +126 -0
  33. {reverse_diagrams-1.3.3 → reverse_diagrams-1.3.5}/src/reports/console_view.py +57 -19
  34. reverse_diagrams-1.3.5/src/reports/save_results.py +221 -0
  35. reverse_diagrams-1.3.5/src/reverse_diagrams.py +428 -0
  36. reverse_diagrams-1.3.5/src/utils/__init__.py +1 -0
  37. reverse_diagrams-1.3.5/src/utils/cache.py +274 -0
  38. reverse_diagrams-1.3.5/src/utils/concurrent.py +361 -0
  39. reverse_diagrams-1.3.5/src/utils/progress.py +257 -0
  40. {reverse_diagrams-1.3.3 → reverse_diagrams-1.3.5}/src/version.py +1 -1
  41. reverse_diagrams-1.3.5/tests/__init__.py +1 -0
  42. reverse_diagrams-1.3.5/tests/conftest.py +155 -0
  43. reverse_diagrams-1.3.5/tests/integration/__init__.py +1 -0
  44. reverse_diagrams-1.3.5/tests/integration/test_cli_integration.py +233 -0
  45. reverse_diagrams-1.3.5/tests/unit/__init__.py +1 -0
  46. reverse_diagrams-1.3.5/tests/unit/test_client_manager.py +206 -0
  47. reverse_diagrams-1.3.5/tests/unit/test_models.py +382 -0
  48. reverse_diagrams-1.3.3/.pre-commit-config.yaml +0 -38
  49. reverse_diagrams-1.3.3/PKG-INFO +0 -247
  50. reverse_diagrams-1.3.3/README.md +0 -214
  51. reverse_diagrams-1.3.3/complete_demo.cast +0 -1021
  52. reverse_diagrams-1.3.3/complete_demo.gif +0 -0
  53. reverse_diagrams-1.3.3/diagrams/code/graph_org.py +0 -86
  54. reverse_diagrams-1.3.3/diagrams/code/graph_sso.py +0 -39
  55. reverse_diagrams-1.3.3/diagrams/code/graph_sso_complete.py +0 -596
  56. reverse_diagrams-1.3.3/diagrams/code/iam_identity_center.png +0 -0
  57. reverse_diagrams-1.3.3/diagrams/code/organizations-state.png +0 -0
  58. reverse_diagrams-1.3.3/diagrams/code/organizations_complete.json +0 -133
  59. reverse_diagrams-1.3.3/diagrams/code/sso-state.png +0 -0
  60. reverse_diagrams-1.3.3/diagrams/json/account_assignments.json +0 -423
  61. reverse_diagrams-1.3.3/diagrams/json/groups.json +0 -92
  62. reverse_diagrams-1.3.3/diagrams/json/organizations.json +0 -112
  63. reverse_diagrams-1.3.3/diagrams/json/organizations_complete.json +0 -133
  64. reverse_diagrams-1.3.3/show_console_view.cast +0 -160
  65. reverse_diagrams-1.3.3/show_console_view.gif +0 -0
  66. reverse_diagrams-1.3.3/src/aws/describe_organization.py +0 -480
  67. reverse_diagrams-1.3.3/src/aws/describe_sso.py +0 -175
  68. reverse_diagrams-1.3.3/src/reports/save_results.py +0 -26
  69. reverse_diagrams-1.3.3/src/reports/tes.py +0 -366
  70. reverse_diagrams-1.3.3/src/reverse_diagrams.py +0 -135
  71. reverse_diagrams-1.3.3/test.py +0 -290
  72. reverse_diagrams-1.3.3/test2.py +0 -44
  73. reverse_diagrams-1.3.3/test3.py +0 -6
  74. reverse_diagrams-1.3.3/testdata.txt +0 -124
  75. {reverse_diagrams-1.3.3 → reverse_diagrams-1.3.5}/CHANGELOG.md +0 -0
  76. {reverse_diagrams-1.3.3 → reverse_diagrams-1.3.5}/LICENSE +0 -0
  77. {reverse_diagrams-1.3.3 → reverse_diagrams-1.3.5}/docs/images/complete_demo.gif +0 -0
  78. {reverse_diagrams-1.3.3 → reverse_diagrams-1.3.5}/docs/images/organizations-state-copy.png +0 -0
  79. {reverse_diagrams-1.3.3 → reverse_diagrams-1.3.5}/docs/images/show_console_view.gif +0 -0
  80. {reverse_diagrams-1.3.3 → reverse_diagrams-1.3.5}/src/__init__.py +0 -0
  81. {reverse_diagrams-1.3.3 → reverse_diagrams-1.3.5}/src/aws/__init__.py +0 -0
  82. {reverse_diagrams-1.3.3 → reverse_diagrams-1.3.5}/src/banner/__init__.py +0 -0
  83. {reverse_diagrams-1.3.3 → reverse_diagrams-1.3.5}/src/banner/banner.py +0 -0
  84. {reverse_diagrams-1.3.3 → reverse_diagrams-1.3.5}/src/dgms/__init__.py +0 -0
  85. {reverse_diagrams-1.3.3 → reverse_diagrams-1.3.5}/src/dgms/graph_mapper.py +0 -0
  86. {reverse_diagrams-1.3.3 → reverse_diagrams-1.3.5}/src/dgms/graph_template.py +0 -0
  87. {reverse_diagrams-1.3.3 → reverse_diagrams-1.3.5}/src/reports/__init__.py +0 -0
@@ -10,7 +10,7 @@ jobs:
10
10
  steps:
11
11
  - uses: actions/checkout@v4
12
12
  - name: Set up Python
13
- uses: actions/setup-python@v4
13
+ uses: actions/setup-python@v5
14
14
  with:
15
15
  python-version: "3.x"
16
16
  - name: Install pypa/build
@@ -22,7 +22,7 @@ jobs:
22
22
  - name: Build a binary wheel and a source tarball
23
23
  run: python3 -m build
24
24
  - name: Store the distribution packages
25
- uses: actions/upload-artifact@v3
25
+ uses: actions/upload-artifact@v4
26
26
  with:
27
27
  name: python-package-distributions
28
28
  path: dist/
@@ -42,7 +42,7 @@ jobs:
42
42
 
43
43
  steps:
44
44
  - name: Download all the dists
45
- uses: actions/download-artifact@v3
45
+ uses: actions/download-artifact@v4
46
46
  with:
47
47
  name: python-package-distributions
48
48
  path: dist/
@@ -63,12 +63,12 @@ jobs:
63
63
 
64
64
  steps:
65
65
  - name: Download all the dists
66
- uses: actions/download-artifact@v3
66
+ uses: actions/download-artifact@v4
67
67
  with:
68
68
  name: python-package-distributions
69
69
  path: dist/
70
70
  - name: Sign the dists with Sigstore
71
- uses: sigstore/gh-action-sigstore-python@v1.2.3
71
+ uses: sigstore/gh-action-sigstore-python@v2.1.1
72
72
  with:
73
73
  inputs: >-
74
74
  ./dist/*.tar.gz
@@ -107,7 +107,7 @@ jobs:
107
107
 
108
108
  steps:
109
109
  - name: Download all the dists
110
- uses: actions/download-artifact@v3
110
+ uses: actions/download-artifact@v4
111
111
  with:
112
112
  name: python-package-distributions
113
113
  path: dist/
@@ -252,3 +252,32 @@ cython_debug/
252
252
  #.idea/
253
253
 
254
254
  # End of https://www.toptal.com/developers/gitignore/api/python,pycharm+all
255
+
256
+ # Project-specific ignores
257
+ # Test files
258
+ test.py
259
+ test2.py
260
+ test3.py
261
+ testdata.txt
262
+
263
+ # Generated diagrams folder (exclude entire folder)
264
+ diagrams/
265
+
266
+ # Terminal history files
267
+ *terminal*history*
268
+ CUserswalejAppDataLocalJetBrainsPyCharm*
269
+
270
+ # Cast files (asciinema recordings)
271
+ *.cast
272
+
273
+ # Temporary summary files (keep only essential docs)
274
+ README_UPDATE_SUMMARY.md
275
+ LOG_LEVEL_CHANGES_SUMMARY.md
276
+ IMPLEMENTATION_STATUS_UPDATE.md
277
+ FINAL_STATUS_SUMMARY.md
278
+
279
+ # Temporary files
280
+ *.tmp
281
+ *.bak
282
+ *.swp
283
+ *~
@@ -0,0 +1,258 @@
1
+ # Design Document: Tag-Based Filtering
2
+
3
+ ## Overview
4
+
5
+ The tag-based filtering feature extends Reverse Diagrams with the capability to filter AWS resources based on their tags, enabling users to create focused architecture diagrams. This feature integrates seamlessly with the existing plugin architecture and provides flexible filtering options for different use cases.
6
+
7
+ ## Architecture
8
+
9
+ ### High-Level Architecture
10
+
11
+ ```mermaid
12
+ graph TB
13
+ CLI[CLI Interface] --> FilterParser[Tag Filter Parser]
14
+ FilterParser --> FilterEngine[Tag Filter Engine]
15
+ FilterEngine --> PluginManager[Plugin Manager]
16
+ PluginManager --> Plugin1[Organizations Plugin]
17
+ PluginManager --> Plugin2[EC2 Plugin]
18
+ PluginManager --> Plugin3[Identity Center Plugin]
19
+
20
+ FilterEngine --> PresetManager[Preset Manager]
21
+ PresetManager --> ConfigStore[Configuration Storage]
22
+
23
+ Plugin1 --> AWSOrg[AWS Organizations API]
24
+ Plugin2 --> AWSEC2[AWS EC2 API]
25
+ Plugin3 --> AWSSSO[AWS SSO API]
26
+
27
+ FilterEngine --> DiagramGenerator[Diagram Generator]
28
+ DiagramGenerator --> Output[Filtered Diagrams]
29
+ ```
30
+
31
+ ### Component Interaction Flow
32
+
33
+ 1. **CLI Parsing**: User provides tag filter options via command line
34
+ 2. **Filter Parsing**: Tag filter parser validates and structures filter criteria
35
+ 3. **Filter Engine**: Coordinates filtering across all plugins
36
+ 4. **Plugin Integration**: Each plugin applies filters during data collection
37
+ 5. **Relationship Preservation**: Maintains resource relationships after filtering
38
+ 6. **Diagram Generation**: Creates diagrams with only filtered resources
39
+
40
+ ## Components and Interfaces
41
+
42
+ ### 1. Tag Filter Engine (`src/filters/tag_filter_engine.py`)
43
+
44
+ **Purpose**: Central coordinator for all tag filtering operations
45
+
46
+ **Key Methods**:
47
+ - `apply_filters(resources, filters)`: Apply tag filters to resource collections
48
+ - `validate_filters(filters)`: Validate filter syntax and logic
49
+ - `combine_filters(include_filters, exclude_filters, logic)`: Combine multiple filters
50
+ - `preserve_relationships(filtered_resources)`: Maintain resource relationships
51
+
52
+ **Interface**:
53
+ ```python
54
+ class TagFilterEngine:
55
+ def apply_filters(self, resources: List[Dict], filters: TagFilterSet) -> List[Dict]
56
+ def validate_filters(self, filters: TagFilterSet) -> ValidationResult
57
+ def combine_filters(self, include: List[TagFilter], exclude: List[TagFilter], logic: str) -> TagFilterSet
58
+ def preserve_relationships(self, resources: List[Dict]) -> List[Dict]
59
+ ```
60
+
61
+ ### 2. Tag Filter Parser (`src/filters/tag_filter_parser.py`)
62
+
63
+ **Purpose**: Parse and validate CLI tag filter arguments
64
+
65
+ **Key Methods**:
66
+ - `parse_cli_args(args)`: Parse CLI arguments into structured filters
67
+ - `parse_tag_expression(expression)`: Parse individual tag expressions
68
+ - `validate_syntax(expression)`: Validate tag filter syntax
69
+
70
+ **Interface**:
71
+ ```python
72
+ class TagFilterParser:
73
+ def parse_cli_args(self, args: argparse.Namespace) -> TagFilterSet
74
+ def parse_tag_expression(self, expression: str) -> TagFilter
75
+ def validate_syntax(self, expression: str) -> bool
76
+ ```
77
+
78
+ ### 3. Plugin Filter Interface (`src/plugins/base.py` extension)
79
+
80
+ **Purpose**: Standardized interface for plugins to support tag filtering
81
+
82
+ **Extended Methods**:
83
+ - `supports_tag_filtering()`: Declare tag filtering capability
84
+ - `apply_tag_filters(filters)`: Apply filters during data collection
85
+ - `get_resource_tags(resource)`: Extract tags from AWS resources
86
+
87
+ **Interface Extension**:
88
+ ```python
89
+ class AWSServicePlugin:
90
+ def supports_tag_filtering(self) -> bool
91
+ def apply_tag_filters(self, filters: TagFilterSet) -> None
92
+ def get_resource_tags(self, resource: Dict) -> Dict[str, str]
93
+ def filter_resources_by_tags(self, resources: List[Dict], filters: TagFilterSet) -> List[Dict]
94
+ ```
95
+
96
+ ### 4. Preset Manager (`src/filters/preset_manager.py`)
97
+
98
+ **Purpose**: Manage saved tag filter configurations
99
+
100
+ **Key Methods**:
101
+ - `save_preset(name, filters)`: Save filter configuration as preset
102
+ - `load_preset(name)`: Load saved filter configuration
103
+ - `list_presets()`: List available presets
104
+ - `delete_preset(name)`: Remove saved preset
105
+
106
+ **Interface**:
107
+ ```python
108
+ class PresetManager:
109
+ def save_preset(self, name: str, filters: TagFilterSet) -> bool
110
+ def load_preset(self, name: str) -> TagFilterSet
111
+ def list_presets(self) -> List[str]
112
+ def delete_preset(self, name: str) -> bool
113
+ ```
114
+
115
+ ## Data Models
116
+
117
+ ### TagFilter
118
+ ```python
119
+ @dataclass
120
+ class TagFilter:
121
+ key: str
122
+ value: Optional[str] = None # None for key-only filters
123
+ operator: str = "equals" # equals, exists, not_equals, not_exists
124
+
125
+ def matches(self, resource_tags: Dict[str, str]) -> bool:
126
+ """Check if this filter matches the given resource tags"""
127
+ ```
128
+
129
+ ### TagFilterSet
130
+ ```python
131
+ @dataclass
132
+ class TagFilterSet:
133
+ include_filters: List[TagFilter]
134
+ exclude_filters: List[TagFilter]
135
+ logic: str = "AND" # AND, OR
136
+ service_specific: Dict[str, List[TagFilter]] = field(default_factory=dict)
137
+
138
+ def apply_to_resource(self, resource: Dict, service: str) -> bool:
139
+ """Determine if resource should be included based on filters"""
140
+ ```
141
+
142
+ ### FilterResult
143
+ ```python
144
+ @dataclass
145
+ class FilterResult:
146
+ included_resources: List[Dict]
147
+ excluded_resources: List[Dict]
148
+ filter_stats: Dict[str, int]
149
+ warnings: List[str]
150
+ ```
151
+
152
+ ## Correctness Properties
153
+
154
+ *A property is a characteristic or behavior that should hold true across all valid executions of a system-essentially, a formal statement about what the system should do. Properties serve as the bridge between human-readable specifications and machine-verifiable correctness guarantees.*
155
+
156
+ ### Property Reflection
157
+
158
+ After reviewing all properties identified in the prework, several can be combined or consolidated:
159
+ - Properties 2.2 and 2.3 (AND/OR logic) can be combined into a single comprehensive logical operations property
160
+ - Properties 3.1, 3.3, and 4.1 (service-specific filtering) can be combined into a service isolation property
161
+ - Properties 5.2-5.7 (CLI parsing) can be combined into a comprehensive CLI parsing property
162
+ - Properties 8.1-8.4 (preset management) can be combined into a preset operations property
163
+
164
+ ### Core Filtering Properties
165
+
166
+ **Property 1: Tag Filter Matching**
167
+ *For any* AWS resource with tags and any tag filter, the filter matching logic should correctly identify whether the resource matches the filter criteria based on key-value or key-only matching rules
168
+ **Validates: Requirements 1.1, 1.2, 1.3**
169
+
170
+ **Property 2: Logical Operations Consistency**
171
+ *For any* set of tag filters with AND or OR logic, the filtering system should include resources that match all filters (AND) or any filter (OR) consistently across all resource types
172
+ **Validates: Requirements 2.1, 2.2, 2.3**
173
+
174
+ **Property 3: Include-Exclude Filter Precedence**
175
+ *For any* combination of include and exclude filters, the system should first apply include filters then remove resources matching exclude filters, ensuring correct precedence
176
+ **Validates: Requirements 2.4**
177
+
178
+ **Property 4: Service Isolation in Filtering**
179
+ *For any* service-specific tag filter, only the specified services should have filters applied while other services include all their resources
180
+ **Validates: Requirements 3.1, 3.3, 4.1**
181
+
182
+ **Property 5: Relationship Preservation**
183
+ *For any* set of filtered resources, all relationships between the remaining resources should be preserved in the final diagram
184
+ **Validates: Requirements 1.5, 4.4**
185
+
186
+ **Property 6: Filter Validation**
187
+ *For any* tag filter input, the validation system should correctly identify valid and invalid filter syntax and provide appropriate error messages
188
+ **Validates: Requirements 2.5, 6.1, 6.4**
189
+
190
+ **Property 7: CLI Argument Parsing**
191
+ *For any* valid CLI tag filter arguments, the parser should correctly extract and structure the filter criteria into the appropriate data models
192
+ **Validates: Requirements 5.2, 5.3, 5.4, 5.5, 5.6, 5.7**
193
+
194
+ **Property 8: Performance Optimization**
195
+ *For any* tag filtering operation, filters should be applied during data collection phase to minimize API calls and processing overhead
196
+ **Validates: Requirements 7.1, 7.2, 7.3**
197
+
198
+ **Property 9: Preset Operations**
199
+ *For any* preset save/load operation, the configuration should be stored and retrieved correctly with all filter settings preserved
200
+ **Validates: Requirements 8.1, 8.2, 8.3, 8.4, 8.5**
201
+
202
+ **Property 10: Plugin Interface Consistency**
203
+ *For any* plugin that supports tag filtering, the filtering behavior should be consistent with the standardized interface across all plugins
204
+ **Validates: Requirements 10.1, 10.2, 10.3, 10.4, 10.5**
205
+
206
+ **Property 11: Empty Result Handling**
207
+ *For any* tag filter that matches no resources, the system should generate appropriate warnings and empty diagrams without errors
208
+ **Validates: Requirements 1.4, 6.2**
209
+
210
+ **Property 12: Graceful Service Degradation**
211
+ *For any* service that doesn't support tags, the filtering system should include all resources from that service and provide appropriate user feedback
212
+ **Validates: Requirements 3.5, 6.3**
213
+
214
+ ## Error Handling
215
+
216
+ ### Filter Validation Errors
217
+ - **Invalid Syntax**: Clear error messages with examples of correct syntax
218
+ - **Conflicting Options**: Guidance on resolving conflicting filter combinations
219
+ - **Missing Required Parameters**: Specific information about required filter components
220
+
221
+ ### Runtime Errors
222
+ - **No Matching Resources**: Warning messages with applied filter details
223
+ - **Broken Relationships**: Warnings about orphaned resources in diagrams
224
+ - **Service Limitations**: Informational messages about services that don't support tags
225
+
226
+ ### Performance Considerations
227
+ - **Large Resource Sets**: Progress indicators for long-running filter operations
228
+ - **API Rate Limits**: Graceful handling of AWS API throttling during filtered data collection
229
+ - **Memory Usage**: Efficient filtering algorithms for large resource collections
230
+
231
+ ## Testing Strategy
232
+
233
+ ### Unit Tests
234
+ - Tag filter parsing and validation
235
+ - Individual filter matching logic
236
+ - CLI argument processing
237
+ - Preset save/load operations
238
+ - Error handling scenarios
239
+
240
+ ### Property-Based Tests
241
+ - **Filter Matching Consistency**: Test filter matching across various resource and tag combinations (minimum 100 iterations)
242
+ - **Logical Operations**: Verify AND/OR logic works correctly with random filter sets (minimum 100 iterations)
243
+ - **Relationship Preservation**: Ensure filtered resources maintain correct relationships (minimum 100 iterations)
244
+ - **CLI Parsing**: Test CLI argument parsing with various input combinations (minimum 100 iterations)
245
+
246
+ Each property test will be tagged with: **Feature: tag-based-filtering, Property {number}: {property_text}**
247
+
248
+ ### Integration Tests
249
+ - End-to-end filtering with real AWS resource data
250
+ - Multi-service filtering scenarios
251
+ - Plugin integration with filtering capabilities
252
+ - Performance testing with large resource sets
253
+
254
+ ### Edge Case Tests
255
+ - Empty filter results
256
+ - Services without tag support
257
+ - Complex filter combinations
258
+ - Invalid filter syntax handling
@@ -0,0 +1,139 @@
1
+ # Requirements Document
2
+
3
+ ## Introduction
4
+
5
+ This specification defines tag-based filtering functionality for Reverse Diagrams, enabling users to create focused architecture diagrams by filtering AWS resources based on their tags. This feature addresses the need to generate diagrams for specific environments, applications, or organizational units without the noise of unrelated resources.
6
+
7
+ ## Glossary
8
+
9
+ - **Tag_Filter**: A key-value pair or key-only filter used to match AWS resource tags
10
+ - **Resource_Filter**: A filtering mechanism that includes or excludes AWS resources based on tag criteria
11
+ - **Diagram_Scope**: The subset of AWS resources included in a generated diagram after applying filters
12
+ - **Tag_Strategy**: The approach used for filtering (include-only, exclude, or mixed filtering)
13
+ - **Plugin_Filter**: A filter applied at the plugin level to control which resources are collected and processed
14
+ - **Account_Filter**: A filter that applies tag-based filtering across all AWS services within an account
15
+ - **Service_Filter**: A filter that applies tag-based filtering to specific AWS services (e.g., EC2 only)
16
+
17
+ ## Requirements
18
+
19
+ ### Requirement 1: Basic Tag Filtering
20
+
21
+ **User Story:** As a DevOps engineer, I want to filter AWS resources by tags, so that I can create diagrams showing only resources relevant to specific environments or applications.
22
+
23
+ #### Acceptance Criteria
24
+
25
+ 1. WHEN a user specifies tag filters via CLI, THE System SHALL collect only resources matching those tag criteria
26
+ 2. WHEN a user provides key-value tag filters (e.g., Environment=Production), THE System SHALL match resources with exact key-value pairs
27
+ 3. WHEN a user provides key-only tag filters (e.g., Environment), THE System SHALL match resources that have the specified tag key regardless of value
28
+ 4. WHEN no resources match the specified tag filters, THE System SHALL generate an empty diagram with appropriate messaging
29
+ 5. WHEN tag filters are applied, THE System SHALL preserve all relationships between filtered resources
30
+
31
+ ### Requirement 2: Multiple Tag Filter Support
32
+
33
+ **User Story:** As a cloud architect, I want to apply multiple tag filters simultaneously, so that I can create highly specific diagrams for complex filtering scenarios.
34
+
35
+ #### Acceptance Criteria
36
+
37
+ 1. WHEN a user specifies multiple tag filters, THE System SHALL support both AND and OR logical operations
38
+ 2. WHEN using AND logic (default), THE System SHALL include only resources matching ALL specified tag filters
39
+ 3. WHEN using OR logic, THE System SHALL include resources matching ANY of the specified tag filters
40
+ 4. WHEN combining include and exclude filters, THE System SHALL first apply include filters then remove resources matching exclude filters
41
+ 5. WHEN tag filter logic is specified, THE System SHALL validate the logical operators and provide clear error messages for invalid combinations
42
+
43
+ ### Requirement 3: Service-Specific Tag Filtering
44
+
45
+ **User Story:** As a system administrator, I want to apply tag filters to specific AWS services, so that I can create focused diagrams for particular service types while including all resources from other services.
46
+
47
+ #### Acceptance Criteria
48
+
49
+ 1. WHEN a user specifies service-specific tag filters, THE System SHALL apply filters only to the specified AWS services
50
+ 2. WHEN using the EC2 plugin with tag filters, THE System SHALL filter EC2 instances, VPCs, subnets, and security groups based on their respective tags
51
+ 3. WHEN using service-specific filters, THE System SHALL include all resources from non-filtered services in the diagram
52
+ 4. WHEN service-specific filters are combined with global filters, THE System SHALL apply both filter sets appropriately
53
+ 5. WHEN a service doesn't support tags, THE System SHALL ignore tag filters for that service and include all resources
54
+
55
+ ### Requirement 4: Account-Wide Tag Filtering
56
+
57
+ **User Story:** As an enterprise architect, I want to apply tag filters across all AWS services in an account, so that I can create comprehensive diagrams filtered by organizational or project criteria.
58
+
59
+ #### Acceptance Criteria
60
+
61
+ 1. WHEN a user specifies account-wide tag filters, THE System SHALL apply the same filter criteria to all supported AWS services
62
+ 2. WHEN using Organizations plugin with tag filters, THE System SHALL filter accounts based on account-level tags
63
+ 3. WHEN using Identity Center plugin with tag filters, THE System SHALL filter permission sets and assignments based on their tags where applicable
64
+ 4. WHEN account-wide filters are applied, THE System SHALL maintain service relationships even when some services have no matching resources
65
+ 5. WHEN combining account-wide and service-specific filters, THE System SHALL apply the most restrictive filter for each service
66
+
67
+ ### Requirement 5: CLI Tag Filter Interface
68
+
69
+ **User Story:** As a user, I want intuitive CLI options for specifying tag filters, so that I can easily create filtered diagrams without complex syntax.
70
+
71
+ #### Acceptance Criteria
72
+
73
+ 1. WHEN a user wants to specify tag filters, THE System SHALL provide clear CLI options for tag filtering
74
+ 2. WHEN using key-value filters, THE System SHALL accept format like `--tag Environment=Production`
75
+ 3. WHEN using key-only filters, THE System SHALL accept format like `--tag-key Environment`
76
+ 4. WHEN specifying multiple filters, THE System SHALL allow multiple `--tag` and `--tag-key` options
77
+ 5. WHEN specifying logical operations, THE System SHALL provide `--tag-logic` option with values `AND` or `OR`
78
+ 6. WHEN specifying exclude filters, THE System SHALL provide `--exclude-tag` and `--exclude-tag-key` options
79
+ 7. WHEN using service-specific filters, THE System SHALL provide `--service-tag` option with service name and tag criteria
80
+
81
+ ### Requirement 6: Tag Filter Validation and Error Handling
82
+
83
+ **User Story:** As a user, I want clear feedback when my tag filters are invalid or produce no results, so that I can correct my filtering criteria.
84
+
85
+ #### Acceptance Criteria
86
+
87
+ 1. WHEN tag filter syntax is invalid, THE System SHALL provide clear error messages with examples of correct syntax
88
+ 2. WHEN tag filters produce no matching resources, THE System SHALL display a warning message listing the applied filters
89
+ 3. WHEN tag filters are applied but some services don't support tags, THE System SHALL log informational messages about which services were not filtered
90
+ 4. WHEN conflicting filter options are specified, THE System SHALL validate the combination and provide guidance on resolution
91
+ 5. WHEN tag filters result in broken relationships, THE System SHALL warn about orphaned resources in the diagram
92
+
93
+ ### Requirement 7: Tag Filter Performance and Optimization
94
+
95
+ **User Story:** As a user working with large AWS environments, I want tag filtering to be performant, so that I can generate filtered diagrams efficiently even with thousands of resources.
96
+
97
+ #### Acceptance Criteria
98
+
99
+ 1. WHEN tag filters are specified, THE System SHALL apply filters during data collection to minimize API calls
100
+ 2. WHEN using pagination with tag filters, THE System SHALL leverage AWS API filtering capabilities where available
101
+ 3. WHEN tag filters are applied, THE System SHALL cache tag information to avoid redundant API calls
102
+ 4. WHEN processing large resource sets, THE System SHALL provide progress indicators for tag filtering operations
103
+ 5. WHEN tag filtering is complete, THE System SHALL report the number of resources filtered and included
104
+
105
+ ### Requirement 8: Tag Filter Configuration and Presets
106
+
107
+ **User Story:** As a team lead, I want to save and reuse common tag filter configurations, so that my team can consistently generate diagrams with standardized filtering criteria.
108
+
109
+ #### Acceptance Criteria
110
+
111
+ 1. WHEN a user wants to save tag filter configurations, THE System SHALL provide options to save filter presets
112
+ 2. WHEN using saved presets, THE System SHALL allow loading predefined tag filter combinations by name
113
+ 3. WHEN managing presets, THE System SHALL provide options to list, create, update, and delete saved configurations
114
+ 4. WHEN presets are used, THE System SHALL allow overriding specific filters while maintaining the preset base
115
+ 5. WHEN sharing presets, THE System SHALL store configurations in a format that can be version controlled and shared across teams
116
+
117
+ ### Requirement 9: Tag Filter Documentation and Examples
118
+
119
+ **User Story:** As a new user, I want comprehensive documentation and examples for tag filtering, so that I can quickly learn how to create filtered diagrams for my use cases.
120
+
121
+ #### Acceptance Criteria
122
+
123
+ 1. WHEN a user requests help for tag filtering, THE System SHALL provide comprehensive CLI help with examples
124
+ 2. WHEN documentation is accessed, THE System SHALL include common use case examples for different filtering scenarios
125
+ 3. WHEN examples are provided, THE System SHALL cover single service filtering, multi-service filtering, and account-wide filtering
126
+ 4. WHEN advanced features are documented, THE System SHALL explain logical operators, exclude filters, and preset management
127
+ 5. WHEN troubleshooting information is needed, THE System SHALL provide guidance for common filtering issues and solutions
128
+
129
+ ### Requirement 10: Integration with Existing Plugin Architecture
130
+
131
+ **User Story:** As a developer, I want tag filtering to integrate seamlessly with the existing plugin architecture, so that all current and future plugins can benefit from filtering capabilities.
132
+
133
+ #### Acceptance Criteria
134
+
135
+ 1. WHEN plugins collect data, THE System SHALL provide a standardized interface for applying tag filters
136
+ 2. WHEN new plugins are developed, THE System SHALL allow plugins to declare their tag filtering capabilities
137
+ 3. WHEN tag filters are applied, THE System SHALL ensure consistent behavior across all plugins
138
+ 4. WHEN plugins don't support tag filtering, THE System SHALL gracefully handle the limitation and inform users
139
+ 5. WHEN plugin-specific tag filtering is needed, THE System SHALL provide extension points for custom filtering logic
@@ -0,0 +1,191 @@
1
+ # Implementation Plan: Tag-Based Filtering
2
+
3
+ ## Overview
4
+
5
+ This implementation plan breaks down the tag-based filtering feature into discrete coding tasks that build incrementally. Each task focuses on specific functionality while ensuring integration with the existing plugin architecture.
6
+
7
+ ## Tasks
8
+
9
+ - [ ] 1. Create core tag filtering data models and utilities
10
+ - Create `TagFilter`, `TagFilterSet`, and `FilterResult` data classes
11
+ - Implement tag matching logic for key-value and key-only filters
12
+ - Add validation methods for filter syntax and combinations
13
+ - _Requirements: 1.1, 1.2, 1.3, 2.5_
14
+
15
+ - [ ] 1.1 Write property test for tag filter matching
16
+ - **Property 1: Tag Filter Matching**
17
+ - **Validates: Requirements 1.1, 1.2, 1.3**
18
+
19
+ - [ ] 2. Implement Tag Filter Parser for CLI integration
20
+ - Create `TagFilterParser` class to parse CLI arguments
21
+ - Support `--tag`, `--tag-key`, `--exclude-tag`, `--exclude-tag-key` options
22
+ - Add `--tag-logic` option for AND/OR operations
23
+ - Add `--service-tag` option for service-specific filtering
24
+ - _Requirements: 5.1, 5.2, 5.3, 5.4, 5.5, 5.6, 5.7_
25
+
26
+ - [ ] 2.1 Write property test for CLI argument parsing
27
+ - **Property 7: CLI Argument Parsing**
28
+ - **Validates: Requirements 5.2, 5.3, 5.4, 5.5, 5.6, 5.7**
29
+
30
+ - [ ] 3. Create Tag Filter Engine as central coordinator
31
+ - Implement `TagFilterEngine` class with core filtering logic
32
+ - Add methods for applying filters to resource collections
33
+ - Implement logical operations (AND/OR) for multiple filters
34
+ - Add include/exclude filter precedence handling
35
+ - _Requirements: 2.1, 2.2, 2.3, 2.4_
36
+
37
+ - [ ] 3.1 Write property test for logical operations consistency
38
+ - **Property 2: Logical Operations Consistency**
39
+ - **Validates: Requirements 2.1, 2.2, 2.3**
40
+
41
+ - [ ] 3.2 Write property test for include-exclude filter precedence
42
+ - **Property 3: Include-Exclude Filter Precedence**
43
+ - **Validates: Requirements 2.4**
44
+
45
+ - [ ] 4. Extend plugin base class with tag filtering interface
46
+ - Add `supports_tag_filtering()` method to `AWSServicePlugin`
47
+ - Add `apply_tag_filters()` method for filter application
48
+ - Add `get_resource_tags()` method for tag extraction
49
+ - Add `filter_resources_by_tags()` method for resource filtering
50
+ - _Requirements: 10.1, 10.2_
51
+
52
+ - [ ] 4.1 Write property test for plugin interface consistency
53
+ - **Property 10: Plugin Interface Consistency**
54
+ - **Validates: Requirements 10.1, 10.2, 10.3, 10.4, 10.5**
55
+
56
+ - [ ] 5. Implement tag filtering in EC2 plugin
57
+ - Add tag filtering support to EC2Plugin class
58
+ - Filter EC2 instances, VPCs, subnets, and security groups by tags
59
+ - Implement service-specific filtering logic
60
+ - Preserve relationships between filtered EC2 resources
61
+ - _Requirements: 3.2, 3.4_
62
+
63
+ - [ ] 5.1 Write property test for service isolation in filtering
64
+ - **Property 4: Service Isolation in Filtering**
65
+ - **Validates: Requirements 3.1, 3.3, 4.1**
66
+
67
+ - [ ] 5.2 Write property test for relationship preservation
68
+ - **Property 5: Relationship Preservation**
69
+ - **Validates: Requirements 1.5, 4.4**
70
+
71
+ - [ ] 6. Implement tag filtering in Organizations plugin
72
+ - Add tag filtering support to OrganizationsPlugin class
73
+ - Filter accounts based on account-level tags
74
+ - Handle organizational units with tag-based account filtering
75
+ - Maintain organization hierarchy after filtering
76
+ - _Requirements: 4.2_
77
+
78
+ - [ ] 7. Implement tag filtering in Identity Center plugin
79
+ - Add tag filtering support to IdentityCenterPlugin class
80
+ - Filter permission sets and assignments based on tags where applicable
81
+ - Handle cases where Identity Center resources may not have tags
82
+ - _Requirements: 4.3_
83
+
84
+ - [ ] 7.1 Write property test for graceful service degradation
85
+ - **Property 12: Graceful Service Degradation**
86
+ - **Validates: Requirements 3.5, 6.3**
87
+
88
+ - [ ] 8. Create Preset Manager for saved configurations
89
+ - Implement `PresetManager` class for filter configuration management
90
+ - Add methods to save, load, list, and delete filter presets
91
+ - Store presets in JSON format for version control compatibility
92
+ - Support preset overrides while maintaining base configuration
93
+ - _Requirements: 8.1, 8.2, 8.3, 8.4, 8.5_
94
+
95
+ - [ ] 8.1 Write property test for preset operations
96
+ - **Property 9: Preset Operations**
97
+ - **Validates: Requirements 8.1, 8.2, 8.3, 8.4, 8.5**
98
+
99
+ - [ ] 9. Integrate tag filtering with CLI interface
100
+ - Update `reverse_diagrams.py` to support tag filtering arguments
101
+ - Add argument parsing for all tag filter options
102
+ - Integrate TagFilterEngine with plugin execution
103
+ - Add validation and error handling for filter arguments
104
+ - _Requirements: 5.1, 6.1, 6.4_
105
+
106
+ - [ ] 9.1 Write property test for filter validation
107
+ - **Property 6: Filter Validation**
108
+ - **Validates: Requirements 2.5, 6.1, 6.4**
109
+
110
+ - [ ] 10. Implement performance optimizations
111
+ - Apply filters during data collection phase to minimize API calls
112
+ - Leverage AWS API filtering capabilities where available
113
+ - Add caching for tag information to avoid redundant calls
114
+ - Implement progress tracking for long-running filter operations
115
+ - _Requirements: 7.1, 7.2, 7.3, 7.4_
116
+
117
+ - [ ] 10.1 Write property test for performance optimization
118
+ - **Property 8: Performance Optimization**
119
+ - **Validates: Requirements 7.1, 7.2, 7.3**
120
+
121
+ - [ ] 11. Add comprehensive error handling and user feedback
122
+ - Implement validation for conflicting filter options
123
+ - Add warnings for empty filter results with applied filter details
124
+ - Add informational messages for services that don't support tags
125
+ - Add warnings for broken relationships in filtered diagrams
126
+ - _Requirements: 6.1, 6.2, 6.3, 6.4, 6.5_
127
+
128
+ - [ ] 11.1 Write property test for empty result handling
129
+ - **Property 11: Empty Result Handling**
130
+ - **Validates: Requirements 1.4, 6.2**
131
+
132
+ - [ ] 12. Create comprehensive documentation and help
133
+ - Add CLI help text with examples for all tag filtering options
134
+ - Create documentation covering common use cases and scenarios
135
+ - Add troubleshooting guide for common filtering issues
136
+ - Include examples for single service, multi-service, and account-wide filtering
137
+ - _Requirements: 9.1, 9.2, 9.3, 9.4, 9.5_
138
+
139
+ - [ ] 13. Checkpoint - Ensure all tests pass
140
+ - Ensure all tests pass, ask the user if questions arise.
141
+
142
+ - [ ] 14. Integration testing and final validation
143
+ - Test end-to-end filtering scenarios with multiple services
144
+ - Validate performance with large resource sets
145
+ - Test preset management functionality
146
+ - Verify backward compatibility with existing functionality
147
+ - _Requirements: All requirements validation_
148
+
149
+ - [ ] 14.1 Write integration tests for multi-service filtering
150
+ - Test filtering across Organizations, EC2, and Identity Center plugins
151
+ - Verify consistent behavior and relationship preservation
152
+
153
+ - [ ] 15. Final checkpoint - Ensure all tests pass
154
+ - Ensure all tests pass, ask the user if questions arise.
155
+
156
+ ## Notes
157
+
158
+ - All tasks are required for comprehensive implementation from the start
159
+ - Each task references specific requirements for traceability
160
+ - Checkpoints ensure incremental validation
161
+ - Property tests validate universal correctness properties with minimum 100 iterations
162
+ - Unit tests validate specific examples and edge cases
163
+ - Integration tests ensure end-to-end functionality
164
+ - The implementation builds incrementally from core models to full integration
165
+
166
+ ## CLI Usage Examples
167
+
168
+ After implementation, users will be able to use tag filtering like this:
169
+
170
+ ```bash
171
+ # Filter EC2 resources by environment tag
172
+ reverse_diagrams --plugin ec2 --tag Environment=Production -r us-east-1
173
+
174
+ # Filter all services by multiple tags with AND logic
175
+ reverse_diagrams -o -i --tag Environment=Production --tag Team=DevOps -r us-east-1
176
+
177
+ # Filter with OR logic
178
+ reverse_diagrams --plugin ec2 --tag Environment=Production --tag Environment=Staging --tag-logic OR -r us-east-1
179
+
180
+ # Service-specific filtering
181
+ reverse_diagrams -o -i --service-tag ec2 Environment=Production -r us-east-1
182
+
183
+ # Exclude specific tags
184
+ reverse_diagrams --plugin ec2 --tag Environment=Production --exclude-tag Status=Deprecated -r us-east-1
185
+
186
+ # Use saved presets
187
+ reverse_diagrams --preset production-env -r us-east-1
188
+
189
+ # Key-only filtering
190
+ reverse_diagrams --plugin ec2 --tag-key CostCenter -r us-east-1
191
+ ```