Skip to content

Commit

Permalink
feat: add initial samples and tests (#2)
Browse files Browse the repository at this point in the history
* feat: add initial samples and tests

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
  • Loading branch information
sofisl and gcf-owl-bot[bot] authored Jul 19, 2022
1 parent 7434542 commit be07219
Show file tree
Hide file tree
Showing 9 changed files with 170 additions and 55 deletions.
14 changes: 7 additions & 7 deletions packages/google-cloud-apigeeregistry/.repo-metadata.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"name": "apigeeregistry",
"name_pretty": "",
"product_documentation": "",
"client_documentation": "",
"issue_tracker": "",
"name_pretty": "Apigee Registry API",
"product_documentation": "https://cloud.google.com/apigee/docs/api-hub/get-started-registry-api",
"client_documentation": "https://cloud.google.com/nodejs/docs/reference/apigeeregistry/latest",
"issue_tracker": "https://github.com/googleapis/nodejs-video-transcoder/issues",
"release_level": "beta",
"language": "",
"repo": "",
"distribution_name": "",
"language": "nodejs",
"repo": "googleapis/nodejs-apigee-registry",
"distribution_name": "@google-cloud/apigee-registry",
"api_id": "apigeeregistry.googleapis.com",
"default_version": "v1",
"requires_billing": true
Expand Down
2 changes: 1 addition & 1 deletion packages/google-cloud-apigeeregistry/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ accept your pull requests.

1. [Select or create a Cloud Platform project][projects].
1. [Enable billing for your project][billing].
1. [Enable the API][enable_api].
1. [Enable the Apigee Registry API API][enable_api].
1. [Set up authentication with a service account][auth] so you can access the
API from your local workstation.

Expand Down
23 changes: 13 additions & 10 deletions packages/google-cloud-apigeeregistry/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
[//]: # "To regenerate it, use `python -m synthtool`."
<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"/>

# [: Client](https://github.com/)
# [Apigee Registry API: Node.js Client](https://github.com/googleapis/nodejs-apigee-registry)

[![release level](https://img.shields.io/badge/release%20level-beta-yellow.svg?style=flat)](https://cloud.google.com/terms/launch-stages)
[![npm version](https://img.shields.io/npm/v/@google-cloud/apigee-registry.svg)](https://www.npmjs.org/package/@google-cloud/apigee-registry)
Expand All @@ -14,11 +14,11 @@ apigeeregistry client for Node.js


A comprehensive list of changes in each version may be found in
[the CHANGELOG](https://github.com//blob/master/CHANGELOG.md).
[the CHANGELOG](https://github.com/googleapis/nodejs-apigee-registry/blob/main/CHANGELOG.md).



* [github.com/](https://github.com/)
* [Apigee Registry API Node.js Client API Reference][client-docs]
* [Apigee Registry API Documentation][product-docs]
* [github.com/googleapis/nodejs-apigee-registry](https://github.com/googleapis/nodejs-apigee-registry)

Read more about the client libraries for Cloud APIs, including the older
Google APIs Client Libraries, in [Client Libraries Explained][explained].
Expand All @@ -43,7 +43,7 @@ Google APIs Client Libraries, in [Client Libraries Explained][explained].

1. [Select or create a Cloud Platform project][projects].
1. [Enable billing for your project][billing].
1. [Enable the API][enable_api].
1. [Enable the Apigee Registry API API][enable_api].
1. [Set up authentication with a service account][auth] so you can access the
API from your local workstation.

Expand All @@ -57,6 +57,9 @@ npm install @google-cloud/apigee-registry



The [Apigee Registry API Node.js Client API Reference][client-docs] documentation
also contains samples.

## Supported Node.js Versions

Our client libraries follow the [Node.js release schedule](https://nodejs.org/en/about/releases/).
Expand Down Expand Up @@ -100,7 +103,7 @@ More Information: [Google Cloud Platform Launch Stages][launch_stages]

## Contributing

Contributions welcome! See the [Contributing Guide](https://github.com//blob/master/CONTRIBUTING.md).
Contributions welcome! See the [Contributing Guide](https://github.com/googleapis/nodejs-apigee-registry/blob/main/CONTRIBUTING.md).

Please note that this `README.md`, the `samples/README.md`,
and a variety of configuration files in this repository (including `.nycrc` and `tsconfig.json`)
Expand All @@ -112,10 +115,10 @@ to its templates in

Apache Version 2.0

See [LICENSE](https://github.com//blob/master/LICENSE)


See [LICENSE](https://github.com/googleapis/nodejs-apigee-registry/blob/main/LICENSE)

[client-docs]: https://cloud.google.com/nodejs/docs/reference/apigeeregistry/latest
[product-docs]: https://cloud.google.com/apigee/docs/api-hub/get-started-registry-api
[shell_img]: https://gstatic.com/cloudssh/images/open-btn.png
[projects]: https://console.cloud.google.com/project
[billing]: https://support.google.com/cloud/answer/6293499#enable-billing
Expand Down
20 changes: 19 additions & 1 deletion packages/google-cloud-apigeeregistry/linkinator.config.json
Original file line number Diff line number Diff line change
@@ -1 +1,19 @@
{"recurse":true,"skip":["'httpRules'","lroOptions.httpRules","https://codecov.io/gh/googleapis/","www.googleapis.com","img.shields.io"],"silent":true,"concurrency":5,"retry":true,"retryErrors":true,"retryErrorsCount":5,"retryErrorsJitter":3000}
{
"recurse": true,
"skip": [
"https://codecov.io/gh/googleapis/",
"www.googleapis.com",
"img.shields.io",
"https://console.cloud.google.com/cloudshell",
"https://support.google.com",
"https://cloud.google.com/nodejs/docs/reference/apigeeregistry/latest",
"https://github.com/googleapis/nodejs-apigee-registry/blob/master/CHANGELOG.md",
"https://github.com/googleapis/nodejs-apigee-registry/blob/addSamples/CHANGELOG.md"
],
"silent": true,
"concurrency": 5,
"retry": true,
"retryErrors": true,
"retryErrorsCount": 5,
"retryErrorsJitter": 3000
}
67 changes: 66 additions & 1 deletion packages/google-cloud-apigeeregistry/package.json
Original file line number Diff line number Diff line change
@@ -1 +1,66 @@
{"name":"@google-cloud/apigee-registry","version":"0.1.0","description":"apigeeregistry client for Node.js","repository":"googleapis/nodejs-apigee-registry","license":"Apache-2.0","author":"Google LLC","main":"build/src/index.js","files":["build/src","build/protos"],"keywords":["google apis client","google api client","google apis","google api","google","google cloud platform","google cloud","cloud","google apigeeregistry","apigeeregistry","apigeeregistry service"],"scripts":{"clean":"gts clean","compile":"tsc -p . && cp -r protos build/","compile-protos":"compileProtos src","docs":"jsdoc -c .jsdoc.js","predocs-test":"npm run docs","docs-test":"linkinator docs","fix":"gts fix","lint":"gts check","prepare":"npm run compile-protos && npm run compile","system-test":"c8 mocha build/system-test","test":"c8 mocha build/test","samples-test":"cd samples/ && npm link ../ && npm test","prelint":"cd samples; npm link ../; npm i"},"dependencies":{"google-gax":"^2.12.0"},"devDependencies":{"@types/mocha":"^8.2.2","@types/node":"^14.14.44","@types/sinon":"^10.0.0","c8":"^7.7.2","gts":"^3.1.0","jsdoc":"^3.6.6","jsdoc-fresh":"^1.0.2","jsdoc-region-tag":"^1.0.6","linkinator":"^2.13.6","mocha":"^8.4.0","null-loader":"^4.0.1","pack-n-play":"^1.0.0-2","sinon":"^10.0.0","ts-loader":"^9.1.2","typescript":"^4.2.4","webpack":"^5.36.2","webpack-cli":"^4.7.0"},"engines":{"node":">=v12.0.0"}}
{
"name": "@google-cloud/apigee-registry",
"version": "0.1.0",
"description": "apigeeregistry client for Node.js",
"repository": "googleapis/nodejs-apigee-registry",
"license": "Apache-2.0",
"author": "Google LLC",
"main": "build/src/index.js",
"files": [
"build/src",
"build/protos"
],
"keywords": [
"google apis client",
"google api client",
"google apis",
"google api",
"google",
"google cloud platform",
"google cloud",
"cloud",
"google apigeeregistry",
"apigeeregistry",
"apigeeregistry service"
],
"scripts": {
"clean": "gts clean",
"compile": "tsc -p . && cp -r protos build/",
"compile-protos": "compileProtos src",
"docs": "jsdoc -c .jsdoc.js",
"predocs-test": "npm run docs",
"docs-test": "linkinator docs",
"fix": "gts fix",
"lint": "gts check",
"prepare": "npm run compile-protos && npm run compile",
"system-test": "c8 mocha build/system-test",
"test": "c8 mocha build/test",
"samples-test": "cd samples/ && npm link ../ && npm test",
"prelint": "cd samples; npm link ../; npm i"
},
"dependencies": {
"google-gax": "^3.1.3"
},
"devDependencies": {
"@types/mocha": "^8.2.2",
"@types/node": "^14.14.44",
"@types/sinon": "^10.0.0",
"c8": "^7.7.2",
"gts": "^3.1.0",
"jsdoc": "^3.6.6",
"jsdoc-fresh": "^1.0.2",
"jsdoc-region-tag": "^1.0.6",
"linkinator": "^2.13.6",
"mocha": "^8.4.0",
"null-loader": "^4.0.1",
"pack-n-play": "^1.0.0-2",
"sinon": "^10.0.0",
"ts-loader": "^9.1.2",
"typescript": "^4.2.4",
"webpack": "^5.36.2",
"webpack-cli": "^4.7.0"
},
"engines": {
"node": ">=v12.0.0"
}
}
76 changes: 52 additions & 24 deletions packages/google-cloud-apigeeregistry/samples/quickstart.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Copyright 2022 Google LLC
//
// 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
Expand All @@ -10,41 +12,67 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//
// ** This file is automatically generated by gapic-generator-typescript. **
// ** https://github.com/googleapis/gapic-generator-typescript **
// ** All changes to this file may be overwritten. **

'use strict';

async function main() {

// [START nodejs_apigee_registry_quickstart]
// Imports the Google Cloud client library
function main(parent) {
// [START apigeeregistry_v1_generated_Registry_ListApis_async]
/**
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Required. The parent, which owns this collection of APIs.
* Format: projects/* /locations/*
*/
// const parent = 'abc123'
/**
* The maximum number of APIs to return.
* The service may return fewer than this value.
* If unspecified, at most 50 values will be returned.
* The maximum is 1000; values above 1000 will be coerced to 1000.
*/
// const pageSize = 1234
/**
* A page token, received from a previous `ListApis` call.
* Provide this to retrieve the subsequent page.
* When paginating, all other parameters provided to `ListApis` must match
* the call that provided the page token.
*/
// const pageToken = 'abc123'
/**
* An expression that can be used to filter the list. Filters use the Common
* Expression Language and can refer to all message fields.
*/
// const filter = 'abc123'

// remove this line after package is released
// eslint-disable-next-line node/no-missing-require
const {RegistryClient} = require('@google-cloud/apigee-registry');
// Imports the Apigeeregistry library
const {RegistryClient} = require('@google-cloud/apigee-registry').v1;

// TODO(developer): replace with your prefered project ID.
// const projectId = 'my-project'
// Instantiates a client
const apigeeregistryClient = new RegistryClient();

// Creates a client
// eslint-disable-next-line no-unused-vars
const client = new {RegistryClient}();
async function callListApis() {
// Construct request
const request = {
parent,
};

//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);
// Run request
const iterable = await apigeeregistryClient.listApisAsync(request);
for await (const response of iterable) {
console.log(response);
}
}
doSomething();
// [END nodejs_apigee_registry_quickstart]

callListApis();
// [END apigeeregistry_v1_generated_Registry_ListApis_async]
}

main(...process.argv.slice(2)).catch(err => {
console.error(err.message);
process.exitCode = 1;
});
process.on('unhandledRejection', err => {
console.error(err.message);
process.exitCode = 1;
});
main(...process.argv.slice(2));
16 changes: 7 additions & 9 deletions packages/google-cloud-apigeeregistry/samples/test/quickstart.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'});

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

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

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

Expand All @@ -42,12 +42,10 @@ describe('Quickstart', () => {
});

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);
assert.throws(() => {
execSync(`node ./quickstart.js projects/${projectId}/locations/global`, {
cwd,
});
}, /9 FAILED_PRECONDITION/);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
// ** All changes to this file may be overwritten. **

/* eslint-disable node/no-missing-require, no-unused-vars */
const apigeeregistry = require('@google-cloud/apigeeregistry');
const apigeeregistry = require('@google-cloud/apigee-registry');

function main() {
const provisioningClient = new apigeeregistry.ProvisioningClient();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@
// ** https://github.com/googleapis/gapic-generator-typescript **
// ** All changes to this file may be overwritten. **

import {ProvisioningClient, RegistryClient} from '@google-cloud/apigeeregistry';
import {
ProvisioningClient,
RegistryClient,
} from '@google-cloud/apigee-registry';

// check that the client class type name can be used
function doStuffWithProvisioningClient(client: ProvisioningClient) {
Expand Down

0 comments on commit be07219

Please sign in to comment.