use of com.amihaiemil.eoyaml.StrictYamlMapping 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.amihaiemil.eoyaml.StrictYamlMapping in project front by artipie.
the class YamlStorage method s3Client.
/**
* Creates {@link S3AsyncClient} instance based on YAML config.
*
* @return Built S3 client.
* @checkstyle MethodNameCheck (3 lines)
*/
@SuppressWarnings("deprecation")
private S3AsyncClient s3Client() {
final S3AsyncClientBuilder builder = S3AsyncClient.builder();
final String region = this.yaml.string("region");
if (region != null) {
builder.region(Region.of(region));
}
final String endpoint = this.yaml.string("endpoint");
if (endpoint != null) {
builder.endpointOverride(URI.create(endpoint));
}
return builder.credentialsProvider(credentials(new StrictYamlMapping(this.yaml).yamlMapping("credentials"))).build();
}
use of com.amihaiemil.eoyaml.StrictYamlMapping in project artipie by artipie.
the class YamlStorage method s3Client.
/**
* Creates {@link S3AsyncClient} instance based on YAML config.
*
* @return Built S3 client.
* @checkstyle MethodNameCheck (3 lines)
*/
@SuppressWarnings("deprecation")
private S3AsyncClient s3Client() {
final S3AsyncClientBuilder builder = S3AsyncClient.builder();
final String region = this.yaml.string("region");
if (region != null) {
builder.region(Region.of(region));
}
final String endpoint = this.yaml.string("endpoint");
if (endpoint != null) {
builder.endpointOverride(URI.create(endpoint));
}
return builder.credentialsProvider(credentials(new StrictYamlMapping(this.yaml).yamlMapping("credentials"))).build();
}
use of com.amihaiemil.eoyaml.StrictYamlMapping 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