ropensci / datapack

An R package to handle data packages
https://docs.ropensci.org/datapack
44 stars 9 forks source link

Add the ability to clear out System Metadata access policy rules #56

Closed amoeba closed 8 years ago

amoeba commented 8 years ago

This kinda relates to #31

I ran into the use case today where I wanted to clear out the already-set accessPolicy rules in an existing sysmeta. So I ran:

sm <- getSystemMetdata(mn, ...)
slot(sm, "accessPolicy") <- data.frame()

and then I could run:

sm <- addAccessRule(sm, user, c("read", "write", "changePermission"))
etc
etc

to set my rules.

Is this the only way to do this right now? If so, I don't think this is the most user-friendly interface. It would be great if I could clear all of the rules and start from scratch without having to use the slot() function with a data.frame (which I'm assuming might confuse some users).

There are probably a few good ways to approach this change, neither one being mutually exclusive:

  1. Write a clearAccessPolicy() or clearAccessRules function which clears all of the rules
  2. Write a setAccessPolicy() function that takes a data.frame with all of the rules you want and overwrites any existing ones
  3. Overload addAccessRule with an extra parameter clear or replace (default: FALSE) which, if TRUE, clears the set of access rules before adding the rule

What do you think @gothub ?

gothub commented 8 years ago

@amoeba clearAccessPolicy() sounds great to me and seems the clearest; setAccessPolicy() seems a bit redundant as addAccessRule() can add multiple rules; and addAccessRule() is maybe a little confusing as you are really clearing the access policy.

amoeba commented 8 years ago

Sounds good to me. Do you have time to implement? I could do it if not.

gothub commented 8 years ago

@amoeba If you have the cycles, please go ahead. I'll look out for a PR :)

amoeba commented 8 years ago

Sounds good. I'll try to get to it tonight.