19
19
import static com.google.cloud.datastore.Validator.validateNamespace;
20
20
21
21
import com.google.api.core.BetaApi;
22
- import com.google.api.gax.core.CredentialsProvider;
23
22
import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider;
24
23
import com.google.api.gax.rpc.TransportChannelProvider;
25
24
import com.google.cloud.ServiceDefaults;
@@ -51,7 +50,6 @@ public class DatastoreOptions extends ServiceOptions<Datastore, DatastoreOptions
51
50
public static final String LOCAL_HOST_ENV_VAR = "DATASTORE_EMULATOR_HOST";
52
51
53
52
private transient TransportChannelProvider channelProvider = null;
54
- private transient CredentialsProvider credentialsProvider = null;
55
53
56
54
private final String namespace;
57
55
private final String databaseId;
@@ -89,7 +87,6 @@ public static class Builder extends ServiceOptions.Builder<Datastore, DatastoreO
89
87
private String namespace;
90
88
private String databaseId;
91
89
private TransportChannelProvider channelProvider = null;
92
- private CredentialsProvider credentialsProvider = null;
93
90
private String host;
94
91
private TransportOptions transportOptions;
95
92
@@ -100,7 +97,6 @@ private Builder(DatastoreOptions options) {
100
97
this.namespace = options.namespace;
101
98
this.databaseId = options.databaseId;
102
99
this.channelProvider = validateChannelProvider(options.channelProvider);
103
- this.credentialsProvider = options.credentialsProvider;
104
100
}
105
101
106
102
@Override
@@ -113,6 +109,9 @@ public Builder setTransportOptions(TransportOptions transportOptions) {
113
109
return super.setTransportOptions(transportOptions);
114
110
}
115
111
112
+ /**
113
+ * Sets the transport to gRPC. Note this functionality is experimental and subject to change.
114
+ */
116
115
@BetaApi
117
116
public Builder setTransportOptions(GrpcTransportOptions transportOptions) {
118
117
this.transportOptions = transportOptions;
@@ -128,6 +127,11 @@ public Builder setHost(String host) {
128
127
/**
129
128
* Sets the {@link TransportChannelProvider} to use with this Datastore client.
130
129
*
130
+ * <p>This is only compatible with clients using a gRPC transport (see {@code
131
+ * DatastoreOptions#setTransportOptions(GrpcTransportOptions)} for more details).
132
+ *
133
+ * <p>This functionality is experimental and subject to change.
134
+ *
131
135
* @param channelProvider A InstantiatingGrpcChannelProvider object that defines the transport
132
136
* provider for this client.
133
137
*/
@@ -137,18 +141,6 @@ public Builder setChannelProvider(TransportChannelProvider channelProvider) {
137
141
return this;
138
142
}
139
143
140
- /**
141
- * Sets the {@link CredentialsProvider} to use with this Datastore client.
142
- *
143
- * @param credentialsProvider A CredentialsProvider object that defines the credential provider
144
- * for this client.
145
- */
146
- @BetaApi
147
- public Builder setCredentialsProvider(CredentialsProvider credentialsProvider) {
148
- this.credentialsProvider = credentialsProvider;
149
- return this;
150
- }
151
-
152
144
@Override
153
145
public DatastoreOptions build() {
154
146
if (this.host == null && this.transportOptions instanceof GrpcTransportOptions) {
@@ -183,8 +175,7 @@ private DatastoreOptions(Builder builder) {
183
175
namespace = MoreObjects.firstNonNull(builder.namespace, defaultNamespace());
184
176
databaseId = MoreObjects.firstNonNull(builder.databaseId, DEFAULT_DATABASE_ID);
185
177
186
- if (getTransportOptions() instanceof HttpTransportOptions
187
- && (builder.channelProvider != null || builder.credentialsProvider != null)) {
178
+ if (getTransportOptions() instanceof HttpTransportOptions && builder.channelProvider != null) {
188
179
throw new IllegalArgumentException(
189
180
"Only gRPC transport allows setting of channel provider or credentials provider");
190
181
} else if (getTransportOptions() instanceof GrpcTransportOptions) {
@@ -193,18 +184,9 @@ private DatastoreOptions(Builder builder) {
193
184
? builder.channelProvider
194
185
: GrpcTransportOptions.setUpChannelProvider(
195
186
DatastoreSettings.defaultGrpcTransportProviderBuilder(), this);
196
-
197
- this.credentialsProvider =
198
- builder.credentialsProvider != null
199
- ? builder.credentialsProvider
200
- : GrpcTransportOptions.setUpCredentialsProvider(this);
201
187
}
202
188
}
203
189
204
- public CredentialsProvider getCredentialsProvider() {
205
- return credentialsProvider;
206
- }
207
-
208
190
public TransportChannelProvider getTransportChannelProvider() {
209
191
return channelProvider;
210
192
}
0 commit comments