-
Notifications
You must be signed in to change notification settings - Fork 2.9k
codelab initial push #1354
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
Merged
Merged
codelab initial push #1354
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
9ac9162
codelab initial push
munkhuushmgl 87007c0
Update iot/api-client/codelab/README.md
gguuss 22066d4
Update iot/api-client/codelab/manager/README.md
gguuss 419a30e
fixed nits
munkhuushmgl 0abf5c0
Merge branch 'adding-codelab' of https://github.com/GoogleCloudPlatfo…
munkhuushmgl 72529ff
2019 added
munkhuushmgl File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,24 @@ | ||
# Java Codelabs | ||
|
||
<a href="https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/java-docs-samples&page=editor&open_in_editor=iot/api-client/manager/README.md"> | ||
<img alt="Open in Cloud Shell" src ="http://gstatic.com/cloudssh/images/open-btn.png"></a> | ||
|
||
This folder contains Java samples that demonstrate an overview of the | ||
Google Cloud IoT Core platform. | ||
|
||
## Quickstart | ||
|
||
1. From the [Google Cloud IoT Core section](https://console.cloud.google.com/iot/) | ||
of the Google Cloud console, create a device registry. | ||
2. Use the [`generate_keys.sh`](generate_keys.sh) script to generate your signing keys: | ||
|
||
./generate_keys.sh | ||
|
||
3. Add a device using the file `rsa_cert.pem`, specifying RS256_X509 and using the | ||
text copy of the public key starting with the ----START---- block of the certificate. | ||
|
||
cat rsa_cert.pem | ||
|
||
4. Connect a device using the HTTP or MQTT device samples in the [manager](./manager) folder. | ||
|
||
5. Programmattically control device configuration and using the device manager sample in the [manager](./manager) folder. |
This file contains hidden or 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,82 @@ | ||
# Cloud IoT Core Commands Java Codelab | ||
|
||
<a href="https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/java-docs-samples&page=editor&open_in_editor=iot/api-client/manager/README.md"> | ||
<img alt="Open in Cloud Shell" src ="http://gstatic.com/cloudssh/images/open-btn.png"></a> | ||
|
||
This sample app demonstrates device management for Google Cloud IoT Core. | ||
|
||
Note that before you can run the sample, you must configure a Google Cloud | ||
PubSub topic for Cloud IoT as described in [the parent README](../README.md). | ||
|
||
Before running the samples, you can set the `GOOGLE_CLOUD_PROJECT` and | ||
`GOOGLE_APPLICATION_CREDENTIALS` environment variables to avoid passing them to | ||
the sample every time you run it. | ||
|
||
## Setup | ||
Run the following command to install the libraries and build the sample with | ||
Maven: | ||
|
||
mvn clean compile assembly:single | ||
|
||
## Running the sample | ||
|
||
The following description summarizes the sample usage: | ||
|
||
usage: MqttCommandsDemo [--cloud_region <arg>] --project_id <arg> | ||
--registry_id <arg> --device_id <arg> | ||
|
||
Cloud IoT Core Commandline Example (MQTT Device / Commands codelab): | ||
|
||
--cloud_region <arg> GCP cloud region (default us-central1). | ||
--private_key_file <arg> Path to RS256 private key file. | ||
--algorithm <arg> Encryption algorithm to use to generate the JWT. | ||
--project_id <arg> GCP cloud project name. | ||
--registry_id <arg> Name for your Device Registry. | ||
--device_id <arg> ID for your Device. | ||
|
||
https://cloud.google.com/iot-core | ||
|
||
For example, if your project ID is `blue-jet-123`, your service account | ||
credentials are stored in your home folder in creds.json and you have generated | ||
your credentials using the shell script provided in the parent folder, you can | ||
run the sample as: | ||
|
||
# Cloud IoT Core Java MQTT example | ||
|
||
This sample app publishes data to Cloud Pub/Sub using the MQTT bridge provided | ||
as part of Google Cloud IoT Core. | ||
|
||
Note that before you can run the sample, you must configure a Google Cloud | ||
PubSub topic for Cloud IoT Core and register a device as described in the | ||
[parent README](../README.md). | ||
|
||
## Setup | ||
|
||
Run the following command to install the dependencies using Maven: | ||
|
||
mvn clean compile | ||
|
||
## Running the sample | ||
|
||
The following command summarizes the sample usage: | ||
|
||
mvn exec:java \ | ||
-Dexec.mainClass="com.example.cloud.iot.examples.MqttCommandsDemo" \ | ||
-Dexec.args="-project_id=my-iot-project \ | ||
-registry_id=my-registry \ | ||
-cloud_region=us-central1 \ | ||
-device_id=my-device \ | ||
-private_key_file=rsa_private_pkcs8 \ | ||
-algorithm=RS256" | ||
|
||
Run mqtt example: | ||
|
||
mvn exec:java \ | ||
-Dexec.mainClass="com.example.cloud.iot.examples.MqttCommandsDemo" \ | ||
-Dexec.args="-project_id=blue-jet-123 \ | ||
-registry_id=my-registry \ | ||
-cloud_region=asia-east1 \ | ||
-device_id=my-device \ | ||
-private_key_file=../rsa_private_pkcs8 \ | ||
-algorithm=RS256" | ||
|
This file contains hidden or 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,130 @@ | ||
<!-- | ||
Copyright 2019 Google Inc. | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
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. | ||
--> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>com.example.cloud</groupId> | ||
<artifactId>cloudiot-manager-demo</artifactId> | ||
<packaging>jar</packaging> | ||
<version>1.0</version> | ||
<name>cloudiot-manager-demo</name> | ||
<url>http://maven.apache.org</url> | ||
|
||
<!-- | ||
The parent pom defines common style checks and testing strategies for our samples. | ||
Removing or replacing it should not affect the execution of the samples in anyway. | ||
--> | ||
<parent> | ||
<groupId>com.google.cloud.samples</groupId> | ||
<artifactId>shared-configuration</artifactId> | ||
<version>1.0.9</version> | ||
</parent> | ||
<properties> | ||
<maven.compiler.target>1.8</maven.compiler.target> | ||
<maven.compiler.source>1.8</maven.compiler.source> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>com.googlecode.lanterna</groupId> | ||
<artifactId>lanterna</artifactId> | ||
<version>3.0.1</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.eclipse.paho</groupId> | ||
<artifactId>org.eclipse.paho.client.mqttv3</artifactId> | ||
<version>1.2.0</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.json</groupId> | ||
<artifactId>json</artifactId> | ||
<version>20090211</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.jsonwebtoken</groupId> | ||
<artifactId>jjwt</artifactId> | ||
<version>0.7.0</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>joda-time</groupId> | ||
<artifactId>joda-time</artifactId> | ||
<version>2.1</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.google.apis</groupId> | ||
<artifactId>google-api-services-cloudiot</artifactId> | ||
<version>v1-rev20181120-1.27.0</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.google.cloud</groupId> | ||
<artifactId>google-cloud-pubsub</artifactId> | ||
<version>0.24.0-beta</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.google.oauth-client</groupId> | ||
<artifactId>google-oauth-client</artifactId> | ||
<version>1.23.0</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.google.guava</groupId> | ||
<artifactId>guava</artifactId> | ||
<version>23.0</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.google.api-client</groupId> | ||
<artifactId>google-api-client</artifactId> | ||
<version>1.23.0</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>commons-cli</groupId> | ||
<artifactId>commons-cli</artifactId> | ||
<version>1.3</version> | ||
</dependency> | ||
|
||
<!-- Test dependencies --> | ||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<version>4.12</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.google.truth</groupId> | ||
<artifactId>truth</artifactId> | ||
<version>0.34</version> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<artifactId>maven-assembly-plugin</artifactId> | ||
<configuration> | ||
<archive> | ||
<manifest> | ||
<mainClass>com.example.cloudiot.Manage</mainClass> | ||
</manifest> | ||
</archive> | ||
<descriptorRefs> | ||
<descriptorRef>jar-with-dependencies</descriptorRef> | ||
</descriptorRefs> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.