package com.css.simulation.resource.common.infra.config.minio;

import io.minio.MinioClient;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Data
@Configuration
@ConfigurationProperties(prefix = "minio")
public class MinioConfiguration {

    private String endpointPrivate;
    private String endpointPublic;
    private String accessKey;
    private String secretKey;
    private String bucketName;

    @Bean
    public SubMinioClient minioClientPrivate() {
        MinioClient minioClient = MinioClient.builder()
                .endpoint(endpointPrivate)
                .credentials(accessKey, secretKey)
                .build();
        return new SubMinioClient(minioClient);
    }

    @Bean
    public SubMinioClient minioClientPublic() {
        MinioClient minioClient = MinioClient.builder()
                .endpoint(endpointPublic)
                .credentials(accessKey, secretKey)
                .build();
        return new SubMinioClient(minioClient);
    }

}
