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

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

public class XMLClientService {
    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 XMLClientService(
            String endpoint, String provider, String username, String password, Integer port)
            throws MinioException {
        this.ENDPOINT = endpoint;
        this.PROVIDER = provider;
        this.USERNAME = username;
        this.PASSWORD = password;
        this.PORT = port;
        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();
    }
}
