MCPcopy Create free account
hub / github.com/apache/arrow / fs___GcsFileSystem__Make

Function fs___GcsFileSystem__Make

r/src/filesystem.cpp:391–462  ·  view source on GitHub ↗

[[gcs::export]]

Source from the content-addressed store, hash-verified

389
390// [[gcs::export]]
391std::shared_ptr<fs::GcsFileSystem> fs___GcsFileSystem__Make(bool anonymous,
392 cpp11::list options) {
393 fs::GcsOptions gcs_opts;
394
395 // Handle auth (anonymous, credentials, default)
396 // (validation/internal coherence handled in R)
397 if (anonymous) {
398 gcs_opts = fs::GcsOptions::Anonymous();
399 } else if (!Rf_isNull(options["access_token"])) {
400 // Convert POSIXct timestamp seconds to nanoseconds
401 std::chrono::nanoseconds ns_count(
402 static_cast<int64_t>(cpp11::as_cpp<double>(options["expiration"])) * 1000000000);
403 auto expiration_timepoint =
404 fs::TimePoint(std::chrono::duration_cast<fs::TimePoint::duration>(ns_count));
405 gcs_opts = fs::GcsOptions::FromAccessToken(
406 cpp11::as_cpp<std::string>(options["access_token"]), expiration_timepoint);
407 // TODO(ARROW-16885): implement FromImpersonatedServiceAccount
408 // } else if (base_credentials != "") {
409 // // static GcsOptions FromImpersonatedServiceAccount(
410 // // const GcsCredentials& base_credentials, const std::string&
411 // target_service_account);
412 // // TODO: construct GcsCredentials
413 // gcs_opts = fs::GcsOptions::FromImpersonatedServiceAccount(base_credentials,
414 // target_service_account);
415 } else if (!Rf_isNull(options["json_credentials"])) {
416 gcs_opts = fs::GcsOptions::FromServiceAccountCredentials(
417 cpp11::as_cpp<std::string>(options["json_credentials"]));
418 } else {
419 gcs_opts = fs::GcsOptions::Defaults();
420 }
421
422 // Handle other attributes
423 if (!Rf_isNull(options["endpoint_override"])) {
424 gcs_opts.endpoint_override = cpp11::as_cpp<std::string>(options["endpoint_override"]);
425 }
426
427 if (!Rf_isNull(options["scheme"])) {
428 gcs_opts.scheme = cpp11::as_cpp<std::string>(options["scheme"]);
429 }
430
431 // /// \brief Location to use for creating buckets.
432 if (!Rf_isNull(options["default_bucket_location"])) {
433 gcs_opts.default_bucket_location =
434 cpp11::as_cpp<std::string>(options["default_bucket_location"]);
435 }
436 // /// \brief If set used to control total time allowed for retrying underlying
437 // /// errors.
438 // ///
439 // /// The default policy is to retry for up to 15 minutes.
440 if (!Rf_isNull(options["retry_limit_seconds"])) {
441 gcs_opts.retry_limit_seconds = cpp11::as_cpp<double>(options["retry_limit_seconds"]);
442 }
443
444 // /// \brief Default metadata for OpenOutputStream.
445 // ///
446 // /// This will be ignored if non-empty metadata is passed to OpenOutputStream.
447 if (!Rf_isNull(options["default_metadata"])) {
448 gcs_opts.default_metadata = strings_to_kvm(options["default_metadata"]);

Callers 1

Calls 5

strings_to_kvmFunction · 0.85
ValueOrStopFunction · 0.85
CancellableIOContextMethod · 0.80
DefaultsFunction · 0.50
MakeFunction · 0.50

Tested by

no test coverage detected