-
Notifications
You must be signed in to change notification settings - Fork 106
/
Copy pathcli.py
270 lines (196 loc) · 8.18 KB
/
cli.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
#!/usr/bin/env python
import click
import logging
import manage
from flask.cli import FlaskGroup
from webservices.common import models
from webservices.rest import app, db
import webservices.legal_docs as legal_docs
from webservices.legal_docs.es_management import CASE_REPO, CASE_INDEX
cli = FlaskGroup(app)
logger = logging.getLogger("cli")
@app.cli.command('load_statutes')
def load_statutes_cli():
legal_docs.load_statutes()
@app.cli.command('load_advisory_opinions')
@click.argument('from_ao_no', default=None, required=False)
def load_advisory_opinions_cli(from_ao_no):
legal_docs.load_advisory_opinions(from_ao_no)
@app.cli.command('load_current_murs')
@click.argument('specific_mur_no', default=None, required=False)
def load_current_murs_cli(specific_mur_no):
legal_docs.load_current_murs(specific_mur_no)
@app.cli.command('load_adrs')
@click.argument('specific_adr_no', default=None, required=False)
def load_adrs_cli(specific_adr_no):
legal_docs.load_adrs(specific_adr_no)
@app.cli.command('load_admin_fines')
@click.argument('specific_af_no', default=None, required=False)
def load_admin_fines_cli(specific_af_no):
legal_docs.load_admin_fines(specific_af_no)
@app.cli.command('load_archived_murs')
@click.argument('mur_no', default=None, required=False)
def load_archived_murs_cli(mur_no):
legal_docs.load_archived_murs(mur_no)
@app.cli.command('extract_pdf_text')
@click.argument('mur_no', default=None, required=False)
def extract_pdf_text_cli(mur_no):
legal_docs.extract_pdf_text(mur_no)
@app.cli.command('delete_doctype_from_es')
@click.argument('index_name', default=None, required=False)
@click.argument('doc_type', default=None, required=False)
def delete_doctype_from_es_cli(index_name, doc_type):
legal_docs.delete_doctype_from_es(index_name, doc_type)
@app.cli.command('delete_single_doctype_from_es')
@click.argument('index_name', default=None, required=False)
@click.argument('doc_type', default=None, required=False)
@click.argument('num_doc_id', default=None, required=False)
def delete_single_doctype_from_es_cli(index_name, doc_type, num_doc_id):
legal_docs.delete_single_doctype_from_es(index_name, doc_type, num_doc_id)
@app.cli.command('delete_murs_from_s3')
def delete_murs_from_s3_cli():
legal_docs.delete_murs_from_s3()
@app.cli.command('show_legal_data')
def show_legal_data_cli():
legal_docs.show_legal_data()
@app.cli.command('create_index')
@click.argument('index_name', default=None, required=False)
def create_index_cli(index_name):
legal_docs.create_index(index_name)
@app.cli.command('delete_index')
@click.argument('index_name', required=True)
def delete_index_cli(index_name):
legal_docs.delete_index(index_name)
@app.cli.command('display_index_alias')
def display_index_alias_cli():
legal_docs.display_index_alias()
@app.cli.command('display_mapping')
@click.argument('index_name', default=None, required=False)
def display_mapping_cli(index_name):
legal_docs.display_mapping(index_name)
@app.cli.command('reload_all_data_by_index')
@click.argument('index_name', default=None, required=False)
def reload_all_data_by_index_cli(index_name):
legal_docs.reload_all_data_by_index(index_name)
@app.cli.command('initialize_legal_data')
@click.argument('index_name', default=None, required=False)
def initialize_legal_data_cli(index_name):
legal_docs.initialize_legal_data(index_name)
@app.cli.command('update_mapping_and_reload_legal_data')
@click.argument('index_name', default=None, required=False)
def update_mapping_and_reload_legal_data_cli(index_name):
legal_docs.update_mapping_and_reload_legal_data(index_name)
@app.cli.command('configure_snapshot_repository')
@click.argument('repo_name', default=CASE_REPO, required=False)
def configure_snapshot_repository_cli(repo_name):
legal_docs.configure_snapshot_repository(repo_name)
@app.cli.command('delete_repository')
@click.argument('repo_name', required=True)
def delete_repository_cli(repo_name):
legal_docs.delete_repository(repo_name)
@app.cli.command('display_repositories')
def display_repositories_cli():
legal_docs.display_repositories()
@app.cli.command('create_es_snapshot')
@click.argument('index_name', default=CASE_INDEX, required=False)
def create_es_snapshot_cli(index_name):
legal_docs.create_es_snapshot(index_name)
@app.cli.command('restore_es_snapshot')
@click.argument('repo_name', default=None, required=False)
@click.argument('snapshot_name', default=None, required=False)
@click.argument('index_name', default=None, required=False)
def restore_es_snapshot_cli(repo_name, snapshot_name, index_name):
legal_docs.restore_es_snapshot(repo_name, snapshot_name, index_name)
@app.cli.command('restore_es_snapshot_downtime')
@click.argument('repo_name', default=None, required=False)
@click.argument('snapshot_name', default=None, required=False)
@click.argument('index_name', default=None, required=False)
def restore_es_snapshot_downtime_cli(repo_name, snapshot_name, index_name):
legal_docs.restore_es_snapshot_downtime(repo_name, snapshot_name, index_name)
@app.cli.command('delete_snapshot')
@click.argument('repo_name', default=None, required=False)
@click.argument('snapshot_name', default=None, required=False)
def delete_snapshot_cli(repo_name, snapshot_name):
legal_docs.delete_snapshot(repo_name, snapshot_name)
@app.cli.command('display_snapshots')
@click.argument('repo_name', default=None, required=False)
def display_snapshots_cli(repo_name):
legal_docs.display_snapshots(repo_name)
@app.cli.command('display_snapshot_detail')
@click.argument('repo_name', default=None, required=False)
@click.argument('snapshot_name', default=None, required=False)
def display_snapshot_detail_cli(repo_name, snapshot_name):
legal_docs.display_snapshot_detail(repo_name, snapshot_name)
@app.cli.command('refresh_materialized')
@click.argument('concurrent', default=True, type=bool)
def refresh_materialized_cli(concurrent=True):
manage.refresh_materialized()
@app.cli.command('cf_startup')
def cf_startup_cli():
manage.cf_startup()
@app.cli.command('update_public_api_key')
@click.argument('space', default=None, required=True)
@click.argument('service_instance_name', default=None, required=True)
@click.argument('token', default=None, required=True)
@click.argument('first_rate_limit', default=250, required=False)
@click.argument('first_rate_limit_duration', default=60000, required=False)
@click.argument('second_rate_limit', default=30000, required=False)
@click.argument('second_rate_limit_duration', default=86400000, required=False)
def create_and_update_public_api_key_cli(
space,
service_instance_name,
token,
first_rate_limit,
first_rate_limit_duration,
second_rate_limit,
second_rate_limit_duration):
manage.create_and_update_public_api_key(
space,
service_instance_name,
token,
first_rate_limit,
first_rate_limit_duration,
second_rate_limit,
second_rate_limit_duration)
@app.cli.command('remove_env_var')
@click.argument('space', default=None, required=True)
@click.argument('service_instance_name', default=None, required=True)
@click.argument('key_to_remove', required=True)
@click.argument('token', default=None, required=True)
def remove_env_var_cli(
space,
service_instance_name,
key_to_remove,
token):
manage.remove_env_var(
space,
service_instance_name,
key_to_remove,
token)
@app.cli.command('add_update_env_var')
@click.argument('space', default=None, required=True)
@click.argument('service_instance_name', default=None, required=True)
@click.argument('key', required=True)
@click.argument('value', required=True)
@click.argument('token', default=None, required=True)
def add_update_env_var_cli(
space,
service_instance_name,
key,
value,
token):
manage.add_update_env_var(
space,
service_instance_name,
key,
value,
token)
@app.cli.command('slack_message')
@click.argument('message')
def slack_message_cli(message):
manage.slack_message(message)
@app.shell_context_processor
def make_shell_context():
return {'app': app, 'db': db, 'models': models}
if __name__ == "__main__":
cli()