@@ -18,7 +18,7 @@ from geonoderest.resources import (
18
18
)
19
19
from geonoderest .documents import GeonodeDocumentsHandler
20
20
from geonoderest .maps import GeonodeMapsHandler
21
- from geonoderest .people import GeonodePeopleHandler
21
+ from geonoderest .users import GeonodeUsersHandler
22
22
from geonoderest .geoapps import GeonodeGeoappsHandler
23
23
from geonoderest .uploads import GeonodeUploadsHandler
24
24
from geonoderest .executionrequest import GeonodeExecutionRequestHandler
@@ -224,14 +224,16 @@ To use this tool you have to set the following environment variables before star
224
224
"patch" , help = "patch datasets metadata"
225
225
)
226
226
datasets_patch .add_argument (type = int , dest = "pk" , help = "pk of dataset to patch" )
227
- datasets_patch .add_argument (
227
+ datasets_patch_mutually_exclusive_group = datasets_patch .add_mutually_exclusive_group ()
228
+
229
+ datasets_patch_mutually_exclusive_group .add_argument (
228
230
"--set" ,
229
231
dest = "fields" ,
230
232
type = str ,
231
233
help = 'patch metadata by providing a json string like: \' {"category":"{"identifier": "farming"}}\' ' ,
232
234
)
233
235
234
- datasets_patch .add_argument (
236
+ datasets_patch_mutually_exclusive_group .add_argument (
235
237
"--json_path" ,
236
238
dest = "json_path" ,
237
239
type = str ,
@@ -289,16 +291,22 @@ To use this tool you have to set the following environment variables before star
289
291
)
290
292
291
293
# PATCH
292
- documents_patch = documents_subparsers .add_parser (
293
- "patch " , help = "patch documents metadata"
294
- )
295
- documents_patch . add_argument ( type = int , dest = "pk" , help = "pk of document to patch" )
296
- documents_patch .add_argument (
294
+ documents_patch = documents_subparsers .add_parser ("patch" , help = "patch documents metadata" )
295
+ documents_patch . add_argument ( type = int , dest = "pk " , help = "pk of documents to patch" )
296
+ documents_patch_mutually_exclusive_group = documents_patch . add_mutually_exclusive_group ( )
297
+
298
+ documents_patch_mutually_exclusive_group .add_argument (
297
299
"--set" ,
298
300
dest = "fields" ,
299
301
type = str ,
300
302
help = 'patch metadata by providing a json string like: \' {"category":"{"identifier": "farming"}}\' ' ,
301
303
)
304
+ documents_patch_mutually_exclusive_group .add_argument (
305
+ "--json_path" ,
306
+ dest = "json_path" ,
307
+ type = str ,
308
+ help = "add metadata by providing a path to a json file" ,
309
+ )
302
310
303
311
# DESCRIBE
304
312
documents_describe = documents_subparsers .add_parser (
@@ -329,12 +337,20 @@ To use this tool you have to set the following environment variables before star
329
337
# PATCH
330
338
maps_patch = maps_subparsers .add_parser ("patch" , help = "patch maps metadata" )
331
339
maps_patch .add_argument (type = int , dest = "pk" , help = "pk of map to patch" )
332
- maps_patch .add_argument (
340
+ maps_patch_mutually_exclusive_group = maps .add_mutually_exclusive_group ()
341
+
342
+ maps_patch_mutually_exclusive_group .add_argument (
333
343
"--set" ,
334
344
dest = "fields" ,
335
345
type = str ,
336
346
help = 'patch metadata by providing a json string like: \' {"category":"{"identifier": "farming"}}\' ' ,
337
347
)
348
+ maps_patch_mutually_exclusive_group .add_argument (
349
+ "--json_path" ,
350
+ dest = "json_path" ,
351
+ type = str ,
352
+ help = "add metadata by providing a path to a json file" ,
353
+ )
338
354
339
355
# DESCRIBE
340
356
maps_describe = maps_subparsers .add_parser ("describe" , help = "get map details" )
@@ -347,22 +363,21 @@ To use this tool you have to set the following environment variables before star
347
363
# CREATE
348
364
maps_create = maps_subparsers .add_parser ("create" , help = "create an (empty) map" )
349
365
350
- maps_create .add_argument (
366
+ maps_create_mutually_exclusive_group = maps_create .add_mutually_exclusive_group ()
367
+ maps_create_mutually_exclusive_group .add_argument (
351
368
"--title" ,
352
369
type = str ,
353
- required = True ,
354
370
dest = "title" ,
355
371
help = "title of the new dataset ..." ,
356
372
)
357
-
358
- maps_create .add_argument (
373
+ maps_create_mutually_exclusive_group .add_argument (
359
374
"--set" ,
360
375
dest = "fields" ,
361
376
type = str ,
362
377
help = 'add metadata by providing a json string like: \' \' { "category": {"identifier": "farming"}, "abstract": "test abstract" }\' \' ' ,
363
378
)
364
379
365
- maps_create .add_argument (
380
+ maps_create_mutually_exclusive_group .add_argument (
366
381
"--json_path" ,
367
382
dest = "json_path" ,
368
383
type = str ,
@@ -395,13 +410,22 @@ To use this tool you have to set the following environment variables before star
395
410
"patch" , help = "patch geoapps metadata"
396
411
)
397
412
geoapps_patch .add_argument (type = int , dest = "pk" , help = "pk of geoapp to patch" )
398
- geoapps_patch .add_argument (
413
+
414
+ geoapps_patch_mutually_exclusive_group = geoapps_patch .add_mutually_exclusive_group ()
415
+ geoapps_patch_mutually_exclusive_group .add_argument (
399
416
"--set" ,
400
417
dest = "fields" ,
401
418
type = str ,
402
419
help = 'patch metadata by providing a json string like: \' {"category":"{"identifier": "farming"}}\' ' ,
403
420
)
404
421
422
+ geoapps_patch_mutually_exclusive_group .add_argument (
423
+ "--json_path" ,
424
+ dest = "json_path" ,
425
+ type = str ,
426
+ help = "patch metadata (user credentials) by providing a path to a json file, like --set written in file ..." ,
427
+ )
428
+
405
429
# DESCRIBE
406
430
geoapps_describe = geoapps_subparsers .add_parser (
407
431
"describe" , help = "get geoapp details"
@@ -419,41 +443,50 @@ To use this tool you have to set the following environment variables before star
419
443
##########################
420
444
# USERS ARGUMENT PARSING #
421
445
##########################
422
- people = subparsers .add_parser (
423
- "people " , help = "people| users commands" , aliases = ("users" , " user" )
446
+ users = subparsers .add_parser (
447
+ "users " , help = "user | users commands" , aliases = ("user" , )
424
448
)
425
- people_subparsers = people .add_subparsers (
426
- help = "geonodectl people commands" , dest = "subcommand" , required = True
449
+ users_subparsers = users .add_subparsers (
450
+ help = "geonodectl users commands" , dest = "subcommand" , required = True
427
451
)
428
452
429
453
# PATCH
430
- people_patch = people_subparsers .add_parser ("patch" , help = "patch users metadata" )
431
- people_patch .add_argument (type = int , dest = "pk" , help = "pk of user to patch" )
432
- people_patch .add_argument (
454
+ users_patch = users_subparsers .add_parser ("patch" , help = "patch users metadata" )
455
+ users_patch .add_argument (type = int , dest = "pk" , help = "pk of user to patch" )
456
+
457
+ user_patch_mutually_exclusive_group = users_patch .add_mutually_exclusive_group ()
458
+ user_patch_mutually_exclusive_group .add_argument (
433
459
"--set" ,
434
460
dest = "fields" ,
435
461
type = str ,
436
462
help = 'patch metadata by providing a json string like: \' {"category":"{"identifier": "farming"}}\' ' ,
437
463
)
438
464
465
+ user_patch_mutually_exclusive_group .add_argument (
466
+ "--json_path" ,
467
+ dest = "json_path" ,
468
+ type = str ,
469
+ help = "patch metadata (user credentials) by providing a path to a json file, like --set written in file ..." ,
470
+ )
471
+
439
472
# DESCRIBE
440
- people_describe = people_subparsers .add_parser (
441
- "describe" , help = "get people details"
473
+ users_describe = users_subparsers .add_parser (
474
+ "describe" , help = "get users details"
442
475
)
443
- people_describe .add_argument (
444
- type = int , dest = "pk" , help = "pk of people to describe ..."
476
+ users_describe .add_argument (
477
+ type = int , dest = "pk" , help = "pk of users to describe ..."
445
478
)
446
- people_describe_subgroup = people_describe .add_mutually_exclusive_group (
479
+ users_describe_subgroup = users_describe .add_mutually_exclusive_group (
447
480
required = False
448
481
)
449
- people_describe_subgroup .add_argument (
482
+ users_describe_subgroup .add_argument (
450
483
"--groups" ,
451
484
dest = "user_groups" ,
452
485
required = False ,
453
486
action = "store_true" ,
454
487
help = "show groups of user with given -pk ..." ,
455
488
)
456
- people_describe_subgroup .add_argument (
489
+ users_describe_subgroup .add_argument (
457
490
"--resources" ,
458
491
dest = "user_resources" ,
459
492
required = False ,
@@ -462,11 +495,77 @@ To use this tool you have to set the following environment variables before star
462
495
)
463
496
464
497
# LIST
465
- people_subparsers .add_parser ("list" , help = "list documents" )
498
+ users_subparsers .add_parser ("list" , help = "list documents" )
466
499
467
500
# DELETE
468
- people_delete = people_subparsers .add_parser ("delete" , help = "delete existing user" )
469
- people_delete .add_argument (type = int , dest = "pk" , help = "pk of geoapp to delete ..." )
501
+ users_delete = users_subparsers .add_parser ("delete" , help = "delete existing user" )
502
+ users_delete .add_argument (type = int , dest = "pk" , help = "pk of geoapp to delete ..." )
503
+
504
+ # CREATE
505
+ users_create = users_subparsers .add_parser ("create" , help = "create a new user" )
506
+ user_create_mutually_exclusive_group = users_create .add_mutually_exclusive_group ()
507
+ user_create_mutually_exclusive_group .add_argument (
508
+ "--username" ,
509
+ type = str ,
510
+ dest = "username" ,
511
+ help = "username of the new user ... (mutually exclusive [a])" ,
512
+ )
513
+
514
+ users_create .add_argument (
515
+ "--email" ,
516
+ type = str ,
517
+ required = False ,
518
+ dest = "email" ,
519
+ help = "email of the new user ... (only working combined with --username) ..." ,
520
+ )
521
+
522
+ users_create .add_argument (
523
+ "--first_name" ,
524
+ type = str ,
525
+ required = False ,
526
+ dest = "first_name" ,
527
+ help = "first_name of the new user (only working combined with --username) ..." ,
528
+ )
529
+
530
+ users_create .add_argument (
531
+ "--last_name" ,
532
+ type = str ,
533
+ required = False ,
534
+ dest = "last_name" ,
535
+ help = "last_name of the new user (only working combined with --username) ..." ,
536
+ )
537
+
538
+ users_create .add_argument (
539
+ "--is_superuser" ,
540
+ action = 'store_true' ,
541
+ required = False ,
542
+ dest = "is_superuser" ,
543
+ default = False ,
544
+ help = "set to make the new user a superuser (only working combined with --username) ..." ,
545
+ )
546
+
547
+ users_create .add_argument (
548
+ "--is_staff" ,
549
+ action = 'store_true' ,
550
+ required = False ,
551
+ dest = "is_staff" ,
552
+ default = False ,
553
+ help = "set to make the new user a staff user (only working combined with --username) ..." ,
554
+ )
555
+
556
+ user_create_mutually_exclusive_group .add_argument (
557
+ "--json_path" ,
558
+ dest = "json_path" ,
559
+ type = str ,
560
+ help = "add metadata (user credentials) by providing a path to a json file, like --set written in file ...(mutually exclusive [b])" ,
561
+ )
562
+
563
+ user_create_mutually_exclusive_group .add_argument (
564
+ "--set" ,
565
+ dest = "fields" ,
566
+ type = str ,
567
+ help = 'create user by providing a json string like: \' {"username":"test_user", "email":"[email protected] ", "first_name": "test_first_name", "last_name":"test_last_name", "is_staff": true, "is_superuser": true}\' ... (mutually exclusive [c])' ,
568
+ )
470
569
471
570
###########################
472
571
# UPLOAD ARGUMENT PARSING #
@@ -530,8 +629,8 @@ To use this tool you have to set the following environment variables before star
530
629
g_obj = GeonodeDocumentsHandler (env = geonode_env )
531
630
case "maps" :
532
631
g_obj = GeonodeMapsHandler (env = geonode_env )
533
- case "people" | " users" | "user" :
534
- g_obj = GeonodePeopleHandler (env = geonode_env )
632
+ case "users" | "user" :
633
+ g_obj = GeonodeUsersHandler (env = geonode_env )
535
634
case "geoapps" | "apps" :
536
635
g_obj = GeonodeGeoappsHandler (env = geonode_env )
537
636
case "uploads" :
@@ -540,7 +639,6 @@ To use this tool you have to set the following environment variables before star
540
639
g_obj = GeonodeExecutionRequestHandler (env = geonode_env )
541
640
case _:
542
641
raise NotImplemented
543
-
544
642
g_obj_func = getattr (g_obj , "cmd_" + args .subcommand )
545
643
g_obj_func (** args .__dict__ )
546
644
0 commit comments