tinybird 0.0.1.dev89__py3-none-any.whl → 0.0.1.dev90__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.

Potentially problematic release.


This version of tinybird might be problematic. Click here for more details.

tinybird/client.py CHANGED
@@ -288,6 +288,25 @@ class TinyB:
288
288
  ds = [x for x in ds if x["name"].startswith(branch)]
289
289
  return ds
290
290
 
291
+ async def secrets(self) -> List[Dict[str, Any]]:
292
+ response = await self._req("/v0/variables")
293
+ return response["variables"]
294
+
295
+ async def get_secret(self, name: str) -> Optional[Dict[str, Any]]:
296
+ return await self._req(f"/v0/variables/{name}")
297
+
298
+ async def create_secret(self, name: str, value: str):
299
+ response = await self._req("/v0/variables", method="POST", data={"name": name, "value": value})
300
+ return response
301
+
302
+ async def update_secret(self, name: str, value: str):
303
+ response = await self._req(f"/v0/variables/{name}", method="PUT", data={"value": value})
304
+ return response
305
+
306
+ async def delete_secret(self, name: str):
307
+ response = await self._req(f"/v0/variables/{name}", method="DELETE")
308
+ return response
309
+
291
310
  async def get_connections(self, service: Optional[str] = None):
292
311
  params = {}
293
312
 
tinybird/tb/__cli__.py CHANGED
@@ -4,5 +4,5 @@ __description__ = 'Tinybird Command Line Tool'
4
4
  __url__ = 'https://www.tinybird.co/docs/cli/introduction.html'
5
5
  __author__ = 'Tinybird'
6
6
  __author_email__ = 'support@tinybird.co'
7
- __version__ = '0.0.1.dev89'
8
- __revision__ = '6153af6'
7
+ __version__ = '0.0.1.dev90'
8
+ __revision__ = 'd11bb13'
tinybird/tb/cli.py CHANGED
@@ -22,6 +22,7 @@ import tinybird.tb.modules.materialization
22
22
  import tinybird.tb.modules.mock
23
23
  import tinybird.tb.modules.pipe
24
24
  import tinybird.tb.modules.playground
25
+ import tinybird.tb.modules.secret
25
26
  import tinybird.tb.modules.tag
26
27
  import tinybird.tb.modules.test
27
28
  import tinybird.tb.modules.token
@@ -0,0 +1,85 @@
1
+ import re
2
+ from typing import Optional
3
+
4
+ import click
5
+
6
+ from tinybird.client import TinyB
7
+ from tinybird.tb.modules.cli import cli
8
+ from tinybird.tb.modules.common import coro, echo_safe_humanfriendly_tables_format_smart_table
9
+ from tinybird.tb.modules.feedback_manager import FeedbackManager
10
+
11
+
12
+ @cli.group()
13
+ @click.pass_context
14
+ def secret(ctx):
15
+ """Secret commands."""
16
+
17
+
18
+ @secret.command(name="ls")
19
+ @click.option("--match", default=None, help="Retrieve any secrets matching the pattern. For example, --match _test")
20
+ @click.pass_context
21
+ @coro
22
+ async def secret_ls(ctx: click.Context, match: Optional[str]):
23
+ """List secrets"""
24
+
25
+ client: TinyB = ctx.ensure_object(dict)["client"]
26
+ secrets = await client.secrets()
27
+ columns = ["name", "created_at", "updated_at"]
28
+ table_human_readable = []
29
+ table_machine_readable = []
30
+ pattern = re.compile(match) if match else None
31
+
32
+ for secret in secrets:
33
+ name = secret["name"]
34
+
35
+ if pattern and not pattern.search(name):
36
+ continue
37
+
38
+ created_at = secret["created_at"]
39
+ updated_at = secret["updated_at"]
40
+
41
+ table_human_readable.append((name, created_at, updated_at))
42
+ table_machine_readable.append({"name": name, "created at": created_at, "updated at": updated_at})
43
+
44
+ click.echo(FeedbackManager.info(message="** Secrets:"))
45
+ echo_safe_humanfriendly_tables_format_smart_table(table_human_readable, column_names=columns)
46
+ click.echo("\n")
47
+
48
+
49
+ @secret.command(name="set")
50
+ @click.argument("name")
51
+ @click.argument("value")
52
+ @click.pass_context
53
+ @coro
54
+ async def secret_set(ctx: click.Context, name: str, value: str):
55
+ """Create or update secrets"""
56
+ try:
57
+ click.echo(FeedbackManager.highlight(message=f"\n» Setting secret '{name}'..."))
58
+ client: TinyB = ctx.ensure_object(dict)["client"]
59
+ existing_secret = None
60
+ try:
61
+ existing_secret = await client.get_secret(name)
62
+ except Exception:
63
+ pass
64
+ if existing_secret:
65
+ await client.update_secret(name, value)
66
+ else:
67
+ await client.create_secret(name, value)
68
+ click.echo(FeedbackManager.success(message=f"\n✓ Secret '{name}' set"))
69
+ except Exception as e:
70
+ click.echo(FeedbackManager.error(message=f"✗ Error: {e}"))
71
+
72
+
73
+ @secret.command(name="rm")
74
+ @click.argument("name")
75
+ @click.pass_context
76
+ @coro
77
+ async def secret_rm(ctx: click.Context, name: str):
78
+ """Delete a secret"""
79
+ try:
80
+ click.echo(FeedbackManager.highlight(message=f"\n» Deleting secret '{name}'..."))
81
+ client: TinyB = ctx.ensure_object(dict)["client"]
82
+ await client.delete_secret(name)
83
+ click.echo(FeedbackManager.success(message=f"\n✓ Secret '{name}' deleted"))
84
+ except Exception as e:
85
+ click.echo(FeedbackManager.error(message=f"✗ Error: {e}"))
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: tinybird
3
- Version: 0.0.1.dev89
3
+ Version: 0.0.1.dev90
4
4
  Summary: Tinybird Command Line Tool
5
5
  Home-page: https://www.tinybird.co/docs/cli/introduction.html
6
6
  Author: Tinybird
@@ -1,5 +1,5 @@
1
1
  tinybird/__cli__.py,sha256=esPl5QDTzuQgHe5FuxWLm-fURFigGGwjnYLh9GuWUw4,232
2
- tinybird/client.py,sha256=Ng4HQHum6ezf7nRZ61PbEOhYvEEPadmXKDYu2SGaL0c,53393
2
+ tinybird/client.py,sha256=B6FaylxfcalxJTjiMgaS1Iyn9aBRsDaphwhC5VKeK6M,54179
3
3
  tinybird/config.py,sha256=5UP_UZ2Qtlm5aOH5W7SbtN8r7X-8u3-r853joKqU5zs,6072
4
4
  tinybird/connectors.py,sha256=7Gjms7b5MAaBFGi3xytsJurCylprONpFcYrzp4Fw2Rc,15241
5
5
  tinybird/context.py,sha256=FfqYfrGX_I7PKGTQo93utaKPDNVYWelg4Hsp3evX5wM,1291
@@ -15,8 +15,8 @@ tinybird/syncasync.py,sha256=IPnOx6lMbf9SNddN1eBtssg8vCLHMt76SuZ6YNYm-Yk,27761
15
15
  tinybird/tornado_template.py,sha256=jjNVDMnkYFWXflmT8KU_Ssbo5vR8KQq3EJMk5vYgXRw,41959
16
16
  tinybird/ch_utils/constants.py,sha256=aYvg2C_WxYWsnqPdZB1ZFoIr8ZY-XjUXYyHKE9Ansj0,3890
17
17
  tinybird/ch_utils/engine.py,sha256=BZuPM7MFS7vaEKK5tOMR2bwSAgJudPrJt27uVEwZmTY,40512
18
- tinybird/tb/__cli__.py,sha256=xWmtpX_BrBWY-ALVqm-M8PCmUyEnwSYABEqNIkELu8M,251
19
- tinybird/tb/cli.py,sha256=qon0Lim-v5hHWWRW7TXaOoGo3p2kc5Xwgg3feI4mbMQ,998
18
+ tinybird/tb/__cli__.py,sha256=Xjw-O5fZcxgHniZqT8Lfpai9LjBf9MYDmOuWtnCwi2c,251
19
+ tinybird/tb/cli.py,sha256=LOOJoNelfyqerVWrMasp2f-8roZzKdSoSa_sMViwHMg,1032
20
20
  tinybird/tb/modules/auth.py,sha256=L1IatO2arRSzys3t8px8xVt8uPWUL5EVD0sFzAV_uVU,9022
21
21
  tinybird/tb/modules/build.py,sha256=-lRGBxKtuipmyl3pmiGcfp67fH1Ed-COfHAZKdgLIWo,10483
22
22
  tinybird/tb/modules/cicd.py,sha256=T0lb9u_bDdTUVe8TwNNb1qQ5KnSPHMVjqPfKF4BBNBw,5347
@@ -44,6 +44,7 @@ tinybird/tb/modules/pipe.py,sha256=gcLz0qHgwKDLsWFY3yFLO9a0ETAV1dFbI8YeLHi9460,2
44
44
  tinybird/tb/modules/playground.py,sha256=CQaz2JqFDdReK2fJY1yZsSwiSY24_jeTb9PKw1WUigA,4848
45
45
  tinybird/tb/modules/project.py,sha256=ei0TIAuRksdV2g2FJqByuV4DPyivQGrZ42z_eQDNBgI,2963
46
46
  tinybird/tb/modules/regions.py,sha256=QjsL5H6Kg-qr0aYVLrvb1STeJ5Sx_sjvbOYO0LrEGMk,166
47
+ tinybird/tb/modules/secret.py,sha256=xxzfKxfFN7GORib1WslCaFDHt_dgnjmfOewyptPU_VM,2820
47
48
  tinybird/tb/modules/shell.py,sha256=a98W4L4gfrmxEyybtu6S4ENXrBYtgNASB5e_evuXQvI,13936
48
49
  tinybird/tb/modules/table.py,sha256=4XrtjM-N0zfNtxVkbvLDQQazno1EPXnxTyo7llivfXk,11035
49
50
  tinybird/tb/modules/tag.py,sha256=anPmMUBc-TbFovlpFi8GPkKA18y7Y0GczMsMms5TZsU,3502
@@ -77,8 +78,8 @@ tinybird/tb_cli_modules/config.py,sha256=IsgdtFRnUrkY8-Zo32lmk6O7u3bHie1QCxLwgp4
77
78
  tinybird/tb_cli_modules/exceptions.py,sha256=pmucP4kTF4irIt7dXiG-FcnI-o3mvDusPmch1L8RCWk,3367
78
79
  tinybird/tb_cli_modules/regions.py,sha256=QjsL5H6Kg-qr0aYVLrvb1STeJ5Sx_sjvbOYO0LrEGMk,166
79
80
  tinybird/tb_cli_modules/telemetry.py,sha256=Hh2Io8ZPROSunbOLuMvuIFU4TqwWPmQTqal4WS09K1A,10449
80
- tinybird-0.0.1.dev89.dist-info/METADATA,sha256=pKJ86pTylK2iqAqdOcWyaaApey6C8eiBM_NpLv-ZzWA,2585
81
- tinybird-0.0.1.dev89.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
82
- tinybird-0.0.1.dev89.dist-info/entry_points.txt,sha256=LwdHU6TfKx4Qs7BqqtaczEZbImgU7Abe9Lp920zb_fo,43
83
- tinybird-0.0.1.dev89.dist-info/top_level.txt,sha256=VqqqEmkAy7UNaD8-V51FCoMMWXjLUlR0IstvK7tJYVY,54
84
- tinybird-0.0.1.dev89.dist-info/RECORD,,
81
+ tinybird-0.0.1.dev90.dist-info/METADATA,sha256=1J8tIFd9v-xKv7yNIMmNAR9ZEx63FSbKgxwM4jiHL-s,2585
82
+ tinybird-0.0.1.dev90.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
83
+ tinybird-0.0.1.dev90.dist-info/entry_points.txt,sha256=LwdHU6TfKx4Qs7BqqtaczEZbImgU7Abe9Lp920zb_fo,43
84
+ tinybird-0.0.1.dev90.dist-info/top_level.txt,sha256=VqqqEmkAy7UNaD8-V51FCoMMWXjLUlR0IstvK7tJYVY,54
85
+ tinybird-0.0.1.dev90.dist-info/RECORD,,