azure-discovery 0.1.0__py3-none-any.whl → 0.1.2__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.
@@ -1,33 +1,33 @@
1
- """Azure Discovery: Azure tenant discovery and visualization via Resource Graph.
2
-
3
- This package can be installed from PyPI as ``azure-discovery`` and used as:
4
-
5
- pip install azure-discovery
6
- azure-discovery discover --tenant-id <id> --subscription <sub-id>
7
-
8
- Programmatic usage:
9
-
10
- from azure_discovery import run_discovery
11
- from azure_discovery.adt_types import AzureDiscoveryRequest, AzureDiscoveryResponse
12
- """
13
-
14
- from .orchestrator import run_discovery
15
- from .adt_types import (
16
- AzureDiscoveryRequest,
17
- AzureDiscoveryResponse,
18
- AzureEnvironment,
19
- DiscoveryFilter,
20
- ResourceNode,
21
- ResourceRelationship,
22
- )
23
-
24
- __all__ = [
25
- "run_discovery",
26
- "AzureDiscoveryRequest",
27
- "AzureDiscoveryResponse",
28
- "AzureEnvironment",
29
- "DiscoveryFilter",
30
- "ResourceNode",
31
- "ResourceRelationship",
32
- ]
33
- __version__ = "0.1.0"
1
+ """Azure Discovery: Azure tenant discovery and visualization via Resource Graph.
2
+
3
+ This package can be installed from PyPI as ``azure-discovery`` and used as:
4
+
5
+ pip install azure-discovery
6
+ azure-discovery discover --tenant-id <id> --subscription <sub-id>
7
+
8
+ Programmatic usage:
9
+
10
+ from azure_discovery import run_discovery
11
+ from azure_discovery.adt_types import AzureDiscoveryRequest, AzureDiscoveryResponse
12
+ """
13
+
14
+ from .orchestrator import run_discovery
15
+ from .adt_types import (
16
+ AzureDiscoveryRequest,
17
+ AzureDiscoveryResponse,
18
+ AzureEnvironment,
19
+ DiscoveryFilter,
20
+ ResourceNode,
21
+ ResourceRelationship,
22
+ )
23
+
24
+ __all__ = [
25
+ "run_discovery",
26
+ "AzureDiscoveryRequest",
27
+ "AzureDiscoveryResponse",
28
+ "AzureEnvironment",
29
+ "DiscoveryFilter",
30
+ "ResourceNode",
31
+ "ResourceRelationship",
32
+ ]
33
+ __version__ = "0.1.2"
azure_discovery/cli.py CHANGED
@@ -17,7 +17,7 @@ from .adt_types import (
17
17
  DiscoveryFilter,
18
18
  VisualizationOptions,
19
19
  )
20
- from .utils.logging import get_logger
20
+ from .utils.logging import enable_cli_logging
21
21
 
22
22
  cli = typer.Typer(help="Azure tenant discovery and visualization CLI")
23
23
 
@@ -83,8 +83,8 @@ def discover_command(
83
83
  Use --quiet to suppress all logs except errors.
84
84
  """
85
85
 
86
- # Initialize logger with quiet mode
87
- get_logger(quiet=quiet)
86
+ # Emit logs to stderr only when run as CLI; library use stays silent.
87
+ enable_cli_logging(quiet=quiet)
88
88
 
89
89
  tag_filters = _parse_tags(required_tag)
90
90
  discovery_filter = DiscoveryFilter(
@@ -1,4 +1,13 @@
1
- """Structured logging helpers."""
1
+ """Structured logging helpers.
2
+
3
+ When used as a library (e.g. imported by auto_iac), no handlers are attached
4
+ by default so the package does not write to stderr and does not interfere
5
+ with the calling application's UI (e.g. Rich live panels). Callers can attach
6
+ their own handler to the \"azure_discovery\" logger if they want to see logs.
7
+
8
+ When run as the CLI, the entrypoint calls enable_cli_logging() so logs are
9
+ emitted to stderr in JSON form.
10
+ """
2
11
 
3
12
  from __future__ import annotations
4
13
 
@@ -31,29 +40,47 @@ def _build_json_formatter() -> logging.Formatter:
31
40
 
32
41
 
33
42
  def get_logger(quiet: bool = False) -> logging.Logger:
34
- """Return module-wide structured logger.
43
+ """Return module-wide logger. Does not attach any handler when used as a library.
44
+
45
+ Library use: no output unless the calling app attaches a handler to
46
+ \"azure_discovery\". CLI use: call enable_cli_logging() first so logs go to stderr.
35
47
 
36
48
  Args:
37
- quiet: If True, only log ERROR and above. Logs always go to stderr.
49
+ quiet: Ignored when no CLI handler is attached. When enable_cli_logging(quiet=True)
50
+ is used, only ERROR and above are emitted.
38
51
  """
39
-
40
52
  logger = logging.getLogger(_LOGGER_NAME)
41
53
  if logger.handlers:
42
- # Update log level if quiet mode changed
43
54
  if quiet:
44
55
  logger.setLevel(logging.ERROR)
45
56
  return logger
46
57
 
47
- # Always use stderr for logs, never stdout
58
+ # Library default: no stderr output; avoid interfering with calling scripts.
59
+ logger.addHandler(logging.NullHandler())
60
+ logger.propagate = False
61
+ if quiet:
62
+ logger.setLevel(logging.ERROR)
63
+ else:
64
+ env_level = os.getenv("AZURE_DISCOVERY_LOG_LEVEL", "INFO").upper()
65
+ logger.setLevel(env_level)
66
+ return logger
67
+
68
+
69
+ def enable_cli_logging(quiet: bool = False) -> None:
70
+ """Attach stderr + JSON handler so logs are emitted when run as the CLI.
71
+
72
+ Call this from the CLI entrypoint only. When used as a library, do not call
73
+ this so the package does not write to stderr.
74
+ """
75
+ logger = logging.getLogger(_LOGGER_NAME)
76
+ # Replace any existing handlers (e.g. NullHandler from get_logger) with our CLI handler.
77
+ logger.handlers.clear()
48
78
  handler = logging.StreamHandler(sys.stderr)
49
79
  handler.setFormatter(_build_json_formatter())
50
80
  logger.addHandler(handler)
51
-
81
+ logger.propagate = False
52
82
  if quiet:
53
83
  logger.setLevel(logging.ERROR)
54
84
  else:
55
85
  env_level = os.getenv("AZURE_DISCOVERY_LOG_LEVEL", "INFO").upper()
56
86
  logger.setLevel(env_level)
57
-
58
- logger.propagate = False
59
- return logger
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: azure-discovery
3
- Version: 0.1.0
3
+ Version: 0.1.2
4
4
  Summary: Lightweight Azure tenant discovery and visualization via Resource Graph. Enumerates subscriptions and resources, normalizes results, and renders interactive dependency graphs. Supports public and sovereign clouds (Gov, China, Germany, Azure Stack).
5
5
  Author: David Frazer <david.frazer336@gmail.com>
6
6
  License-Expression: MIT
@@ -1,6 +1,6 @@
1
- azure_discovery/__init__.py,sha256=tK8HAgGDPhdvsTOdWFHZK0pB5JUZBo6G23w7np2w8dE,835
1
+ azure_discovery/__init__.py,sha256=XoegHZgjqgojOp8yggmypiG7J9sUVGq6JPBv0yC4wQo,868
2
2
  azure_discovery/api.py,sha256=J1iRt3SyVqbSbVpvQgfQcwDtzGK-PT7QlU5QQDTnv_k,1290
3
- azure_discovery/cli.py,sha256=Qqjifxu-zbsktkxpA0_8LI7PntgnmUOvs1NlcCu_Vj0,4233
3
+ azure_discovery/cli.py,sha256=kSm1gVytcjxp9qfMdMmuLQX8PmgNWlZ8xqQ0lx7sV-8,4283
4
4
  azure_discovery/orchestrator.py,sha256=xD_W0qHw46ahia95Lbam2UUa13jw4jnStWc-DE7nQLU,839
5
5
  azure_discovery/adt_types/__init__.py,sha256=wKv5ggC77-hCve-96VWnkjsjAe-zbzbcHEi1jQCCjOw,433
6
6
  azure_discovery/adt_types/errors.py,sha256=_I_2CTzEowzoXEXZcJEcyknmOYovG30IvX-jXt7d0RE,340
@@ -13,10 +13,10 @@ azure_discovery/reporting/html.py,sha256=jH4BJjZFGFpoSvquxnosMx1AIyWfUf0immdDnqm
13
13
  azure_discovery/utils/__init__.py,sha256=oIrIQN9OPeaE3djBcB5sR1PhBpkdkw9lA8QEEv4agHY,292
14
14
  azure_discovery/utils/azure_clients.py,sha256=TG4tWivxE2IvKSBGRUtWF0eA25Wb0GrILor2nrfcwmY,5972
15
15
  azure_discovery/utils/graph_helpers.py,sha256=XQTqEg9SPU6V3r2qas2BII6-KquBizc5DclbCLAfLKg,1181
16
- azure_discovery/utils/logging.py,sha256=LvT9Fea__hqOq2UwScHpT8eElW4ArzwyZwVMBSMUgoc,1692
17
- azure_discovery-0.1.0.dist-info/licenses/LICENSE,sha256=H5Cd8vqg-_kMV2v3EQEc9JgLWLa-tZKrn8ekdbVRE_0,1085
18
- azure_discovery-0.1.0.dist-info/METADATA,sha256=ruZ-wVxReb5QSxtV2WEXSV6SWJ7s_ViUQ-DGu4MCbCI,15516
19
- azure_discovery-0.1.0.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
20
- azure_discovery-0.1.0.dist-info/entry_points.txt,sha256=ZoF7ybEeKIn5Q2Rklb77swS2lZ-4L_NzXhUOo1pFttM,61
21
- azure_discovery-0.1.0.dist-info/top_level.txt,sha256=aui6halihvG0KwHYrQYpTpu5gO-dI-Xr3nQ1JRB1vIk,16
22
- azure_discovery-0.1.0.dist-info/RECORD,,
16
+ azure_discovery/utils/logging.py,sha256=hTpScdRRxqOCTI5jpKQ9owA3XzTnHLErFo5eRpDXW6A,3048
17
+ azure_discovery-0.1.2.dist-info/licenses/LICENSE,sha256=H5Cd8vqg-_kMV2v3EQEc9JgLWLa-tZKrn8ekdbVRE_0,1085
18
+ azure_discovery-0.1.2.dist-info/METADATA,sha256=qru5Xlk77B_DpFrDLrWn8sIK5d8Vk46UwB6CB97xK00,15516
19
+ azure_discovery-0.1.2.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
20
+ azure_discovery-0.1.2.dist-info/entry_points.txt,sha256=ZoF7ybEeKIn5Q2Rklb77swS2lZ-4L_NzXhUOo1pFttM,61
21
+ azure_discovery-0.1.2.dist-info/top_level.txt,sha256=aui6halihvG0KwHYrQYpTpu5gO-dI-Xr3nQ1JRB1vIk,16
22
+ azure_discovery-0.1.2.dist-info/RECORD,,