validio-cli 10.0.7__tar.gz → 10.1.0__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 (29) hide show
  1. {validio_cli-10.0.7 → validio_cli-10.1.0}/PKG-INFO +1 -1
  2. {validio_cli-10.0.7 → validio_cli-10.1.0}/pyproject.toml +2 -2
  3. {validio_cli-10.0.7 → validio_cli-10.1.0}/pyproject.toml.orig +2 -2
  4. {validio_cli-10.0.7 → validio_cli-10.1.0}/validio_cli/bin/entities/code.py +5 -1
  5. {validio_cli-10.0.7 → validio_cli-10.1.0}/validio_cli/bin/entities/resources.py +1 -1
  6. {validio_cli-10.0.7 → validio_cli-10.1.0}/validio_cli/bin/entities/sources.py +1 -1
  7. validio_cli-10.1.0/validio_cli/bin/entities/validator_debug_queries.py +130 -0
  8. {validio_cli-10.0.7 → validio_cli-10.1.0}/validio_cli/bin/main.py +6 -0
  9. {validio_cli-10.0.7 → validio_cli-10.1.0}/README_PUBLIC.md +0 -0
  10. {validio_cli-10.0.7 → validio_cli-10.1.0}/validio_cli/__init__.py +0 -0
  11. {validio_cli-10.0.7 → validio_cli-10.1.0}/validio_cli/bin/entities/channels.py +0 -0
  12. {validio_cli-10.0.7 → validio_cli-10.1.0}/validio_cli/bin/entities/config.py +0 -0
  13. {validio_cli-10.0.7 → validio_cli-10.1.0}/validio_cli/bin/entities/credentials.py +0 -0
  14. {validio_cli-10.0.7 → validio_cli-10.1.0}/validio_cli/bin/entities/dbt.py +0 -0
  15. {validio_cli-10.0.7 → validio_cli-10.1.0}/validio_cli/bin/entities/filters.py +0 -0
  16. {validio_cli-10.0.7 → validio_cli-10.1.0}/validio_cli/bin/entities/incidents.py +0 -0
  17. {validio_cli-10.0.7 → validio_cli-10.1.0}/validio_cli/bin/entities/integrations.py +0 -0
  18. {validio_cli-10.0.7 → validio_cli-10.1.0}/validio_cli/bin/entities/metrics.py +0 -0
  19. {validio_cli-10.0.7 → validio_cli-10.1.0}/validio_cli/bin/entities/namespaces.py +0 -0
  20. {validio_cli-10.0.7 → validio_cli-10.1.0}/validio_cli/bin/entities/notification_rules.py +0 -0
  21. {validio_cli-10.0.7 → validio_cli-10.1.0}/validio_cli/bin/entities/segmentations.py +0 -0
  22. {validio_cli-10.0.7 → validio_cli-10.1.0}/validio_cli/bin/entities/segments.py +0 -0
  23. {validio_cli-10.0.7 → validio_cli-10.1.0}/validio_cli/bin/entities/users.py +0 -0
  24. {validio_cli-10.0.7 → validio_cli-10.1.0}/validio_cli/bin/entities/validators.py +0 -0
  25. {validio_cli-10.0.7 → validio_cli-10.1.0}/validio_cli/bin/entities/windows.py +0 -0
  26. {validio_cli-10.0.7 → validio_cli-10.1.0}/validio_cli/components.py +0 -0
  27. {validio_cli-10.0.7 → validio_cli-10.1.0}/validio_cli/metadata.py +0 -0
  28. {validio_cli-10.0.7 → validio_cli-10.1.0}/validio_cli/namespace.py +0 -0
  29. {validio_cli-10.0.7 → validio_cli-10.1.0}/validio_cli/schema.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: validio-cli
3
- Version: 10.0.7
3
+ Version: 10.1.0
4
4
  Summary: CLI tool to interact with the Validio platform
5
5
  Author: Validio
6
6
  Author-email: Validio <support@validio.io>
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "validio-cli"
3
- version = "10.0.7"
3
+ version = "10.1.0"
4
4
  description = "CLI tool to interact with the Validio platform"
5
5
  requires-python = ">=3.10,<4"
6
6
  readme = "README_PUBLIC.md"
@@ -107,5 +107,5 @@ ignore_packages = ["MYPY-EXTENSIONS"]
107
107
  zero = true
108
108
 
109
109
  [build-system]
110
- requires = ["uv_build>=0.12.1,<0.13.0"]
110
+ requires = ["uv_build>=0.12.3,<0.13.0"]
111
111
  build-backend = "uv_build"
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "validio-cli"
3
- version = "10.0.7"
3
+ version = "10.1.0"
4
4
  description = "CLI tool to interact with the Validio platform"
5
5
  authors = [{ name = "Validio", email = "support@validio.io" }]
6
6
  requires-python = ">=3.10,<4"
@@ -52,7 +52,7 @@ module-name = ["validio_cli"]
52
52
  module-root = ""
53
53
 
54
54
  [build-system]
55
- requires = ["uv_build>=0.12.1,<0.13.0"]
55
+ requires = ["uv_build>=0.12.3,<0.13.0"]
56
56
  build-backend = "uv_build"
57
57
 
58
58
  [tool.ruff]
@@ -209,6 +209,7 @@ async def plan(
209
209
  segmentation: list[str] = target_option("segmentation"),
210
210
  source: list[str] = target_option("source"),
211
211
  validator: list[str] = target_option("validator"),
212
+ validator_debug_query: list[str] = target_option("validator-debug-query"),
212
213
  window: list[str] = target_option("window"),
213
214
  progress: bool = show_progress_option,
214
215
  ) -> None:
@@ -243,6 +244,7 @@ async def plan(
243
244
  segmentations=set(segmentation),
244
245
  sources=set(source),
245
246
  validators=set(validator),
247
+ validator_debug_queries=set(validator_debug_query),
246
248
  windows=set(window),
247
249
  ),
248
250
  show_progress=progress,
@@ -273,6 +275,7 @@ async def apply(
273
275
  segmentation: list[str] = target_option("segmentation"),
274
276
  source: list[str] = target_option("source"),
275
277
  validator: list[str] = target_option("validator"),
278
+ validator_debug_query: list[str] = target_option("validator-debug-query"),
276
279
  window: list[str] = target_option("window"),
277
280
  progress: bool = show_progress_option,
278
281
  test_credentials: bool = typer.Option(
@@ -319,6 +322,7 @@ async def apply(
319
322
  segmentations=set(segmentation),
320
323
  sources=set(source),
321
324
  validators=set(validator),
325
+ validator_debug_queries=set(validator_debug_query),
322
326
  windows=set(window),
323
327
  ),
324
328
  show_progress=progress,
@@ -450,7 +454,7 @@ async def _import(
450
454
  tags_ctx=plan_result.tags_context,
451
455
  include_schema=include_schema,
452
456
  )
453
- output.write_text(s)
457
+ output.write_text(s, encoding="utf-8")
454
458
  print(f"Generated file {output.absolute()}")
455
459
 
456
460
 
@@ -113,7 +113,7 @@ def _read_resource_file(file: pathlib.Path) -> dict:
113
113
  if not file.is_file():
114
114
  raise ValidioError(f"'{file.absolute()}' is not a file")
115
115
 
116
- obj = json.loads(file.read_text())
116
+ obj = json.loads(file.read_text(encoding="utf-8"))
117
117
  if not isinstance(obj, dict):
118
118
  raise ValidioError(f"expected json object in resource file: got {type(obj)}")
119
119
 
@@ -953,7 +953,7 @@ async def _infer_schema_bigquery(
953
953
 
954
954
 
955
955
  def _write_schema(filename: Path, schema: Any) -> None:
956
- filename.write_text(json.dumps(schema, indent=2))
956
+ filename.write_text(json.dumps(schema, indent=2), encoding="utf-8")
957
957
 
958
958
  print(f"Schema written to {filename}")
959
959
 
@@ -0,0 +1,130 @@
1
+ import typer
2
+ from validio_sdk._api.api import APIClient
3
+ from validio_sdk.config import ValidioConfig
4
+ from validio_sdk.exception import ValidioError
5
+
6
+ from validio_cli import (
7
+ AsyncTyper,
8
+ ConfigDir,
9
+ Identifier,
10
+ Identifiers,
11
+ Namespace,
12
+ OutputFormat,
13
+ OutputFormatOption,
14
+ OutputSettings,
15
+ get_client,
16
+ output_json,
17
+ output_ok_or_error,
18
+ output_text,
19
+ )
20
+ from validio_cli.bin.entities.validators import get_validator_id
21
+ from validio_cli.namespace import get_namespace
22
+
23
+ app = AsyncTyper(help="Debug queries saved on validators")
24
+
25
+
26
+ @app.async_command(help="List validator debug queries")
27
+ async def get(
28
+ config_dir: str = ConfigDir,
29
+ output_format: OutputFormat = OutputFormatOption,
30
+ namespace: str = Namespace(),
31
+ identifier: str = Identifier,
32
+ validator: str = typer.Option(
33
+ None, help="List debug queries for this Validator (name or ID)"
34
+ ),
35
+ ) -> None:
36
+ if identifier and validator:
37
+ raise ValidioError("--validator can't be used together with an identifier")
38
+
39
+ vc, cfg = get_client(config_dir)
40
+
41
+ validator_id = (
42
+ await get_validator_id(vc, cfg, validator, namespace) if validator else None
43
+ )
44
+
45
+ debug_queries = await vc.get_validator_debug_queries(
46
+ validator_debug_query_id=identifier,
47
+ validator_id=validator_id,
48
+ namespace_id=get_namespace(namespace, cfg),
49
+ )
50
+
51
+ if output_format == OutputFormat.JSON:
52
+ return output_json(debug_queries, identifier)
53
+
54
+ return output_text(
55
+ debug_queries,
56
+ fields={
57
+ "name": OutputSettings(attribute_name="resourceName"),
58
+ "validator": OutputSettings(
59
+ reformat=lambda validator: validator["resourceName"]
60
+ ),
61
+ "default": OutputSettings(attribute_name="defaultQuery"),
62
+ "age": OutputSettings.string_as_datetime(attribute_name="createdAt"),
63
+ },
64
+ )
65
+
66
+
67
+ @app.async_command(help="Delete validator debug query")
68
+ async def delete(
69
+ config_dir: str = ConfigDir,
70
+ output_format: OutputFormat = OutputFormatOption,
71
+ namespace: str = Namespace(),
72
+ identifiers: list[str] = Identifiers,
73
+ ) -> None:
74
+ if not identifiers:
75
+ raise ValidioError("no identifiers are provided")
76
+
77
+ vc, cfg = get_client(config_dir)
78
+
79
+ debug_query_ids = [
80
+ debug_query_id
81
+ for debug_query_id in [
82
+ await get_validator_debug_query_id(vc, cfg, identifier, namespace)
83
+ for identifier in identifiers
84
+ ]
85
+ if debug_query_id
86
+ ]
87
+
88
+ result = await vc.delete_validator_debug_queries(debug_query_ids)
89
+
90
+ if output_format == OutputFormat.JSON:
91
+ return output_json(result)
92
+
93
+ return output_ok_or_error(result)
94
+
95
+
96
+ async def get_validator_debug_query_id(
97
+ vc: APIClient, cfg: ValidioConfig, identifier: str, namespace: str
98
+ ) -> str | None:
99
+ """
100
+ Ensure the identifier is a resource id.
101
+
102
+ If it doesn't have the expected prefix, do a resource lookup by name.
103
+ """
104
+ identifier_type = "validator debug query"
105
+ prefix = "VDQ_"
106
+
107
+ if not identifier:
108
+ print(f"Missing {identifier_type} id or name")
109
+ return None
110
+
111
+ if identifier.startswith(prefix):
112
+ return identifier
113
+
114
+ resource = await vc.get_validator_debug_queries(
115
+ validator_debug_query_id=identifier,
116
+ namespace_id=get_namespace(namespace, cfg),
117
+ )
118
+
119
+ if resource is None:
120
+ print(f"No {identifier_type} with name or id {identifier} found")
121
+ return None
122
+
123
+ if not isinstance(resource, dict):
124
+ raise ValidioError("failed to get validator debug query id")
125
+
126
+ return resource["id"]
127
+
128
+
129
+ if __name__ == "__main__":
130
+ app()
@@ -30,6 +30,7 @@ from validio_cli.bin.entities import (
30
30
  segments,
31
31
  sources,
32
32
  users,
33
+ validator_debug_queries,
33
34
  validators,
34
35
  windows,
35
36
  )
@@ -78,6 +79,11 @@ app.add_typer(segments.app, no_args_is_help=True, name="segments")
78
79
  app.add_typer(sources.app, no_args_is_help=True, name="sources")
79
80
  app.add_typer(users.app, no_args_is_help=True, name="users")
80
81
  app.add_typer(validators.app, no_args_is_help=True, name="validators")
82
+ app.add_typer(
83
+ validator_debug_queries.app,
84
+ no_args_is_help=True,
85
+ name="validator-debug-queries",
86
+ )
81
87
  app.add_typer(windows.app, no_args_is_help=True, name="windows")
82
88
 
83
89