Skip to content

Commit b52cf97

Browse files
committed
add migration guide
1 parent c4913a9 commit b52cf97

File tree

1 file changed

+146
-0
lines changed

1 file changed

+146
-0
lines changed

doc/v3-migration-guide.md

Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,3 +126,149 @@ auto limit = google::cloud::bigtable::RowReader::NO_ROWS_LIMIT;
126126
### Spanner
127127

128128
### Storage
129+
130+
<details>
131+
<summary><code>ClientOptions</code> is removed</summary>
132+
133+
The `ClientOptions` class is no longer available. You should now use
134+
`google::cloud::Options` to configure the `Client`.
135+
136+
**Before:**
137+
138+
```cpp
139+
#include "google/cloud/storage/client.h"
140+
141+
void CreateClient() {
142+
auto credentials = google::cloud::storage::oauth2::GoogleDefaultCredentials().value();
143+
auto options = google::cloud::storage::ClientOptions(credentials);
144+
options.set_project_id("my-project");
145+
options.set_upload_buffer_size(1024 * 1024);
146+
147+
google::cloud::storage::Client client(options);
148+
}
149+
```
150+
151+
**After:**
152+
153+
```cpp
154+
#include "google/cloud/storage/client.h"
155+
#include "google/cloud/storage/options.h" // For option structs
156+
157+
void CreateClient() {
158+
auto credentials = google::cloud::MakeGoogleDefaultCredentials();
159+
auto client = google::cloud::storage::Client(
160+
google::cloud::Options{}
161+
.set<google::cloud::Oauth2CredentialsOption>(credentials)
162+
.set<google::cloud::storage::ProjectIdOption>("my-project")
163+
.set<google::cloud::storage::UploadBufferSizeOption>(1024 * 1024));
164+
}
165+
```
166+
167+
Use the following table to map `ClientOptions` setters to
168+
`google::cloud::Options`:
169+
170+
| `ClientOptions` Method | Replacement Option (`.set<T>(value)`) |
171+
| :------------------------------------ | :------------------------------------------------------ |
172+
| `set_credentials(c)` | `google::cloud::storage::Oauth2CredentialsOption` |
173+
| `set_project_id(p)` | `google::cloud::storage::ProjectIdOption` |
174+
| `set_endpoint(url)` | `google::cloud::storage::RestEndpointOption` |
175+
| `set_iam_endpoint(url)` | `google::cloud::storage::IamEndpointOption` |
176+
| `SetDownloadBufferSize` | `google::cloud::storage::DownloadBufferSizeOption` |
177+
| `SetUploadBufferSizee` | `google::cloud::storage::UploadBufferSizeOption` |
178+
| `set_maximum_simple_upload_size(s)` | `google::cloud::storage::MaximumSimpleUploadSizeOption` |
179+
| `set_enable_http_tracing(true)` | `google::cloud::LoggingComponentsOption` |
180+
| `set_enable_raw_client_tracing(true)` | `google::cloud::LoggingComponentsOption` |
181+
182+
**Example for Tracing:**
183+
184+
```cpp
185+
// Before
186+
options.set_enable_http_tracing(true);
187+
188+
// After
189+
auto opts = Options{}.lookup<LoggingComponentsOption>().insert("raw-client");
190+
```
191+
192+
</details>
193+
194+
<details>
195+
<summary><code>ChannelOptions</code> is removed</summary>
196+
197+
The `ChannelOptions` class is no longer available. You should now use
198+
`google::cloud::Options` to configure the transport channel.
199+
200+
**Before:**
201+
202+
```cpp
203+
#include "google/cloud/storage/grpc_plugin.h"
204+
205+
void CreateClient() {
206+
auto options = google::cloud::storage::ChannelOptions()
207+
.set_ssl_root_path("path/to/roots.pem");
208+
209+
auto client = google::cloud::storage::MakeGrpcClient(
210+
google::cloud::storage::ClientOptions(), options);
211+
}
212+
```
213+
214+
**After:**
215+
216+
```cpp
217+
#include "google/cloud/storage/grpc_plugin.h"
218+
#include "google/cloud/grpc_options.h"
219+
#include "google/cloud/common_options.h"
220+
221+
void CreateClient() {
222+
auto client = google::cloud::storage::MakeGrpcClient(
223+
google::cloud::Options{}.set<google::cloud::CARootsFilePathOption>(
224+
"path/to/roots.pem"));
225+
}
226+
```
227+
228+
</details>
229+
230+
<details>
231+
<summary>ChannelOptions Mapping</summary>
232+
233+
Use the following table to map `ChannelOptions` setters to
234+
`google::cloud::Options`:
235+
236+
| `ChannelOptions` Method | Replacement Option (`.set<T>(value)`) |
237+
| :---------------------- | :------------------------------------- |
238+
| `set_ssl_root_path(p)` | `google::cloud::CARootsFilePathOption` |
239+
240+
</details>
241+
242+
<details>
243+
<summary><code>Client</code> Constructor</summary>
244+
245+
The constructor `Client(ClientOptions)` is removed. The default constructor
246+
`Client()` generally uses default options and default credentials. To customize,
247+
use `Client(Options)`.
248+
249+
**Before:**
250+
251+
```cpp
252+
#include "google/cloud/storage/client.h"
253+
254+
void CreateClient() {
255+
auto credentials = google::cloud::storage::oauth2::GoogleDefaultCredentials().value();
256+
auto options = google::cloud::storage::ClientOptions(credentials);
257+
auto client = google::cloud::storage::Client(options);
258+
}
259+
```
260+
261+
**After:**
262+
263+
```cpp
264+
#include "google/cloud/storage/client.h"
265+
#include "google/cloud/storage/options.h"
266+
267+
void CreateClient() {
268+
auto credentials = google::cloud::MakeGoogleDefaultCredentials();
269+
auto client = google::cloud::storage::Client(
270+
google::cloud::Options{}.set<google::cloud::storage::Oauth2CredentialsOption>(credentials));
271+
}
272+
```
273+
274+
</details>

0 commit comments

Comments
 (0)