|
15 | 15 | #ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_STORAGE_CLIENT_H |
16 | 16 | #define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_STORAGE_CLIENT_H |
17 | 17 |
|
| 18 | +#include "google/cloud/storage/client_options.h" |
18 | 19 | #include "google/cloud/storage/hmac_key_metadata.h" |
19 | 20 | #include "google/cloud/storage/internal/policy_document_request.h" |
20 | 21 | #include "google/cloud/storage/internal/request_project_id.h" |
@@ -3421,79 +3422,6 @@ class Client { |
3421 | 3422 | } |
3422 | 3423 | ///@} |
3423 | 3424 |
|
3424 | | - /** |
3425 | | - * Creates the default client type given the options. |
3426 | | - * |
3427 | | - * @param options the client options, these are used to control credentials, |
3428 | | - * buffer sizes, etc. |
3429 | | - * @param policies the client policies, these control the behavior of the |
3430 | | - * client, for example, how to backoff when an operation needs to be |
3431 | | - * retried, or what operations cannot be retried because they are not |
3432 | | - * idempotent. |
3433 | | - * |
3434 | | - * @deprecated use the constructor from `google::cloud::Options` instead. |
3435 | | - */ |
3436 | | - template <typename... Policies> |
3437 | | - explicit Client(ClientOptions options, Policies&&... policies) |
3438 | | - : Client(InternalOnly{}, internal::ApplyPolicies( |
3439 | | - internal::MakeOptions(std::move(options)), |
3440 | | - std::forward<Policies>(policies)...)) {} |
3441 | | - |
3442 | | - /** |
3443 | | - * Creates the default client type given the credentials and policies. |
3444 | | - * |
3445 | | - * @param credentials a set of credentials to initialize the `ClientOptions`. |
3446 | | - * @param policies the client policies, these control the behavior of the |
3447 | | - * client, for example, how to backoff when an operation needs to be |
3448 | | - * retried, or what operations cannot be retried because they are not |
3449 | | - * idempotent. |
3450 | | - * |
3451 | | - * @deprecated use the constructor from `google::cloud::Options` instead. |
3452 | | - */ |
3453 | | - template <typename... Policies> |
3454 | | - explicit Client(std::shared_ptr<oauth2::Credentials> credentials, |
3455 | | - Policies&&... policies) |
3456 | | - : Client(InternalOnly{}, |
3457 | | - internal::ApplyPolicies( |
3458 | | - internal::DefaultOptions(std::move(credentials), {}), |
3459 | | - std::forward<Policies>(policies)...)) {} |
3460 | | - |
3461 | | - /** |
3462 | | - * Create a Client using ClientOptions::CreateDefaultClientOptions(). |
3463 | | - * |
3464 | | - * @deprecated use the constructor from `google::cloud::Options` instead. |
3465 | | - */ |
3466 | | - static StatusOr<Client> CreateDefaultClient(); |
3467 | | - |
3468 | | - /// Builds a client and maybe override the retry, idempotency, and/or backoff |
3469 | | - /// policies. |
3470 | | - /// @deprecated This was intended only for test code, applications should not |
3471 | | - /// use it. |
3472 | | - template <typename... Policies> |
3473 | | -#if !defined(_MSC_VER) || _MSC_VER >= 1920 |
3474 | | - GOOGLE_CLOUD_CPP_DEPRECATED( |
3475 | | - "applications should not need this." |
3476 | | - " Please use the constructors from ClientOptions instead." |
3477 | | - " For mocking, please use testing::ClientFromMock() instead." |
3478 | | - " Please file a bug at https://github.com/googleapis/google-cloud-cpp" |
3479 | | - " if you have a use-case not covered by these.") |
3480 | | -#endif // _MSC_VER |
3481 | | - // We cannot `std::move(connection)` because it is used twice in the delegated |
3482 | | - // constructor parameters. And we cannot just use `StorageConnection const&` |
3483 | | - // because we do hold on to the `std::shared_ptr<>`. |
3484 | | - explicit Client( |
3485 | | - std::shared_ptr<internal::StorageConnection> const& connection, |
3486 | | - Policies&&... policies) |
3487 | | - : Client(InternalOnly{}, |
3488 | | - internal::ApplyPolicies( |
3489 | | - internal::DefaultOptions( |
3490 | | - connection->client_options().credentials(), {}), |
3491 | | - std::forward<Policies>(policies)...), |
3492 | | - // We cannot std::move() because it is also used in the previous |
3493 | | - // parameter. |
3494 | | - connection) { |
3495 | | - } |
3496 | | - |
3497 | 3425 | /// Define a tag to disable automatic decorations of the StorageConnection. |
3498 | 3426 | struct NoDecorations {}; |
3499 | 3427 |
|
@@ -3675,8 +3603,20 @@ struct ClientImplDetails { |
3675 | 3603 | // NOLINTNEXTLINE(performance-unnecessary-value-param) |
3676 | 3604 | static Client CreateClient(std::shared_ptr<StorageConnection> c, |
3677 | 3605 | Policies&&... p) { |
3678 | | - auto opts = |
3679 | | - internal::ApplyPolicies(c->options(), std::forward<Policies>(p)...); |
| 3606 | + struct ApplyPoliciesHelper { |
| 3607 | + Options& opts; |
| 3608 | + void operator()(RetryPolicy const& p) { |
| 3609 | + opts.set<RetryPolicyOption>(p.clone()); |
| 3610 | + } |
| 3611 | + void operator()(BackoffPolicy const& p) { |
| 3612 | + opts.set<BackoffPolicyOption>(p.clone()); |
| 3613 | + } |
| 3614 | + void operator()(IdempotencyPolicy const& p) { |
| 3615 | + opts.set<IdempotencyPolicyOption>(p.clone()); |
| 3616 | + } |
| 3617 | + }; |
| 3618 | + auto opts = c->options(); |
| 3619 | + (ApplyPoliciesHelper{opts}(std::forward<Policies>(p)), ...); |
3680 | 3620 | return CreateWithDecorations(opts, std::move(c)); |
3681 | 3621 | } |
3682 | 3622 | }; |
|
0 commit comments