Skip to content

Commit

Permalink
update region tags (#1179)
Browse files Browse the repository at this point in the history
* region tags: request/logging example

* analytics

* mailgun

* mailjet, sendgrid

* cloud sql and postgresql and datastore

* Storage, twilio

* pubsub

* fixed app.yaml errors
  • Loading branch information
averikitsch authored Aug 20, 2018
1 parent a7690e7 commit 8ca37ee
Show file tree
Hide file tree
Showing 29 changed files with 68 additions and 79 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

// [START simple_logging_example]
// [START gae_java8_logging_example]
// With @WebServlet annotation the webapp/WEB-INF/web.xml is no longer required.
@WebServlet(
name = "RequestLogging",
Expand All @@ -44,4 +44,4 @@ public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOExc
// [END_EXCLUDE]
}
}
// [END simple_logging_example]
// [END gae_java8_logging_example]
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

// [START simple_request_example]
// [START gae_java8_request_example]
// With @WebServlet annotation the webapp/WEB-INF/web.xml is no longer required.
@WebServlet(name = "requests", description = "Requests: Trivial request", urlPatterns = "/requests")
public class RequestsServlet extends HttpServlet {
Expand All @@ -32,4 +32,4 @@ public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOExc
resp.getWriter().println("Hello, world");
}
}
// [END simple_request_example]
// [END gae_java8_request_example]
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

// [START simple_logging_example]
// [START gae_java_logging_example]
public class LoggingServlet extends HttpServlet {
private static final Logger log = Logger.getLogger(LoggingServlet.class.getName());

Expand All @@ -36,6 +36,5 @@ public void doGet(HttpServletRequest req, HttpServletResponse resp)
resp.getWriter().println("Check logs for results");
// [END_EXCLUDE]
}
}
// [END simple_logging_example]

}
// [END gae_java_logging_example]
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

// [START simple_request_example]
// [START gae_java_request_example]
public class RequestsServlet extends HttpServlet {
@Override
public void doGet(HttpServletRequest req, HttpServletResponse resp)
Expand All @@ -29,5 +29,4 @@ public void doGet(HttpServletRequest req, HttpServletResponse resp)
resp.getWriter().println("Hello, world");
}
}
// [END simple_request_example]

// [END gae_java_request_example]
4 changes: 2 additions & 2 deletions flexible/analytics/src/main/appengine/app.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ handlers:
- url: /.*
script: this field is required, but ignored

# [START env_variables]
# [START gae_flex_analytics_env_variables]
env_variables:
GA_TRACKING_ID: YOUR-GA-TRACKING-ID
# [END env_variables]
# [END gae_flex_analytics_env_variables]
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.impl.client.HttpClientBuilder;

// [START example]
// [START gae_flex_analytics_track_event]
@SuppressWarnings("serial")
@WebServlet(name = "analytics", value = "")
public class AnalyticsServlet extends HttpServlet {
Expand Down Expand Up @@ -63,4 +63,4 @@ public void doGet(HttpServletRequest req, HttpServletResponse resp)
resp.getWriter().println("Event tracked.");
}
}
// [END example]
// [END gae_flex_analytics_track_event]
12 changes: 6 additions & 6 deletions flexible/cloudsql/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<version>1.0.9</version>
</parent>

<!-- [START properties] -->
<!-- [START gae_flex_mysql_properties] -->
<properties>
<!--
INSTANCE_CONNECTION_NAME from Cloud Console > SQL > Instance Details > Properties
Expand All @@ -50,7 +50,7 @@
<!-- [END_EXCLUDE] -->
<sqlURL>jdbc:mysql://google/${database}?cloudSqlInstance=${INSTANCE_CONNECTION_NAME}&amp;socketFactory=com.google.cloud.sql.mysql.SocketFactory&amp;user=${user}&amp;password=${password}&amp;useSSL=false</sqlURL>
</properties>
<!-- [END properties] -->
<!-- [END gae_flex_mysql_properties] -->

<dependencies>
<dependency>
Expand All @@ -75,7 +75,7 @@
<type>jar</type>
<scope>provided</scope>
</dependency>
<!-- [START dependencies] -->
<!-- [START gae_flex_mysql_dependencies] -->
<dependency> <!-- http://dev.mysql.com/doc/connector-j/en/ -->
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
Expand All @@ -86,17 +86,17 @@
<artifactId>mysql-socket-factory-connector-j-6</artifactId>
<version>1.0.10</version>
</dependency>
<!-- [END dependencies] -->
<!-- [END gae_flex_mysql_dependencies] -->
</dependencies>
<build>
<!-- [START resources] -->
<!-- [START gae_flex_mysql_resources] -->
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<!-- [END resources] -->
<!-- [END gae_flex_mysql_resources] -->
<!-- for hot reload of the web application -->
<outputDirectory>${project.build.directory}/${project.build.finalName}/WEB-INF/classes</outputDirectory>
<plugins>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

// [START example]
// [START gae_flex_mysql_app]
@SuppressWarnings("serial")
@WebServlet(name = "cloudsql", value = "")
public class CloudSqlServlet extends HttpServlet {
Expand Down Expand Up @@ -126,4 +126,4 @@ public void init() throws ServletException {
}
}
}
// [END example]
// [END gae_flex_mysql_app]
2 changes: 0 additions & 2 deletions flexible/cloudstorage/src/main/appengine/app.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,5 @@ handlers:
- url: /.*
script: this field is required, but ignored

# [START env_variables]
env_variables:
BUCKET_NAME: YOUR-BUCKET-NAME
# [END env_variables]
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.Part;

// [START example]
// [START gae_flex_storage_app]
@SuppressWarnings("serial")
@WebServlet(name = "upload", value = "/upload")
@MultipartConfig()
Expand Down Expand Up @@ -67,4 +67,4 @@ public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOEx
resp.getWriter().print(blob.getMediaLink());
}
}
// [END example]
// [END gae_flex_storage_app]
4 changes: 2 additions & 2 deletions flexible/datastore/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@
<type>jar</type>
<scope>provided</scope>
</dependency>
<!-- [START dependencies] -->
<!-- [START gae_flex_datastore_config] -->
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-datastore</artifactId>
<version>1.38.0</version>
</dependency>
<!-- [END dependencies] -->
<!-- [END gae_flex_datastore_config] -->
</dependencies>
<build>
<!-- for hot reload of the web application -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

// [START example]
// [START gae_flex_datastore_app]
@SuppressWarnings("serial")
@WebServlet(name = "datastore", value = "")
public class DatastoreServlet extends HttpServlet {
Expand Down Expand Up @@ -82,4 +82,4 @@ public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOExc
}
}
}
// [END example]
// [END gae_flex_datastore_app]
4 changes: 2 additions & 2 deletions flexible/mailgun/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
<type>jar</type>
<scope>provided</scope>
</dependency>
<!-- [START dependencies] -->
<!-- [START gae_flex_mailgun_dependencies] -->
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-core</artifactId>
Expand All @@ -64,7 +64,7 @@
<artifactId>jersey-multipart</artifactId>
<version>1.19.4</version>
</dependency>
<!-- [END dependencies] -->
<!-- [END gae_flex_mailgun_dependencies] -->
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.core.MediaType;

// [START example]
@SuppressWarnings("serial")
@WebServlet(name = "mailgun", value = "/send/email")
public class MailgunServlet extends HttpServlet {
Expand All @@ -57,7 +56,7 @@ public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOEx
}

//CHECKSTYLE OFF: VariableDeclarationUsageDistance
// [START simple]
// [START gae_flex_mailgun_simple_message]
private ClientResponse sendSimpleMessage(String recipient) {
Client client = Client.create();
client.addFilter(new HTTPBasicAuthFilter("api", MAILGUN_API_KEY));
Expand All @@ -71,9 +70,9 @@ private ClientResponse sendSimpleMessage(String recipient) {
return webResource.type(MediaType.APPLICATION_FORM_URLENCODED).post(ClientResponse.class,
formData);
}
// [END simple]
// [END gae_flex_mailgun_simple_message]

// [START complex]
// [START gae_flex_mailgun_complex_message]
private ClientResponse sendComplexMessage(String recipient) {
Client client = Client.create();
client.addFilter(new HTTPBasicAuthFilter("api", MAILGUN_API_KEY));
Expand All @@ -90,7 +89,6 @@ private ClientResponse sendComplexMessage(String recipient) {
return webResource.type(MediaType.MULTIPART_FORM_DATA_TYPE)
.post(ClientResponse.class, formData);
}
// [END complex]
// [END gae_flex_mailgun_complex_message]
//CHECKSTYLE ON: VariableDeclarationUsageDistance
}
// [END example]
4 changes: 2 additions & 2 deletions flexible/mailjet/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@
<type>jar</type>
<scope>provided</scope>
</dependency>
<!-- [START dependencies] -->
<!-- [START gae_flex_mailjet_dependencies] -->
<dependency>
<groupId>com.mailjet</groupId>
<artifactId>mailjet-client</artifactId>
<version>${mailjet-version}</version>
</dependency>
<!-- [END dependencies] -->
<!-- [END gae_flex_mailjet_dependencies] -->
</dependencies>
<build>
<!-- for hot reload of the web application -->
Expand Down
4 changes: 2 additions & 2 deletions flexible/mailjet/src/main/appengine/app.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ handlers:
- url: /.*
script: this field is required, but ignored

# [START env_variables]
# [START gae_flex_mailjet_yaml]
env_variables:
MAILJET_API_KEY: YOUR-MAILJET-API-KEY
MAILJET_SECRET_KEY: YOUR-MAILJET-SECRET-KEY
# [END env_variables]
# [END gae_flex_mailjet_yaml]
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

// [START mailjet_imports]
// [START gae_flex_mailjet_config]

package com.example.mailjet;

Expand All @@ -34,9 +34,9 @@
import org.json.JSONArray;
import org.json.JSONObject;

// [END mailjet_imports]
// [END gae_flex_mailjet_config]

// [START app]
// [START gae_flex_mailjet_send_message]
@SuppressWarnings("serial")
@WebServlet(name = "mailjet", value = "/send/email")
public class MailjetServlet extends HttpServlet {
Expand Down Expand Up @@ -80,4 +80,4 @@ public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOEx
}
}
}
// [END app]
// [END gae_flex_mailjet_send_message]
12 changes: 6 additions & 6 deletions flexible/postgres/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<version>1.0.9</version>
</parent>

<!-- [START properties] -->
<!-- [START gae_flex_postgres_properties] -->
<properties>
<!--
INSTANCE_CONNECTION_NAME from Cloud Console > SQL > Instance Details > Properties
Expand All @@ -50,7 +50,7 @@
<!-- [END_EXCLUDE] -->
<sqlURL>jdbc:postgresql://google/${database}?useSSL=false&amp;socketFactoryArg=${INSTANCE_CONNECTION_NAME}&amp;socketFactory=com.google.cloud.sql.postgres.SocketFactory&amp;user=${user}&amp;password=${password}</sqlURL>
</properties>
<!-- [END properties] -->
<!-- [END gae_flex_postgres_properties] -->

<dependencies>
<dependency>
Expand All @@ -75,7 +75,7 @@
<type>jar</type>
<scope>provided</scope>
</dependency>
<!-- [START dependencies] -->
<!-- [START gae_flex_postgres_dependencies] -->
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
Expand All @@ -87,17 +87,17 @@
<artifactId>postgres-socket-factory</artifactId>
<version>1.0.10</version>
</dependency>
<!-- [END dependencies] -->
<!-- [END gae_flex_postgres_dependencies] -->
</dependencies>
<build>
<!-- [START resources] -->
<!-- [START gae_flex_postgres_resources] -->
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<!-- [END resources] -->
<!-- [END gae_flex_postgres_resources] -->
<!-- for hot reload of the web application -->
<outputDirectory>${project.build.directory}/${project.build.finalName}/WEB-INF/classes</outputDirectory>
<plugins>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

// [START example]
// [START gae_flex_postgres_app]
@SuppressWarnings("serial")
@WebServlet(name = "postgresql", value = "")
public class PostgresSqlServlet extends HttpServlet {
Expand Down Expand Up @@ -124,4 +124,4 @@ public void init() throws ServletException {
}
}
}
// [END example]
// [END gae_flex_postgres_app]
Loading

0 comments on commit 8ca37ee

Please sign in to comment.