Java API updating index templates: script parse exception

Hi there,

Looking for some pointers or tips for upgrading elasticsearch. Currently under 1.4. I've been reading about the changes to mappings and the java API to upgrade to 2.1.

I'm following the conventions for sending the templates via the HTTP api to construct the source here:
https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-templates.html

Everything works when I send the generated string to the server directly. However, using the java API, I'm getting a strange exception with the same string:

ScriptParseException[unexpected field [settings]]

The java docs to update a template isn't very verbose. Am I missing something?

Following https://www.elastic.co/guide/en/elasticsearch/client/java-api/current/indexed-scripts.html
using "mustache" for the scriptlang as suggested there.

EDIT:

I was using the wrong functions. I copied from ES's test examples here. Was confused between 'scripts' and 'templates' as it's not entirely clear at first glance in the docs.