Skip to content
This repository has been archived by the owner on Jul 20, 2023. It is now read-only.

Commit

Permalink
feat: add initial samples (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
sofisl authored Mar 30, 2021
1 parent 728ac20 commit e12039f
Show file tree
Hide file tree
Showing 30 changed files with 89 additions and 106 deletions.
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Thanks for stopping by to let us know something could be better!
This is the client library for . We will only be able to assist with issues that pertain to the behaviors of this library. If the issue you're experiencing is due to the behavior of the product itself, please visit the [ Support page]() to reach the most relevant engineers.

2) Did someone already solve this?
- Search the issues already opened: https://github.com/googleapis/nodejs-servicemanagement/issues
- Search the issues already opened: https://github.com/googleapis/nodejs-service-management/issues
- Search the issues on our "catch-all" repository: https://github.com/googleapis/google-cloud-node
- Search or ask on StackOverflow (engineers monitor these tags): http://stackoverflow.com/questions/tagged/google-cloud-platform+node.js

Expand All @@ -26,7 +26,7 @@ If the support paths suggested above still do not result in a resolution, please
- OS:
- Node.js version:
- npm version:
- `undefined` version:
- `@google-cloud/service-management` version:

#### Steps to reproduce

Expand Down
4 changes: 2 additions & 2 deletions .kokoro/common.cfg

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions .kokoro/continuous/node10/common.cfg

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .kokoro/continuous/node10/docs.cfg

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions .kokoro/continuous/node12/common.cfg

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .kokoro/continuous/node12/lint.cfg

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .kokoro/continuous/node12/samples-test.cfg

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .kokoro/continuous/node12/system-test.cfg

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions .kokoro/presubmit/node10/common.cfg

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions .kokoro/presubmit/node12/common.cfg

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .kokoro/presubmit/node12/samples-test.cfg

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .kokoro/presubmit/node12/system-test.cfg

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions .kokoro/release/docs-devsite.cfg

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions .kokoro/release/docs.cfg

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions .kokoro/release/publish.cfg

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .repo-metadata.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "servicemanagement",
"name": "service-management",
"name_pretty": "Service Management API",
"product_documentation": "https://cloud.google.com/service-infrastructure/docs/overview/",
"client_documentation": "https://cloud.google.com/service-infrastructure/docs/service-management/reference",
Expand Down
28 changes: 11 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
# [Service Management API: Node.js Client](https://github.com/googleapis/nodejs-service-management)

[![release level](https://img.shields.io/badge/release%20level-general%20availability%20%28GA%29-brightgreen.svg?style=flat)](https://cloud.google.com/terms/launch-stages)
[![npm version](https://img.shields.io/npm/v/undefined.svg)](https://www.npmjs.org/package/undefined)
[![npm version](https://img.shields.io/npm/v/@google-cloud/service-management.svg)](https://www.npmjs.org/package/@google-cloud/service-management)
[![codecov](https://img.shields.io/codecov/c/github/googleapis/nodejs-service-management/master.svg?style=flat)](https://codecov.io/gh/googleapis/nodejs-service-management)




Servicemanagement client for Node.js
Service management client for Node.js


A comprehensive list of changes in each version may be found in
Expand Down Expand Up @@ -51,34 +51,28 @@ Google APIs Client Libraries, in [Client Libraries Explained][explained].
### Installing the client library

```bash
npm install undefined
npm install @google-cloud/service-management
```


### Using the client library

```javascript
// Imports the Google Cloud client library

// remove this line after package is released
// eslint-disable-next-line node/no-missing-require
const {ServiceManagerClient} = require('');
// Imports the Google Cloud client library
const {ServiceManagerClient} = require('@google-cloud/service-management');

// TODO(developer): replace with your prefered project ID.
// const projectId = 'my-project'

// Creates a client
// eslint-disable-next-line no-unused-vars
const client = new {ServiceManagerClient}();

//TODO(library generator): write the actual function you will be testing
async function doSomething() {
console.log('DPE! Change this code so that it shows how to use the library! See comments below on structure.')
// const [thing] = await client.methodName({
// });
// console.info(thing);
const client = new ServiceManagerClient();

async function listServices() {
const [thing] = await client.listServices({producerProjectId: projectId});
console.info(thing);
}
doSomething();
listServices();

```

Expand Down
2 changes: 1 addition & 1 deletion linkinator.config.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"recurse":true,"skip":["https://codecov.io/gh/googleapis/","www.googleapis.com","img.shields.io"],"silent":true,"concurrency":10}
{"recurse":true,"skip":["https://codecov.io/gh/googleapis/","www.googleapis.com","img.shields.io", "https://github.com/googleapis/nodejs-service-management/blob/master/CHANGELOG.md"],"silent":true,"concurrency":10}
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "undefined",
"name": "@google-cloud/service-management",
"version": "0.1.0",
"description": "Servicemanagement client for Node.js",
"repository": "googleapis/nodejs-servicemanagement",
"description": "Service management client for Node.js",
"repository": "googleapis/nodejs-service-management",
"license": "Apache-2.0",
"author": "Google LLC",
"main": "build/src/index.js",
Expand Down Expand Up @@ -54,13 +54,13 @@
"mocha": "^8.3.1",
"null-loader": "^4.0.1",
"pack-n-play": "^1.0.0-2",
"sinon": "^9.2.4",
"sinon": "^10.0.0",
"ts-loader": "^8.0.17",
"typescript": "^4.2.3",
"webpack": "^5.24.4",
"webpack-cli": "^4.5.0"
},
"engines": {
"node": ">=v10.24.0"
"node": ">=v10.0.0"
}
}
4 changes: 2 additions & 2 deletions protos/google/api/servicemanagement/v1/servicemanager.proto
Original file line number Diff line number Diff line change
Expand Up @@ -451,10 +451,10 @@ message ListServiceRolloutsRequest {
// Required. Use `filter` to return subset of rollouts.
// The following filters are supported:
// -- To limit the results to only those in
// [status](google.api.servicemanagement.v1.RolloutStatus) 'SUCCESS',
// status (google.api.servicemanagement.v1.RolloutStatus) 'SUCCESS',
// use filter='status=SUCCESS'
// -- To limit the results to those in
// [status](google.api.servicemanagement.v1.RolloutStatus) 'CANCELLED'
// status (google.api.servicemanagement.v1.RolloutStatus) 'CANCELLED'
// or 'FAILED', use filter='status=CANCELLED OR status=FAILED'
string filter = 4 [(google.api.field_behavior) = REQUIRED];
}
Expand Down
2 changes: 1 addition & 1 deletion protos/protos.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion protos/protos.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion samples/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"test": "c8 mocha --timeout 600000 test/*.js"
},
"dependencies": {
"": "^0.1.0"
"@google-cloud/service-management": "^0.1.0"
},
"devDependencies": {
"c8": "^7.1.0",
Expand Down
26 changes: 10 additions & 16 deletions samples/quickstart.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,31 +13,25 @@

'use strict';

async function main() {
async function main(projectId) {
// [START nodejs_service_management_quickstart]
// Imports the Google Cloud client library

// remove this line after package is released
// eslint-disable-next-line node/no-missing-require
const {ServiceManagerClient} = require('');
// Imports the Google Cloud client library
const {ServiceManagerClient} = require('@google-cloud/service-management');

// TODO(developer): replace with your prefered project ID.
// const projectId = 'my-project'

// Creates a client
// eslint-disable-next-line no-unused-vars
const client = new {ServiceManagerClient}();
const client = new ServiceManagerClient();

//TODO(library generator): write the actual function you will be testing
async function doSomething() {
console.log(
'DPE! Change this code so that it shows how to use the library! See comments below on structure.'
);
// const [thing] = await client.methodName({
// });
// console.info(thing);
async function listServices() {
const [services] = await client.listServices({
producerProjectId: projectId,
});
console.info(services);
}
doSomething();
listServices();
// [END nodejs_service_management_quickstart]
}

Expand Down
13 changes: 4 additions & 9 deletions samples/test/quickstart.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,30 +21,25 @@ const path = require('path');
const cp = require('child_process');
const {before, describe, it} = require('mocha');
// eslint-disable-next-line node/no-missing-require
const {ServiceManagerClient} = require('');
const {ServiceManagerClient} = require('@google-cloud/service-management');
// eslint-disable-next-line no-unused-vars, node/no-missing-require
const {assert} = require('chai');

const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'});

const cwd = path.join(__dirname, '..');

const client = new {ServiceManagerClient}();
const client = new ServiceManagerClient();

describe('Quickstart', () => {
//TODO: remove this if not using the projectId
// eslint-disable-next-line no-unused-vars
let projectId;

before(async () => {
// eslint-disable-next-line no-unused-vars
projectId = await client.getProjectId();
});

it('should run quickstart', async () => {
//TODO: remove this line
// eslint-disable-next-line no-unused-vars
const stdout = execSync('node ./quickstart.js', {cwd});
//assert(stdout, stdout !== null);
const stdout = execSync(`node ./quickstart.js ${projectId}`, {cwd});
assert.match(stdout, /\[[\s\S]*\]/);
});
});
Loading

0 comments on commit e12039f

Please sign in to comment.