Skip to content

Commit 01104af

Browse files
authored
impl(storage): remove deprecated Client constructors (googleapis#15869)
* impl(storage): remove deprecated Client constructors
1 parent 04c9b39 commit 01104af

5 files changed

Lines changed: 68 additions & 24 deletions

File tree

-10.3 KB
Binary file not shown.
223 Bytes
Binary file not shown.

doc/v3-migration-guide.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -555,6 +555,71 @@ void CreateClient() {
555555

556556
</details>
557557

558+
<details>
559+
<summary>Removed <code>Client(Connection, NoDecorations)</code> constructor</summary>
560+
561+
The `Client` constructor that accepted a `StorageConnection` and the
562+
`NoDecorations` tag has been removed. This was intended only for test code.
563+
564+
**Before:**
565+
566+
```cpp
567+
#include "google/cloud/storage/client.h"
568+
#include "google/cloud/storage/testing/mock_storage_connection.h"
569+
570+
void TestClient() {
571+
auto mock = std::make_shared<google::cloud::storage::testing::MockStorageConnection>();
572+
// ...
573+
auto client = google::cloud::storage::Client(
574+
mock, google::cloud::storage::Client::NoDecorations{});
575+
}
576+
```
577+
578+
**After:**
579+
580+
```cpp
581+
#include "google/cloud/storage/client.h"
582+
#include "google/cloud/storage/testing/mock_storage_connection.h"
583+
584+
void TestClient() {
585+
auto mock = std::make_shared<google::cloud::storage::testing::MockStorageConnection>();
586+
// ...
587+
auto client = google::cloud::storage::internal::ClientImplDetails::CreateWithoutDecorations(mock);
588+
}
589+
```
590+
591+
</details>
592+
593+
<details>
594+
<summary>Removed <code>Client::raw_client()</code></summary>
595+
596+
The `Client::raw_client()` method has been removed. This was intended only for
597+
internal use or testing. If you need access to the underlying connection for
598+
testing purposes, use `google::cloud::storage::internal::ClientImplDetails`.
599+
600+
**Before:**
601+
602+
```cpp
603+
#include "google/cloud/storage/client.h"
604+
605+
void UseRawClient(google::cloud::storage::Client client) {
606+
auto connection = client.raw_client();
607+
}
608+
```
609+
610+
**After:**
611+
612+
```cpp
613+
#include "google/cloud/storage/client.h"
614+
615+
void UseRawClient(google::cloud::storage::Client client) {
616+
auto connection =
617+
google::cloud::storage::internal::ClientImplDetails::GetConnection(client);
618+
}
619+
```
620+
621+
</details>
622+
558623
### IAM
559624

560625
<details>

google/cloud/storage/client.h

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3441,27 +3441,6 @@ class Client {
34413441
/// Define a tag to disable automatic decorations of the StorageConnection.
34423442
struct NoDecorations {};
34433443

3444-
/// Builds a client with a specific StorageConnection, without decorations.
3445-
/// @deprecated This was intended only for test code, applications should not
3446-
/// use it.
3447-
GOOGLE_CLOUD_CPP_DEPRECATED(
3448-
"applications should not need this."
3449-
" Please file a bug at https://github.com/googleapis/google-cloud-cpp"
3450-
" if you do.")
3451-
explicit Client(std::shared_ptr<internal::StorageConnection> connection,
3452-
NoDecorations)
3453-
: Client(InternalOnlyNoDecorations{}, std::move(connection)) {}
3454-
3455-
/// Access the underlying `StorageConnection`.
3456-
/// @deprecated Only intended for implementors, do not use.
3457-
GOOGLE_CLOUD_CPP_DEPRECATED(
3458-
"applications should not need this."
3459-
" Please file a bug at https://github.com/googleapis/google-cloud-cpp"
3460-
" if you do.")
3461-
std::shared_ptr<internal::StorageConnection> raw_client() const {
3462-
return connection_;
3463-
}
3464-
34653444
private:
34663445
friend class internal::NonResumableParallelUploadState;
34673446
friend class internal::ResumableParallelUploadState;

google/cloud/storage/grpc_plugin_test.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,9 @@ TEST(GrpcPluginTest, HybridUsesGrpcBufferOptions) {
117117
ScopedEnvironment("GOOGLE_CLOUD_CPP_STORAGE_GRPC_CONFIG", absl::nullopt);
118118
auto client = MakeGrpcClient(
119119
TestOptions().set<storage_experimental::GrpcPluginOption>("media"));
120-
EXPECT_GE(
121-
client.raw_client()->options().get<storage::UploadBufferSizeOption>(),
122-
32 * 1024 * 1024L);
120+
auto connection = ClientImplDetails::GetConnection(client);
121+
EXPECT_GE(connection->options().get<storage::UploadBufferSizeOption>(),
122+
32 * 1024 * 1024UL);
123123
}
124124

125125
TEST(GrpcPluginTest, BackwardsCompatibilityShims) {

0 commit comments

Comments
 (0)