<div id="outer" class="outer-wrapper">
	<div id="dataservice-documentation-container" class="container-fluid"
		ng-controller="DSDocumentationController as vm">


        <div id="loading-spinner" ng-show="vm.isLoading==true">
            <div class="spinner spinner-lg spinner-inline" />
            {{:: 'dataservice-documentation.LoadingCodeSamples' | translate}}
	    </div>
        <div translate="dataservice-documentation.connecting-heading1"></div>
        <h5>{{vm.connectionDetailTitle}}</h5>
        <div><strong>&nbsp;&nbsp;&nbsp;JDBC:&nbsp;</strong>{{vm.jdbcConnectionString}}</div>
        <div><strong>&nbsp;&nbsp;&nbsp;OData:&nbsp;</strong>{{vm.odataUrl}}</div>
        <p></p>
        <!--  Tabs for Code Samples -->
        <div id="sample-tabs" ng-show="vm.isLoading==false">
            <uib-tabset>
            <!--  -->
            <!--  -->
            <!--  Java Code Sample -->
            <uib-tab
                heading="{{:: 'dataservice-documentation.javaTab' | translate}}">
                <p></p>
                <!-- instructions -->
                <div translate="dataservice-documentation.java-instructions"></div>
                <!-- Code Sample -->
                <div><pre><code>public void execute() throws SQLException {
    String url = "{{vm.jdbcConnectionString}}";
    String sql = "select 1"; //CHANGE ME
 
    Class.forName("org.teiid.jdbc.TeiidDriver");
 
    Connection connection;
    try{
        connection = DriverManager.getConnection(url, "{user}", "{user}"); //Update credentials accordingly
        Statement statement = connection.createStatement();
        ResultSet results = statement.executeQuery(sql);
        while(results.next()) {
          System.out.println(results.getString(1));
        }
        results.close();
        statement.close();
    } catch (SQLException e){
        e.printStackTrace();
        throw e;
    } finally {
        try{
          connection.close();
        }catch(SQLException e1){
          // ignore
        }
    }
}</code></pre>
                </div>
            </uib-tab>
            <!--  -->
            <!--  -->
            <!--  Javascript Code Sample -->
            <uib-tab
                heading="{{:: 'dataservice-documentation.javaScriptTab' | translate}}">
                <p></p>
                <!-- instructions -->
                <div translate="dataservice-documentation.javascript-instructions"></div>
                <!-- Code Sample -->
                <div><pre><code>$.ajax({
             type: 'GET',
             dataType: 'json',
             headers: {
                          Accept: 'application: 'application/json',
                          Authorization: 'Basic xxxxxxxxxxx',
                          url: '{{vm.odataUrl}}',
             success: function(data)
                          for (var x = 0; x < data.length; x++) {
                                      console.log(data[i]);
                          }
             },
             error: function(data) {
                         console.log('Error code: ' + data.errorCode);
                         console.log('Error message: ' + data.errorMessage);
             }
});</code></pre>
                </div>
            </uib-tab>
            <!--  -->
            <!--  -->
            <!--  Node.js Code Sample -->
            <uib-tab
                heading="{{:: 'dataservice-documentation.nodeTab' | translate}}">
                <p></p>
                <!-- instructions -->
                <div translate="dataservice-documentation.node-instructions"></div>
                <!-- Code Sample -->
                <div><pre><code>o('{{vm.odataUrl}}').get(function(data) {
  console.log(data); //returns an array of data
});</code></pre></div>
            </uib-tab>
            <!--  Python Code Sample -->
            <uib-tab
                heading="{{:: 'dataservice-documentation.pythonTab' | translate}}">
                <p></p>
                <!-- instructions -->
                <div translate="dataservice-documentation.python-instructions"></div>
                <!-- Code Sample -->
                <div><pre><code>import requests
from requests.auth import HTTPBasicAuth

headers = {'accept': 'application/json;odata=verbose'}
r = requests.get({{vm.odataUrl}}, auth=HTTPBasicAuth('someUser', 'somePassword'), headers=headers)

print r.json()</code></pre>
                </div>
            </uib-tab>
            <!--  -->
            <!--  -->
            <!--  PHP Code Sample -->
            <uib-tab
                heading="{{:: 'dataservice-documentation.phpTab' | translate}}">
                <p></p>
                <!-- instructions -->
                <div translate="dataservice-documentation.php-instructions"></div>
                <!-- Code Sample -->
                <div><pre><code>$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 100);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Authorization: Basic xxxxxxxxxx'));
$api_request_parameters = array('filter'=>"some_field eq 'some value'");
$api_request_url = "{{vm.odataUrl}}";
$api_request_url .= "?".http_build_query($api_request_parameters);
$curl_setopt($ch, CURLOPT_URL, $api_request_url);
$response = curl_exec($ch);
curl_close($ch);</pre></code>
                </div>
            </uib-tab>
            </uib-tabset>
        </div>

	</div>