|
1 | 1 | [//]: # "This README.md file is auto-generated, all changes to this file will be lost." |
2 | | -[//]: # "To regenerate it, use `npm run generate-scaffolding`." |
| 2 | +[//]: # "To regenerate it, use `python -m synthtool`." |
3 | 3 | <img src="https://avatars2.githubusercontent.com/u/2810941?v=3&s=96" alt="Google Cloud Platform logo" title="Google Cloud Platform" align="right" height="96" width="96"/> |
4 | 4 |
|
5 | 5 | # [Cloud Redis: Node.js Client](https://github.com/googleapis/nodejs-redis) |
6 | 6 |
|
7 | | -[](https://cloud.google.com/terms/launch-stages) |
| 7 | +[](https://cloud.google.com/terms/launch-stages) |
8 | 8 | [](https://www.npmjs.org/package/@google-cloud/redis) |
9 | 9 | [](https://codecov.io/gh/googleapis/nodejs-redis) |
10 | 10 |
|
11 | | -> Node.js idiomatic client for [Cloud Redis][product-docs]. |
12 | 11 |
|
13 | | -Client for Google Cloud Redis |
| 12 | + |
| 13 | + |
| 14 | +Google Cloud Memorystore for Redis API client for Node.js |
14 | 15 |
|
15 | 16 |
|
16 | 17 | * [Cloud Redis Node.js Client API Reference][client-docs] |
17 | | -* [github.com/googleapis/nodejs-redis](https://github.com/googleapis/nodejs-redis) |
18 | 18 | * [Cloud Redis Documentation][product-docs] |
| 19 | +* [github.com/googleapis/nodejs-redis](https://github.com/googleapis/nodejs-redis) |
19 | 20 |
|
20 | 21 | Read more about the client libraries for Cloud APIs, including the older |
21 | 22 | Google APIs Client Libraries, in [Client Libraries Explained][explained]. |
@@ -24,10 +25,12 @@ Google APIs Client Libraries, in [Client Libraries Explained][explained]. |
24 | 25 |
|
25 | 26 | **Table of contents:** |
26 | 27 |
|
| 28 | + |
27 | 29 | * [Quickstart](#quickstart) |
28 | 30 | * [Before you begin](#before-you-begin) |
29 | 31 | * [Installing the client library](#installing-the-client-library) |
30 | 32 | * [Using the client library](#using-the-client-library) |
| 33 | +* [Samples](#samples) |
31 | 34 | * [Versioning](#versioning) |
32 | 35 | * [Contributing](#contributing) |
33 | 36 | * [License](#license) |
@@ -36,25 +39,50 @@ Google APIs Client Libraries, in [Client Libraries Explained][explained]. |
36 | 39 |
|
37 | 40 | ### Before you begin |
38 | 41 |
|
39 | | -1. Select or create a Cloud Platform project. |
| 42 | +1. [Select or create a Cloud Platform project][projects]. |
| 43 | +1. [Enable billing for your project][billing]. |
| 44 | +1. [Enable the Cloud Redis API][enable_api]. |
| 45 | +1. [Set up authentication with a service account][auth] so you can access the |
| 46 | + API from your local workstation. |
40 | 47 |
|
41 | | - [Go to the projects page][projects] |
| 48 | +### Installing the client library |
42 | 49 |
|
43 | | -1. Enable billing for your project. |
| 50 | +```bash |
| 51 | +npm install @google-cloud/redis |
| 52 | +``` |
44 | 53 |
|
45 | | - [Enable billing][billing] |
46 | 54 |
|
47 | | -1. [Set up authentication with a service account][auth] so you can access the |
48 | | - API from your local workstation. |
| 55 | +### Using the client library |
49 | 56 |
|
50 | | -[projects]: https://console.cloud.google.com/project |
51 | | -[billing]: https://support.google.com/cloud/answer/6293499#enable-billing |
52 | | -[enable_api]: https://console.cloud.google.com/flows/enableapi?apiid= |
53 | | -[auth]: https://cloud.google.com/docs/authentication/getting-started |
| 57 | +```javascript |
| 58 | +/** |
| 59 | + * List instances in a given location. |
| 60 | + * @param {string} project. |
| 61 | + * @param {string} location, e.g., us-east-1. |
| 62 | + */ |
| 63 | +async function main(projectId, location) { |
| 64 | + const {CloudRedisClient} = require('@google-cloud/redis'); |
| 65 | + const client = new CloudRedisClient(); |
| 66 | + const formattedParent = client.locationPath(projectId, location); |
| 67 | + const request = { |
| 68 | + parent: formattedParent, |
| 69 | + }; |
| 70 | + const resp = (await client.listInstances(request))[0]; |
| 71 | + console.info(resp); |
| 72 | +} |
54 | 73 |
|
55 | | -### Installing the client library |
| 74 | +``` |
56 | 75 |
|
57 | | - npm install --save @google-cloud/redis |
| 76 | + |
| 77 | + |
| 78 | +## Samples |
| 79 | + |
| 80 | +Samples are in the [`samples/`](https://github.com/googleapis/nodejs-redis/tree/master/samples) directory. The samples' `README.md` |
| 81 | +has instructions for running the samples. |
| 82 | + |
| 83 | +| Sample | Source Code | Try it | |
| 84 | +| --------------------------- | --------------------------------- | ------ | |
| 85 | +| Quickstart | [source code](https://github.com/googleapis/nodejs-redis/blob/master/samples/quickstart.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-redis&page=editor&open_in_editor=samples/quickstart.js,samples/README.md) | |
58 | 86 |
|
59 | 87 |
|
60 | 88 |
|
@@ -65,10 +93,15 @@ also contains samples. |
65 | 93 |
|
66 | 94 | This library follows [Semantic Versioning](http://semver.org/). |
67 | 95 |
|
| 96 | + |
| 97 | + |
| 98 | + |
68 | 99 | This library is considered to be in **alpha**. This means it is still a |
69 | 100 | work-in-progress and under active development. Any release is subject to |
70 | 101 | backwards-incompatible changes at any time. |
71 | 102 |
|
| 103 | + |
| 104 | + |
72 | 105 | More Information: [Google Cloud Platform Launch Stages][launch_stages] |
73 | 106 |
|
74 | 107 | [launch_stages]: https://cloud.google.com/terms/launch-stages |
@@ -84,6 +117,9 @@ Apache Version 2.0 |
84 | 117 | See [LICENSE](https://github.com/googleapis/nodejs-redis/blob/master/LICENSE) |
85 | 118 |
|
86 | 119 | [client-docs]: https://cloud.google.com/nodejs/docs/reference/redis/latest/ |
87 | | -[product-docs]: https://cloud.google.com/memorystore/docs |
| 120 | +[product-docs]: https://cloud.google.com/memorystore/docs/redis/ |
88 | 121 | [shell_img]: https://gstatic.com/cloudssh/images/open-btn.png |
89 | | - |
| 122 | +[projects]: https://console.cloud.google.com/project |
| 123 | +[billing]: https://support.google.com/cloud/answer/6293499#enable-billing |
| 124 | +[enable_api]: https://console.cloud.google.com/flows/enableapi?apiid=redis.googleapis.com |
| 125 | +[auth]: https://cloud.google.com/docs/authentication/getting-started |