arnmatch 2026.1.2__py3-none-any.whl → 2026.2.0__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.01.2"
3
+ __version__ = "2026.02.0"
4
4
 
5
5
  import sys
6
6
  from dataclasses import dataclass
@@ -29,6 +29,8 @@ class ARN:
29
29
  resource_type: str # canonical type (from AWS docs)
30
30
  resource_types: list[str] # all known names including Resource Explorer
31
31
  attributes: dict[str, str]
32
+ aws_sdk_service: str | None = None
33
+ cloudformation_resource: str | None = None
32
34
 
33
35
  @cached_property
34
36
  def resource_id(self) -> str:
@@ -78,7 +80,7 @@ class ARN:
78
80
  return self.resource_id
79
81
 
80
82
  @cached_property
81
- def aws_sdk_services(self):
83
+ def aws_sdk_services(self) -> list[str]:
82
84
  """Get AWS SDK (boto3) client names for this resource's service.
83
85
 
84
86
  Returns list of client names that can interact with this resource type.
@@ -106,17 +108,19 @@ def arnmatch(arn: str) -> ARN:
106
108
  if service not in ARN_PATTERNS:
107
109
  raise ARNError(f"Unknown service: {service}")
108
110
 
109
- for regex, type_names in ARN_PATTERNS[service]:
110
- match = regex.match(arn)
111
+ for pattern in ARN_PATTERNS[service]:
112
+ match = pattern['regex'].match(arn)
111
113
  if match:
112
114
  return ARN(
113
115
  aws_partition=partition,
114
116
  aws_service=service,
115
117
  aws_region=region,
116
118
  aws_account=account,
117
- resource_type=type_names[0], # canonical
118
- resource_types=type_names, # all known names
119
+ resource_type=pattern['names'][0], # canonical
120
+ resource_types=pattern['names'], # all known names
119
121
  attributes=match.groupdict(),
122
+ aws_sdk_service=pattern['sdk'],
123
+ cloudformation_resource=pattern['cfn'],
120
124
  )
121
125
 
122
126
  raise ARNError(f"No pattern matched ARN: {arn}")
@@ -132,12 +136,14 @@ def main() -> None:
132
136
  try:
133
137
  result = arnmatch(arn)
134
138
  print(f"aws_service: {result.aws_service}")
139
+ print(f"aws_sdk_service: {result.aws_sdk_service}")
135
140
  print(f"aws_sdk_services: {','.join(result.aws_sdk_services)}")
136
141
  print(f"aws_region: {result.aws_region}")
137
142
  print(f"aws_account: {result.aws_account}")
138
143
  print(f"resource_type: {result.resource_type}")
139
144
  print(f"resource_id: {result.resource_id}")
140
145
  print(f"resource_name: {result.resource_name}")
146
+ print(f"cloudformation_resource: {result.cloudformation_resource}")
141
147
  except ARNError as e:
142
148
  print(f"Error: {e}", file=sys.stderr)
143
149
  sys.exit(1)