Skip to content

Commit

Permalink
feat(cli): added include-users option for group and org dump/load;
Browse files Browse the repository at this point in the history
- Added `--include-users` argument for group and org dump/load.
  • Loading branch information
JVickery-TBS committed Aug 22, 2023
1 parent bda19c1 commit f136ba0
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
5 changes: 5 additions & 0 deletions ckanapi/cli/dump.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,13 @@ def reply(error, record=None):
requests_kwargs = None
if arguments['--insecure']:
requests_kwargs = {'verify': False}
include_users = False
if arguments['--include-users']:
include_users = True
obj = ckan.call_action(thing_show, {'id': name,
'include_datasets': False,
'include_password_hash': True,
'include_users': include_users,
}, requests_kwargs=requests_kwargs)
except NotFound:
reply('NotFound')
Expand Down Expand Up @@ -210,6 +214,7 @@ def b(name):
+ b('--get-request')
+ b('--datastore-fields')
+ b('--resource-views')
+ b('--include-users')
+ ['value-here-to-make-docopt-happy']
)

Expand Down
6 changes: 6 additions & 0 deletions ckanapi/cli/load.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,10 @@ def reply(action, error, response):
if arguments['--insecure']:
requests_kwargs = {'verify': False}

include_users = False
if arguments['--include-users']:
include_users = True

if obj is not None:
existing = None
if not arguments['--create-only']:
Expand All @@ -185,6 +189,7 @@ def reply(action, error, response):
{'id': name,
'include_datasets': False,
'include_password_hash': True,
'include_users': include_users,
},
requests_kwargs=requests_kwargs)
except NotFound:
Expand Down Expand Up @@ -261,6 +266,7 @@ def b(name):
+ b('--update-only')
+ b('--upload-resources')
+ b('--upload-logo')
+ b('--include-users')
)


Expand Down
5 changes: 3 additions & 2 deletions ckanapi/cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@
[[-c CONFIG] [-u USER] | -r SITE_URL [-a APIKEY] [--insecure]]
ckanapi dump (datasets | groups | organizations | users | related)
(ID_OR_NAME ... | --all) ([-O JSONL_OUTPUT] | [-D DIRECTORY])
[-p PROCESSES] [-dqwzR]
[-p PROCESSES] [-dqwzRU]
[[-c CONFIG] [-u USER] | -r SITE_URL [-a APIKEY] [-g] [--insecure]]
ckanapi load datasets
[--upload-resources] [-I JSONL_INPUT] [-s START] [-m MAX]
[-p PROCESSES] [-l LOG_FILE] [-n | -o] [-qwz]
[[-c CONFIG] [-u USER] | -r SITE_URL [-a APIKEY] [--insecure]]
ckanapi load (groups | organizations)
[--upload-logo] [-I JSONL_INPUT] [-s START] [-m MAX]
[-p PROCESSES] [-l LOG_FILE] [-n | -o] [-qwz]
[-p PROCESSES] [-l LOG_FILE] [-n | -o] [-qwzU]
[[-c CONFIG] [-u USER] | -r SITE_URL [-a APIKEY] [--insecure]]
ckanapi load (users | related)
[-I JSONL_INPUT] [-s START] [-m MAX] [-p PROCESSES] [-l LOG_FILE]
Expand Down Expand Up @@ -70,6 +70,7 @@
record is number 1 [default: 1]
-u --ckan-user=USER perform actions as user with this name, uses the
site sysadmin user when not specified
-U --include-users include users of a group/organization
--upload-logo upload logo image of a group/organization if the
image is stored in the original server, otherwise
its image url will be used
Expand Down

0 comments on commit f136ba0

Please sign in to comment.