tinybird 0.0.1.dev111__py3-none-any.whl → 0.0.1.dev112__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/tb/__cli__.py +2 -2
- tinybird/tb/modules/cli.py +8 -1
- tinybird/tb/modules/common.py +60 -86
- tinybird/tb/modules/connection.py +42 -0
- tinybird/tb/modules/create.py +11 -0
- tinybird/tb/modules/feedback_manager.py +1 -1
- {tinybird-0.0.1.dev111.dist-info → tinybird-0.0.1.dev112.dist-info}/METADATA +1 -1
- {tinybird-0.0.1.dev111.dist-info → tinybird-0.0.1.dev112.dist-info}/RECORD +11 -11
- {tinybird-0.0.1.dev111.dist-info → tinybird-0.0.1.dev112.dist-info}/WHEEL +0 -0
- {tinybird-0.0.1.dev111.dist-info → tinybird-0.0.1.dev112.dist-info}/entry_points.txt +0 -0
- {tinybird-0.0.1.dev111.dist-info → tinybird-0.0.1.dev112.dist-info}/top_level.txt +0 -0
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.
|
|
8
|
-
__revision__ = '
|
|
7
|
+
__version__ = '0.0.1.dev112'
|
|
8
|
+
__revision__ = 'eb9e376'
|
tinybird/tb/modules/cli.py
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
import json
|
|
7
7
|
import logging
|
|
8
8
|
import os
|
|
9
|
+
import shutil
|
|
9
10
|
import sys
|
|
10
11
|
from os import getcwd
|
|
11
12
|
from pathlib import Path
|
|
@@ -48,7 +49,13 @@ DEFAULT_PATTERNS: List[Tuple[str, Union[str, Callable[[str], str]]]] = [
|
|
|
48
49
|
VERSION = f"{__cli__.__version__} (rev {__cli__.__revision__})"
|
|
49
50
|
|
|
50
51
|
|
|
51
|
-
@click.group(
|
|
52
|
+
@click.group(
|
|
53
|
+
cls=CatchAuthExceptions,
|
|
54
|
+
context_settings={
|
|
55
|
+
"help_option_names": ["-h", "--help"],
|
|
56
|
+
"max_content_width": shutil.get_terminal_size().columns - 10,
|
|
57
|
+
},
|
|
58
|
+
)
|
|
52
59
|
@click.option(
|
|
53
60
|
"--debug/--no-debug",
|
|
54
61
|
default=False,
|
tinybird/tb/modules/common.py
CHANGED
|
@@ -1751,90 +1751,69 @@ async def remove_release(
|
|
|
1751
1751
|
click.echo(FeedbackManager.info_no_release_deleted())
|
|
1752
1752
|
|
|
1753
1753
|
|
|
1754
|
-
async def
|
|
1754
|
+
async def run_aws_iamrole_connection_flow(
|
|
1755
1755
|
client: TinyB,
|
|
1756
1756
|
service: str,
|
|
1757
|
-
|
|
1758
|
-
region: Optional[str],
|
|
1759
|
-
policy: str = "write",
|
|
1760
|
-
no_validate: Optional[bool] = False,
|
|
1757
|
+
policy: str = "read",
|
|
1761
1758
|
):
|
|
1762
|
-
if
|
|
1763
|
-
|
|
1764
|
-
client, service=service, policy=policy
|
|
1765
|
-
)
|
|
1759
|
+
if service == DataConnectorType.AMAZON_DYNAMODB:
|
|
1760
|
+
raise NotImplementedError("DynamoDB is not supported yet")
|
|
1766
1761
|
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
show_default=False,
|
|
1771
|
-
prompt_suffix="Press y to continue:",
|
|
1772
|
-
):
|
|
1773
|
-
sys.exit(1)
|
|
1762
|
+
resource_type = "table" if service == DataConnectorType.AMAZON_DYNAMODB else "bucket"
|
|
1763
|
+
resource_name = click.prompt(f"Enter the name of the {resource_type}")
|
|
1764
|
+
validate_string_connector_param(resource_type.capitalize(), resource_name)
|
|
1774
1765
|
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
pyperclip.copy(access_policy)
|
|
1778
|
-
except Exception:
|
|
1779
|
-
access_policy_copied = False
|
|
1766
|
+
resource_region = click.prompt(f"Enter the region where the {resource_type} is located")
|
|
1767
|
+
validate_string_connector_param("Region", resource_region)
|
|
1780
1768
|
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
"<table_name>": "<table_name> with your DynamoDB table name",
|
|
1784
|
-
}
|
|
1769
|
+
access_policy, trust_policy, external_id = await get_aws_iamrole_policies(client, service=service, policy=policy)
|
|
1770
|
+
access_policy = access_policy.replace("<bucket>", resource_name)
|
|
1785
1771
|
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1772
|
+
if not click.confirm(
|
|
1773
|
+
FeedbackManager.prompt_s3_iamrole_connection_login_aws(),
|
|
1774
|
+
show_default=False,
|
|
1775
|
+
prompt_suffix="Press y to continue:",
|
|
1776
|
+
):
|
|
1777
|
+
sys.exit(1)
|
|
1791
1778
|
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
if access_policy_copied
|
|
1798
|
-
else FeedbackManager.prompt_s3_iamrole_connection_policy_not_copied(access_policy=access_policy)
|
|
1799
|
-
),
|
|
1800
|
-
show_default=False,
|
|
1801
|
-
prompt_suffix="Press y to continue:",
|
|
1802
|
-
):
|
|
1803
|
-
sys.exit(1)
|
|
1804
|
-
|
|
1805
|
-
trust_policy_copied = True
|
|
1806
|
-
try:
|
|
1807
|
-
pyperclip.copy(trust_policy)
|
|
1808
|
-
except Exception:
|
|
1809
|
-
trust_policy_copied = False
|
|
1810
|
-
|
|
1811
|
-
if not click.confirm(
|
|
1812
|
-
(
|
|
1813
|
-
FeedbackManager.prompt_s3_iamrole_connection_role(trust_policy=trust_policy)
|
|
1814
|
-
if trust_policy_copied
|
|
1815
|
-
else FeedbackManager.prompt_s3_iamrole_connection_role_not_copied(trust_policy=trust_policy)
|
|
1816
|
-
),
|
|
1817
|
-
show_default=False,
|
|
1818
|
-
prompt_suffix="Press y to continue:",
|
|
1819
|
-
):
|
|
1820
|
-
sys.exit(1)
|
|
1821
|
-
else:
|
|
1822
|
-
try:
|
|
1823
|
-
trust_policy = await client.get_trust_policy(service)
|
|
1824
|
-
external_id = trust_policy["Statement"][0]["Condition"]["StringEquals"]["sts:ExternalId"]
|
|
1825
|
-
except Exception:
|
|
1826
|
-
external_id = ""
|
|
1779
|
+
access_policy_copied = True
|
|
1780
|
+
try:
|
|
1781
|
+
pyperclip.copy(access_policy)
|
|
1782
|
+
except Exception:
|
|
1783
|
+
access_policy_copied = False
|
|
1827
1784
|
|
|
1828
|
-
if not
|
|
1829
|
-
|
|
1830
|
-
|
|
1785
|
+
if not click.confirm(
|
|
1786
|
+
(
|
|
1787
|
+
FeedbackManager.prompt_s3_iamrole_connection_policy(access_policy=access_policy)
|
|
1788
|
+
if access_policy_copied
|
|
1789
|
+
else FeedbackManager.prompt_s3_iamrole_connection_policy_not_copied(access_policy=access_policy)
|
|
1790
|
+
),
|
|
1791
|
+
show_default=False,
|
|
1792
|
+
prompt_suffix="Press y to continue:",
|
|
1793
|
+
):
|
|
1794
|
+
sys.exit(1)
|
|
1831
1795
|
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1796
|
+
trust_policy_copied = True
|
|
1797
|
+
try:
|
|
1798
|
+
pyperclip.copy(trust_policy)
|
|
1799
|
+
except Exception:
|
|
1800
|
+
trust_policy_copied = False
|
|
1836
1801
|
|
|
1837
|
-
|
|
1802
|
+
if not click.confirm(
|
|
1803
|
+
(
|
|
1804
|
+
FeedbackManager.prompt_s3_iamrole_connection_role(trust_policy=trust_policy)
|
|
1805
|
+
if trust_policy_copied
|
|
1806
|
+
else FeedbackManager.prompt_s3_iamrole_connection_role_not_copied(trust_policy=trust_policy)
|
|
1807
|
+
),
|
|
1808
|
+
show_default=False,
|
|
1809
|
+
prompt_suffix="Press y to continue:",
|
|
1810
|
+
):
|
|
1811
|
+
sys.exit(1)
|
|
1812
|
+
|
|
1813
|
+
role_arn = click.prompt("Enter the ARN of the role you just created")
|
|
1814
|
+
validate_string_connector_param("Role ARN", role_arn)
|
|
1815
|
+
|
|
1816
|
+
return role_arn, resource_region, external_id
|
|
1838
1817
|
|
|
1839
1818
|
|
|
1840
1819
|
async def get_aws_iamrole_policies(client: TinyB, service: str, policy: str = "write"):
|
|
@@ -1867,20 +1846,15 @@ async def get_aws_iamrole_policies(client: TinyB, service: str, policy: str = "w
|
|
|
1867
1846
|
return json.dumps(access_policy, indent=4), json.dumps(trust_policy, indent=4), external_id
|
|
1868
1847
|
|
|
1869
1848
|
|
|
1870
|
-
async def validate_aws_iamrole_connection_name(
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
raise CLIConnectionException(FeedbackManager.info_connection_already_exists(name=connection_name))
|
|
1876
|
-
else:
|
|
1877
|
-
while not connection_name:
|
|
1878
|
-
connection_name = click.prompt("Enter the name for this connection", default=None, show_default=False)
|
|
1879
|
-
assert isinstance(connection_name, str)
|
|
1849
|
+
async def validate_aws_iamrole_connection_name(client: TinyB) -> str:
|
|
1850
|
+
connection_name = None
|
|
1851
|
+
while not connection_name:
|
|
1852
|
+
connection_name = click.prompt("Enter the name for this connection", default=None, show_default=False)
|
|
1853
|
+
assert isinstance(connection_name, str)
|
|
1880
1854
|
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1855
|
+
if await client.get_connector(connection_name) is not None:
|
|
1856
|
+
click.echo(FeedbackManager.info_connection_already_exists(name=connection_name))
|
|
1857
|
+
connection_name = None
|
|
1884
1858
|
assert isinstance(connection_name, str)
|
|
1885
1859
|
return connection_name
|
|
1886
1860
|
|
|
@@ -15,8 +15,12 @@ from tinybird.tb.modules.common import (
|
|
|
15
15
|
_get_setting_value,
|
|
16
16
|
coro,
|
|
17
17
|
echo_safe_humanfriendly_tables_format_smart_table,
|
|
18
|
+
run_aws_iamrole_connection_flow,
|
|
19
|
+
validate_aws_iamrole_connection_name,
|
|
18
20
|
)
|
|
21
|
+
from tinybird.tb.modules.create import generate_aws_iamrole_connection_file
|
|
19
22
|
from tinybird.tb.modules.feedback_manager import FeedbackManager
|
|
23
|
+
from tinybird.tb.modules.project import Project
|
|
20
24
|
|
|
21
25
|
DATA_CONNECTOR_SETTINGS: Dict[DataConnectorType, List[str]] = {
|
|
22
26
|
DataConnectorType.KAFKA: [
|
|
@@ -123,3 +127,41 @@ async def connection_ls(ctx: Context, service: Optional[DataConnectorType] = Non
|
|
|
123
127
|
column_names = [c.replace("kafka_", "") for c in columns]
|
|
124
128
|
echo_safe_humanfriendly_tables_format_smart_table(table, column_names=column_names)
|
|
125
129
|
click.echo("\n")
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
@connection.group(name="create")
|
|
133
|
+
@click.pass_context
|
|
134
|
+
def connection_create(ctx: Context) -> None:
|
|
135
|
+
"""Create a connection."""
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
@connection_create.command(name="s3", short_help="Creates a AWS S3 connection.")
|
|
139
|
+
@click.pass_context
|
|
140
|
+
@coro
|
|
141
|
+
async def connection_create_s3(ctx: Context) -> None:
|
|
142
|
+
"""
|
|
143
|
+
Creates a AWS S3 connection.
|
|
144
|
+
|
|
145
|
+
\b
|
|
146
|
+
$ tb connection create s3
|
|
147
|
+
"""
|
|
148
|
+
project: Project = ctx.ensure_object(dict)["project"]
|
|
149
|
+
obj: Dict[str, Any] = ctx.ensure_object(dict)
|
|
150
|
+
client: TinyB = obj["client"]
|
|
151
|
+
service = DataConnectorType.AMAZON_S3
|
|
152
|
+
connection_name = await validate_aws_iamrole_connection_name(client)
|
|
153
|
+
role_arn, region, external_id = await run_aws_iamrole_connection_flow(
|
|
154
|
+
client,
|
|
155
|
+
service=service,
|
|
156
|
+
policy="read", # For now only read since we only support import from S3
|
|
157
|
+
)
|
|
158
|
+
|
|
159
|
+
await generate_aws_iamrole_connection_file(
|
|
160
|
+
name=connection_name, service=service, role_arn=role_arn, region=region, folder=project.folder
|
|
161
|
+
)
|
|
162
|
+
if external_id:
|
|
163
|
+
click.echo(
|
|
164
|
+
FeedbackManager.success_s3_iam_connection_created(
|
|
165
|
+
connection_name=connection_name, external_id=external_id, role_arn=role_arn
|
|
166
|
+
)
|
|
167
|
+
)
|
tinybird/tb/modules/create.py
CHANGED
|
@@ -353,6 +353,17 @@ def generate_connection_file(name: str, content: str, folder: str) -> Path:
|
|
|
353
353
|
return f.relative_to(folder)
|
|
354
354
|
|
|
355
355
|
|
|
356
|
+
async def generate_aws_iamrole_connection_file(
|
|
357
|
+
name: str, service: str, role_arn: str, region: str, folder: str
|
|
358
|
+
) -> None:
|
|
359
|
+
content = f"""TYPE {service}
|
|
360
|
+
|
|
361
|
+
S3_ARN {role_arn}
|
|
362
|
+
S3_REGION {region}
|
|
363
|
+
"""
|
|
364
|
+
generate_connection_file(name, content, folder)
|
|
365
|
+
|
|
366
|
+
|
|
356
367
|
def create_rules(folder: str, source: str, agent: str):
|
|
357
368
|
if agent == "cursor":
|
|
358
369
|
extension = ".cursorrules"
|
|
@@ -498,7 +498,7 @@ Ready? """
|
|
|
498
498
|
|
|
499
499
|
prompt_s3_iamrole_connection_login_aws = prompt_message("""[1] Log into your AWS Console\n\n""")
|
|
500
500
|
prompt_s3_iamrole_connection_policy = prompt_message(
|
|
501
|
-
"""\n[2] Go to IAM > Policies. Create a new policy with the following permissions
|
|
501
|
+
"""\n[2] Go to IAM > Policies. Create a new policy with the following permissions:\n\n{access_policy}\n\n(The policy has been copied to your clipboard)\n\n"""
|
|
502
502
|
)
|
|
503
503
|
prompt_s3_iamrole_connection_policy_not_copied = prompt_message(
|
|
504
504
|
"""\n[2] Go to IAM > Policies. Create a new policy with the following permissions. Please, copy this policy and replace <bucket> with your bucket name:\n\n{access_policy}\n\n"""
|
|
@@ -15,22 +15,22 @@ 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=
|
|
18
|
+
tinybird/tb/__cli__.py,sha256=XBYsgERHHC2rSmVZ_I1ovdmeZxmG3you6UQuNA4-qR4,252
|
|
19
19
|
tinybird/tb/cli.py,sha256=H_HaZhkimKgkryYXpBjHfY9Qtg-ZORiONU3psDNpzDk,1135
|
|
20
20
|
tinybird/tb/modules/auth.py,sha256=L1IatO2arRSzys3t8px8xVt8uPWUL5EVD0sFzAV_uVU,9022
|
|
21
21
|
tinybird/tb/modules/build.py,sha256=h5drdmDFX8NHts9dA2Zepao7KSgMAl3DZGyFufVZP78,11085
|
|
22
22
|
tinybird/tb/modules/cicd.py,sha256=k2hCout_N1g_rRAMWo_cf9tAGiJ1Puu5eiTV2DPob20,6939
|
|
23
|
-
tinybird/tb/modules/cli.py,sha256=
|
|
24
|
-
tinybird/tb/modules/common.py,sha256=
|
|
23
|
+
tinybird/tb/modules/cli.py,sha256=sZEYoJVfqN6zaCSN5NQRrzQLXxeJ5nDO7EnFXit9qh8,16157
|
|
24
|
+
tinybird/tb/modules/common.py,sha256=d2kkXrkoMBmh_CirBBgLw1E1_cxKUUB3ZE_Mx1x9tww,81717
|
|
25
25
|
tinybird/tb/modules/config.py,sha256=FqdLpLaKpYubqw3xkB4EX06ufZYDgGRxONR_9i-y-KE,11416
|
|
26
|
-
tinybird/tb/modules/connection.py,sha256=
|
|
26
|
+
tinybird/tb/modules/connection.py,sha256=IL095_8ideKM1Ueen3BdsYvJKA05VAdpv7bSQjhXKJo,5354
|
|
27
27
|
tinybird/tb/modules/copy.py,sha256=MAVqKip8_QhOYq99U_XuqSO6hCLJEh5sFtbhcXtI3SI,5802
|
|
28
|
-
tinybird/tb/modules/create.py,sha256=
|
|
28
|
+
tinybird/tb/modules/create.py,sha256=3Yz257QM7c8OgWlVRacnNXFkZPsDQFNLzJSVr83Xe70,14335
|
|
29
29
|
tinybird/tb/modules/datasource.py,sha256=dNCK9iCR2xPLfwqqwg2ixyE6NuoVEiJU2mBZBmOYrVY,16906
|
|
30
30
|
tinybird/tb/modules/deployment.py,sha256=UIW3W0qKBRk2o4gE8WDjmq9-UkrNZjtkbyKvcQR203k,19515
|
|
31
31
|
tinybird/tb/modules/endpoint.py,sha256=EhVoGAXsFz-83Fiwj1gI-I73iRRvL49d0W81un7hvPE,12080
|
|
32
32
|
tinybird/tb/modules/exceptions.py,sha256=4A2sSjCEqKUMqpP3WI00zouCWW4uLaghXXLZBSw04mY,3363
|
|
33
|
-
tinybird/tb/modules/feedback_manager.py,sha256=
|
|
33
|
+
tinybird/tb/modules/feedback_manager.py,sha256=7e-O-LyTi_hTln47Y_FuSWerggZQLUGqfTJeYK6D9i4,69479
|
|
34
34
|
tinybird/tb/modules/fmt.py,sha256=qpf9APqKTKL2uphNgdbj4OMVyLkAxZn6dn4eHF99L5g,3553
|
|
35
35
|
tinybird/tb/modules/infra.py,sha256=GA5xnYLlVItPfJu_3_5NIdHQDuyfk2Z71wtcn9NncGA,33189
|
|
36
36
|
tinybird/tb/modules/job.py,sha256=956Pj8BEEsiD2GZsV9RKKVM3I_CveOLgS82lykO5ukk,2963
|
|
@@ -81,8 +81,8 @@ tinybird/tb_cli_modules/config.py,sha256=IsgdtFRnUrkY8-Zo32lmk6O7u3bHie1QCxLwgp4
|
|
|
81
81
|
tinybird/tb_cli_modules/exceptions.py,sha256=pmucP4kTF4irIt7dXiG-FcnI-o3mvDusPmch1L8RCWk,3367
|
|
82
82
|
tinybird/tb_cli_modules/regions.py,sha256=QjsL5H6Kg-qr0aYVLrvb1STeJ5Sx_sjvbOYO0LrEGMk,166
|
|
83
83
|
tinybird/tb_cli_modules/telemetry.py,sha256=Hh2Io8ZPROSunbOLuMvuIFU4TqwWPmQTqal4WS09K1A,10449
|
|
84
|
-
tinybird-0.0.1.
|
|
85
|
-
tinybird-0.0.1.
|
|
86
|
-
tinybird-0.0.1.
|
|
87
|
-
tinybird-0.0.1.
|
|
88
|
-
tinybird-0.0.1.
|
|
84
|
+
tinybird-0.0.1.dev112.dist-info/METADATA,sha256=qVwK9fWPocmfDDsDhlUcPh61jVOZhCV7vZAgMzLn-xs,1612
|
|
85
|
+
tinybird-0.0.1.dev112.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
|
86
|
+
tinybird-0.0.1.dev112.dist-info/entry_points.txt,sha256=LwdHU6TfKx4Qs7BqqtaczEZbImgU7Abe9Lp920zb_fo,43
|
|
87
|
+
tinybird-0.0.1.dev112.dist-info/top_level.txt,sha256=VqqqEmkAy7UNaD8-V51FCoMMWXjLUlR0IstvK7tJYVY,54
|
|
88
|
+
tinybird-0.0.1.dev112.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|