info.freelibrary.vertx.s3.service.S3ClientServiceVertxEBProxy Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of vertx-s3-service Show documentation
Show all versions of vertx-s3-service Show documentation
An S3 client library for the Vert.x toolkit
/*
* Copyright 2014 Red Hat, Inc.
*
* Red Hat licenses this file to you 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.
*/
package info.freelibrary.vertx.s3.service;
import io.vertx.core.eventbus.DeliveryOptions;
import io.vertx.core.Vertx;
import io.vertx.core.Future;
import io.vertx.core.json.JsonObject;
import io.vertx.core.json.JsonArray;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.function.Function;
import io.vertx.serviceproxy.ServiceException;
import io.vertx.serviceproxy.ServiceExceptionMessageCodec;
import io.vertx.serviceproxy.ProxyUtils;
import info.freelibrary.vertx.s3.HttpHeaders;
import info.freelibrary.vertx.s3.S3Object;
import io.vertx.core.Future;
/*
Generated Proxy code - DO NOT EDIT
@author Roger the Robot
*/
@SuppressWarnings({"unchecked", "rawtypes"})
public class S3ClientServiceVertxEBProxy implements S3ClientService {
private Vertx _vertx;
private String _address;
private DeliveryOptions _options;
private boolean closed;
public S3ClientServiceVertxEBProxy(Vertx vertx, String address) {
this(vertx, address, null);
}
public S3ClientServiceVertxEBProxy(Vertx vertx, String address, DeliveryOptions options) {
this._vertx = vertx;
this._address = address;
this._options = options;
try {
this._vertx.eventBus().registerDefaultCodec(ServiceException.class, new ServiceExceptionMessageCodec());
} catch (IllegalStateException ex) {
}
}
@Override
public Future put(String aBucket, S3Object aS3Object){
if (closed) return io.vertx.core.Future.failedFuture("Proxy is closed");
JsonObject _json = new JsonObject();
_json.put("aBucket", aBucket);
_json.put("aS3Object", aS3Object != null ? aS3Object.toJson() : null);
DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options) : new DeliveryOptions();
_deliveryOptions.addHeader("action", "put");
return _vertx.eventBus().request(_address, _json, _deliveryOptions).map(msg -> {
return msg.body() != null ? new info.freelibrary.vertx.s3.HttpHeaders((JsonObject)msg.body()) : null;
});
}
@Override
public Future get(String aBucket, String aKey){
if (closed) return io.vertx.core.Future.failedFuture("Proxy is closed");
JsonObject _json = new JsonObject();
_json.put("aBucket", aBucket);
_json.put("aKey", aKey);
DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options) : new DeliveryOptions();
_deliveryOptions.addHeader("action", "get");
return _vertx.eventBus().request(_address, _json, _deliveryOptions).map(msg -> {
return msg.body() != null ? new info.freelibrary.vertx.s3.S3Object((JsonObject)msg.body()) : null;
});
}
@Override
public Future close(){
if (closed) return io.vertx.core.Future.failedFuture("Proxy is closed");
closed = true;
JsonObject _json = new JsonObject();
DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options) : new DeliveryOptions();
_deliveryOptions.addHeader("action", "close");
return _vertx.eventBus().request(_address, _json, _deliveryOptions).map(msg -> {
return msg.body();
});
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy