Skip to content

Commit

Permalink
feat!: write samples (#3)
Browse files Browse the repository at this point in the history
* feat!: write samples
  • Loading branch information
sofisl authored Jan 6, 2021
1 parent 0d39379 commit 80c4ef6
Show file tree
Hide file tree
Showing 13 changed files with 621 additions and 89 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"release_level": "BETA",
"language": "nodejs",
"repo": "googleapis/nodejs-artifact-registry",
"distribution_name": "@google-devtools/artifact-registry",
"distribution_name": "@google-cloud/artifact-registry",
"api_id": "artifactregistry.googleapis.com",
"requires_billing": true
}
Expand Down
23 changes: 12 additions & 11 deletions packages/google-devtools-artifactregistry/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# [Artifact Registry: Node.js Client](https://github.com/googleapis/nodejs-artifact-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-devtools/artifact-registry.svg)](https://www.npmjs.org/package/@google-devtools/artifact-registry)
[![npm version](https://img.shields.io/npm/v/@google-cloud/artifact-registry.svg)](https://www.npmjs.org/package/@google-cloud/artifact-registry)
[![codecov](https://img.shields.io/codecov/c/github/googleapis/nodejs-artifact-registry/master.svg?style=flat)](https://codecov.io/gh/googleapis/nodejs-artifact-registry)


Expand Down Expand Up @@ -51,7 +51,7 @@ Google APIs Client Libraries, in [Client Libraries Explained][explained].
### Installing the client library

```bash
npm install @google-devtools/artifact-registry
npm install @google-cloud/artifact-registry
```


Expand All @@ -62,23 +62,24 @@ npm install @google-devtools/artifact-registry

// remove this line after package is released
// eslint-disable-next-line node/no-missing-require
const {ArtifactRegistryClient} = require('@google-devtools/artifact-registry');
const {
ArtifactRegistryClient,
} = require('@google-cloud/artifact-registry');

// 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 {ArtifactRegistryClient}();
const client = new ArtifactRegistryClient();

//TODO(library generator): write the actual function you will be testing
async function doSomething() {
console.log('Developer! 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 listsRepositories() {
const repositories = await client.listRepositories({
parent: `projects/${projectId}/locations/${location}`,
});
console.info(repositories);
}
doSomething();
listsRepositories();

```

Expand Down
4 changes: 2 additions & 2 deletions packages/google-devtools-artifactregistry/package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "@google-devtools/artifact-registry",
"name": "@google-cloud/artifact-registry",
"version": "0.1.0",
"description": "Artifactregistry client for Node.js",
"repository": "googleapis/nodejs-artifactregistry",
"repository": "googleapis/nodejs-artifact-registry",
"license": "Apache-2.0",
"author": "Google LLC",
"main": "build/src/index.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/google-devtools-artifactregistry/protos/protos.js

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

352 changes: 324 additions & 28 deletions packages/google-devtools-artifactregistry/protos/protos.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"test": "c8 mocha --timeout 600000 test/*.js"
},
"dependencies": {
"@google-devtools/artifact-registry": "^0.1.0"
"@google-cloud/artifact-registry": "^0.1.0"
},
"devDependencies": {
"c8": "^7.1.0",
Expand Down
23 changes: 9 additions & 14 deletions packages/google-devtools-artifactregistry/samples/quickstart.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,33 +13,28 @@

'use strict';

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

// remove this line after package is released
// eslint-disable-next-line node/no-missing-require
const {
ArtifactRegistryClient,
} = require('@google-devtools/artifact-registry');
const {ArtifactRegistryClient} = require('@google-cloud/artifact-registry');

// 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 {ArtifactRegistryClient}();
const client = new ArtifactRegistryClient();

//TODO(library generator): write the actual function you will be testing
async function doSomething() {
console.log(
'Developer! 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 listsRepositories() {
const repositories = await client.listRepositories({
parent: `projects/${projectId}/locations/${location}`,
});
console.info(repositories);
}
doSomething();
listsRepositories();
// [END nodejs_artifact_registry_quickstart]
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,31 +20,26 @@
const path = require('path');
const cp = require('child_process');
const {before, describe, it} = require('mocha');
// eslint-disable-next-line node/no-missing-require
const {ArtifactRegistryClient} = require('@google-devtools/artifact-registry');
// eslint-disable-next-line no-unused-vars, node/no-missing-require
const {ArtifactRegistryClient} = require('@google-cloud/artifact-registry');
const {assert} = require('chai');

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

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

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

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 disability
// 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} ${location}`, {
cwd,
});
assert(stdout, stdout.match(/\[\]/));
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -2361,9 +2361,7 @@ export class ArtifactRegistryClient {
listRepositoriesAsync(
request?: protos.google.devtools.artifactregistry.v1beta2.IListRepositoriesRequest,
options?: CallOptions
): AsyncIterable<
protos.google.devtools.artifactregistry.v1beta2.IRepository
> {
): AsyncIterable<protos.google.devtools.artifactregistry.v1beta2.IRepository> {
request = request || {};
options = options || {};
options.otherArgs = options.otherArgs || {};
Expand All @@ -2380,9 +2378,7 @@ export class ArtifactRegistryClient {
this.innerApiCalls['listRepositories'] as GaxCall,
(request as unknown) as RequestType,
callSettings
) as AsyncIterable<
protos.google.devtools.artifactregistry.v1beta2.IRepository
>;
) as AsyncIterable<protos.google.devtools.artifactregistry.v1beta2.IRepository>;
}
listPackages(
request: protos.google.devtools.artifactregistry.v1beta2.IListPackagesRequest,
Expand Down Expand Up @@ -2579,9 +2575,7 @@ export class ArtifactRegistryClient {
this.innerApiCalls['listPackages'] as GaxCall,
(request as unknown) as RequestType,
callSettings
) as AsyncIterable<
protos.google.devtools.artifactregistry.v1beta2.IPackage
>;
) as AsyncIterable<protos.google.devtools.artifactregistry.v1beta2.IPackage>;
}
listVersions(
request: protos.google.devtools.artifactregistry.v1beta2.IListVersionsRequest,
Expand Down Expand Up @@ -2784,9 +2778,7 @@ export class ArtifactRegistryClient {
this.innerApiCalls['listVersions'] as GaxCall,
(request as unknown) as RequestType,
callSettings
) as AsyncIterable<
protos.google.devtools.artifactregistry.v1beta2.IVersion
>;
) as AsyncIterable<protos.google.devtools.artifactregistry.v1beta2.IVersion>;
}
listFiles(
request: protos.google.devtools.artifactregistry.v1beta2.IListFilesRequest,
Expand Down
Loading

0 comments on commit 80c4ef6

Please sign in to comment.