Skip to content

Commit

Permalink
chore: generate README from synth.py (#173)
Browse files Browse the repository at this point in the history
* chore: generate the README via synth.py

* restore transport section
  • Loading branch information
chingor13 committed May 5, 2020
1 parent 90413f7 commit 6657436
Show file tree
Hide file tree
Showing 5 changed files with 152 additions and 60 deletions.
42 changes: 42 additions & 0 deletions .readme-partials.yaml
@@ -0,0 +1,42 @@
custom_content: |
#### Calling Cloud Spanner
Here is a code snippet showing a simple usage example. Add the following imports
at the top of your file:
```java
import com.google.cloud.spanner.DatabaseClient;
import com.google.cloud.spanner.DatabaseId;
import com.google.cloud.spanner.ResultSet;
import com.google.cloud.spanner.Spanner;
import com.google.cloud.spanner.SpannerOptions;
import com.google.cloud.spanner.Statement;
```
Then, to make a query to Spanner, use the following code:
```java
// Instantiates a client
SpannerOptions options = SpannerOptions.newBuilder().build();
Spanner spanner = options.getService();
String instance = "my-instance";
String database = "my-database";
try {
// Creates a database client
DatabaseClient dbClient = spanner.getDatabaseClient(
DatabaseId.of(options.getProjectId(), instance, database));
// Queries the database
try (ResultSet resultSet = dbClient.singleUse().executeQuery(Statement.of("SELECT 1"))) {
// Prints the results
while (resultSet.next()) {
System.out.printf("%d\n", resultSet.getLong(0));
}
}
} finally {
// Closes the client which will free up the resources used
spanner.close();
}
```
#### Complete source code
In [DatabaseSelect.java](https://github.com/googleapis/google-cloud-java/tree/master/google-cloud-examples/src/main/java/com/google/cloud/examples/spanner/snippets/DatabaseSelect.java) we put together all the code shown above in a single program.
5 changes: 4 additions & 1 deletion .repo-metadata.json
Expand Up @@ -3,11 +3,14 @@
"name_pretty": "Cloud Spanner",
"product_documentation": "https://cloud.google.com/spanner/docs/",
"client_documentation": "https://googleapis.dev/java/google-cloud-spanner/latest/",
"api_description": "is a fully managed, mission-critical, \nrelational database service that offers transactional consistency at global scale, \nschemas, SQL (ANSI 2011 with extensions), and automatic, synchronous replication \nfor high availability.\n\nBe sure to activate the Cloud Spanner API on the Developer's Console to\nuse Cloud Spanner from your project.",
"issue_tracker": "https://issuetracker.google.com/issues?q=componentid:190851%2B%20status:open",
"release_level": "ga",
"language": "java",
"repo": "googleapis/java-spanner",
"repo_short": "java-spanner",
"distribution_name": "com.google.cloud:google-cloud-spanner",
"api_id": "spanner.googleapis.com"
"api_id": "spanner.googleapis.com",
"transport": "grpc",
"requires_billing": true
}
162 changes: 105 additions & 57 deletions README.md
@@ -1,43 +1,50 @@
# Google Cloud Java Client for Spanner
# Google Cloud Spanner Client for Java

Java idiomatic client for [Cloud Spanner][cloud-spanner].
Java idiomatic client for [Cloud Spanner][product-docs].

[![Kokoro CI](http://storage.googleapis.com/cloud-devrel-public/java/badges/google-cloud-java/master.svg)](http://storage.googleapis.com/cloud-devrel-public/java/badges/google-cloud-java/master.html)
[![Maven](https://img.shields.io/maven-central/v/com.google.cloud/google-cloud-spanner.svg)](https://img.shields.io/maven-central/v/com.google.cloud/google-cloud-spanner.svg)
[![Codacy Badge](https://api.codacy.com/project/badge/grade/9da006ad7c3a4fe1abd142e77c003917)](https://www.codacy.com/app/mziccard/google-cloud-java)
[![Maven][maven-version-image]][maven-version-link]
![Stability][stability-image]

- [Product Documentation][spanner-product-docs]
- [Client Library Documentation][spanner-client-lib-docs]
- [Product Documentation][product-docs]
- [Client Library Documentation][javadocs]

## Quickstart
If you are using Maven with a BOM, add this to your pom.xml file.

If you are using Maven with [BOM][libraries-bom], add this to your pom.xml file
```xml
<dependencyManagement>
<dependencies>
<dependencies>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>libraries-bom</artifactId>
<version>5.1.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>libraries-bom</artifactId>
<version>3.0.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<artifactId>google-cloud-spanner</artifactId>
</dependency>

<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-spanner</artifactId>
</dependency>
```
[//]: # ({x-version-update-start:google-cloud-spanner:released})
If you are using Maven without a BOM, add this to your dependencies.

If you are using Maven without BOM, add this to your dependencies:

```xml
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-spanner</artifactId>
<version>1.53.0</version>
<version>1.52.0</version>
</dependency>

```

[//]: # ({x-version-update-start:google-cloud-spanner:released})

If you are using Gradle, add this to your dependencies
```Groovy
compile 'com.google.cloud:google-cloud-spanner:1.53.0'
Expand All @@ -50,27 +57,37 @@ libraryDependencies += "com.google.cloud" % "google-cloud-spanner" % "1.53.0"

## Authentication

See the
[Authentication](https://github.com/googleapis/google-cloud-java#authentication)
section in the base directory's README.
See the [Authentication][authentication] section in the base directory's README.

## Getting Started

### Prerequisites

You will need a [Google Cloud Platform Console][developer-console] project with the Cloud Spanner [API enabled][enable-api].
You will need to [enable billing][enable-billing] to use Google Cloud Spanner.
[Follow these instructions][create-project] to get your project set up. You will also need to set up the local development environment by
[installing the Google Cloud SDK][cloud-sdk] and running the following commands in command line:
`gcloud auth login` and `gcloud config set project [YOUR PROJECT ID]`.

### Installation and setup

You'll need to obtain the `google-cloud-spanner` library. See the [Quickstart](#quickstart) section
to add `google-cloud-spanner` as a dependency in your code.

## About Cloud Spanner

[Cloud Spanner][cloud-spanner] is a fully managed, mission-critical,

[Cloud Spanner][product-docs] is a fully managed, mission-critical,
relational database service that offers transactional consistency at global scale,
schemas, SQL (ANSI 2011 with extensions), and automatic, synchronous replication
for high availability.

Be sure to activate the Cloud Spanner API on the Developer's Console to
use Cloud Spanner from your project.

See the [Spanner client lib docs][spanner-client-lib-docs] to learn how to
interact with Cloud Spanner using this Client Library.
See the [Cloud Spanner client library docs][javadocs] to learn how to
use this Cloud Spanner Client Library.

## Getting Started
#### Prerequisites
Please refer to the [getting
started](https://cloud.google.com/spanner/docs/getting-started/java/) guide.

#### Calling Cloud Spanner
Here is a code snippet showing a simple usage example. Add the following imports
Expand Down Expand Up @@ -112,48 +129,79 @@ try {

#### Complete source code

In [DatabaseSelect.java](../../google-cloud-examples/src/main/java/com/google/cloud/examples/spanner/snippets/DatabaseSelect.java) we put together all the code shown above in a single program.
In [DatabaseSelect.java](https://github.com/googleapis/google-cloud-java/tree/master/google-cloud-examples/src/main/java/com/google/cloud/examples/spanner/snippets/DatabaseSelect.java) we put together all the code shown above in a single program.

## Troubleshooting

To get help, follow the instructions in the [shared Troubleshooting
document](https://github.com/googleapis/google-cloud-common/blob/master/troubleshooting/readme.md#troubleshooting).

Transport
---------
Spanner uses gRPC for the transport layer.

## Java Versions

Java 7 or above is required for using this client.
## Troubleshooting

## Testing
To get help, follow the instructions in the [shared Troubleshooting document][troubleshooting].

This library has tools to help make tests for code using Cloud Spanner.
## Transport

See [TESTING] to read more about testing.
Cloud Spanner uses gRPC for the transport layer.

## Java Versions

Java 7 or above is required for using this client.

## Versioning


This library follows [Semantic Versioning](http://semver.org/).

It is currently in major version zero (`0.y.z`), which means that anything may
change at any time and the public API should not be considered stable.

## Contributing


Contributions to this library are always welcome and highly encouraged.

See [CONTRIBUTING] for more information on how to get started.
See [CONTRIBUTING][contributing] for more information how to get started.

## License
Please note that this project is released with a Contributor Code of Conduct. By participating in
this project you agree to abide by its terms. See [Code of Conduct][code-of-conduct] for more
information.

Apache 2.0 - See [LICENSE] for more information.
## License

[CONTRIBUTING]:https://github.com/googleapis/google-cloud-java/blob/master/CONTRIBUTING.md
[LICENSE]: https://github.com/googleapis/google-cloud-java/blob/master/LICENSE
[TESTING]: https://github.com/googleapis/google-cloud-java/blob/master/TESTING.md#testing-code-that-uses-cloud-spanner
[cloud-platform]: https://cloud.google.com/
[cloud-spanner]: https://cloud.google.com/spanner/
[spanner-product-docs]: https://cloud.google.com/spanner/docs/
[spanner-client-lib-docs]: https://googleapis.dev/java/google-cloud-clients/latest/index.html?com/google/cloud/spanner/package-summary.html
Apache 2.0 - See [LICENSE][license] for more information.

## CI Status

Java Version | Status
------------ | ------
Java 7 | [![Kokoro CI][kokoro-badge-image-1]][kokoro-badge-link-1]
Java 8 | [![Kokoro CI][kokoro-badge-image-2]][kokoro-badge-link-2]
Java 8 OSX | [![Kokoro CI][kokoro-badge-image-3]][kokoro-badge-link-3]
Java 8 Windows | [![Kokoro CI][kokoro-badge-image-4]][kokoro-badge-link-4]
Java 11 | [![Kokoro CI][kokoro-badge-image-5]][kokoro-badge-link-5]

[product-docs]: https://cloud.google.com/spanner/docs/
[javadocs]: https://googleapis.dev/java/google-cloud-spanner/latest/
[kokoro-badge-image-1]: http://storage.googleapis.com/cloud-devrel-public/java/badges/java-spanner/java7.svg
[kokoro-badge-link-1]: http://storage.googleapis.com/cloud-devrel-public/java/badges/java-spanner/java7.html
[kokoro-badge-image-2]: http://storage.googleapis.com/cloud-devrel-public/java/badges/java-spanner/java8.svg
[kokoro-badge-link-2]: http://storage.googleapis.com/cloud-devrel-public/java/badges/java-spanner/java8.html
[kokoro-badge-image-3]: http://storage.googleapis.com/cloud-devrel-public/java/badges/java-spanner/java8-osx.svg
[kokoro-badge-link-3]: http://storage.googleapis.com/cloud-devrel-public/java/badges/java-spanner/java8-osx.html
[kokoro-badge-image-4]: http://storage.googleapis.com/cloud-devrel-public/java/badges/java-spanner/java8-win.svg
[kokoro-badge-link-4]: http://storage.googleapis.com/cloud-devrel-public/java/badges/java-spanner/java8-win.html
[kokoro-badge-image-5]: http://storage.googleapis.com/cloud-devrel-public/java/badges/java-spanner/java11.svg
[kokoro-badge-link-5]: http://storage.googleapis.com/cloud-devrel-public/java/badges/java-spanner/java11.html
[stability-image]: https://img.shields.io/badge/stability-ga-green
[maven-version-image]: https://img.shields.io/maven-central/v/com.google.cloud/google-cloud-spanner.svg
[maven-version-link]: https://search.maven.org/search?q=g:com.google.cloud%20AND%20a:google-cloud-spanner&core=gav
[authentication]: https://github.com/googleapis/google-cloud-java#authentication
[developer-console]: https://console.developers.google.com/
[create-project]: https://cloud.google.com/resource-manager/docs/creating-managing-projects
[cloud-sdk]: https://cloud.google.com/sdk/
[troubleshooting]: https://github.com/googleapis/google-cloud-common/blob/master/troubleshooting/readme.md#troubleshooting
[contributing]: https://github.com/googleapis/java-spanner/blob/master/CONTRIBUTING.md
[code-of-conduct]: https://github.com/googleapis/java-spanner/blob/master/CODE_OF_CONDUCT.md#contributor-code-of-conduct
[license]: https://github.com/googleapis/java-spanner/blob/master/LICENSE
[enable-billing]: https://cloud.google.com/apis/docs/getting-started#enabling_billing
[enable-api]: https://console.cloud.google.com/flows/enableapi?apiid=spanner.googleapis.com
[libraries-bom]: https://github.com/GoogleCloudPlatform/cloud-opensource-java/wiki/The-Google-Cloud-Platform-Libraries-BOM
[shell_img]: https://gstatic.com/cloudssh/images/open-btn.png
2 changes: 1 addition & 1 deletion synth.metadata
Expand Up @@ -19,7 +19,7 @@
"git": {
"name": "synthtool",
"remote": "https://github.com/googleapis/synthtool.git",
"sha": "52638600f387deb98efb5f9c85fec39e82aa9052"
"sha": "716f741f2d307b48cbe8a5bc3bc883571212344a"
}
}
],
Expand Down
1 change: 0 additions & 1 deletion synth.py
Expand Up @@ -76,7 +76,6 @@
java.format_code('proto-google-cloud-spanner-admin-instance-v1/src')

java.common_templates(excludes=[
'README.md',
'.kokoro/continuous/common.cfg',
'.kokoro/nightly/common.cfg',
'.kokoro/presubmit/common.cfg',
Expand Down

0 comments on commit 6657436

Please sign in to comment.