Skip to content

Commit 46ab65a

Browse files
Merge branch 'master' into kms-gapic
2 parents f7630f5 + a4866b4 commit 46ab65a

File tree

108 files changed

+5686
-3216
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

108 files changed

+5686
-3216
lines changed

appengine-java8/cloudsql-postgres/pom.xml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
<version>1.0.9</version>
3131
</parent>
3232

33-
<!-- [START properties] -->
33+
<!-- [START gae_java8_postgres_properties] -->
3434
<properties>
3535
<!--
3636
INSTANCE_CONNECTION_NAME from Cloud Console > SQL > Instance Details > Properties
@@ -46,7 +46,7 @@
4646
<maven.compiler.source>1.8</maven.compiler.source>
4747
<!-- [END_EXCLUDE] -->
4848
</properties>
49-
<!-- [END properties] -->
49+
<!-- [END gae_java8_postgres_properties] -->
5050

5151
<dependencies>
5252
<dependency>
@@ -69,7 +69,7 @@
6969
<version>1.27.0</version>
7070
</dependency>
7171

72-
<!-- [START dependencies] -->
72+
<!-- [START gae_java8_postgres_dependencies] -->
7373
<dependency>
7474
<groupId>org.postgresql</groupId>
7575
<artifactId>postgresql</artifactId>
@@ -81,14 +81,14 @@
8181
<artifactId>postgres-socket-factory</artifactId>
8282
<version>1.0.11</version>
8383
</dependency>
84-
<!-- [END dependencies] -->
84+
<!-- [END gae_java8_postgres_dependencies] -->
8585
</dependencies>
8686

8787
<build>
8888
<!-- for hot reload of the web application -->
8989
<outputDirectory>${project.build.directory}/${project.build.finalName}/WEB-INF/classes</outputDirectory>
9090
<plugins>
91-
<!-- [START plugins] -->
91+
<!-- [START gae_java8_postgres_plugins] -->
9292
<plugin>
9393
<groupId>org.apache.maven.plugins</groupId>
9494
<artifactId>maven-war-plugin</artifactId>
@@ -114,7 +114,7 @@
114114
<deploy.stopPreviousVersion>true</deploy.stopPreviousVersion>
115115
</configuration>
116116
</plugin>
117-
<!-- [END plugins] -->
117+
<!-- [END gae_java8_postgres_plugins] -->
118118
</plugins>
119119
</build>
120120
</project>

appengine-java8/cloudsql-postgres/src/main/java/com/example/appengine/postgresql/PostgreSqlServlet.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
import javax.servlet.http.HttpServletRequest;
3434
import javax.servlet.http.HttpServletResponse;
3535

36-
// [START example]
3736
@SuppressWarnings("serial")
3837
// With @WebServlet annotation the webapp/WEB-INF/web.xml is no longer required.
3938
@WebServlet(name = "PostgreSQL",
@@ -93,4 +92,3 @@ public void init() throws ServletException {
9392
}
9493
}
9594
}
96-
// [END example]

appengine-java8/cloudsql-postgres/src/main/webapp/WEB-INF/appengine-web.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
See the License for the specific language governing permissions and
1212
limitations under the License.
1313
-->
14-
<!-- [START config] -->
14+
<!-- [START gae_java8_postgres_config] -->
1515
<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
1616
<threadsafe>true</threadsafe>
1717
<runtime>java8</runtime>
@@ -20,4 +20,4 @@
2020
<property name="cloudsql" value="jdbc:postgresql://google/${database}?cloudSqlInstance=${INSTANCE_CONNECTION_NAME}&amp;socketFactory=com.google.cloud.sql.postgres.SocketFactory&amp;user=${user}&amp;password=${password}" />
2121
</system-properties>
2222
</appengine-web-app>
23-
<!-- [END config] -->
23+
<!-- [END gae_java8_postgres_config] -->

appengine-java8/cloudsql/pom.xml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
<version>1.0.9</version>
3131
</parent>
3232

33-
<!-- [START properties] -->
33+
<!-- [START gae_java8_mysql_properties] -->
3434
<properties>
3535
<!--
3636
INSTANCE_CONNECTION_NAME from Cloud Console > SQL > Instance Details > Properties
@@ -48,7 +48,7 @@
4848
<maven.compiler.source>1.8</maven.compiler.source>
4949
<!-- [END_EXCLUDE] -->
5050
</properties>
51-
<!-- [END properties] -->
51+
<!-- [END gae_java8_mysql_properties] -->
5252

5353
<dependencies>
5454
<dependency>
@@ -71,7 +71,7 @@
7171
<version>1.27.0</version>
7272
</dependency>
7373

74-
<!-- [START dependencies] -->
74+
<!-- [START gae_java8_mysql_dependencies] -->
7575
<dependency> <!-- Only used locally -->
7676
<groupId>mysql</groupId>
7777
<artifactId>mysql-connector-java</artifactId>
@@ -82,13 +82,13 @@
8282
<artifactId>mysql-socket-factory</artifactId>
8383
<version>1.0.11</version>
8484
</dependency>
85-
<!-- [END dependencies] -->
85+
<!-- [END gae_java8_mysql_dependencies] -->
8686
</dependencies>
8787
<build>
8888
<!-- for hot reload of the web application -->
8989
<outputDirectory>${project.build.directory}/${project.build.finalName}/WEB-INF/classes</outputDirectory>
9090
<plugins>
91-
<!-- [START plugins] -->
91+
<!-- [START gae_java8_mysql_plugins] -->
9292
<plugin>
9393
<groupId>org.apache.maven.plugins</groupId>
9494
<artifactId>maven-war-plugin</artifactId>
@@ -114,7 +114,7 @@
114114
<deploy.stopPreviousVersion>true</deploy.stopPreviousVersion>
115115
</configuration>
116116
</plugin>
117-
<!-- [END plugins] -->
117+
<!-- [END gae_java8_mysql_plugins] -->
118118
</plugins>
119119
</build>
120120
</project>

appengine-java8/cloudsql/src/main/java/com/example/appengine/cloudsql/CloudSqlServlet.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
import javax.servlet.http.HttpServletRequest;
4242
import javax.servlet.http.HttpServletResponse;
4343

44-
// [START example]
44+
// [START gae_java8_mysql_app]
4545
@SuppressWarnings("serial")
4646
// With @WebServlet annotation the webapp/WEB-INF/web.xml is no longer required.
4747
@WebServlet(name = "CloudSQL",
@@ -100,4 +100,4 @@ public void init() throws ServletException {
100100
}
101101
}
102102
}
103-
// [END example]
103+
// [END gae_java8_mysql_app]

appengine-java8/cloudsql/src/main/webapp/WEB-INF/appengine-web.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
See the License for the specific language governing permissions and
1212
limitations under the License.
1313
-->
14-
<!-- [START config] -->
14+
<!-- [START gae_java8_mysql_config] -->
1515
<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
1616
<threadsafe>true</threadsafe>
1717
<runtime>java8</runtime>
@@ -22,4 +22,4 @@
2222
<property name="cloudsql" value="jdbc:mysql://google/${database}?useSSL=false&amp;cloudSqlInstance=${INSTANCE_CONNECTION_NAME}&amp;socketFactory=com.google.cloud.sql.mysql.SocketFactory&amp;user=${user}&amp;password=${password}" />
2323
</system-properties>
2424
</appengine-web-app>
25-
<!-- [END config] -->
25+
<!-- [END gae_java8_mysql_config] -->
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Scheduling a Cloud Datastore export
2+
3+
This Google App Engine (GAE) app receives export requests at `/cloud-datastore-export` and
4+
sends an export request to the [Cloud Datastore Admin API](https://cloud.google.com/datastore/docs/reference/admin/rest/v1/projects/export).
5+
6+
## Before you begin
7+
8+
This app requires the following to complete export operations:
9+
10+
1. A Google Cloud project with billing enabled.
11+
1. A Cloud Storage bucket for your export files.
12+
1. The App Engine default service account must have permission
13+
to write to the Cloud Storage bucket and have the Cloud Datastore Import Export Admin IAM role.
14+
15+
For more information on completing these requirements, see the
16+
[Cloud Datastore documentation](https://cloud.google.com/datastore/docs/schedule-export#before_you_begin).
17+
18+
## Deploying
19+
20+
Set the target project in gcloud:
21+
22+
gcloud config set project PROJECT_NAME
23+
24+
Deploy the GAE app:
25+
26+
mvn appengine:deploy
27+
28+
The app takes the following parameters:
29+
30+
* `output_url_prefix` (required)-specifies where to save your Cloud Datastore export. If the URL ends with a `/`, it's used as is. Otherwise, the app adds a timesamp to the url.
31+
* `kind` (optional, multiple)-restricts export to only these kinds.
32+
* `namespace_id` (optional, multiple)-restricts export to only these namespaces.
33+
34+
Modify and deploy the cronjob:
35+
36+
gcloud app deploy cron.yaml
37+
38+
You can test your cron job by running the job manually:
39+
40+
<a href="https://console.cloud.google.com/appengine/cronjobs">Open the Cron Jobs page</a>
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
cron:
2+
- description: "Daily Cloud Datastore Export"
3+
url: /cloud-datastore-export?output_url_prefix=gs://<EXPORT_BUCKET>&kind=<KIND_NAME>
4+
schedule: every 24 hours
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project>
3+
<modelVersion>4.0.0</modelVersion>
4+
<packaging>war</packaging>
5+
<version>1.0-SNAPSHOT</version>
6+
7+
<groupId>com.example.datastore</groupId>
8+
<artifactId>schedule-export</artifactId>
9+
10+
<parent>
11+
<groupId>com.google.cloud.samples</groupId>
12+
<artifactId>shared-configuration</artifactId>
13+
<version>1.0.10</version>
14+
</parent>
15+
16+
<properties>
17+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
18+
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
19+
<maven.compiler.source>1.8</maven.compiler.source>
20+
<maven.compiler.target>1.8</maven.compiler.target>
21+
<maven.compiler.showDeprecation>true</maven.compiler.showDeprecation>
22+
<archiveClasses>true</archiveClasses>
23+
</properties>
24+
25+
<prerequisites>
26+
<maven>3.5</maven>
27+
</prerequisites>
28+
29+
<dependencies>
30+
<!-- Compile/runtime dependencies -->
31+
<dependency>
32+
<groupId>com.google.appengine</groupId>
33+
<artifactId>appengine-api-1.0-sdk</artifactId>
34+
<version>1.9.59</version>
35+
</dependency>
36+
<dependency>
37+
<groupId>com.google.guava</groupId>
38+
<artifactId>guava</artifactId>
39+
<version>25.1-android</version>
40+
</dependency>
41+
<dependency>
42+
<groupId>javax.servlet</groupId>
43+
<artifactId>javax.servlet-api</artifactId>
44+
<version>3.1.0</version>
45+
<type>jar</type>
46+
<scope>provided</scope>
47+
</dependency>
48+
<dependency>
49+
<groupId>org.json</groupId>
50+
<artifactId>json</artifactId>
51+
<version>20180130</version>
52+
</dependency>
53+
54+
<!-- Test Dependencies -->
55+
<dependency>
56+
<groupId>com.google.appengine</groupId>
57+
<artifactId>appengine-testing</artifactId>
58+
<version>1.9.59</version>
59+
<scope>test</scope>
60+
</dependency>
61+
<dependency>
62+
<groupId>com.google.truth</groupId>
63+
<artifactId>truth</artifactId>
64+
<version>0.33</version>
65+
<scope>test</scope>
66+
</dependency>
67+
<dependency>
68+
<groupId>junit</groupId>
69+
<artifactId>junit</artifactId>
70+
<version>4.12</version>
71+
<scope>test</scope>
72+
</dependency>
73+
<dependency>
74+
<groupId>org.mockito</groupId>
75+
<artifactId>mockito-all</artifactId>
76+
<version>2.0.2-beta</version>
77+
<scope>test</scope>
78+
</dependency>
79+
</dependencies>
80+
81+
<build>
82+
<!-- for hot reload of the web application-->
83+
<outputDirectory>${project.build.directory}/${project.build.finalName}/WEB-INF/classes</outputDirectory>
84+
<plugins>
85+
<plugin>
86+
<groupId>com.google.cloud.tools</groupId>
87+
<artifactId>appengine-maven-plugin</artifactId>
88+
<version>1.3.2</version>
89+
<configuration>
90+
</configuration>
91+
</plugin>
92+
</plugins>
93+
</build>
94+
</project>

0 commit comments

Comments
 (0)