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

Function fs___GcsFileSystem__Make

r/src/filesystem.cpp:366–437  ·  view source on GitHub ↗

[[gcs::export]]

Source from the content-addressed store, hash-verified

364
365// [[gcs::export]]
366std::shared_ptr<fs::GcsFileSystem> fs___GcsFileSystem__Make(bool anonymous,
367 cpp11::list options) {
368 fs::GcsOptions gcs_opts;
369
370 // Handle auth (anonymous, credentials, default)
371 // (validation/internal coherence handled in R)
372 if (anonymous) {
373 gcs_opts = fs::GcsOptions::Anonymous();
374 } else if (!Rf_isNull(options["access_token"])) {
375 // Convert POSIXct timestamp seconds to nanoseconds
376 std::chrono::nanoseconds ns_count(
377 static_cast<int64_t>(cpp11::as_cpp<double>(options["expiration"])) * 1000000000);
378 auto expiration_timepoint =
379 fs::TimePoint(std::chrono::duration_cast<fs::TimePoint::duration>(ns_count));
380 gcs_opts = fs::GcsOptions::FromAccessToken(
381 cpp11::as_cpp<std::string>(options["access_token"]), expiration_timepoint);
382 // TODO(ARROW-16885): implement FromImpersonatedServiceAccount
383 // } else if (base_credentials != "") {
384 // // static GcsOptions FromImpersonatedServiceAccount(
385 // // const GcsCredentials& base_credentials, const std::string&
386 // target_service_account);
387 // // TODO: construct GcsCredentials
388 // gcs_opts = fs::GcsOptions::FromImpersonatedServiceAccount(base_credentials,
389 // target_service_account);
390 } else if (!Rf_isNull(options["json_credentials"])) {
391 gcs_opts = fs::GcsOptions::FromServiceAccountCredentials(
392 cpp11::as_cpp<std::string>(options["json_credentials"]));
393 } else {
394 gcs_opts = fs::GcsOptions::Defaults();
395 }
396
397 // Handle other attributes
398 if (!Rf_isNull(options["endpoint_override"])) {
399 gcs_opts.endpoint_override = cpp11::as_cpp<std::string>(options["endpoint_override"]);
400 }
401
402 if (!Rf_isNull(options["scheme"])) {
403 gcs_opts.scheme = cpp11::as_cpp<std::string>(options["scheme"]);
404 }
405
406 // /// \brief Location to use for creating buckets.
407 if (!Rf_isNull(options["default_bucket_location"])) {
408 gcs_opts.default_bucket_location =
409 cpp11::as_cpp<std::string>(options["default_bucket_location"]);
410 }
411 // /// \brief If set used to control total time allowed for retrying underlying
412 // /// errors.
413 // ///
414 // /// The default policy is to retry for up to 15 minutes.
415 if (!Rf_isNull(options["retry_limit_seconds"])) {
416 gcs_opts.retry_limit_seconds = cpp11::as_cpp<double>(options["retry_limit_seconds"]);
417 }
418
419 // /// \brief Default metadata for OpenOutputStream.
420 // ///
421 // /// This will be ignored if non-empty metadata is passed to OpenOutputStream.
422 if (!Rf_isNull(options["default_metadata"])) {
423 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