Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Endpoints Migration sample #563

Merged
merged 26 commits into from
Mar 28, 2017
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
910aaf6
Moving endpoints discovery sample to migration-example
frankyn Feb 27, 2017
61710f5
Updated Plugins to fix known bug and updated READMEs
frankyn Feb 27, 2017
c74c254
Removed mentions of discovery doc from README
frankyn Feb 27, 2017
9c6b1be
Removing mentions of iOS from sample
frankyn Feb 27, 2017
a34b2d9
Updating endpoints frameworks plugin version
frankyn Feb 28, 2017
b9f9d69
Modified pom.xml and web.xml for docs
frankyn Mar 1, 2017
64387e6
Lowercase J in Jenkins.sh
frankyn Mar 10, 2017
7f1fa4e
Updated README.md to reflect generated path and removed discovery
frankyn Mar 13, 2017
e7ad617
Adding API explorer to README and fixed s/https/http/
frankyn Mar 13, 2017
09c91c0
Fixing typo: missing ']'
frankyn Mar 13, 2017
1fa6128
Fix typo: missing e in appengine
frankyn Mar 13, 2017
ee2ee14
Added configuration to endpoints-framework-plugin in pom.xml
frankyn Mar 14, 2017
741bf74
Updated version in pom.xml and set versions for build.gradle
frankyn Mar 14, 2017
a74aa1f
Updating App Engine Maven plugin version
frankyn Mar 14, 2017
be9fa47
Merge branch 'master' into discovery-endpoints-migration
frankyn Mar 14, 2017
e373132
Fixed formatted the migration-example/README.md
frankyn Mar 15, 2017
252139d
Adding region tags to build.gradle
frankyn Mar 22, 2017
66119b6
Adding endpoints frameworks plugin build.gradle comments
frankyn Mar 22, 2017
253b125
Fixing typo in region tag
frankyn Mar 22, 2017
8566518
Split endpointsServer and endpointsClient region tags
frankyn Mar 22, 2017
7ef7d53
Removing endpointsClient closure.
frankyn Mar 23, 2017
5352b92
Merge branch 'master' into discovery-endpoints-migration
frankyn Mar 23, 2017
f30850f
Merge branch 'master' into discovery-endpoints-migration
frankyn Mar 25, 2017
f5a83b8
Update version number of app-gradle-plugin
frankyn Mar 27, 2017
c272e72
Merge branch 'discovery-endpoints-migration' of github.com:GoogleClou…
frankyn Mar 27, 2017
2736b3c
Merge branch 'master' into discovery-endpoints-migration
lesv Mar 27, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions appengine/endpoints-frameworks-v2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
This directory contains Google Cloud Endpoints Frameworks for App Engine for
App Engine Standard samples. The [`backend/`](backend/) directory contains the
sample code for the [quickstart][4] for Cloud Endpoints Frameworks on App Engine
using an OpenAPI development process. The [`discovery/`](discovery/) directory
contains the sample code for [migrated][2] prior version of [Cloud Endpoints
Frameworks][1] project to the new [Cloud Endpoints Frameworks for App Engine][8]
using a discovery document development process.
using an OpenAPI development process. The [`migration-example/`](migration-example/) directory
contains the sample code for a [migrated][2] version of the [Cloud Endpoints
Frameworks][1] sample project to the new [Cloud Endpoints Frameworks for App Engine][8]
development process.

The new Google Cloud Endpoints Frameworks for App Engine provides
[additional functionality][3] using OpenAPI which may require payment.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
# Hello World Google Cloud Endpoints for App Engine with a discovery document
# Hello World Google Cloud Endpoints for App Engine

This sample provides an example of a [migration][7] from the prior version of
[Google Cloud Endpoints Frameworks][3] to new [Google Cloud Endpoints Frameworks for App Engine][8]
while still using a discovery document. This sample contains comments of how to
use the prior Endpoints Frameworks as well. For clarity, the prior Endpoints
Frameworks and the new Endpoints Frameworks are denoted as Endpoints Frameworks v1.0
and Endpoints Frameworks v2.0 respectively.
[Google Cloud Endpoints Frameworks][3] to new [Google Cloud Endpoints Frameworks for App Engine][8].
This sample contains comments of how to use the prior Endpoints Frameworks as
well. For clarity, the prior Endpoints Frameworks and the new Endpoints
Frameworks are denoted as Endpoints Frameworks v1.0 and Endpoints Frameworks
v2.0, respectively.

Google Cloud Endpoints Frameworks v2.0 provides new functionality which may
require payment and uses an OpenAPI specification instead of the discovery document.
The OpenAPI development process is explained [here][8] and a quickstart is
provided [here][9].
require payment and uses an OpenAPI specification. The OpenAPI development
process is explained [here][8] and a quickstart is provided [here][9].

## Products
- [Google App Engine Standard][1]
Expand All @@ -30,23 +29,27 @@ provided [here][9].
1. [Optional]: User Authenticating with Google Accounts in Web Clients

1. Update the `WEB_CLIENT_ID` in [Constants.java](src/main/java/com/example/helloendpoints/Constants.java)
to reflect the web client ID you have registered in the [Credentials on Developers Console for OAuth 2.0 client IDs][6].
to reflect the web client ID you have registered in the
[Credentials on Developers Console for OAuth 2.0 client IDs][6].

1. Update the value of `google.devrel.samples.helloendpoints.CLIENT_ID` in [base.js](src/main/webapp/js/base.js)
to reflect the web client ID you have registered in the [Credentials on Developers Console for OAuth 2.0 client IDs][6].
1. Update the value of `google.devrel.samples.helloendpoints.CLIENT_ID` in
[base.js](src/main/webapp/js/base.js) to reflect the web client ID you
have registered in the
[Credentials on Developers Console for OAuth 2.0 client IDs][6].

1. [Optional]: User Authenticating with Google Accounts in other Applications Types

- Inside [Constants.java](src/main/java/com/example/helloendpoints/Constants.java) you will find placeholders for Android
and iOS applications using Google Accounts client IDs registered in the
applications using Google Accounts client IDs registered in the
[Credentials on Developers Console for OAuth 2.0 client IDs][6].

- These client IDs are used when defining annotation for this sample API found in [Greetings.java](src/main/java/com/example/helloendpoints/Greetings.java).
- These client IDs are used when defining annotation for this sample API
found in [Greetings.java](src/main/java/com/example/helloendpoints/Greetings.java).

- You can read more about different user authentication supported [here][12].


1. [Optional]: Use Cloud Endpoints Frameworks v2.0 Maven and Gradle discovery and
1. [Optional]: Use Cloud Endpoints Frameworks v2.0 Maven and Gradle
client library generation plugins with Cloud Endpoints Frameworks v1.0.

- Uncomment `Endpoints Frameworks v1.0` sections and comment
Expand All @@ -62,57 +65,61 @@ provided [here][9].

### Maven

1. Build a fresh binary with
1. Build a fresh binary by using:

`mvn clean compile`

1. Run the application locally at [localhost:8080][5] with
1. Run the application locally at [http://localhost:8080][5] by using:

`mvn appengine:run`

1. Generate the client library in a zip file named `helloworld-v1-java.zip` with
1. Explore local server's API explorer by browsing to:

[http://localhost:8080/_ah/api/explorer][13]

1. Generate the client library located at `target/client-libs/helloworld-v1-java.zip`
by using:

`mvn endpoints-framework:clientLibs`

1. Deploy your application to Google App Engine with
1. Deploy your application to Google App Engine by using:

`mvn appengine:deploy`

### Gradle

1. Build a fresh binary with
1. Build a fresh binary by using:

`gradle clean compileJava`

1. Run the application locally at [localhost:8080][5] with
1. Run the application locally at [http://localhost:8080][5] by using:

`gradle appengineRun`

1. Generate the client library in a zip file named `helloworld-v1-java.zip` with
1. Explore local server's API explorer by browsing to:

`gradle endpointsClientLibs`
[http://localhost:8080/_ah/api/explorer][13]

1. Deploy your application to Google App Engine with
1. Generate the client library located at `build/endpointsClientLibs/helloworld-v1-java.zip`
by using:

`gradle appengineDeploy`
`gradle endpointsClientLibs`

## Known issues
1. Deploy your application to Google App Engine by using:

There's a [bug][13] where `<version>1</version>` is required in the
[appengine-web.xml](src/main/webapp/WEB-INF/appengine-web.xml) to run
this sample locally. This will become optional in the near future.
`gradle appengineDeploy`


[1]: https://cloud.google.com/appengine/docs/java/
[2]: http://java.com/en/
[3]: https://cloud.google.com/appengine/docs/java/endpoints/
[4]: https://cloud.google.com/appengine/docs/java/tools/maven
[5]: https://localhost:8080/
[5]: http://localhost:8080/
[6]: https://console.developers.google.com/project/_/apiui/credential
[7]: https://cloud.google.com/appengine/docs/java/endpoints/migrating
[8]: https://cloud.google.com/endpoints/docs/frameworks/java/about-cloud-endpoints-frameworks
[9]: https://cloud.google.com/endpoints/docs/frameworks/java/quickstart-frameworks-java
[10]: https://github.com/GoogleCloudPlatform/endpoints-framework-maven-plugin
[11]: https://github.com/GoogleCloudPlatform/endpoints-framework-gradle-plugin
[12]: https://cloud.google.com/endpoints/docs/authenticating-users-frameworks
[13]: https://github.com/cloudendpoints/endpoints-java/issues/43
[13]: http://localhost:8080/_ah/api/explorer
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ buildscript { // Configuration for building
jcenter() // Bintray's repository - a fast Maven Central mirror & more
}
dependencies {
classpath 'com.google.cloud.tools:appengine-gradle-plugin:+' // latest App Engine Gradle tasks
classpath 'com.google.cloud.tools:endpoints-framework-gradle-plugin:+'
classpath 'com.google.cloud.tools:appengine-gradle-plugin:1.1.0'
classpath 'com.google.cloud.tools:endpoints-framework-gradle-plugin:1.0.0-beta6'
}
}

Expand All @@ -43,7 +43,7 @@ dependencies {
// End of Endpoints Frameworks v1.0

// Endpoints Frameworks v2.0
compile "com.google.endpoints:endpoints-framework:+"
compile group: 'com.google.endpoints', name: 'endpoints-framework-tools', version: '2.0.4'
// End of Endpoints Frameworks v2.0
}

Expand All @@ -58,8 +58,8 @@ appengine { // App Engine tasks configuration
}
}

group = "com.example.helloendpoints" // Generated output GroupId
version = "1" // Version in generated output
group = 'com.example.helloendpoints' // Generated output GroupId
version = '1' // Version in generated output

sourceCompatibility = 1.7 // App Engine Standard uses Java 7
targetCompatibility = 1.7 // App Engine Standard uses Java 7
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,6 @@ limitations under the License.
</parent>

<properties>
<!-- Uncomment to use Endpoints Frameworks v1.0 -->
<!--
<appengine.endpoints.version>1.9.48</appengine.endpoints.version>
-->
<!-- End of Endpoints Frameworks v1.0 -->
<appengine.maven.version>1.0.0</appengine.maven.version>
<endpoints.maven.plugin.version>1.0.0-beta2</endpoints.maven.plugin.version>
<endpoints.framework.version>2.0.0-beta.12</endpoints.framework.version>
<javax.inject.version>1</javax.inject.version>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
Expand All @@ -53,18 +45,24 @@ limitations under the License.
<dependencies>
<!-- Compile/runtime dependencies -->
<!-- Uncomment to use Endpoints Frameworks v1.0 -->
<!--<dependency>
<!--
[START appengine-endpoints]
<dependency>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-endpoints</artifactId>
<version>${appengine.endpoints.version}</version>
</dependency>-->
<version>1.9.48</version>
</dependency>
[END appengine-endpoints]
-->
<!-- End of Endpoints Frameworks v1.0 -->
<!-- Endpoints Frameworks v2.0 -->
<!-- [START endpoints-frameworks] -->
<dependency>
<groupId>com.google.endpoints</groupId>
<artifactId>endpoints-framework</artifactId>
<version>${endpoints.framework.version}</version>
<version>2.0.4</version>
</dependency>
<!-- [END endpoints-frameworks] -->
<!-- End of Endpoints Frameworks v2.0 -->
<dependency>
<groupId>javax.servlet</groupId>
Expand All @@ -83,31 +81,26 @@ limitations under the License.
<!-- for hot reload of the web application-->
<outputDirectory>${project.build.directory}/${project.build.finalName}/WEB-INF/classes</outputDirectory>
<plugins>
<!-- [START appengine-plugin] -->
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>appengine-maven-plugin</artifactId>
<version>${appengine.maven.version}</version>
<version>1.2.1</version>
<configuration>
<!-- deploy configuration -->
</configuration>
</plugin>
<!-- [END appengine-plugin] -->
<!-- [START endpoints-frameworks-plugin] -->
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>endpoints-framework-maven-plugin</artifactId>
<version>${endpoints.maven.plugin.version}</version>
<version>1.0.0-beta3</version>
<configuration>
<webappDir>src/main/webapp</webappDir>
<discoveryDocDir>${project.build.directory}/generated-sources/appengine-endpoints/WEB-INF</discoveryDocDir>
<!-- plugin configuration -->
</configuration>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>discoveryDocs</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- [END endpoints-frameworks-plugin] -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>versions-maven-plugin</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
public class Constants {
public static final String WEB_CLIENT_ID = "replace this with your web client ID";
public static final String ANDROID_CLIENT_ID = "replace this with your Android client ID";
public static final String IOS_CLIENT_ID = "replace this with your iOS client ID";
public static final String ANDROID_AUDIENCE = WEB_CLIENT_ID;

public static final String EMAIL_SCOPE = "https://www.googleapis.com/auth/userinfo.email";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
@Api(name = "helloworld",
version = "v1",
scopes = {Constants.EMAIL_SCOPE},
clientIds = {Constants.WEB_CLIENT_ID, Constants.ANDROID_CLIENT_ID, Constants.IOS_CLIENT_ID},
clientIds = {Constants.WEB_CLIENT_ID, Constants.ANDROID_CLIENT_ID},
audiences = {Constants.ANDROID_AUDIENCE}
)
public class Greetings {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ See the License for the specific language governing permissions and
limitations under the License.
-->
<threadsafe>true</threadsafe>
<version>1</version>
<system-properties>
<property name="java.util.logging.config.file" value="WEB-INF/logging.properties"/>
</system-properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,12 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!-- Uncomment to use Endpoints Frameworks v1.0 -->
<!--
[START appengine-endpoints]
<servlet>
<!-- Uncomment to use Endpoints Frameworks v1.0 -->
<!--
<servlet-name>SystemServiceServlet</servlet-name>
<servlet-class>com.google.api.server.spi.SystemServiceServlet</servlet-class>
-->
<!-- End of Endpoints Frameworks v1.0 -->
<!-- Endpoints Frameworks v2.0 -->
<servlet-name>EndpointsServlet</servlet-name>
<servlet-class>com.google.api.server.spi.EndpointsServlet</servlet-class>
<!-- End of Endpoints Frameworks v2.0 -->
<init-param>
<param-name>services</param-name>
<param-value>com.example.helloendpoints.Greetings</param-value>
Expand All @@ -35,17 +30,34 @@ limitations under the License.
</init-param>
</servlet>
<servlet-mapping>
<!-- Uncomment to use Endpoints Frameworks v1.0 -->
<!--
<servlet-name>SystemServiceServlet</servlet-name>
<url-pattern>/_ah/spi/*</url-pattern>
-->
<!-- End of Endpoints Frameworks v1.0 -->
<!-- Endpoints Frameworks v2.0 -->
</servlet-mapping>
[END appengine-endpoints]
-->
<!-- End of Endpoints Frameworks v1.0 -->

<!-- Endpoints Frameworks v2.0 -->
<!-- [START endpoints-frameworks] -->
<servlet>
<servlet-name>EndpointsServlet</servlet-name>
<servlet-class>com.google.api.server.spi.EndpointsServlet</servlet-class>
<init-param>
<param-name>services</param-name>
<param-value>com.example.helloendpoints.Greetings</param-value>
</init-param>
<init-param>
<param-name>restricted</param-name>
<param-value>false</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>EndpointsServlet</servlet-name>
<url-pattern>/_ah/api/*</url-pattern>
<!-- End of Endpoints Frameworks v2.0 -->
</servlet-mapping>
<!-- [END endpoints-frameworks] -->
<!-- End of Endpoints Frameworks v2.0 -->

<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
Expand Down