001
002package com.commercetools.ml.client;
003
004import java.io.Closeable;
005
006import io.vrap.rmf.base.client.ApiHttpClient;
007import io.vrap.rmf.base.client.SerializerOnlyApiHttpClient;
008import io.vrap.rmf.base.client.utils.Generated;
009
010/**
011 * Entrypoint for building requests against the API
012 */
013@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen")
014public class ApiRoot implements Closeable {
015
016    private final ApiHttpClient apiHttpClient;
017
018    private ApiRoot(final ApiHttpClient apiHttpClient) {
019        this.apiHttpClient = apiHttpClient;
020    }
021
022    public static ApiRoot of() {
023        return new ApiRoot(SerializerOnlyApiHttpClient.of());
024    }
025
026    public static ApiRoot fromClient(final ApiHttpClient apiHttpClient) {
027        return new ApiRoot(apiHttpClient);
028    }
029
030    public ByProjectKeyRequestBuilder withProjectKey(String projectKey) {
031        return new ByProjectKeyRequestBuilder(this.apiHttpClient, projectKey);
032    }
033
034    @Override
035    public void close() {
036        if (apiHttpClient == null) {
037            return;
038        }
039        try {
040            apiHttpClient.close();
041        }
042        catch (final Throwable ignored) {
043        }
044    }
045}