@@ -26,9 +26,7 @@ use colored::Colorize;
26
26
use itertools:: Itertools ;
27
27
use quickwit_common:: uri:: Uri ;
28
28
use quickwit_common:: GREEN_COLOR ;
29
- use quickwit_config:: {
30
- validate_identifier, ConfigFormat , SourceConfig , CLI_INGEST_SOURCE_ID , INGEST_API_SOURCE_ID ,
31
- } ;
29
+ use quickwit_config:: { validate_identifier, ConfigFormat , SourceConfig } ;
32
30
use quickwit_metastore:: checkpoint:: SourceCheckpoint ;
33
31
use quickwit_rest_client:: rest_client:: { QuickwitClient , Transport } ;
34
32
use quickwit_storage:: load_file;
@@ -143,13 +141,6 @@ pub struct ToggleSourceArgs {
143
141
pub enable : bool ,
144
142
}
145
143
146
- #[ derive( Debug , Eq , PartialEq ) ]
147
- pub struct ToggleIngestApiArgs {
148
- pub cluster_endpoint : Url ,
149
- pub index_id : String ,
150
- pub enable : bool ,
151
- }
152
-
153
144
#[ derive( Debug , Eq , PartialEq ) ]
154
145
pub struct DeleteSourceArgs {
155
146
pub cluster_endpoint : Url ,
@@ -183,7 +174,6 @@ pub struct ResetCheckpointArgs {
183
174
pub enum SourceCliCommand {
184
175
CreateSource ( CreateSourceArgs ) ,
185
176
ToggleSource ( ToggleSourceArgs ) ,
186
- ToggleIngestApi ( ToggleIngestApiArgs ) ,
187
177
DeleteSource ( DeleteSourceArgs ) ,
188
178
DescribeSource ( DescribeSourceArgs ) ,
189
179
ListSources ( ListSourcesArgs ) ,
@@ -195,7 +185,6 @@ impl SourceCliCommand {
195
185
match self {
196
186
Self :: CreateSource ( args) => create_source_cli ( args) . await ,
197
187
Self :: ToggleSource ( args) => toggle_source_cli ( args) . await ,
198
- Self :: ToggleIngestApi ( args) => toggle_ingest_api_cli ( args) . await ,
199
188
Self :: DeleteSource ( args) => delete_source_cli ( args) . await ,
200
189
Self :: DescribeSource ( args) => describe_source_cli ( args) . await ,
201
190
Self :: ListSources ( args) => list_sources_cli ( args) . await ,
@@ -215,9 +204,6 @@ impl SourceCliCommand {
215
204
"disable" => {
216
205
Self :: parse_toggle_source_args ( subcommand, submatches) . map ( Self :: ToggleSource )
217
206
}
218
- "ingest-api" => {
219
- Self :: parse_toggle_ingest_api_args ( submatches) . map ( Self :: ToggleIngestApi )
220
- }
221
207
"delete" => Self :: parse_delete_args ( submatches) . map ( Self :: DeleteSource ) ,
222
208
"describe" => Self :: parse_describe_args ( submatches) . map ( Self :: DescribeSource ) ,
223
209
"list" => Self :: parse_list_args ( submatches) . map ( Self :: ListSources ) ,
@@ -273,23 +259,6 @@ impl SourceCliCommand {
273
259
} )
274
260
}
275
261
276
- fn parse_toggle_ingest_api_args ( matches : & ArgMatches ) -> anyhow:: Result < ToggleIngestApiArgs > {
277
- let cluster_endpoint = matches
278
- . value_of ( "endpoint" )
279
- . map ( Url :: from_str)
280
- . expect ( "`endpoint` is a required arg." ) ?;
281
- let index_id = matches
282
- . value_of ( "index" )
283
- . expect ( "`index` is a required arg." )
284
- . to_string ( ) ;
285
- let enable = matches. is_present ( "enable" ) ;
286
- Ok ( ToggleIngestApiArgs {
287
- cluster_endpoint,
288
- index_id,
289
- enable,
290
- } )
291
- }
292
-
293
262
fn parse_delete_args ( matches : & ArgMatches ) -> anyhow:: Result < DeleteSourceArgs > {
294
263
let cluster_endpoint = matches
295
264
. value_of ( "endpoint" )
@@ -388,13 +357,6 @@ async fn create_source_cli(args: CreateSourceArgs) -> anyhow::Result<()> {
388
357
async fn toggle_source_cli ( args : ToggleSourceArgs ) -> anyhow:: Result < ( ) > {
389
358
debug ! ( args=?args, "toggle-source" ) ;
390
359
println ! ( "❯ Toggling source..." ) ;
391
- if args. source_id == CLI_INGEST_SOURCE_ID {
392
- bail ! (
393
- "Source `{}` is managed by Quickwit, you cannot enable or disable a source managed by \
394
- Quickwit.",
395
- args. source_id
396
- ) ;
397
- }
398
360
let transport = Transport :: new ( args. cluster_endpoint ) ;
399
361
let qw_client = QuickwitClient :: new ( transport) ;
400
362
qw_client
@@ -412,37 +374,9 @@ async fn toggle_source_cli(args: ToggleSourceArgs) -> anyhow::Result<()> {
412
374
Ok ( ( ) )
413
375
}
414
376
415
- pub async fn toggle_ingest_api_cli ( args : ToggleIngestApiArgs ) -> anyhow:: Result < ( ) > {
416
- debug ! ( args=?args, "toggle-ingest-api" ) ;
417
- println ! (
418
- "❯ {}abling ingest API..." ,
419
- if args. enable { "En" } else { "Dis" }
420
- ) ;
421
- let transport = Transport :: new ( args. cluster_endpoint ) ;
422
- let qw_client = QuickwitClient :: new ( transport) ;
423
- qw_client
424
- . sources ( & args. index_id )
425
- . toggle ( INGEST_API_SOURCE_ID , args. enable )
426
- . await
427
- . context ( "Failed to update source" ) ?;
428
- let toggled_state_name = if args. enable { "enabled" } else { "disabled" } ;
429
- println ! (
430
- "{} Source successfully {}." ,
431
- toggled_state_name,
432
- "✔" . color( GREEN_COLOR )
433
- ) ;
434
- Ok ( ( ) )
435
- }
436
-
437
377
async fn delete_source_cli ( args : DeleteSourceArgs ) -> anyhow:: Result < ( ) > {
438
378
debug ! ( args=?args, "delete-source" ) ;
439
379
println ! ( "❯ Deleting source..." ) ;
440
- if args. source_id == INGEST_API_SOURCE_ID || args. source_id == CLI_INGEST_SOURCE_ID {
441
- bail ! (
442
- "Source `{}` is managed by Quickwit, you cannot delete a source managed by Quickwit." ,
443
- args. source_id
444
- ) ;
445
- }
446
380
validate_identifier ( "Source ID" , & args. source_id ) ?;
447
381
448
382
if !args. assume_yes {
@@ -735,63 +669,6 @@ mod tests {
735
669
}
736
670
}
737
671
738
- #[ test]
739
- fn test_parse_toggle_ingest_api_args ( ) {
740
- {
741
- let app = build_cli ( ) . no_binary_name ( true ) ;
742
- let matches = app
743
- . try_get_matches_from ( vec ! [
744
- "source" ,
745
- "ingest-api" ,
746
- "--endpoint" ,
747
- "https://quickwit-cluster.io" ,
748
- "--index" ,
749
- "foo" ,
750
- "--enable" ,
751
- ] )
752
- . unwrap ( ) ;
753
- let command = CliCommand :: parse_cli_args ( & matches) . unwrap ( ) ;
754
- let expected_command =
755
- CliCommand :: Source ( SourceCliCommand :: ToggleIngestApi ( ToggleIngestApiArgs {
756
- cluster_endpoint : Url :: from_str ( "https://quickwit-cluster.io" ) . unwrap ( ) ,
757
- index_id : "foo" . to_string ( ) ,
758
- enable : true ,
759
- } ) ) ;
760
- assert_eq ! ( command, expected_command) ;
761
- }
762
- {
763
- let app = build_cli ( ) . no_binary_name ( true ) ;
764
- let matches = app
765
- . try_get_matches_from ( vec ! [ "source" , "ingest-api" , "--index" , "foo" , "--disable" ] )
766
- . unwrap ( ) ;
767
- let command = CliCommand :: parse_cli_args ( & matches) . unwrap ( ) ;
768
- let expected_command =
769
- CliCommand :: Source ( SourceCliCommand :: ToggleIngestApi ( ToggleIngestApiArgs {
770
- cluster_endpoint : Url :: from_str ( "http://127.0.0.1:7280" ) . unwrap ( ) ,
771
- index_id : "foo" . to_string ( ) ,
772
- enable : false ,
773
- } ) ) ;
774
- assert_eq ! ( command, expected_command) ;
775
- }
776
- {
777
- let app = build_cli ( ) . no_binary_name ( true ) ;
778
- let matches = app. try_get_matches_from ( vec ! [
779
- "source" ,
780
- "ingest-api" ,
781
- "--index" ,
782
- "foo" ,
783
- "--enable" ,
784
- "--disable" ,
785
- ] ) ;
786
- assert ! ( matches. is_err( ) ) ;
787
- }
788
- {
789
- let app = build_cli ( ) . no_binary_name ( true ) ;
790
- let matches = app. try_get_matches_from ( vec ! [ "source" , "ingest-api" , "--index" , "foo" ] ) ;
791
- assert ! ( matches. is_err( ) ) ;
792
- }
793
- }
794
-
795
672
#[ test]
796
673
fn test_parse_delete_source_args ( ) {
797
674
let app = build_cli ( ) . no_binary_name ( true ) ;
0 commit comments