<commit_before>package loadster.sdk.client;

import feign.*;
import feign.jackson.JacksonDecoder;
import feign.jackson.JacksonEncoder;
import loadster.sdk.exceptions.ApiException;
import loadster.sdk.types.*;

import java.io.IOException;
import java.io.InputStream;
import java.util.List;

/**
 * Simplified client interface for the Workbench API.
 */
public class WorkbenchApiClient {
    private WorkbenchApi jsonApi;

    public WorkbenchApiClient(final String host, final int port, final String apiKey) {
        jsonApi = Feign.builder().decoder(new JacksonDecoder()).encoder(new JacksonEncoder()).requestInterceptor(new RequestInterceptor() {
            @Override
            public void apply(RequestTemplate requestTemplate) {
                requestTemplate.query("apiKey", apiKey);
            }
        }).target(WorkbenchApi.class, "http://" + host + ":" + port);
    }

    /**
     * Lists all projects.
     */
    public List<Reference> listProjects() throws ApiException, IOException {
        return jsonApi.listProjects();
    }

    /**
     * Gets details on a project.
     */
    public Project getProject(String id) throws ApiException, IOException {
        return jsonApi.getProject(id);
    }

    /**
     * Gets details on a scenario.
     */
    public Scenario getScenario(String projectId, String scenarioId) throws ApiException, IOException {
        return jsonApi.getScenario(projectId, scenarioId);
    }

    /**
     * Gets details on a script.
     */
    public Script getScript(String projectId, String scriptId) throws ApiException, IOException {
        return jsonApi.getScript(projectId, scriptId);
    }

    /**
     * Gets details on a data set.
     */
    public DataSet getDataSet(String projectId, String dataSetId) throws ApiException, IOException {
        return jsonApi.getDataSet(projectId, dataSetId);
    }

    /**
     * Gets details on a test.
     */
    public Test getTest(String projectId, String scenarioId, String testId) throws ApiException, IOException {
        return jsonApi.getTest(projectId, scenarioId, testId);
    }

    /**
     * Attempts to start a test for a scenario.
     */
    public Test startTest(Scenario scenario) throws ApiException, IOException {
        return jsonApi.startTest(scenario.getProjectId(), scenario.getId());
    }

    /**
     * Gets up-to-date status on a test.
     */
    public TestStatus getTestStatus(Test test) throws ApiException, IOException {
        return jsonApi.getTestStatus(test.getProjectId(), test.getScenarioId(), test.getId());
    }

    /**
     * Fetches an HTML test report for a test. The test has to be finished or this will fail.
     */
    public InputStream getTestReport(Test test) throws ApiException, IOException {
        return jsonApi.getTestReport(test.getProjectId(), test.getScenarioId(), test.getId()).body().asInputStream();
    }

    /**
     * Fetches statistics for a test. The test has to be finished or this will fail.
     */
    public TestStatistics getTestStatistics(Test test) throws ApiException, IOException {
        return jsonApi.getTestStatistics(test.getProjectId(), test.getScenarioId(), test.getId());<commit_msg>Fix bug with missing project/scenario ids.<commit_after>package loadster.sdk.client;

import feign.*;
import feign.jackson.JacksonDecoder;
import feign.jackson.JacksonEncoder;
import loadster.sdk.exceptions.ApiException;
import loadster.sdk.types.*;

import java.io.IOException;
import java.io.InputStream;
import java.util.List;

/**
 * Simplified client interface for the Workbench API.
 */
public class WorkbenchApiClient {
    private WorkbenchApi jsonApi;

    public WorkbenchApiClient(final String host, final int port, final String apiKey) {
        jsonApi = Feign.builder().decoder(new JacksonDecoder()).encoder(new JacksonEncoder()).requestInterceptor(new RequestInterceptor() {
            @Override
            public void apply(RequestTemplate requestTemplate) {
                requestTemplate.query("apiKey", apiKey);
            }
        }).target(WorkbenchApi.class, "http://" + host + ":" + port);
    }

    /**
     * Lists all projects.
     */
    public List<Reference> listProjects() throws ApiException, IOException {
        return jsonApi.listProjects();
    }

    /**
     * Gets details on a project.
     */
    public Project getProject(String id) throws ApiException, IOException {
        return jsonApi.getProject(id);
    }

    /**
     * Gets details on a scenario.
     */
    public Scenario getScenario(String projectId, String scenarioId) throws ApiException, IOException {
        return jsonApi.getScenario(projectId, scenarioId);
    }

    /**
     * Gets details on a script.
     */
    public Script getScript(String projectId, String scriptId) throws ApiException, IOException {
        return jsonApi.getScript(projectId, scriptId);
    }

    /**
     * Gets details on a data set.
     */
    public DataSet getDataSet(String projectId, String dataSetId) throws ApiException, IOException {
        return jsonApi.getDataSet(projectId, dataSetId);
    }

    /**
     * Gets details on a test.
     */
    public Test getTest(String projectId, String scenarioId, String testId) throws ApiException, IOException {
        return jsonApi.getTest(projectId, scenarioId, testId);
    }

    /**
     * Attempts to start a test for a scenario.
     */
    public Test startTest(Scenario scenario) throws ApiException, IOException {
        Test test = jsonApi.startTest(scenario.getProjectId(), scenario.getId());

        test.setProjectId(scenario.getProjectId());
        test.setScenarioId(scenario.getId());

        return test;
    }

    /**
     * Gets up-to-date status on a test.
     */
    public TestStatus getTestStatus(Test test) throws ApiException, IOException {
        return jsonApi.getTestStatus(test.getProjectId(), test.getScenarioId(), test.getId());
    }

    /**
     * Fetches an HTML test report for a test. The test has to be finished or this will fail.
     */
    public InputStream getTestReport(Test test) throws ApiException, IOException {
        return jsonApi.getTestReport(test.getProjectId(), test.getScenarioId(), test.getId()).body().asInputStream();
    }

    /**
     * Fetches statistics for a test. The test has to be finished or this will fail.
     */
    public TestStatistics getTestStatistics(Test test) throws ApiException, IOException {
        return jsonApi.getTestStatistics(test.getProjectId(), test.getScenarioId(), test.getId());
{'fraction_non_alphanumeric': 0.10056722367009045, 'fraction_numerical': 0.0, 'mean_word_length': 3.037128712871287, 'pattern_counts': {'":': 2, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '134555', 'n_tokens_mistral': 1761, 'n_tokens_neox': 1755, 'n_words': 497}