Skip to end of metadata
Go to start of metadata

Once you have completed the creation of your script, you need to publish it to the repository manager for execution. This is done by REST API invocations against the endpoint:

http://localhost:8081/service/siesta/rest/v1/script

This endpoint accepts JSON-formatted payloads with your script as the content.

Example JSON formatted file maven.json with a simple repository creation script:

{
  "name": "maven",
  "type": "groovy",
  "content": "repository.createMavenHosted('private')"
}

The JSON file maven.json located in the current directory can be published to the repository manager with an HTTP POST like:

curl -v -X POST -u admin:admin123 --header "Content-Type: application/json" 'http://localhost:8081/service/siesta/rest/v1/script' -d @maven.json

 A list of scripts stored on the repository manager can be accessed with:

curl -v -X GET -u admin:admin123 'http://localhost:8081/service/siesta/rest/v1/script'

The same call with a script name appended returns the actual script content. 

A script can be executed by sending a POST to the run method of the specific script.

curl -v -X POST -u admin:admin123 --header "Content-Type: text/plain" 'http://localhost:8081/service/siesta/rest/v1/script/maven/run'

A successful execution should result in a HTTP/1.1 200 OK.

Scripts can be removed with a HTTP DELETE operation to the specific script:

curl -v -X DELETE -u admin:admin123 'http://localhost:8081/service/siesta/rest/v1/script/maven'

Scripts can receive run-time parameters via the REST API:

curl -v -X POST -u admin:admin123 --header "Content-Type: text/plain" 'http://localhost:8081/service/siesta/rest/v1/script/updateAnonymousAccess/run' -d 'false'

and receive them as arguments that have to be parsed by the script as desired:

security.setAnonymousAccess(Boolean.valueOf(args))

Interaction with the REST API for scripts can be done with any scripting language capable of HTTP calls as mentioned above. In the following section you can find some further detailed examples.

  • No labels