package org.apache.seatunnel.datasource.plugin.csv;

import io.minio.MinioClient;
import io.minio.errors.MinioException;

public class CSVClientService {
    private String ENDPOINT;
    private String PROVIDER;
    private String USERNAME;
    private String PASSWORD;
    private String BUCKET;

    private Integer PORT;

    private final String clientId = "Client" + (int) (Math.random() * 100000000);
    private MinioClient minioClient;

    public CSVClientService(
            String endpoint,
            String provider,
            String username,
            String password,
            Integer port,
            String backet)
            throws MinioException {
        this.ENDPOINT = endpoint;
        this.PROVIDER = provider;
        this.USERNAME = username;
        this.PASSWORD = password;
        this.PORT = port;
        this.BUCKET = backet;
        setMinioClient(endpoint, provider, username, password, port);
    }

    public MinioClient getMinioClient() {
        return minioClient;
    }

    public void setMinioClient(
            String endpoint, String provider, String username, String password, Integer port)
            throws MinioException {
        minioClient =
                new MinioClient.Builder()
                        .endpoint(endpoint, port, false)
                        .credentials(username, password)
                        .build();
    }
}
