-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #68 from udacity/gce_update
Gce update
- Loading branch information
Showing
9 changed files
with
284 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// If you would like more information on the gradle-appengine-plugin please refer to the github page | ||
// https://github.com/GoogleCloudPlatform/gradle-appengine-plugin | ||
|
||
buildscript { | ||
repositories { | ||
jcenter() | ||
} | ||
dependencies { | ||
classpath 'com.google.appengine:gradle-appengine-plugin:1.9.42' | ||
} | ||
} | ||
|
||
repositories { | ||
jcenter(); | ||
} | ||
|
||
apply plugin: 'java' | ||
apply plugin: 'war' | ||
apply plugin: 'appengine' | ||
|
||
sourceCompatibility = JavaVersion.VERSION_1_7 | ||
targetCompatibility = JavaVersion.VERSION_1_7 | ||
|
||
dependencies { | ||
appengineSdk 'com.google.appengine:appengine-java-sdk:1.9.42' | ||
compile 'com.google.appengine:appengine-endpoints:1.9.42' | ||
compile 'com.google.appengine:appengine-endpoints-deps:1.9.42' | ||
compile 'javax.servlet:servlet-api:2.5' | ||
compile 'com.google.api-client:google-api-client:1.23.0' | ||
compile 'com.google.http-client:google-http-client-android:1.23.0' | ||
} | ||
|
||
appengine { | ||
downloadSdk = true | ||
appcfg { | ||
oauth2 = true | ||
} | ||
endpoints { | ||
getClientLibsOnBuild = true | ||
getDiscoveryDocsOnBuild = true | ||
googleClientVersion = '1.23.0' | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
FinalProject/backend/src/main/java/com/udacity/gradle/builditbigger/backend/MyBean.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.udacity.gradle.builditbigger.backend; | ||
|
||
/** The object model for the data we are sending through endpoints */ | ||
public class MyBean { | ||
|
||
private String myData; | ||
|
||
public String getData() { | ||
return myData; | ||
} | ||
|
||
public void setData(String data) { | ||
myData = data; | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
FinalProject/backend/src/main/java/com/udacity/gradle/builditbigger/backend/MyEndpoint.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
For step-by-step instructions on connecting your Android application to this backend module, | ||
see "App Engine Java Endpoints Module" template documentation at | ||
https://github.com/GoogleCloudPlatform/gradle-appengine-templates/tree/master/HelloEndpoints | ||
*/ | ||
|
||
package com.udacity.gradle.builditbigger.backend; | ||
|
||
import com.google.api.server.spi.config.Api; | ||
import com.google.api.server.spi.config.ApiMethod; | ||
import com.google.api.server.spi.config.ApiNamespace; | ||
|
||
import javax.inject.Named; | ||
|
||
/** An endpoint class we are exposing */ | ||
@Api( | ||
name = "myApi", | ||
version = "v1", | ||
namespace = @ApiNamespace( | ||
ownerDomain = "backend.builditbigger.gradle.udacity.com", | ||
ownerName = "backend.builditbigger.gradle.udacity.com", | ||
packagePath = "" | ||
) | ||
) | ||
public class MyEndpoint { | ||
|
||
/** A simple endpoint method that takes a name and says Hi back */ | ||
@ApiMethod(name = "sayHi") | ||
public MyBean sayHi(@Named("name") String name) { | ||
MyBean response = new MyBean(); | ||
response.setData("Hi, " + name); | ||
|
||
return response; | ||
} | ||
|
||
} |
10 changes: 10 additions & 0 deletions
10
FinalProject/backend/src/main/webapp/WEB-INF/appengine-web.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<appengine-web-app xmlns="http://appengine.google.com/ns/1.0"> | ||
<application>myApplicationId</application> | ||
<version>1</version> | ||
<threadsafe>true</threadsafe> | ||
|
||
<system-properties> | ||
<property name="java.util.logging.config.file" value="WEB-INF/logging.properties"/> | ||
</system-properties> | ||
</appengine-web-app> |
13 changes: 13 additions & 0 deletions
13
FinalProject/backend/src/main/webapp/WEB-INF/logging.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# A default java.util.logging configuration. | ||
# (All App Engine logging is through java.util.logging by default). | ||
# | ||
# To use this configuration, copy it into your application's WEB-INF | ||
# folder and add the following to your appengine-web.xml: | ||
# | ||
# <system-properties> | ||
# <property name="java.util.logging.config.file" value="WEB-INF/logging.properties"/> | ||
# </system-properties> | ||
# | ||
|
||
# Set the default logging level for all loggers to WARNING | ||
.level = WARNING |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<web-app xmlns="http://java.sun.com/xml/ns/javaee" version="2.5"> | ||
<servlet> | ||
<servlet-name>SystemServiceServlet</servlet-name> | ||
<servlet-class>com.google.api.server.spi.SystemServiceServlet</servlet-class> | ||
<init-param> | ||
<param-name>services</param-name> | ||
<param-value>com.udacity.gradle.builditbigger.backend.MyEndpoint</param-value> | ||
</init-param> | ||
</servlet> | ||
<servlet-mapping> | ||
<servlet-name>SystemServiceServlet</servlet-name> | ||
<url-pattern>/_ah/spi/*</url-pattern> | ||
</servlet-mapping> | ||
|
||
<welcome-file-list> | ||
<welcome-file>index.html</welcome-file> | ||
</welcome-file-list> | ||
</web-app> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Hello, Endpoints!</title> | ||
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css"> | ||
<link rel="stylesheet" | ||
href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap-theme.min.css"> | ||
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script> | ||
<script src="//netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script> | ||
</head> | ||
<body role="document" style="padding-top: 70px;"> | ||
<div class="navbar navbar-inverse navbar-fixed-top" role="navigation"> | ||
<div class="container"> | ||
<div class="navbar-header"> | ||
<a class="navbar-brand" href="#">Hello, Endpoints!</a> | ||
</div> | ||
<div class="navbar-collapse collapse"> | ||
<ul class="nav navbar-nav"> | ||
<li class="dropdown"> | ||
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Documentation <b | ||
class="caret"></b></a> | ||
<ul class="dropdown-menu"> | ||
<li><a href="https://developers.google.com/appengine/docs/java/">Google App | ||
Engine</a></li> | ||
<li><a href="https://developers.google.com/appengine/docs/java/endpoints/">Google | ||
Cloud Endpoints</a></li> | ||
<li> | ||
<a href="https://github.com/GoogleCloudPlatform/gradle-appengine-templates/tree/master/HelloEndpoints">Connecting | ||
your Android application to this backend</a></li> | ||
</ul> | ||
</li> | ||
<li><a href="/_ah/api/explorer">Google Cloud Endpoints API Explorer</a></li> | ||
<li><a href="https://console.developers.google.com">Google Developers Console</a> | ||
</li> | ||
</ul> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<div class="container theme-showcase" role="main"> | ||
<!-- | ||
Output from Endpoints API call. | ||
--> | ||
<div class="alert alert-success" style="visibility: collapse;" id="outputAlert"></div> | ||
|
||
<!-- | ||
A form that takes a text value and submits it to the Endpoint, | ||
access to the Endpoint is enabled once the client is loaded below. | ||
--> | ||
<div class="jumbotron"> | ||
<div class="row"> | ||
<div class="col-lg-12"> | ||
<h1>Hello, Endpoints!</h1> | ||
<p>Enter your name and press the button below to call your Google Cloud Endpoints | ||
API.</p> | ||
<form> | ||
<div class="input-group"> | ||
<input type="text" class="form-control input-lg" placeholder="Name" | ||
id="nameInput"/> | ||
<span class="input-group-btn"> | ||
<button class="btn btn-default btn-primary btn-group btn-lg" | ||
type="submit" id="helloButton">Say "Hello" »</button> | ||
</span> | ||
</div> | ||
</form> | ||
<br/> | ||
<p>If you need step-by-step instructions for connecting your Android application to | ||
this backend module, see <a | ||
href="https://github.com/GoogleCloudPlatform/gradle-appengine-templates/tree/master/HelloEndpoints">"App | ||
Engine Java Endpoints Module" template documentation</a>.</p> | ||
<p> | ||
<small> | ||
For more information about Google App Engine for Java, check out the <a | ||
href="https://developers.google.com/appengine/docs/java/">App Engine | ||
documentation</a>.<br/> | ||
To learn more about Google Cloud Endpoints, see <a | ||
href="https://developers.google.com/appengine/docs/java/endpoints/">Cloud | ||
Endpoints documentation</a>.<br/> | ||
If you'd like to access your generated Google Cloud Endpoints APIs directly, | ||
see the <a href="/_ah/api/explorer">Cloud Endpoints API Explorer</a>. | ||
</small> | ||
</p> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<script type="text/javascript"> | ||
// A function that attaches a "Say Hello" button click handler | ||
function enableClick() { | ||
document.getElementById('helloButton').onclick = function() { | ||
var name = document.getElementById('nameInput').value; | ||
gapi.client.myApi.sayHi({'name': name}).execute( | ||
function(response) { | ||
var outputAlertDiv = document.getElementById('outputAlert'); | ||
outputAlertDiv.style.visibility = 'visible'; | ||
|
||
if (!response.error) { | ||
outputAlertDiv.className = 'alert alert-success'; | ||
outputAlertDiv.innerHTML = '<h2>' + response.result.data + '</h2>'; | ||
} | ||
else if (response.error) { | ||
outputAlertDiv.className = 'alert alert-danger'; | ||
outputAlertDiv.innerHTML = '<b>Error Code: </b>' + response.error.code + ' [' + response.error.message + ']'; | ||
} | ||
} | ||
); | ||
return false; | ||
} | ||
} | ||
// This is called initially | ||
function init() { | ||
var apiName = 'myApi'; | ||
var apiVersion = 'v1'; | ||
var apiRoot = 'https://' + window.location.host + '/_ah/api'; | ||
if (window.location.hostname == 'localhost' | ||
|| window.location.hostname == '127.0.0.1' | ||
|| ((window.location.port != "") && (window.location.port > 1023))) { | ||
// We're probably running against the DevAppServer | ||
apiRoot = 'http://' + window.location.host + '/_ah/api'; | ||
} | ||
var callback = function() { | ||
enableClick(); | ||
} | ||
gapi.client.load(apiName, apiVersion, callback, apiRoot); | ||
} | ||
|
||
</script> | ||
<!-- | ||
Load the Google APIs Client Library for JavaScript | ||
More info here : https://developers.google.com/api-client-library/javascript/reference/referencedocs | ||
--> | ||
|
||
<script src="https://apis.google.com/js/client.js?onload=init"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
include ':app' | ||
include ':app', ':backend' |