use of com.artipie.asto.s3.S3Storage in project front by artipie.
the class YamlStorage method storage.
/**
* Provides a storage.
*
* @return Storage instance.
*/
public Storage storage() {
@SuppressWarnings("deprecation") final YamlMapping strict = new StrictYamlMapping(this.yaml);
final String type = strict.string("type");
final Storage storage;
if ("fs".equals(type)) {
storage = new FileStorage(Path.of(strict.string("path")));
} else if ("s3".equals(type)) {
storage = new S3Storage(this.s3Client(), strict.string("bucket"), !"false".equals(this.yaml.string("multipart")));
} else if ("etcd".equals(type)) {
storage = new EtcdStorage(YamlStorage.etcdClient(strict.yamlMapping("connection")));
} else {
throw new IllegalStateException(String.format("Unsupported storage type: '%s'", type));
}
return storage;
}
use of com.artipie.asto.s3.S3Storage in project airavata-data-lake by apache.
the class AnyStorageSerializer method serializeToMap.
public static Map<String, Object> serializeToMap(AnyStorage anyStorage) {
Map<String, Object> fields = new HashMap<>();
Map<Descriptors.FieldDescriptor, Object> allFields = null;
switch(anyStorage.getStorageCase()) {
case SSH_STORAGE:
SSHStorage sshStorage = anyStorage.getSshStorage();
allFields = sshStorage.getAllFields();
fields.put(StorageConstants.STORAGE_TYPE_LABEL, StorageConstants.SSH_STORAGE_TYPE_LABEL);
break;
case S3_STORAGE:
S3Storage s3Storage = anyStorage.getS3Storage();
allFields = s3Storage.getAllFields();
fields.put(StorageConstants.STORAGE_TYPE_LABEL, StorageConstants.S3_STORAGE_TYPE_LABEL);
break;
case STORAGE_NOT_SET:
break;
}
if (allFields != null) {
allFields.forEach((descriptor, value) -> {
String fieldName = descriptor.getJsonName();
fields.put(fieldName, value);
});
}
return fields;
}
use of com.artipie.asto.s3.S3Storage in project artipie by artipie.
the class YamlStorage method storage.
/**
* Provides a storage.
*
* @return Storage instance.
*/
public Storage storage() {
@SuppressWarnings("deprecation") final YamlMapping strict = new StrictYamlMapping(this.yaml);
final String type = strict.string("type");
final Storage storage;
if ("fs".equals(type)) {
storage = new FileStorage(Path.of(strict.string("path")));
} else if ("s3".equals(type)) {
storage = new S3Storage(this.s3Client(), strict.string("bucket"), !"false".equals(this.yaml.string("multipart")));
} else if ("etcd".equals(type)) {
storage = new EtcdStorage(YamlStorage.etcdClient(strict.yamlMapping("connection")));
} else {
throw new IllegalStateException(String.format("Unsupported storage type: '%s'", type));
}
return storage;
}
Aggregations