datastore = DatastoreFactory.get().create( options.credential(credential).projectId(datasetId).build());
public HttpDatastoreRpc(DatastoreOptions options) { HttpTransportOptions httpTransportOptions = (HttpTransportOptions) options.getTransportOptions(); HttpTransport transport = httpTransportOptions.getHttpTransportFactory().create(); com.google.datastore.v1.client.DatastoreOptions.Builder clientBuilder = new com.google.datastore.v1.client.DatastoreOptions.Builder() .projectId(options.getProjectId()) .initializer(getHttpRequestInitializer(options, httpTransportOptions)) .transport(transport); String normalizedHost = options.getHost() != null ? options.getHost().toLowerCase() : ""; if (isLocalHost(normalizedHost)) { clientBuilder = clientBuilder.localHost(removeScheme(normalizedHost)); } else if (!removeScheme(com.google.datastore.v1.client.DatastoreFactory.DEFAULT_HOST) .equals(removeScheme(normalizedHost)) && !normalizedHost.isEmpty()) { String fullUrl = normalizedHost; if (fullUrl.charAt(fullUrl.length() - 1) != '/') { fullUrl = fullUrl + '/'; } fullUrl = fullUrl + com.google.datastore.v1.client.DatastoreFactory.VERSION + "/projects/" + options.getProjectId(); clientBuilder = clientBuilder.projectId(null).projectEndpoint(fullUrl); } client = com.google.datastore.v1.client.DatastoreFactory.get().create(clientBuilder.build()); }
/** * @see #getOptionsFromEnv() */ public static Datastore getDatastoreFromEnv() throws GeneralSecurityException, IOException { return DatastoreFactory.get().create(getOptionsFromEnv().build()); }
/** * @see #getOptionsFromEnv() */ public static Datastore getDatastoreFromEnv() throws GeneralSecurityException, IOException { return DatastoreFactory.get().create(getOptionsFromEnv().build()); }
public HttpDatastoreRpc(DatastoreOptions options) { HttpTransportOptions httpTransportOptions = (HttpTransportOptions) options.getTransportOptions(); HttpTransport transport = httpTransportOptions.getHttpTransportFactory().create(); com.google.datastore.v1.client.DatastoreOptions.Builder clientBuilder = new com.google.datastore.v1.client.DatastoreOptions.Builder() .projectId(options.getProjectId()) .initializer(getHttpRequestInitializer(options, httpTransportOptions)) .transport(transport); String normalizedHost = options.getHost() != null ? options.getHost().toLowerCase() : ""; if (isLocalHost(normalizedHost)) { clientBuilder = clientBuilder.localHost(removeScheme(normalizedHost)); } else if (!removeScheme(com.google.datastore.v1.client.DatastoreFactory.DEFAULT_HOST) .equals(removeScheme(normalizedHost)) && !normalizedHost.isEmpty()) { String fullUrl = normalizedHost; if (fullUrl.charAt(fullUrl.length() - 1) != '/') { fullUrl = fullUrl + '/'; } fullUrl = fullUrl + com.google.datastore.v1.client.DatastoreFactory.VERSION + "/projects/" + options.getProjectId(); clientBuilder = clientBuilder.projectId(null).projectEndpoint(fullUrl); } client = com.google.datastore.v1.client.DatastoreFactory.get().create(clientBuilder.build()); }
datastore = DatastoreFactory.get().create(DatastoreHelper.getOptionsFromEnv() .projectId(projectId).build()); } catch (GeneralSecurityException exception) {
/** * Builds a Cloud Datastore client for the given pipeline options, project and an optional * locahost. */ public Datastore getDatastore( PipelineOptions pipelineOptions, String projectId, @Nullable String localhost) { Credentials credential = pipelineOptions.as(GcpOptions.class).getGcpCredential(); HttpRequestInitializer initializer; if (credential != null) { initializer = new ChainingHttpRequestInitializer( new HttpCredentialsAdapter(credential), new RetryHttpRequestInitializer()); } else { initializer = new RetryHttpRequestInitializer(); } DatastoreOptions.Builder builder = new DatastoreOptions.Builder().projectId(projectId).initializer(initializer); if (localhost != null) { builder.localHost(localhost); } else { builder.host("batch-datastore.googleapis.com"); } return DatastoreFactory.get().create(builder.build()); }
/** Build a new datastore client. */ static Datastore getDatastore(PipelineOptions pipelineOptions, String projectId) { Credentials credential = pipelineOptions.as(GcpOptions.class).getGcpCredential(); HttpRequestInitializer initializer; if (credential != null) { initializer = new ChainingHttpRequestInitializer( new HttpCredentialsAdapter(credential), new RetryHttpRequestInitializer()); } else { initializer = new RetryHttpRequestInitializer(); } DatastoreOptions.Builder builder = new DatastoreOptions.Builder().projectId(projectId).initializer(initializer); return DatastoreFactory.get().create(builder.build()); }