Skip to content

Commit

Permalink
docs: add sample test (#552)
Browse files Browse the repository at this point in the history
* docs: add sample test 

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
  • Loading branch information
sofisl and gcf-owl-bot[bot] authored Sep 16, 2022
1 parent 05d5954 commit 4d29f12
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 25 deletions.
42 changes: 32 additions & 10 deletions packages/google-cloud-oslogin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,18 +57,40 @@ npm install @google-cloud/os-login
### Using the client library

```javascript
const {OsLoginServiceClient} = require('@google-cloud/os-login');
const client = new OsLoginServiceClient();

async function quickstart() {
const [loginProfile] = await client.getLoginProfile({
name: 'users/beckwith@google.com',
});
console.log('Login Profile:');
console.log(loginProfile);
/**
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Required. The unique ID for the user in format `users/{user}`.
*/
// const name = 'abc123'
/**
* The project ID of the Google Cloud Platform project.
*/
// const projectId = 'abc123'
/**
* A system ID for filtering the results of the request.
*/
// const systemId = 'abc123'

// Imports the Oslogin library
const {OsLoginServiceClient} = require('@google-cloud/os-login').v1;

// Instantiates a client
const osloginClient = new OsLoginServiceClient();

async function callGetLoginProfile() {
// Construct request
const request = {
name,
};

// Run request
const response = await osloginClient.getLoginProfile(request);
console.log(response[0]);
}

quickstart();
callGetLoginProfile();

```

Expand Down
2 changes: 1 addition & 1 deletion packages/google-cloud-oslogin/samples/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@
"chai": "^4.2.0",
"mocha": "^8.0.0"
}
}
}
58 changes: 44 additions & 14 deletions packages/google-cloud-oslogin/samples/quickstart.js
Original file line number Diff line number Diff line change
@@ -1,34 +1,64 @@
// Copyright 2017 Google LLC
// 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
//
// http://www.apache.org/licenses/LICENSE-2.0
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// 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() {
function main(name) {
// [START oslogin_quickstart]
const {OsLoginServiceClient} = require('@google-cloud/os-login');
const client = new OsLoginServiceClient();

async function quickstart() {
const [loginProfile] = await client.getLoginProfile({
name: 'users/beckwith@google.com',
});
console.log('Login Profile:');
console.log(loginProfile);
/**
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Required. The unique ID for the user in format `users/{user}`.
*/
// const name = 'abc123'
/**
* The project ID of the Google Cloud Platform project.
*/
// const projectId = 'abc123'
/**
* A system ID for filtering the results of the request.
*/
// const systemId = 'abc123'

// Imports the Oslogin library
const {OsLoginServiceClient} = require('@google-cloud/os-login').v1;

// Instantiates a client
const osloginClient = new OsLoginServiceClient();

async function callGetLoginProfile() {
// Construct request
const request = {
name,
};

// Run request
const response = await osloginClient.getLoginProfile(request);
console.log(response[0]);
}

quickstart();
callGetLoginProfile();
// [END oslogin_quickstart]
}

main();
process.on('unhandledRejection', err => {
console.error(err.message);
process.exitCode = 1;
});
main(...process.argv.slice(2));

0 comments on commit 4d29f12

Please sign in to comment.