Skip to content

Commit c5fd101

Browse files
authored
Merge pull request #563 from GoogleCloudPlatform/discovery-endpoints-migration
Update Endpoints Migration sample
2 parents 824adf3 + 2736b3c commit c5fd101

File tree

19 files changed

+110
-81
lines changed

19 files changed

+110
-81
lines changed

appengine/endpoints-frameworks-v2/README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
This directory contains Google Cloud Endpoints Frameworks for App Engine for
44
App Engine Standard samples. The [`backend/`](backend/) directory contains the
55
sample code for the [quickstart][4] for Cloud Endpoints Frameworks on App Engine
6-
using an OpenAPI development process. The [`discovery/`](discovery/) directory
7-
contains the sample code for [migrated][2] prior version of [Cloud Endpoints
8-
Frameworks][1] project to the new [Cloud Endpoints Frameworks for App Engine][8]
9-
using a discovery document development process.
6+
using an OpenAPI development process. The [`migration-example/`](migration-example/) directory
7+
contains the sample code for a [migrated][2] version of the [Cloud Endpoints
8+
Frameworks][1] sample project to the new [Cloud Endpoints Frameworks for App Engine][8]
9+
development process.
1010

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

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

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

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

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

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

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

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

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

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

4851

49-
1. [Optional]: Use Cloud Endpoints Frameworks v2.0 Maven and Gradle discovery and
52+
1. [Optional]: Use Cloud Endpoints Frameworks v2.0 Maven and Gradle
5053
client library generation plugins with Cloud Endpoints Frameworks v1.0.
5154

5255
- Uncomment `Endpoints Frameworks v1.0` sections and comment
@@ -62,57 +65,61 @@ provided [here][9].
6265
6366
### Maven
6467
65-
1. Build a fresh binary with
68+
1. Build a fresh binary by using:
6669
6770
`mvn clean compile`
6871
69-
1. Run the application locally at [localhost:8080][5] with
72+
1. Run the application locally at [http://localhost:8080][5] by using:
7073
7174
`mvn appengine:run`
7275
73-
1. Generate the client library in a zip file named `helloworld-v1-java.zip` with
76+
1. Explore local server's API explorer by browsing to:
77+
78+
[http://localhost:8080/_ah/api/explorer][13]
79+
80+
1. Generate the client library located at `target/client-libs/helloworld-v1-java.zip`
81+
by using:
7482
7583
`mvn endpoints-framework:clientLibs`
7684
77-
1. Deploy your application to Google App Engine with
85+
1. Deploy your application to Google App Engine by using:
7886
7987
`mvn appengine:deploy`
8088
8189
### Gradle
8290
83-
1. Build a fresh binary with
91+
1. Build a fresh binary by using:
8492
8593
`gradle clean compileJava`
8694
87-
1. Run the application locally at [localhost:8080][5] with
95+
1. Run the application locally at [http://localhost:8080][5] by using:
8896
8997
`gradle appengineRun`
9098
91-
1. Generate the client library in a zip file named `helloworld-v1-java.zip` with
99+
1. Explore local server's API explorer by browsing to:
92100
93-
`gradle endpointsClientLibs`
101+
[http://localhost:8080/_ah/api/explorer][13]
94102
95-
1. Deploy your application to Google App Engine with
103+
1. Generate the client library located at `build/endpointsClientLibs/helloworld-v1-java.zip`
104+
by using:
96105
97-
`gradle appengineDeploy`
106+
`gradle endpointsClientLibs`
98107
99-
## Known issues
108+
1. Deploy your application to Google App Engine by using:
100109
101-
There's a [bug][13] where `<version>1</version>` is required in the
102-
[appengine-web.xml](src/main/webapp/WEB-INF/appengine-web.xml) to run
103-
this sample locally. This will become optional in the near future.
110+
`gradle appengineDeploy`
104111
105112
106113
[1]: https://cloud.google.com/appengine/docs/java/
107114
[2]: http://java.com/en/
108115
[3]: https://cloud.google.com/appengine/docs/java/endpoints/
109116
[4]: https://cloud.google.com/appengine/docs/java/tools/maven
110-
[5]: https://localhost:8080/
117+
[5]: http://localhost:8080/
111118
[6]: https://console.developers.google.com/project/_/apiui/credential
112119
[7]: https://cloud.google.com/appengine/docs/java/endpoints/migrating
113120
[8]: https://cloud.google.com/endpoints/docs/frameworks/java/about-cloud-endpoints-frameworks
114121
[9]: https://cloud.google.com/endpoints/docs/frameworks/java/quickstart-frameworks-java
115122
[10]: https://github.com/GoogleCloudPlatform/endpoints-framework-maven-plugin
116123
[11]: https://github.com/GoogleCloudPlatform/endpoints-framework-gradle-plugin
117124
[12]: https://cloud.google.com/endpoints/docs/authenticating-users-frameworks
118-
[13]: https://github.com/cloudendpoints/endpoints-java/issues/43
125+
[13]: http://localhost:8080/_ah/api/explorer

appengine/endpoints-frameworks-v2/discovery/build.gradle renamed to appengine/endpoints-frameworks-v2/migration-example/build.gradle

+24-5
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,21 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15+
// [START buildscript]
1516
buildscript { // Configuration for building
1617
repositories {
1718
mavenCentral()
1819
jcenter() // Bintray's repository - a fast Maven Central mirror & more
1920
}
2021
dependencies {
21-
classpath 'com.google.cloud.tools:appengine-gradle-plugin:+' // latest App Engine Gradle tasks
22-
classpath 'com.google.cloud.tools:endpoints-framework-gradle-plugin:+'
22+
// App Engine Gradle plugin
23+
classpath 'com.google.cloud.tools:appengine-gradle-plugin:1.1.1'
24+
25+
// Endpoints Frameworks Gradle plugin
26+
classpath 'com.google.cloud.tools:endpoints-framework-gradle-plugin:1.0.0-beta6'
2327
}
2428
}
29+
// [END buildscript]
2530

2631
repositories { // repositories for Jar's you access in your code
2732
mavenCentral()
@@ -30,8 +35,14 @@ repositories { // repositories for Jar's you access in your code
3035

3136
apply plugin: 'java' // standard Java tasks
3237
apply plugin: 'war' // standard Web Archive plugin
38+
39+
// [START apply_appengine]
3340
apply plugin: 'com.google.cloud.tools.appengine' // App Engine tasks
41+
// [END apply_appengine]
42+
43+
// [START apply_endpoints-framework-server]
3444
apply plugin: 'com.google.cloud.tools.endpoints-framework-server'
45+
// [END apply_endpoints-framework-server]
3546

3647
dependencies {
3748
providedCompile group: 'javax.servlet', name: 'servlet-api', version:'2.5'
@@ -43,7 +54,9 @@ dependencies {
4354
// End of Endpoints Frameworks v1.0
4455

4556
// Endpoints Frameworks v2.0
46-
compile "com.google.endpoints:endpoints-framework:+"
57+
// [START endpoints-tools]
58+
compile group: 'com.google.endpoints', name: 'endpoints-framework-tools', version: '2.0.4'
59+
// [END endpoints-tools]
4760
// End of Endpoints Frameworks v2.0
4861
}
4962

@@ -58,8 +71,14 @@ appengine { // App Engine tasks configuration
5871
}
5972
}
6073

61-
group = "com.example.helloendpoints" // Generated output GroupId
62-
version = "1" // Version in generated output
74+
/* [START endpoints-server]
75+
endpointsServer {
76+
// Endpoints Framework Plugin server-side configuration
77+
}
78+
[END endpoints-server] */
79+
80+
group = 'com.example.helloendpoints' // Generated output GroupId
81+
version = '1' // Version in generated output
6382

6483
sourceCompatibility = 1.7 // App Engine Standard uses Java 7
6584
targetCompatibility = 1.7 // App Engine Standard uses Java 7

appengine/endpoints-frameworks-v2/discovery/pom.xml renamed to appengine/endpoints-frameworks-v2/migration-example/pom.xml

+17-24
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,6 @@ limitations under the License.
3030
</parent>
3131

3232
<properties>
33-
<!-- Uncomment to use Endpoints Frameworks v1.0 -->
34-
<!--
35-
<appengine.endpoints.version>1.9.48</appengine.endpoints.version>
36-
-->
37-
<!-- End of Endpoints Frameworks v1.0 -->
38-
<appengine.maven.version>1.0.0</appengine.maven.version>
39-
<endpoints.maven.plugin.version>1.0.0-beta2</endpoints.maven.plugin.version>
40-
<endpoints.framework.version>2.0.0-beta.12</endpoints.framework.version>
4133
<javax.inject.version>1</javax.inject.version>
4234
<maven.compiler.source>1.7</maven.compiler.source>
4335
<maven.compiler.target>1.7</maven.compiler.target>
@@ -53,18 +45,24 @@ limitations under the License.
5345
<dependencies>
5446
<!-- Compile/runtime dependencies -->
5547
<!-- Uncomment to use Endpoints Frameworks v1.0 -->
56-
<!--<dependency>
48+
<!--
49+
[START appengine-endpoints]
50+
<dependency>
5751
<groupId>com.google.appengine</groupId>
5852
<artifactId>appengine-endpoints</artifactId>
59-
<version>${appengine.endpoints.version}</version>
60-
</dependency>-->
53+
<version>1.9.48</version>
54+
</dependency>
55+
[END appengine-endpoints]
56+
-->
6157
<!-- End of Endpoints Frameworks v1.0 -->
6258
<!-- Endpoints Frameworks v2.0 -->
59+
<!-- [START endpoints-frameworks] -->
6360
<dependency>
6461
<groupId>com.google.endpoints</groupId>
6562
<artifactId>endpoints-framework</artifactId>
66-
<version>${endpoints.framework.version}</version>
63+
<version>2.0.4</version>
6764
</dependency>
65+
<!-- [END endpoints-frameworks] -->
6866
<!-- End of Endpoints Frameworks v2.0 -->
6967
<dependency>
7068
<groupId>javax.servlet</groupId>
@@ -83,31 +81,26 @@ limitations under the License.
8381
<!-- for hot reload of the web application-->
8482
<outputDirectory>${project.build.directory}/${project.build.finalName}/WEB-INF/classes</outputDirectory>
8583
<plugins>
84+
<!-- [START appengine-plugin] -->
8685
<plugin>
8786
<groupId>com.google.cloud.tools</groupId>
8887
<artifactId>appengine-maven-plugin</artifactId>
89-
<version>${appengine.maven.version}</version>
88+
<version>1.2.1</version>
9089
<configuration>
9190
<!-- deploy configuration -->
9291
</configuration>
9392
</plugin>
93+
<!-- [END appengine-plugin] -->
94+
<!-- [START endpoints-frameworks-plugin] -->
9495
<plugin>
9596
<groupId>com.google.cloud.tools</groupId>
9697
<artifactId>endpoints-framework-maven-plugin</artifactId>
97-
<version>${endpoints.maven.plugin.version}</version>
98+
<version>1.0.0-beta3</version>
9899
<configuration>
99-
<webappDir>src/main/webapp</webappDir>
100-
<discoveryDocDir>${project.build.directory}/generated-sources/appengine-endpoints/WEB-INF</discoveryDocDir>
100+
<!-- plugin configuration -->
101101
</configuration>
102-
<executions>
103-
<execution>
104-
<phase>generate-sources</phase>
105-
<goals>
106-
<goal>discoveryDocs</goal>
107-
</goals>
108-
</execution>
109-
</executions>
110102
</plugin>
103+
<!-- [END endpoints-frameworks-plugin] -->
111104
<plugin>
112105
<groupId>org.codehaus.mojo</groupId>
113106
<artifactId>versions-maven-plugin</artifactId>

appengine/endpoints-frameworks-v2/discovery/src/main/java/com/example/helloendpoints/Constants.java renamed to appengine/endpoints-frameworks-v2/migration-example/src/main/java/com/example/helloendpoints/Constants.java

-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
public class Constants {
2323
public static final String WEB_CLIENT_ID = "replace this with your web client ID";
2424
public static final String ANDROID_CLIENT_ID = "replace this with your Android client ID";
25-
public static final String IOS_CLIENT_ID = "replace this with your iOS client ID";
2625
public static final String ANDROID_AUDIENCE = WEB_CLIENT_ID;
2726

2827
public static final String EMAIL_SCOPE = "https://www.googleapis.com/auth/userinfo.email";

appengine/endpoints-frameworks-v2/discovery/src/main/java/com/example/helloendpoints/Greetings.java renamed to appengine/endpoints-frameworks-v2/migration-example/src/main/java/com/example/helloendpoints/Greetings.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
@Api(name = "helloworld",
3636
version = "v1",
3737
scopes = {Constants.EMAIL_SCOPE},
38-
clientIds = {Constants.WEB_CLIENT_ID, Constants.ANDROID_CLIENT_ID, Constants.IOS_CLIENT_ID},
38+
clientIds = {Constants.WEB_CLIENT_ID, Constants.ANDROID_CLIENT_ID},
3939
audiences = {Constants.ANDROID_AUDIENCE}
4040
)
4141
public class Greetings {

appengine/endpoints-frameworks-v2/discovery/src/main/webapp/WEB-INF/appengine-web.xml renamed to appengine/endpoints-frameworks-v2/migration-example/src/main/webapp/WEB-INF/appengine-web.xml

-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ See the License for the specific language governing permissions and
1616
limitations under the License.
1717
-->
1818
<threadsafe>true</threadsafe>
19-
<version>1</version>
2019
<system-properties>
2120
<property name="java.util.logging.config.file" value="WEB-INF/logging.properties"/>
2221
</system-properties>

appengine/endpoints-frameworks-v2/discovery/src/main/webapp/WEB-INF/web.xml renamed to appengine/endpoints-frameworks-v2/migration-example/src/main/webapp/WEB-INF/web.xml

+26-14
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,12 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1414
See the License for the specific language governing permissions and
1515
limitations under the License.
1616
-->
17+
<!-- Uncomment to use Endpoints Frameworks v1.0 -->
18+
<!--
19+
[START appengine-endpoints]
1720
<servlet>
18-
<!-- Uncomment to use Endpoints Frameworks v1.0 -->
19-
<!--
2021
<servlet-name>SystemServiceServlet</servlet-name>
2122
<servlet-class>com.google.api.server.spi.SystemServiceServlet</servlet-class>
22-
-->
23-
<!-- End of Endpoints Frameworks v1.0 -->
24-
<!-- Endpoints Frameworks v2.0 -->
25-
<servlet-name>EndpointsServlet</servlet-name>
26-
<servlet-class>com.google.api.server.spi.EndpointsServlet</servlet-class>
27-
<!-- End of Endpoints Frameworks v2.0 -->
2823
<init-param>
2924
<param-name>services</param-name>
3025
<param-value>com.example.helloendpoints.Greetings</param-value>
@@ -35,17 +30,34 @@ limitations under the License.
3530
</init-param>
3631
</servlet>
3732
<servlet-mapping>
38-
<!-- Uncomment to use Endpoints Frameworks v1.0 -->
39-
<!--
4033
<servlet-name>SystemServiceServlet</servlet-name>
4134
<url-pattern>/_ah/spi/*</url-pattern>
42-
-->
43-
<!-- End of Endpoints Frameworks v1.0 -->
44-
<!-- Endpoints Frameworks v2.0 -->
35+
</servlet-mapping>
36+
[END appengine-endpoints]
37+
-->
38+
<!-- End of Endpoints Frameworks v1.0 -->
39+
40+
<!-- Endpoints Frameworks v2.0 -->
41+
<!-- [START endpoints-frameworks] -->
42+
<servlet>
43+
<servlet-name>EndpointsServlet</servlet-name>
44+
<servlet-class>com.google.api.server.spi.EndpointsServlet</servlet-class>
45+
<init-param>
46+
<param-name>services</param-name>
47+
<param-value>com.example.helloendpoints.Greetings</param-value>
48+
</init-param>
49+
<init-param>
50+
<param-name>restricted</param-name>
51+
<param-value>false</param-value>
52+
</init-param>
53+
</servlet>
54+
<servlet-mapping>
4555
<servlet-name>EndpointsServlet</servlet-name>
4656
<url-pattern>/_ah/api/*</url-pattern>
47-
<!-- End of Endpoints Frameworks v2.0 -->
4857
</servlet-mapping>
58+
<!-- [END endpoints-frameworks] -->
59+
<!-- End of Endpoints Frameworks v2.0 -->
60+
4961
<welcome-file-list>
5062
<welcome-file>index.html</welcome-file>
5163
</welcome-file-list>

0 commit comments

Comments
 (0)