AppVeyor REST API Client (from Swagger, in Java)

Build Status

AppVeyor REST API client generated from the unofficial Swagger definition in Java. The primary purpose of this project is to serve as a demonstration and test of the Swagger definition using the Java language. It is also suitable for use as a library to access the AppVeyor API from languages which run on the JVM. Users should be aware that the generated classes are a bit clunky and the API is likely to change frequently as a result of updates to swagger-codegen or the REST API.

Introductory Example

import name.kevinlocke.appveyor.ApiClient;
import name.kevinlocke.appveyor.ApiException;
import name.kevinlocke.appveyor.api.ProjectApi;
import name.kevinlocke.appveyor.model.Build;

public class AppveyorApiExample {
    public static void main(String[] args) {
        ApiClient apiClient = new ApiClient();
        apiClient.setApiKeyPrefix("Bearer");
        // API Token from https://ci.appveyor.com/api-token
        apiClient.setApiKey(apiToken);

        ProjectApi projectApi = new ProjectApi(apiClient);
        try {
            Build build =
                // Account name and slug from AppVeyor project URL
                projectApi.getProjectLastBuild(accountName, projectSlug)
                    .getBuild();
            System.out.println("Last build status: " + build.getStatus());
        } catch (ApiException e) {
            System.err.println("Error getting last build: " + e.getMessage());
        }
    }
}

Usage

Maven

To use this project as a dependency with Maven, add the following dependency to your project’s pom.xml:

<dependency>
  <groupId>name.kevinlocke.appveyor</groupId>
  <artifactId>appveyor-swagger</artifactId>
  <version>0.1.0</version>
</dependency>

sbt

To use this project as a dependency with sbt add the following dependency to your project’s build.sbt:

libraryDependencies += "name.kevinlocke.appveyor" % "appveyor-swagger" % "0.1.0"

Gradle

To use this project as a dependency with Gradle, add the following dependency to your project’s build.gradle:

compile "name.kevinlocke.appveyor:appveyor-swagger:0.1.0"

Others

To use this project as a dependency of another build system, a JAR can be created by running the following commands:

git clone --branch v0.1.0 https://github.com/kevinoid/appveyor-swagger-java.git
cd appveyor-swagger-java
mvn package

The generated JAR file will be at target/appveyor-swagger-0.1.0.jar.

Testing

Running the tests defined in this project requires an AppVeyor account. The API Token must be set in the environment variable $APPVEYOR_API_TOKEN when running the tests. This can be accomplished as follows:

APPVEYOR_API_TOKEN=deadbeef mvn test

License

This library is available under the terms of the MIT License.