com.couchbase.client.core.protostellar.manager.ProtostellarCoreBucketManager Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of core-io Show documentation
Show all versions of core-io Show documentation
The official Couchbase JVM Core IO Library
/*
* Copyright 2023 Couchbase, Inc.
*
* 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
*
* https://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.
*/
package com.couchbase.client.core.protostellar.manager;
import com.couchbase.client.core.CoreProtostellar;
import com.couchbase.client.core.annotation.Stability;
import com.couchbase.client.core.config.BucketType;
import com.couchbase.client.core.endpoint.http.CoreCommonOptions;
import com.couchbase.client.core.manager.CoreBucketManagerOps;
import com.couchbase.client.core.manager.bucket.CoreBucketSettings;
import com.couchbase.client.core.manager.bucket.CoreCompressionMode;
import com.couchbase.client.core.manager.bucket.CoreConflictResolutionType;
import com.couchbase.client.core.manager.bucket.CoreEvictionPolicyType;
import com.couchbase.client.core.manager.bucket.CoreStorageBackend;
import com.couchbase.client.core.msg.kv.DurabilityLevel;
import com.couchbase.client.core.protostellar.CoreProtostellarAccessors;
import com.couchbase.client.core.protostellar.ProtostellarRequest;
import com.couchbase.client.protostellar.admin.bucket.v1.CreateBucketRequest;
import com.couchbase.client.protostellar.admin.bucket.v1.DeleteBucketRequest;
import com.couchbase.client.protostellar.admin.bucket.v1.ListBucketsRequest;
import com.couchbase.client.protostellar.admin.bucket.v1.ListBucketsResponse;
import com.couchbase.client.protostellar.admin.bucket.v1.UpdateBucketRequest;
import java.time.Duration;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
import static com.couchbase.client.core.protostellar.CoreProtostellarUtil.incompatibleProtostellar;
import static com.couchbase.client.core.protostellar.CoreProtostellarUtil.unsupportedInProtostellar;
import static java.util.Objects.requireNonNull;
@Stability.Internal
public class ProtostellarCoreBucketManager implements CoreBucketManagerOps {
private final CoreProtostellar core;
public ProtostellarCoreBucketManager(CoreProtostellar core) {
this.core = requireNonNull(core);
}
@Override
public CompletableFuture createBucket(CoreBucketSettings settings, CoreCommonOptions options) {
ProtostellarRequest request = ProtostellarCoreBucketManagerRequests.createBucketRequest(core, settings, options);
return CoreProtostellarAccessors.async(core,
request,
(endpoint) -> endpoint.bucketAdminStub().withDeadline(request.deadline()).createBucket(request.request()),
(response) -> null)
.thenApply(obj -> null);
}
@Override
public CompletableFuture updateBucket(CoreBucketSettings settings, CoreCommonOptions options) {
ProtostellarRequest request = ProtostellarCoreBucketManagerRequests.updateBucketRequest(core, settings, options);
return CoreProtostellarAccessors.async(core,
request,
(endpoint) -> endpoint.bucketAdminStub().withDeadline(request.deadline()).updateBucket(request.request()),
(response) -> null)
.thenApply(obj -> null);
}
@Override
public CompletableFuture dropBucket(String bucketName, CoreCommonOptions options) {
ProtostellarRequest request = ProtostellarCoreBucketManagerRequests.deleteBucketRequest(core, bucketName, options);
return CoreProtostellarAccessors.async(core,
request,
(endpoint) -> endpoint.bucketAdminStub().withDeadline(request.deadline()).deleteBucket(request.request()),
(response) -> null)
.thenApply(obj -> null);
}
@Override
public CompletableFuture