io.basestar.database.DatabaseClient Maven / Gradle / Ivy
package io.basestar.database;
/*-
* #%L
* basestar-database-client
* %%
* Copyright (C) 2019 - 2020 Basestar.IO
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
import com.google.common.base.Joiner;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.Multimap;
import io.basestar.auth.Caller;
import io.basestar.database.options.*;
import io.basestar.database.transport.Transport;
import io.basestar.schema.Instance;
import io.basestar.schema.Namespace;
import io.basestar.util.Name;
import io.basestar.util.PagedList;
import lombok.RequiredArgsConstructor;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.CompletableFuture;
@RequiredArgsConstructor
public class DatabaseClient implements Database {
private final String baseUrl;
private final Transport transport;
@Override
public Namespace namespace() {
return null;
}
@Override
public CompletableFuture read(final Caller caller, final ReadOptions options) {
final Name schema = options.getSchema();
final String id = options.getId();
final Multimap query = HashMultimap.create();
addVersion(query, options.getVersion());
addExpand(query, options.getExpand());
// addProjection(query, options.getProjection());
return transport.get(objectUrl(schema, id), query, headers(caller), instanceReader());
}
@Override
public CompletableFuture create(final Caller caller, final CreateOptions options) {
final Name schema = options.getSchema();
final String id = options.getId();
final Map data = options.getData();
final Multimap query = HashMultimap.create();
addExpand(query, options.getExpand());
// addProjection(query, options.getProjection());
return null;
}
@Override
public CompletableFuture update(final Caller caller, final UpdateOptions options) {
final Name schema = options.getSchema();
final String id = options.getId();
final Map data = options.getData();
final Multimap query = HashMultimap.create();
addVersion(query, options.getVersion());
addExpand(query, options.getExpand());
// addProjection(query, options.getProjection());
return null;
}
@Override
public CompletableFuture delete(final Caller caller, final DeleteOptions options) {
final Name schema = options.getSchema();
final String id = options.getId();
final Multimap query = HashMultimap.create();
addVersion(query, options.getVersion());
return transport.delete(objectUrl(schema, id), query, headers(caller), instanceReader());
}
@Override
public CompletableFuture> query(final Caller caller, final QueryOptions options) {
return null;
}
@Override
public CompletableFuture> queryLink(final Caller caller, final QueryLinkOptions options) {
return null;
}
@Override
public CompletableFuture
© 2015 - 2025 Weber Informatics LLC | Privacy Policy