Skip to content

Commit

Permalink
fix: deprecate databaseId on datastore-v1-proto-client DatastoreOpt…
Browse files Browse the repository at this point in the history
…ions (#1190)
  • Loading branch information
kolea2 committed Sep 14, 2023
1 parent 410b939 commit 12a3d27
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 4 deletions.
Expand Up @@ -41,7 +41,9 @@
*/
public class DatastoreOptions {
private final String projectId;
private final String databaseId;

@Deprecated private final String databaseId;

private final String projectEndpoint;
private final String host;
private final String localHost;
Expand Down Expand Up @@ -75,7 +77,9 @@ public static class Builder {
"Can set at most one of project endpoint, host, and local host.";

private String projectId;
private String databaseId;

@Deprecated private String databaseId;

private String projectEndpoint;
private String host;
private String localHost;
Expand Down Expand Up @@ -107,8 +111,19 @@ public Builder projectId(String projectId) {
return this;
}

/** Sets the database ID used to access Cloud Datastore. */
/**
* This field is ignored and will be removed in a future release. Please set the database id on
* the request itself. For example:
*
* <pre>{@code
* CommitRequest.newBuilder()
* .setDatabaseId("my-database-id")
* ....
* .build();
* }</pre>
*/
@BetaApi
@Deprecated
public Builder databaseId(String databaseId) {
this.databaseId = databaseId;
return this;
Expand Down Expand Up @@ -188,7 +203,19 @@ public String getProjectId() {
return projectId;
}

/**
* This field is ignored and will be removed in a future release. Please set the database id on
* the request itself. For example:
*
* <pre>{@code
* CommitRequest.newBuilder()
* .setDatabaseId("my-database-id")
* ....
* .build();
* }</pre>
*/
@BetaApi
@Deprecated
public String getDatabaseId() {
return databaseId;
}
Expand Down
Expand Up @@ -216,6 +216,7 @@ public void create_LocalHost() {
}

@Test
// TODO: remove this test once deprecated `databaseId` is removed
public void setDatabaseId() {
DatastoreOptions options =
new DatastoreOptions.Builder()
Expand Down
Expand Up @@ -55,7 +55,6 @@ public HttpDatastoreRpc(DatastoreOptions options) {
com.google.datastore.v1.client.DatastoreOptions.Builder clientBuilder =
new com.google.datastore.v1.client.DatastoreOptions.Builder()
.projectId(options.getProjectId())
.databaseId(options.getDatabaseId())
.initializer(getHttpRequestInitializer(options, httpTransportOptions))
.transport(transport);
String normalizedHost = options.getHost() != null ? options.getHost().toLowerCase() : "";
Expand Down

0 comments on commit 12a3d27

Please sign in to comment.