GitHub user dlukyanov opened a pull request:
https://github.com/apache/zeppelin/pull/1957
Branch 0.6 Groovy Interpreter
### What is this PR for?
Groovy Interpreter
### What type of PR is it?
Feature
### Todos
* [Code] - Task
* [Samples] - Task
* [Documentation] - Task
* [Test cases] - Task
### What is the Jira issue?
TODO
### How should this be tested?
Outline the steps to test the PR here.
### Samples
```groovy
%groovy
//get a parameter defined as z.angularBind('ngSearchParam', value,
'paragraph_id')
//g is a context object for groovy to avoid mix with z object?
def param = g.angular('ngSearchParam')
//send request
https://www.googleapis.com/customsearch/v1?q=ngSearchParam_value
def r = HTTP.get(
//assume you defined groovy interpreter property
`search_baseurl`='https://www.googleapis.com/customsearch/v1'
//in groovy object o.getProperty('A') == o.'A' == o.A == o['A']
url : g.search_baseurl,
query: [ q: param ],
headers: [
'Accept':'application/json',
//'Authorization:' : g.getProperty('search_auth'),
]
)
//check response code
if( r.response.code==200 ) {
g.html().with{
//g.html() renders %angular to output and returns
groovy.xml.MarkupBuilder
h2("the response ${r.response.code}")
span( r.response.body )
h2("headers")
pre( r.response.headers.join('\n') )
}
} else {
//just to show that it's possible to use println with multiline groovy
string to render output
println("""%angular
<script> alert ("code=${r.response.code} \n msg=${r.response.message}")
</script>
""")
}
```
```groovy
%groovy
//renders a table with headers a, b, c and two rows
g.table(
[
['a','b','c'],
['a1','b1','c1'],
['a2','b2','c2'],
]
)
```
### Questions:
* Does the licenses files need update?
no
* Is there breaking changes for older versions?
no
* Does this needs documentation?
yes
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/char-com-ua/zeppelin branch-0.6
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/zeppelin/pull/1957.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #1957
----
commit b26ab991b31108474d517a6dcecf82ae475f3488
Author: dlukyanov <[email protected]>
Date: 2017-01-29T09:38:32Z
groovy interpreter: base
commit 590a15d17689fbc0305fd8a730db23a91cbe544c
Author: dlukyanov <[email protected]>
Date: 2017-01-29T10:59:57Z
groovy interpreter: revision.txt
----
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---