Closed MarkEdmondson1234 closed 5 years ago
Enable this curl
curl -X GET -H "Authorization: Bearer [OAUTH2_TOKEN]" \
"https://www.googleapis.com/storage/v1/b/[BUCKET_NAME]/o?versions=true"
Hi Mark! I'm back again for Octoberfest..Oh wait, Hactoberfest. Anyways, I can tackle this one. Do you think having a separate function for disabling and checking the versioning are necessary or just this one should be sufficient?
Actually, I can probably do the checking first within the enabling function in case its already enabled.
Hooray for Hacktoberfest!
I think it needs another parameter adding to the object functions, which call the generation to get/delete/list, and another argument for the bucket functions to turn on/off/list versioning. Put up some candidates for how it will work R function argument wise before you work on it too much.
Sounds good. Will do.
I think it makes sense to only support these 4 actions in one function (on/off/status/list). My reasoning is that the 4th action ("list") returns what would be required as arguments for the remaining 2 actions of get and delete (namely the GENERATION_NUMBER piece). The first 3 actions just print the results. The 4th will probably return an object (guessing it will return a list or I can coerce it). Anyways, let me know if you have any suggestions/feedback.
# proposed function call examples
bucket_versioning(action = "enable", bucket = "gs://fakebucket")
> gs://[BUCKET_NAME]: Versioning is now on!
bucket_versioning(action = "disable", bucket = "gs://fakebucket")
> gs://[BUCKET_NAME]: Versioning is now off!
bucket_versioning(action = "status", bucket = "gs://fakebucket")
> Checking bucket version status:
> gs://[BUCKET_NAME]: Enabled
bucket_versioning(action = "list", bucket = "gs://fakebucket")
> gs://[BUCKET_NAME]/[OBJECT_NAME1]#[GENERATION_NUMBER1]
> gs://[BUCKET_NAME]/[OBJECT_NAME1]#[GENERATION_NUMBER2]
> gs://[BUCKET_NAME]/[OBJECT_NAME1]#[GENERATION_NUMBER3]
Should I create a new file called versioning.R
in The R folder of the package or add this to an existing file?
Ok cool makes sense.
Yes put it in a new file versioning.R
for easy code reading, and could we just change the function name to gcs_version_bucket
to keep it consistent with the rest.
If I was starting again I would change all the functions to gcs_object_verb
but now we are stuck with gcs_verb_object
:)
Totally get it. Not a problem, best to be consistent with the current naming convention. Will update shortly.
I've made good progress and completed the "status" part of the function. Here is what the output looks like:
> gcs_version_bucket(bucket = Sys.getenv("SAMPLE_BUCKET"), action = "status")
Versioning is NOT ENABLED for "cardinal-path"
For now, I've enabled versioning through gsutil and after enabling it there, this is what it looks like after:
> gcs_version_bucket(bucket = Sys.getenv("SAMPLE_BUCKET"), action = "status")
Versioning is ENABLED for "cardinal-path"
I check for valid/read accesible buckets in the beginning of the function:
> gcs_version_bucket(bucket = "wrong_or_inaccesible_bucket_name", action = "status")
Request failed [404]. Retrying in 1 seconds...
Request failed [404]. Retrying in 1 seconds...
2018-10-19 22:30:41> Request Status Code: 404
Scopes: https://www.googleapis.com/auth/devstorage.full_control
Method: service_json
Error in value[[3L]](cond) :
Bucket not found. Check bucket name and if you have read permissions.
Looked for wrong_or_inaccesible_bucket_name
Need to document this and provide some examples
@MarkEdmondson1234 was thinking of tackling this later in the week, but good to see that you could get to it first. Just curious, how you generated that html documentation? Did you use RStudio and a Rnotebook? Would love to know for any future documentation.
It takes it out of the in-R documentation (e.g. ?gcs_version_bucket
) via the pkgdown documentation package - https://pkgdown.r-lib.org/ Cuts down the work considerably.
Great thanks for the explanation! Makes sense. Why write the same documentation twice.
Buckets can give a history of versions for objects when they are overwritted, activated by this API https://cloud.google.com/storage/docs/using-object-versioning
May be causing this issue ( https://github.com/cloudyr/googleCloudStorageR/issues/95 ) at the moment for buckets that already have it activated.