clear-skies-cortex 2.0.4__py3-none-any.whl → 2.0.5__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.
- {clear_skies_cortex-2.0.4.dist-info → clear_skies_cortex-2.0.5.dist-info}/METADATA +1 -1
- {clear_skies_cortex-2.0.4.dist-info → clear_skies_cortex-2.0.5.dist-info}/RECORD +5 -5
- clearskies_cortex/models/cortex_catalog_entity.py +159 -0
- {clear_skies_cortex-2.0.4.dist-info → clear_skies_cortex-2.0.5.dist-info}/WHEEL +0 -0
- {clear_skies_cortex-2.0.4.dist-info → clear_skies_cortex-2.0.5.dist-info}/licenses/LICENSE +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: clear-skies-cortex
|
|
3
|
-
Version: 2.0.
|
|
3
|
+
Version: 2.0.5
|
|
4
4
|
Summary: Cortex module for Clearskies
|
|
5
5
|
Project-URL: Docs, https://https://clearskies.info/modules/clear-skies-cortex
|
|
6
6
|
Project-URL: Repository, https://github.com/clearskies-py/cortex
|
|
@@ -9,7 +9,7 @@ clearskies_cortex/defaults/__init__.py,sha256=tulZSvFgp4YUKj_bnArIevmlpC8z_AQKO0
|
|
|
9
9
|
clearskies_cortex/defaults/default_cortex_auth.py,sha256=sWlWgXIoCXk0FkwK3Kz33TVohsaVpIOS9qj2Ef5_YN8,2135
|
|
10
10
|
clearskies_cortex/defaults/default_cortex_url.py,sha256=sKBDQVPJWc4ozBquZ7fKryTbUOXYfrH6hUcQuUtMXEU,1576
|
|
11
11
|
clearskies_cortex/models/__init__.py,sha256=zckJ4-KOjIcmtN7h7lXOESUu3d6JBsZZJq-s2MJ0NLQ,1145
|
|
12
|
-
clearskies_cortex/models/cortex_catalog_entity.py,sha256=
|
|
12
|
+
clearskies_cortex/models/cortex_catalog_entity.py,sha256=NZ4nLWtZaZ6dFv6uBrxvwFO5XoayAfMF3sBZynETiOU,12172
|
|
13
13
|
clearskies_cortex/models/cortex_catalog_entity_domain.py,sha256=AOa07Fq-SWc8zkg6g-fBi5x1GnGg42GhPM2GozrgC2c,2327
|
|
14
14
|
clearskies_cortex/models/cortex_catalog_entity_group.py,sha256=D5Je_kX4dBW8jkhmZBca02mFYT3cqK1walleMXTlcdg,1295
|
|
15
15
|
clearskies_cortex/models/cortex_catalog_entity_scorecard.py,sha256=XT08_865AzsiMGsybIhQPQ8jTR1HrCfAtRAME7MdDo0,2372
|
|
@@ -22,7 +22,7 @@ clearskies_cortex/models/cortex_scorecard.py,sha256=aiM8_MkdMT_n-a6teG8y6zWSLmHu
|
|
|
22
22
|
clearskies_cortex/models/cortex_team.py,sha256=UUS1KHufPqhO29h4eKIfeZzUz75KjwkqaW5ItmdAKS4,4356
|
|
23
23
|
clearskies_cortex/models/cortex_team_category_tree.py,sha256=PRCIGeZrBoGiH1a7Q8ZsYYzSfj4cZF9tIRcBWEKAX60,1898
|
|
24
24
|
clearskies_cortex/models/cortex_team_department.py,sha256=_0Go97ZFr_GCd_ol0iBw7Px5F_gE94WtAWFGnzQ9y-M,1582
|
|
25
|
-
clear_skies_cortex-2.0.
|
|
26
|
-
clear_skies_cortex-2.0.
|
|
27
|
-
clear_skies_cortex-2.0.
|
|
28
|
-
clear_skies_cortex-2.0.
|
|
25
|
+
clear_skies_cortex-2.0.5.dist-info/METADATA,sha256=PfbWy_SRD4tqNgOIxZuu38nrb5cDnzJMuVCn6Xn0f7Y,2117
|
|
26
|
+
clear_skies_cortex-2.0.5.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
27
|
+
clear_skies_cortex-2.0.5.dist-info/licenses/LICENSE,sha256=MkEX8JF8kZxdyBpTTcB0YTd-xZpWnHvbRlw-pQh8u58,1069
|
|
28
|
+
clear_skies_cortex-2.0.5.dist-info/RECORD,,
|
|
@@ -245,3 +245,162 @@ class CortexCatalogEntity(Model):
|
|
|
245
245
|
def parse_owners(self) -> dataclasses.EntityTeamOwner:
|
|
246
246
|
"""Parse the owners column into a dictionary."""
|
|
247
247
|
return from_dict(dataclasses.EntityTeamOwner, data=self.owners)
|
|
248
|
+
|
|
249
|
+
def get_group_tags(self) -> list[str]:
|
|
250
|
+
"""Get groups as simple tags.
|
|
251
|
+
|
|
252
|
+
Returns groups that don't have a key:value format.
|
|
253
|
+
|
|
254
|
+
Returns:
|
|
255
|
+
List of group names that are simple tags without key:value format.
|
|
256
|
+
|
|
257
|
+
Example:
|
|
258
|
+
>>> entity.groups = ["my-tag", "team:platform", "production"]
|
|
259
|
+
>>> entity.get_group_tags()
|
|
260
|
+
["my-tag", "production"]
|
|
261
|
+
"""
|
|
262
|
+
tags: list[str] = []
|
|
263
|
+
if self.groups:
|
|
264
|
+
for group in self.groups:
|
|
265
|
+
if ":" not in group:
|
|
266
|
+
tags.append(group)
|
|
267
|
+
return tags
|
|
268
|
+
|
|
269
|
+
def get_group_value(self, key: str) -> str | None:
|
|
270
|
+
"""Get the value for a specific group key.
|
|
271
|
+
|
|
272
|
+
Groups can be formatted as "key:value" pairs. This method extracts
|
|
273
|
+
the value for a given key.
|
|
274
|
+
|
|
275
|
+
Args:
|
|
276
|
+
key: The group key to look up.
|
|
277
|
+
|
|
278
|
+
Returns:
|
|
279
|
+
The value associated with the key, or None if not found.
|
|
280
|
+
|
|
281
|
+
Example:
|
|
282
|
+
>>> entity.groups = ["team:platform", "env:production"]
|
|
283
|
+
>>> entity.get_group_value("team")
|
|
284
|
+
"platform"
|
|
285
|
+
"""
|
|
286
|
+
if self.groups:
|
|
287
|
+
for group in self.groups:
|
|
288
|
+
if group.startswith(f"{key}:"):
|
|
289
|
+
return group.split(":", 1)[1]
|
|
290
|
+
return None
|
|
291
|
+
|
|
292
|
+
def get_git_repository_url(self) -> str | None:
|
|
293
|
+
"""Get the Git repository URL.
|
|
294
|
+
|
|
295
|
+
Returns:
|
|
296
|
+
The repository URL, or None if not configured.
|
|
297
|
+
|
|
298
|
+
Example:
|
|
299
|
+
>>> entity.git = {"repository": "https://github.com/org/repo"}
|
|
300
|
+
>>> entity.get_git_repository_url()
|
|
301
|
+
"https://github.com/org/repo"
|
|
302
|
+
"""
|
|
303
|
+
if not self.git:
|
|
304
|
+
return None
|
|
305
|
+
return self.git.get("repository") or self.git.get("repositoryUrl")
|
|
306
|
+
|
|
307
|
+
def get_git_provider(self) -> str | None:
|
|
308
|
+
"""Get the Git provider name.
|
|
309
|
+
|
|
310
|
+
Returns:
|
|
311
|
+
The provider name (e.g., "github", "gitlab", "bitbucket", "azure-devops"),
|
|
312
|
+
or None if not configured.
|
|
313
|
+
|
|
314
|
+
Example:
|
|
315
|
+
>>> entity.git = {"provider": "github", "repository": "..."}
|
|
316
|
+
>>> entity.get_git_provider()
|
|
317
|
+
"github"
|
|
318
|
+
"""
|
|
319
|
+
if not self.git:
|
|
320
|
+
return None
|
|
321
|
+
return self.git.get("provider")
|
|
322
|
+
|
|
323
|
+
def get_git_project_id(self) -> str | None:
|
|
324
|
+
"""Extract the project/repository identifier from the Git configuration.
|
|
325
|
+
|
|
326
|
+
Cortex supports multiple SCM providers (GitHub, GitLab, Bitbucket, Azure DevOps).
|
|
327
|
+
This method extracts the project identifier in a provider-agnostic way.
|
|
328
|
+
|
|
329
|
+
For GitLab, this returns the numeric project ID if available in the URL.
|
|
330
|
+
For GitHub/Bitbucket, this returns the "owner/repo" format.
|
|
331
|
+
For Azure DevOps, this returns the project/repo path.
|
|
332
|
+
|
|
333
|
+
Returns:
|
|
334
|
+
The project identifier as a string, or None if not found.
|
|
335
|
+
|
|
336
|
+
Example:
|
|
337
|
+
>>> entity.git = {"repository": "https://github.com/org/repo"}
|
|
338
|
+
>>> entity.get_git_project_id()
|
|
339
|
+
"org/repo"
|
|
340
|
+
|
|
341
|
+
>>> entity.git = {"repository": "https://gitlab.com/projects/12345"}
|
|
342
|
+
>>> entity.get_git_project_id()
|
|
343
|
+
"12345"
|
|
344
|
+
"""
|
|
345
|
+
if not self.git:
|
|
346
|
+
return None
|
|
347
|
+
|
|
348
|
+
repo_url = self.git.get("repository") or self.git.get("repositoryUrl") or ""
|
|
349
|
+
|
|
350
|
+
# GitLab numeric project ID format: https://gitlab.com/projects/12345
|
|
351
|
+
if "/projects/" in repo_url:
|
|
352
|
+
try:
|
|
353
|
+
project_id = repo_url.split("/projects/")[1].split("/")[0]
|
|
354
|
+
return project_id
|
|
355
|
+
except IndexError:
|
|
356
|
+
pass
|
|
357
|
+
|
|
358
|
+
# Standard URL format: https://provider.com/owner/repo or https://provider.com/owner/repo.git
|
|
359
|
+
# Works for GitHub, GitLab (path format), Bitbucket
|
|
360
|
+
for prefix in ["github.com/", "gitlab.com/", "bitbucket.org/"]:
|
|
361
|
+
if prefix in repo_url:
|
|
362
|
+
try:
|
|
363
|
+
path = repo_url.split(prefix)[1]
|
|
364
|
+
# Remove .git suffix if present
|
|
365
|
+
if path.endswith(".git"):
|
|
366
|
+
path = path[:-4]
|
|
367
|
+
# Remove trailing slashes
|
|
368
|
+
path = path.rstrip("/")
|
|
369
|
+
# Return owner/repo format
|
|
370
|
+
parts = path.split("/")
|
|
371
|
+
if len(parts) >= 2:
|
|
372
|
+
return f"{parts[0]}/{parts[1]}"
|
|
373
|
+
except IndexError:
|
|
374
|
+
pass
|
|
375
|
+
|
|
376
|
+
# Azure DevOps format: https://dev.azure.com/org/project/_git/repo
|
|
377
|
+
if "dev.azure.com/" in repo_url:
|
|
378
|
+
try:
|
|
379
|
+
path = repo_url.split("dev.azure.com/")[1]
|
|
380
|
+
parts = path.split("/")
|
|
381
|
+
if len(parts) >= 4 and parts[2] == "_git":
|
|
382
|
+
return f"{parts[0]}/{parts[1]}/{parts[3]}"
|
|
383
|
+
except IndexError:
|
|
384
|
+
pass
|
|
385
|
+
|
|
386
|
+
return None
|
|
387
|
+
|
|
388
|
+
@property
|
|
389
|
+
def is_cloud_resource(self) -> bool:
|
|
390
|
+
"""Check if entity represents a cloud resource.
|
|
391
|
+
|
|
392
|
+
Cortex supports pulling in resources from AWS, Azure, and Google Cloud.
|
|
393
|
+
This property checks if the entity type indicates a cloud resource.
|
|
394
|
+
|
|
395
|
+
Returns:
|
|
396
|
+
True if the entity type indicates a cloud resource.
|
|
397
|
+
|
|
398
|
+
Example:
|
|
399
|
+
>>> entity.type = "AWS::Lambda::Function"
|
|
400
|
+
>>> entity.is_cloud_resource
|
|
401
|
+
True
|
|
402
|
+
"""
|
|
403
|
+
if not self.type:
|
|
404
|
+
return False
|
|
405
|
+
cloud_prefixes = ("AWS::", "Azure::", "Google::")
|
|
406
|
+
return self.type.startswith(cloud_prefixes)
|
|
File without changes
|
|
File without changes
|