Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
## Modifying/Adding code

Most of the SDK is generated code. Modifications to code will be persisted between generations, but may
result in merge conflicts between manual patches and changes from the generator. The generator will never
modify the contents of the `arcade-java/lib/` and `arcade-java-examples/` directories.

## Adding and running examples

TODO

## Building the repository from source

If you’d like to use the repository from source, you can build and install it from git:

```sh
git clone git@github.com/ArcadeAI/arcade-java.git
SKIP_MOCK_TESTS=true ./gradlew build publishToMavenLocal # This will skip the integration tests, see below on info on how to run them.
```
## Running tests

Most tests require you to [run a mock server](https://github.com/stoplightio/prism) against the OpenAPI spec to run the tests.

```sh
# you will need npm installed
./scripts/mock --daemon
```

The mock serer will run in the background allowing you to run tests from the command line `./gradlew test` or from your IDE.

To stop the mock server run:
```shell
pkill -f prism
```

## Linting and formatting

This repository uses [Spotless](https://github.com/diffplug/spotless/tree/main/plugin-gradle) to lint and format the code in the repository.

To lint:

```sh
$ ./scripts/lint
```

To format and fix all issues automatically:

```sh
$ ./scripts/format
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package dev.arcade.example.simple;

import dev.arcade.client.ArcadeClient;
import dev.arcade.client.okhttp.ArcadeOkHttpClient;
import dev.arcade.models.ExecuteToolRequest;
import dev.arcade.models.ExecuteToolResponse;
import dev.arcade.models.ToolExecuteParams;

/**
* Example of calling a tool using the Arcade Java SDK.
*/
public class PlaySpotify {

/**
* Simple main method example.
* @param args Not used.
*/
public static void main(String[] args) {

// Configures using the `ARCADE_API_KEY` environment variable
ArcadeClient client = ArcadeOkHttpClient.fromEnv();

String userId = System.getenv("ARCADE_USER_ID"); // the Spotify tool require a userId
if (userId == null) {
throw new IllegalArgumentException("Missing ARCADE_USER_ID environment variable");
}

ToolExecuteParams params = ToolExecuteParams.builder()
.executeToolRequest(ExecuteToolRequest.builder()
.toolName("Spotify.ResumePlayback@1.0.2")
.userId(userId)
.build())
.build();
ExecuteToolResponse executeToolResponse = client.tools().execute(params);
executeToolResponse
.output()
.ifPresentOrElse(
output -> System.out.println("Tool output: " + output._value()),
() -> System.out.println("No output for this tool"));
}
}
4 changes: 2 additions & 2 deletions scripts/mock
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ echo "==> Starting mock server with URL ${URL}"

# Run prism mock on the given spec
if [ "$1" == "--daemon" ]; then
npm exec --package=@stainless-api/prism-cli@5.8.5 -- prism mock "$URL" &> .prism.log &
npm exec --package=@stainless-api/prism-cli@5.16.1 -- prism mock "$URL" &> .prism.log &

# Wait for server to come online
echo -n "Waiting for server"
Expand All @@ -37,5 +37,5 @@ if [ "$1" == "--daemon" ]; then

echo
else
npm exec --package=@stainless-api/prism-cli@5.8.5 -- prism mock "$URL"
npm exec --package=@stainless-api/prism-cli@5.16.1 -- prism mock "$URL"
fi
Loading