Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor fixes for private datasets #145

Merged
merged 3 commits into from
Nov 1, 2019
Merged

Minor fixes for private datasets #145

merged 3 commits into from
Nov 1, 2019

Conversation

LTLA
Copy link
Contributor

@LTLA LTLA commented Oct 31, 2019

The problem

On one of our internal CKAN instances, we have private datasets that do not behave properly upon attempts to _show or _patch them, even when the key is supplied.

library(ckanr)
key <- "XXXXX"
package_search("my_package", url="https://some_ckan_location.com", key=key)
## Error: 403 - Authorization Error
##   message Access denied: User  not authorized to read package BLAH-BLAH-BLAH

Some detective work suggests that the as.ckan_package() is trying to convert character strings into package objects but lacks the authorization to do so as the key is not passed.

Solution

Pass the key to as.ckan_package(). I have only done this for the subset of functions that I actually needed for my day-to-day work, but it seems that it would be necessary for all functions.

Incidentally, I also took the liberty of adding a private= argument to package_create() so that I could easily create private packages. It works pretty well, but I'm not sure how you would like this to be tested; I don't want to spawn private repositories all over someone else's CKAN instance.

@sckott
Copy link
Contributor

sckott commented Nov 1, 2019

thanks very much @LTLA

Playing around with your branch, i'm testing package_create with private var, and it appears that you need to pass an organization if private=TRUE. Do you agree on that?, e.g,. this works

org <- organization_create("foobar2342234", title = "Foo bars", description = "love foo bars")
package_create("foobar4", author="Jane Doe", private=TRUE, owner_org = org$id)

But if i just tried package_create("foobar4", author="Jane Doe", private=TRUE) it fails for me saying an organization is needed.

If your agreed on this, please update the parameter definition for private describing this.

We could also check if a user passes an organization id or not if we see that private=TRUE, and stop with message if there's no org id passed - OR we could let the CKAN instance error message do that work as it does right now


for testing, we don't really have a great setup right now - i've been wanting to be able to spin up a test CKAN instance on travis/circle-ci, but haven't figured it out yet.


the other changes for as.package look good. opened an issue for the rest of the pkg #146

@LTLA
Copy link
Contributor Author

LTLA commented Nov 1, 2019

Do you agree on that?

Thanks, yes, I hadn't noticed - documentation updated.

we could let the CKAN instance error message do that work as it does right now

Makes sense.

@sckott
Copy link
Contributor

sckott commented Nov 1, 2019

thanks

@sckott sckott merged commit bf0fa55 into ropensci:master Nov 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants