arnmatch 2026.2.0__py3-none-any.whl → 2026.2.1__py3-none-any.whl

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.
arnmatch/__init__.py CHANGED
@@ -1,6 +1,6 @@
1
1
  """ARN pattern matching using regex patterns."""
2
2
 
3
- __version__ = "2026.02.0"
3
+ __version__ = "2026.2.1"
4
4
 
5
5
  import sys
6
6
  from dataclasses import dataclass
@@ -0,0 +1,134 @@
1
+ Metadata-Version: 2.4
2
+ Name: arnmatch
3
+ Version: 2026.2.1
4
+ Summary: Parse AWS ARNs into structured data (2000+ resource types)
5
+ Author-email: Andrey Gubarev <andrey@andreygubarev.com>
6
+ License-Expression: Apache-2.0
7
+ License-File: LICENSE
8
+ Requires-Python: >=3.10
9
+ Description-Content-Type: text/markdown
10
+
11
+ # arnmatch
12
+
13
+ Parse AWS ARNs into structured data.
14
+
15
+ ![Python 3.10+](https://img.shields.io/badge/python-3.10%2B-blue)
16
+ [![PyPI](https://img.shields.io/pypi/v/arnmatch)](https://pypi.org/project/arnmatch/)
17
+
18
+ ## Overview
19
+
20
+ Working with AWS at scale raises questions that are surprisingly hard to answer:
21
+
22
+ 1. **What resource does this ARN represent?** - ARN formats vary across services with no consistent parsing rules
23
+ 2. **What ARN formats exist?** - No single source documents all valid ARN patterns
24
+ 3. **What resource types exist on AWS?** - Scattered across 300+ service documentation pages
25
+ 4. **What CloudFormation type maps to this ARN?** - No direct ARN-to-CFN mapping exists
26
+
27
+ arnmatch answers these questions by:
28
+ - Parsing ARNs into structured components (service, region, account, resource type, resource ID)
29
+ - Providing a complete index of 2000+ resource types from 300+ AWS services
30
+ - Mapping ARNs to CloudFormation resource types (e.g., `arn:aws:lambda:...:function:X` → `AWS::Lambda::Function`)
31
+
32
+ Patterns are auto-generated from [AWS Service Authorization Reference](https://docs.aws.amazon.com/service-authorization/latest/reference/).
33
+
34
+ ## Features
35
+
36
+ - Zero runtime dependencies
37
+ - 300+ AWS services, 2000+ resource types
38
+ - Patterns auto-generated from AWS official documentation
39
+ - CLI and library interface
40
+ - CloudFormation resource type mapping
41
+ - Boto3 SDK service name mapping
42
+
43
+ ## Installation
44
+
45
+ ```bash
46
+ pip install arnmatch
47
+ ```
48
+
49
+ ## Quick Start
50
+
51
+ ### CLI
52
+
53
+ ```bash
54
+ $ arnmatch "arn:aws:lambda:us-east-1:123456789012:function:my-function"
55
+ aws_service: lambda
56
+ aws_sdk_service: lambda
57
+ aws_sdk_services: lambda
58
+ aws_region: us-east-1
59
+ aws_account: 123456789012
60
+ resource_type: function
61
+ resource_id: my-function
62
+ resource_name: my-function
63
+ cloudformation_resource: AWS::Lambda::Function
64
+ ```
65
+
66
+ ### Library
67
+
68
+ ```python
69
+ from arnmatch import arnmatch
70
+
71
+ result = arnmatch("arn:aws:lambda:us-east-1:123456789012:function:my-function")
72
+
73
+ result.aws_service # "lambda"
74
+ result.aws_region # "us-east-1"
75
+ result.aws_account # "123456789012"
76
+ result.resource_type # "function"
77
+ result.resource_id # "my-function"
78
+ result.resource_name # "my-function"
79
+ result.cloudformation_resource # "AWS::Lambda::Function"
80
+ result.aws_sdk_service # "lambda"
81
+ ```
82
+
83
+ ## API Reference
84
+
85
+ ### `arnmatch(arn: str) -> ARN`
86
+
87
+ Parse an ARN string and return structured data.
88
+
89
+ Raises `ARNError` if the ARN format is invalid or no pattern matches.
90
+
91
+ ### `ARN`
92
+
93
+ Dataclass with parsed ARN components:
94
+
95
+ | Field | Type | Description |
96
+ |-------|------|-------------|
97
+ | `aws_partition` | `str` | AWS partition (aws, aws-cn, aws-us-gov) |
98
+ | `aws_service` | `str` | AWS service name |
99
+ | `aws_region` | `str` | AWS region (may be empty for global resources) |
100
+ | `aws_account` | `str` | AWS account ID |
101
+ | `resource_type` | `str` | Canonical resource type from AWS docs |
102
+ | `resource_types` | `list[str]` | All known names for this resource type |
103
+ | `attributes` | `dict[str, str]` | All captured attributes from the ARN |
104
+ | `aws_sdk_service` | `str \| None` | Primary boto3 client name |
105
+ | `cloudformation_resource` | `str \| None` | CloudFormation resource type |
106
+
107
+ Properties:
108
+
109
+ | Property | Description |
110
+ |----------|-------------|
111
+ | `resource_id` | Resource identifier (prefers attributes ending in `Id`, then `Name`, then last attribute) |
112
+ | `resource_name` | Resource name (prefers attributes ending in `Name`, falls back to `resource_id`) |
113
+ | `aws_sdk_services` | List of boto3 client names (e.g., `['elb', 'elbv2']` for elasticloadbalancing) |
114
+
115
+ ### `ARNError`
116
+
117
+ Exception raised when ARN parsing fails. Inherits from `ValueError`.
118
+
119
+ ## Development
120
+
121
+ Prerequisites: [uv](https://github.com/astral-sh/uv)
122
+
123
+ ```bash
124
+ make lint # Run ruff linter
125
+ make test # Run pytest tests
126
+ make check # Run lint and test
127
+ make generate # Regenerate patterns from AWS docs
128
+ make build # Build wheel and tarball
129
+ make publish # Build and upload to PyPI
130
+ ```
131
+
132
+ ## Versioning
133
+
134
+ [CalVer](https://calver.org/) format `YYYY.MM.MICRO` (e.g., `2026.2.0`).
@@ -0,0 +1,7 @@
1
+ arnmatch/__init__.py,sha256=aE28ZxEr62CrnJpZz9ievkif6yiRxaPl78ZI9F-BMBA,4829
2
+ arnmatch/arn_patterns.py,sha256=cPdXXV2ma3C5OjULLj-n35OkZMotNPBYKmBkSBNh9ZM,515238
3
+ arnmatch-2026.2.1.dist-info/METADATA,sha256=UNoAMKwfHbQDQVqZ2wh70M_ap7I9ORUy9uBoemKiuCA,4354
4
+ arnmatch-2026.2.1.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
5
+ arnmatch-2026.2.1.dist-info/entry_points.txt,sha256=k4tR_yh3Rodi-BfwVhc_6TktgYhE7BfMy6s0Zzq6EFk,43
6
+ arnmatch-2026.2.1.dist-info/licenses/LICENSE,sha256=yaQvdAwp_8m38IzGH2b78UxfHSd1GkLrxLhbu_YqDcg,9267
7
+ arnmatch-2026.2.1.dist-info/RECORD,,
@@ -0,0 +1,182 @@
1
+ Copyright 2026 Andrey Gubarev
2
+
3
+ Apache License
4
+ Version 2.0, January 2004
5
+ http://www.apache.org/licenses/
6
+
7
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
8
+
9
+ 1. Definitions.
10
+
11
+ "License" shall mean the terms and conditions for use, reproduction, and
12
+ distribution as defined by Sections 1 through 9 of this document.
13
+
14
+ "Licensor" shall mean the copyright owner or entity authorized by the
15
+ copyright owner that is granting the License.
16
+
17
+ "Legal Entity" shall mean the union of the acting entity and all other
18
+ entities that control, are controlled by, or are under common control with
19
+ that entity. For the purposes of this definition, "control" means (i) the
20
+ power, direct or indirect, to cause the direction or management of such
21
+ entity, whether by contract or otherwise, or (ii) ownership of fifty percent
22
+ (50%) or more of the outstanding shares, or (iii) beneficial ownership of
23
+ such entity.
24
+
25
+ "You" (or "Your") shall mean an individual or Legal Entity exercising
26
+ permissions granted by this License.
27
+
28
+ "Source" form shall mean the preferred form for making modifications,
29
+ including but not limited to software source code, documentation source,
30
+ and configuration files.
31
+
32
+ "Object" form shall mean any form resulting from mechanical transformation
33
+ or translation of a Source form, including but not limited to compiled
34
+ object code, generated documentation, and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or Object form,
37
+ made available under the License, as indicated by a copyright notice that
38
+ is included in or attached to the work (an example is provided in the
39
+ Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object form,
42
+ that is based on (or derived from) the Work and for which the editorial
43
+ revisions, annotations, elaborations, or other modifications represent, as
44
+ a whole, an original work of authorship. For the purposes of this License,
45
+ Derivative Works shall not include works that remain separable from, or
46
+ merely link (or bind by name) to the interfaces of, the Work and Derivative
47
+ Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including the original
50
+ version of the Work and any modifications or additions to that Work or
51
+ Derivative Works thereof, that is intentionally submitted to Licensor for
52
+ inclusion in the Work by the copyright owner or by an individual or Legal
53
+ Entity authorized to submit on behalf of the copyright owner. For the
54
+ purposes of this definition, "submitted" means any form of electronic,
55
+ verbal, or written communication sent to the Licensor or its
56
+ representatives, including but not limited to communication on electronic
57
+ mailing lists, source code control systems, and issue tracking systems that
58
+ are managed by, or on behalf of, the Licensor for the purpose of discussing
59
+ and improving the Work, but excluding communication that is conspicuously
60
+ marked or otherwise designated in writing by the copyright owner as
61
+ "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity on
64
+ behalf of whom a Contribution has been received by Licensor and subsequently
65
+ incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License.
68
+
69
+ Subject to the terms and conditions of this License, each Contributor hereby
70
+ grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
71
+ irrevocable copyright license to reproduce, prepare Derivative Works of,
72
+ publicly display, publicly perform, sublicense, and distribute the Work and
73
+ such Derivative Works in Source or Object form.
74
+
75
+ 3. Grant of Patent License.
76
+
77
+ Subject to the terms and conditions of this License, each Contributor hereby
78
+ grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
79
+ irrevocable (except as stated in this section) patent license to make, have
80
+ made, use, offer to sell, sell, import, and otherwise transfer the Work,
81
+ where such license applies only to those patent claims licensable by such
82
+ Contributor that are necessarily infringed by their Contribution(s) alone
83
+ or by combination of their Contribution(s) with the Work to which such
84
+ Contribution(s) was submitted. If You institute patent litigation against
85
+ any entity (including a cross-claim or counterclaim in a lawsuit) alleging
86
+ that the Work or a Contribution incorporated within the Work constitutes
87
+ direct or contributory patent infringement, then any patent licenses granted
88
+ to You under this License for that Work shall terminate as of the date such
89
+ litigation is filed.
90
+
91
+ 4. Redistribution.
92
+
93
+ You may reproduce and distribute copies of the Work or Derivative Works
94
+ thereof in any medium, with or without modifications, and in Source or
95
+ Object form, provided that You meet the following conditions:
96
+
97
+ (a) You must give any other recipients of the Work or Derivative Works a
98
+ copy of this License; and
99
+
100
+ (b) You must cause any modified files to carry prominent notices stating
101
+ that You changed the files; and
102
+
103
+ (c) You must retain, in the Source form of any Derivative Works that You
104
+ distribute, all copyright, patent, trademark, and attribution notices
105
+ from the Source form of the Work, excluding those notices that do not
106
+ pertain to any part of the Derivative Works; and
107
+
108
+ (d) If the Work includes a "NOTICE" text file as part of its distribution,
109
+ then any Derivative Works that You distribute must include a readable
110
+ copy of the attribution notices contained within such NOTICE file,
111
+ excluding those notices that do not pertain to any part of the
112
+ Derivative Works, in at least one of the following places: within a
113
+ NOTICE text file distributed as part of the Derivative Works; within
114
+ the Source form or documentation, if provided along with the Derivative
115
+ Works; or, within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents of the
117
+ NOTICE file are for informational purposes only and do not modify the
118
+ License. You may add Your own attribution notices within Derivative
119
+ Works that You distribute, alongside or as an addendum to the NOTICE
120
+ text from the Work, provided that such additional attribution notices
121
+ cannot be construed as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and may
124
+ provide additional or different license terms and conditions for use,
125
+ reproduction, or distribution of Your modifications, or for any such
126
+ Derivative Works as a whole, provided Your use, reproduction, and
127
+ distribution of the Work otherwise complies with the conditions stated
128
+ in this License.
129
+
130
+ 5. Submission of Contributions.
131
+
132
+ Unless You explicitly state otherwise, any Contribution intentionally
133
+ submitted for inclusion in the Work by You to the Licensor shall be under
134
+ the terms and conditions of this License, without any additional terms or
135
+ conditions. Notwithstanding the above, nothing herein shall supersede or
136
+ modify the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks.
140
+
141
+ This License does not grant permission to use the trade names, trademarks,
142
+ service marks, or product names of the Licensor, except as required for
143
+ reasonable and customary use in describing the origin of the Work and
144
+ reproducing the content of the NOTICE file.
145
+
146
+ 7. Disclaimer of Warranty.
147
+
148
+ Unless required by applicable law or agreed to in writing, Licensor provides
149
+ the Work (and each Contributor provides its Contributions) on an "AS IS"
150
+ BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
151
+ implied, including, without limitation, any warranties or conditions of
152
+ TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR
153
+ PURPOSE. You are solely responsible for determining the appropriateness of
154
+ using or redistributing the Work and assume any risks associated with Your
155
+ exercise of permissions under this License.
156
+
157
+ 8. Limitation of Liability.
158
+
159
+ In no event and under no legal theory, whether in tort (including
160
+ negligence), contract, or otherwise, unless required by applicable law
161
+ (such as deliberate and grossly negligent acts) or agreed to in writing,
162
+ shall any Contributor be liable to You for damages, including any direct,
163
+ indirect, special, incidental, or consequential damages of any character
164
+ arising as a result of this License or out of the use or inability to use
165
+ the Work (including but not limited to damages for loss of goodwill, work
166
+ stoppage, computer failure or malfunction, or any and all other commercial
167
+ damages or losses), even if such Contributor has been advised of the
168
+ possibility of such damages.
169
+
170
+ 9. Accepting Warranty or Additional Liability.
171
+
172
+ While redistributing the Work or Derivative Works thereof, You may choose
173
+ to offer, and charge a fee for, acceptance of support, warranty, indemnity,
174
+ or other liability obligations and/or rights consistent with this License.
175
+ However, in accepting such obligations, You may act only on Your own behalf
176
+ and on Your sole responsibility, not on behalf of any other Contributor,
177
+ and only if You agree to indemnify, defend, and hold each Contributor
178
+ harmless for any liability incurred by, or claims asserted against, such
179
+ Contributor by reason of your accepting any such warranty or additional
180
+ liability.
181
+
182
+ END OF TERMS AND CONDITIONS
@@ -1,121 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: arnmatch
3
- Version: 2026.2.0
4
- Summary: Parse AWS ARNs into structured data (2000+ resource types)
5
- Author-email: Andrey Gubarev <andrey@andreygubarev.com>
6
- Requires-Python: >=3.10
7
- Description-Content-Type: text/markdown
8
-
9
- # arnmatch
10
-
11
- Parse AWS ARNs into structured data.
12
-
13
- ![Python 3.10+](https://img.shields.io/badge/python-3.10%2B-blue)
14
-
15
- ## Why
16
-
17
- AWS ARN formats are inconsistent. This problem was unsolved. Now it's solved (for 2000+ resource types from 300+ services). You're welcome.
18
-
19
- ## Features
20
-
21
- - Zero runtime dependencies
22
- - 300+ AWS services, 2000+ resource types supported
23
- - Patterns auto-generated from AWS official documentation
24
- - CLI and library interface
25
- - Extracts resource type, ID, and name with smart heuristics
26
-
27
- ## Installation
28
-
29
- ```bash
30
- pip install arnmatch
31
- ```
32
-
33
- ## Quick Start
34
-
35
- ### CLI
36
-
37
- ```bash
38
- $ uvx arnmatch "arn:aws:lambda:us-east-1:123456789012:function:my-function"
39
- aws_service: lambda
40
- aws_sdk_services: lambda
41
- aws_region: us-east-1
42
- aws_account: 123456789012
43
- resource_type: function
44
- resource_id: my-function
45
- resource_name: my-function
46
- ```
47
-
48
- ### Library
49
-
50
- ```python
51
- from arnmatch import arnmatch
52
-
53
- arn = "arn:aws:lambda:us-east-1:123456789012:function:my-function"
54
- result = arnmatch(arn)
55
-
56
- print(result.aws_service) # lambda
57
- print(result.aws_sdk_services) # ['lambda']
58
- print(result.aws_region) # us-east-1
59
- print(result.aws_account) # 123456789012
60
- print(result.resource_type) # function
61
- print(result.resource_id) # my-function
62
- print(result.resource_name) # my-function
63
- print(result.attributes) # {'Partition': 'aws', 'Region': 'us-east-1', ...}
64
- ```
65
-
66
- ## API Reference
67
-
68
- ### `arnmatch(arn: str) -> ARN`
69
-
70
- Parse an ARN string and return structured data.
71
-
72
- Raises `ARNError` if the ARN format is invalid or no pattern matches.
73
-
74
- ### `ARN`
75
-
76
- Dataclass with parsed ARN components:
77
-
78
- | Field | Type | Description |
79
- |-------|------|-------------|
80
- | `aws_partition` | `str` | AWS partition (aws, aws-cn, aws-us-gov) |
81
- | `aws_service` | `str` | AWS service name |
82
- | `aws_region` | `str` | AWS region (may be empty for global resources) |
83
- | `aws_account` | `str` | AWS account ID |
84
- | `resource_type` | `str` | Canonical resource type from AWS docs |
85
- | `resource_types` | `list[str]` | All known names for this resource type |
86
- | `attributes` | `dict[str, str]` | All captured attributes from the pattern |
87
-
88
- Properties:
89
-
90
- | Property | Description |
91
- |----------|-------------|
92
- | `resource_id` | Resource identifier (prefers groups ending in `Id`, falls back to `Name`, then last group) |
93
- | `resource_name` | Resource name (prefers groups ending in `Name`, falls back to `resource_id`) |
94
- | `aws_sdk_services` | List of boto3 client names for this service (e.g., `['elb', 'elbv2']` for elasticloadbalancing) |
95
-
96
- ### `ARNError`
97
-
98
- Exception raised when ARN parsing fails. Inherits from `ValueError`.
99
-
100
- ## Versioning
101
-
102
- This project uses [CalVer](https://calver.org/) with format `YYYY.0M.MICRO` (e.g., `2026.01.0`).
103
-
104
- ## Development
105
-
106
- Prerequisites: [uv](https://github.com/astral-sh/uv)
107
-
108
- ```bash
109
- make lint # Run ruff linter
110
- make test # Run pytest tests
111
- make check # Run lint and test
112
- make build # Build wheel and tarball
113
- make publish # Build and upload to PyPI
114
- make clean # Remove build artifacts
115
- ```
116
-
117
- Regenerate patterns from AWS docs:
118
-
119
- ```bash
120
- cd codegen && uv run codegen.py
121
- ```
@@ -1,6 +0,0 @@
1
- arnmatch/__init__.py,sha256=TgauAqg2U3XIVfJPmwHrB2upT_9nFnr9JPPaqOnFP9Q,4830
2
- arnmatch/arn_patterns.py,sha256=cPdXXV2ma3C5OjULLj-n35OkZMotNPBYKmBkSBNh9ZM,515238
3
- arnmatch-2026.2.0.dist-info/METADATA,sha256=qow_9ffV0_jPe2PjzVbZIXXsepNkoXT2D-HdTsq514A,3353
4
- arnmatch-2026.2.0.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
5
- arnmatch-2026.2.0.dist-info/entry_points.txt,sha256=k4tR_yh3Rodi-BfwVhc_6TktgYhE7BfMy6s0Zzq6EFk,43
6
- arnmatch-2026.2.0.dist-info/RECORD,,