rdxz2-utill 0.0.3__py3-none-any.whl → 0.1.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.
utill/cmd/utill.py CHANGED
@@ -2,89 +2,231 @@ import click
2
2
 
3
3
 
4
4
  @click.group()
5
- def main(): pass
5
+ def main():
6
+ pass
6
7
 
7
8
 
8
- # Conf
9
+ # MARK: Conf
9
10
 
10
11
 
11
- @main.group('conf', help='Configure this library')
12
- def main__conf(): pass
13
- @main__conf.command('init', help='Initialize env files')
14
- @click.argument('mode', type=click.Choice(['google-cloud', 'postgresql', 'metabase']))
15
- def main__conf__init(**kwargs): from ._conf import _init; _init(**kwargs)
16
- @main__conf.command('list', help='List all configs')
17
- @click.option('-m', 'module', type=click.Choice(['postgresql', 'metabase']), help='List config for a specific modules')
18
- def main__conf__list(**kwargs): from ._conf import _list; _list(**kwargs)
19
- @main__conf.command('set', help='Set configuration variables')
20
- @click.option('-e', 'vars', type=(str, str), multiple=True, required=True, help='Variables -> K V')
21
- def main__conf__set(**kwargs): from ._conf import _set; _set(**kwargs)
12
+ @main.group("conf", help="Configure this library")
13
+ def main__conf():
14
+ pass
22
15
 
23
16
 
24
- # PG
17
+ @main__conf.command("init", help="Initialize env files")
18
+ @click.argument("mode", type=click.Choice(["google-cloud", "postgresql", "metabase"]))
19
+ def main__conf__init(**kwargs):
20
+ from ._conf import _init
25
21
 
22
+ _init(**kwargs)
26
23
 
27
- @main.group('pg', help='PostgreSQL utility')
28
- def main__pg(): pass
29
- @main__pg.command('pg-to-pg', help='Copy table from one PG instance to another')
30
- @click.argument('src_profile', type=str)
31
- @click.argument('src_table', type=str)
32
- @click.argument('dst_profile', type=str)
33
- @click.argument('dst_table', type=str)
34
- @click.option('-c', '--columns', type=str, default='*', help='Columns to copy')
35
- def main__pg__pg_to_pg(**kwargs): from ._pg import _pg_to_pg; _pg_to_pg(**kwargs)
36
- @main__pg.command('upload-csv', help='Upload CSV file into PG table')
37
- @click.argument('profile', type=str)
38
- @click.argument('src_filename', type=click.Path())
39
- @click.argument('dst_table', type=str)
40
- def main__pg__upload_csv(**kwargs): from ._pg import _upload_csv; _upload_csv(**kwargs)
41
24
 
25
+ @main__conf.command("list", help="List all configs")
26
+ @click.option(
27
+ "-m",
28
+ "module",
29
+ type=click.Choice(["postgresql", "metabase"]),
30
+ help="List config for a specific modules",
31
+ )
32
+ def main__conf__list(**kwargs):
33
+ from ._conf import _list
42
34
 
43
- # BQ
35
+ _list(**kwargs)
44
36
 
45
37
 
46
- @main.group('bq', help='BigQuery utility')
47
- def main__bq(): pass
48
- @main__bq.command('upload-csv', help='Upload CSV file into BQ table')
49
- @click.argument('src_filename', type=click.Path())
50
- @click.argument('dst_table_fqn', type=str)
51
- @click.option('-c', 'columns', type=(str, str), required=True, multiple=True, help='Columns -> Name DataType')
52
- @click.option('--partition-col', 'partition_col', type=str, help='Partition column')
53
- @click.option('--cluster-col', 'cluster_cols', type=str, multiple=True, help='Cluster column(s)')
54
- @click.option('--project', type=str, help='Billing project')
55
- def main__bq__upload_csv(**kwargs): from ._bq import _upload_csv; _upload_csv(**kwargs)
56
- @main__bq.command('download-table', help='Download a BQ table into CSV file')
57
- @click.argument('src_table_fqn', type=str)
58
- @click.argument('dst_filename', type=str)
59
- @click.option('--project', type=str, help='Billing project')
60
- def main__bq__download_table(**kwargs): from ._bq import _download_table; _download_table(**kwargs)
38
+ @main__conf.command("set", help="Set configuration variables")
39
+ @click.option(
40
+ "-e", "vars", type=(str, str), multiple=True, required=True, help="Variables -> K V"
41
+ )
42
+ def main__conf__set(**kwargs):
43
+ from ._conf import _set
61
44
 
45
+ _set(**kwargs)
62
46
 
63
- # Encyrption
64
47
 
48
+ # MARK: Metabase
65
49
 
66
- @main.group('enc', help='Encryption utility')
67
- def main__enc(): pass
68
- @main__enc.command('encrypt', help='Encrypt a string / file')
69
- @click.argument('src', type=str)
70
- @click.option('-p', 'password', type=str, required=True, help='The password')
71
- def main__enc__encrypt(**kwargs): from ._enc import _encrypt; _encrypt(**kwargs)
72
50
 
51
+ @main.group("mb", help="Metabase utility commands")
52
+ def main__mb():
53
+ pass
73
54
 
74
- # Other utilities
75
55
 
56
+ @main__mb.command(
57
+ "jl-grant", help="Grant access to Metabase questions/collections/dashboards"
58
+ )
59
+ @click.option("-u", "--email", "emails", type=str, multiple=True, help="User emails")
60
+ @click.option("-l", "--url", "urls", type=str, multiple=True, help="URLs")
61
+ @click.option(
62
+ "-c",
63
+ "create_user_if_not_exists",
64
+ type=bool,
65
+ is_flag=True,
66
+ help="Create user if not exists, also reactivate user if it's already exists default: False",
67
+ )
68
+ def main__mb__grant(**kwargs):
69
+ from ._mb import _jl_grant
76
70
 
77
- @main.command('random', help='Generate random string')
78
- @click.option('-l', 'length', type=int, default=32, help='Length of the random string')
79
- @click.option('-a', 'alphanum', is_flag=True, default=False, help='Use alphanumeric only (a-Z, 0-9)')
80
- def main__random(**kwargs): from ._main import _random; _random(**kwargs)
71
+ _jl_grant(**kwargs)
81
72
 
82
73
 
83
- @main.command('unique', help='Get unique values')
84
- @click.argument('strings', nargs=-1)
85
- @click.option('-s', 'sort', type=bool, is_flag=True, help='Sort the output')
86
- def main__unique(**kwargs): from ._main import _unique; _unique(**kwargs)
74
+ @main__mb.command(
75
+ "copy-permissions", help="Copy all permissions from one user to another"
76
+ )
77
+ @click.argument("src_email", type=str)
78
+ @click.argument("dst_emails", type=str, nargs=-1)
79
+ def main__mb__copy_permissions(**kwargs):
80
+ from ._mb import _copy_permissions
87
81
 
82
+ _copy_permissions(**kwargs)
88
83
 
89
- if __name__ == '__main__':
84
+
85
+ @main__mb.command("reset-password", help="Reset Metabase user password")
86
+ @click.option(
87
+ "-u",
88
+ "--email",
89
+ "emails",
90
+ type=str,
91
+ required=True,
92
+ multiple=True,
93
+ help="User emails",
94
+ )
95
+ def main__mb__reset_password(**kwargs):
96
+ from ._mb import _reset_password
97
+
98
+ _reset_password(**kwargs)
99
+
100
+
101
+ @main__mb.command("disable-user", help="Disable Metabase user")
102
+ @click.option(
103
+ "-u",
104
+ "--email",
105
+ "emails",
106
+ type=str,
107
+ required=True,
108
+ multiple=True,
109
+ help="User emails",
110
+ )
111
+ def main__mb__disable_user(**kwargs):
112
+ from ._mb import _disable_user
113
+
114
+ _disable_user(**kwargs)
115
+
116
+
117
+ # MARK: PG
118
+
119
+
120
+ @main.group("pg", help="PostgreSQL utility")
121
+ def main__pg():
122
+ pass
123
+
124
+
125
+ @main__pg.command("pg-to-pg", help="Copy table from one PG instance to another")
126
+ @click.argument("src_profile", type=str)
127
+ @click.argument("src_table", type=str)
128
+ @click.argument("dst_profile", type=str)
129
+ @click.argument("dst_table", type=str)
130
+ @click.option("-c", "--columns", type=str, default="*", help="Columns to copy")
131
+ def main__pg__pg_to_pg(**kwargs):
132
+ from ._pg import _pg_to_pg
133
+
134
+ _pg_to_pg(**kwargs)
135
+
136
+
137
+ @main__pg.command("upload-csv", help="Upload CSV file into PG table")
138
+ @click.argument("profile", type=str)
139
+ @click.argument("src_filename", type=click.Path())
140
+ @click.argument("dst_table", type=str)
141
+ def main__pg__upload_csv(**kwargs):
142
+ from ._pg import _upload_csv
143
+
144
+ _upload_csv(**kwargs)
145
+
146
+
147
+ # MARK: BQ
148
+
149
+
150
+ @main.group("bq", help="BigQuery utility")
151
+ def main__bq():
152
+ pass
153
+
154
+
155
+ @main__bq.command("upload-csv", help="Upload CSV file into BQ table")
156
+ @click.argument("src_filename", type=click.Path())
157
+ @click.argument("dst_table_fqn", type=str)
158
+ @click.option(
159
+ "-c",
160
+ "columns",
161
+ type=(str, str),
162
+ required=True,
163
+ multiple=True,
164
+ help="Columns -> Name DataType",
165
+ )
166
+ @click.option("--partition-col", "partition_col", type=str, help="Partition column")
167
+ @click.option(
168
+ "--cluster-col", "cluster_cols", type=str, multiple=True, help="Cluster column(s)"
169
+ )
170
+ @click.option("--project", type=str, help="Billing project")
171
+ def main__bq__upload_csv(**kwargs):
172
+ from ._bq import _upload_csv
173
+
174
+ _upload_csv(**kwargs)
175
+
176
+
177
+ @main__bq.command("download-table", help="Download a BQ table into CSV file")
178
+ @click.argument("src_table_fqn", type=str)
179
+ @click.argument("dst_filename", type=str)
180
+ @click.option("--project", type=str, help="Billing project")
181
+ def main__bq__download_table(**kwargs):
182
+ from ._bq import _download_table
183
+
184
+ _download_table(**kwargs)
185
+
186
+
187
+ # MARK: Encyrption
188
+
189
+
190
+ @main.group("enc", help="Encryption utility")
191
+ def main__enc():
192
+ pass
193
+
194
+
195
+ @main__enc.command("encrypt", help="Encrypt a string / file")
196
+ @click.argument("src", type=str)
197
+ @click.option("-p", "password", type=str, required=True, help="The password")
198
+ def main__enc__encrypt(**kwargs):
199
+ from ._enc import _encrypt
200
+
201
+ _encrypt(**kwargs)
202
+
203
+
204
+ # MARK: Other utilities
205
+
206
+
207
+ @main.command("random", help="Generate random string")
208
+ @click.option("-l", "length", type=int, default=32, help="Length of the random string")
209
+ @click.option(
210
+ "-a",
211
+ "alphanum",
212
+ is_flag=True,
213
+ default=False,
214
+ help="Use alphanumeric only (a-Z, 0-9)",
215
+ )
216
+ def main__random(**kwargs):
217
+ from ._main import _random
218
+
219
+ _random(**kwargs)
220
+
221
+
222
+ @main.command("unique", help="Get unique values")
223
+ @click.argument("strings", nargs=-1)
224
+ @click.option("-s", "sort", type=bool, is_flag=True, help="Sort the output")
225
+ def main__unique(**kwargs):
226
+ from ._main import _unique
227
+
228
+ _unique(**kwargs)
229
+
230
+
231
+ if __name__ == "__main__":
90
232
  main()