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

Commit

Permalink
samples: auto-generate samples for GAPIC clients (#202)
Browse files Browse the repository at this point in the history
* feat: auto-generate samples for GAPIC clients

PiperOrigin-RevId: 398106791

Source-Link: googleapis/googleapis@4f46ddc

Source-Link: https://github.com/googleapis/googleapis-gen/commit/43a09facba0e5c80d2587724d7ef21be90e0b18c
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNDNhMDlmYWNiYTBlNWM4MGQyNTg3NzI0ZDdlZjIxYmU5MGUwYjE4YyJ9

* 🦉 Updates from OwlBot

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* 🦉 Updates from OwlBot

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
  • Loading branch information
gcf-owl-bot[bot] and gcf-owl-bot[bot] authored Sep 22, 2021
1 parent 7a9bb5e commit b50db96
Show file tree
Hide file tree
Showing 294 changed files with 19,642 additions and 108 deletions.
59 changes: 59 additions & 0 deletions samples/generated/v1/dataset_service.create_dataset.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
// Copyright 2021 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
//
// 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.

'use strict';

function main(parent, dataset) {
// [START aiplatform_create_dataset_sample]
/**
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Required. The resource name of the Location to create the Dataset in.
* Format: `projects/{project}/locations/{location}`
*/
// const parent = 'abc123'
/**
* Required. The Dataset to create.
*/
// const dataset = ''

// Imports the Aiplatform library
const {DatasetServiceClient} = require('@google-cloud/aiplatform').v1;

// Instantiates a client
const aiplatformClient = new DatasetServiceClient();

async function createDataset() {
// Construct request
const request = {
parent,
dataset,
};

// Run request
const [operation] = await aiplatformClient.createDataset(request);
const [response] = await operation.promise();
console.log(response);
}

createDataset();
// [END aiplatform_create_dataset_sample]
}

process.on('unhandledRejection', err => {
console.error(err.message);
process.exitCode = 1;
});
main(...process.argv.slice(2));
55 changes: 55 additions & 0 deletions samples/generated/v1/dataset_service.delete_dataset.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// Copyright 2021 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
//
// 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.

'use strict';

function main(name) {
// [START aiplatform_delete_dataset_sample]
/**
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Required. The resource name of the Dataset to delete.
* Format:
* `projects/{project}/locations/{location}/datasets/{dataset}`
*/
// const name = 'abc123'

// Imports the Aiplatform library
const {DatasetServiceClient} = require('@google-cloud/aiplatform').v1;

// Instantiates a client
const aiplatformClient = new DatasetServiceClient();

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

// Run request
const [operation] = await aiplatformClient.deleteDataset(request);
const [response] = await operation.promise();
console.log(response);
}

deleteDataset();
// [END aiplatform_delete_dataset_sample]
}

process.on('unhandledRejection', err => {
console.error(err.message);
process.exitCode = 1;
});
main(...process.argv.slice(2));
60 changes: 60 additions & 0 deletions samples/generated/v1/dataset_service.export_data.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
// Copyright 2021 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
//
// 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.

'use strict';

function main(name, exportConfig) {
// [START aiplatform_export_data_sample]
/**
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Required. The name of the Dataset resource.
* Format:
* `projects/{project}/locations/{location}/datasets/{dataset}`
*/
// const name = 'abc123'
/**
* Required. The desired output location.
*/
// const exportConfig = ''

// Imports the Aiplatform library
const {DatasetServiceClient} = require('@google-cloud/aiplatform').v1;

// Instantiates a client
const aiplatformClient = new DatasetServiceClient();

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

// Run request
const [operation] = await aiplatformClient.exportData(request);
const [response] = await operation.promise();
console.log(response);
}

exportData();
// [END aiplatform_export_data_sample]
}

process.on('unhandledRejection', err => {
console.error(err.message);
process.exitCode = 1;
});
main(...process.argv.slice(2));
58 changes: 58 additions & 0 deletions samples/generated/v1/dataset_service.get_annotation_spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// Copyright 2021 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
//
// 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.

'use strict';

function main(name) {
// [START aiplatform_get_annotation_spec_sample]
/**
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Required. The name of the AnnotationSpec resource.
* Format:
* `projects/{project}/locations/{location}/datasets/{dataset}/annotationSpecs/{annotation_spec}`
*/
// const name = 'abc123'
/**
* Mask specifying which fields to read.
*/
// const readMask = ''

// Imports the Aiplatform library
const {DatasetServiceClient} = require('@google-cloud/aiplatform').v1;

// Instantiates a client
const aiplatformClient = new DatasetServiceClient();

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

// Run request
const response = await aiplatformClient.getAnnotationSpec(request);
console.log(response);
}

getAnnotationSpec();
// [END aiplatform_get_annotation_spec_sample]
}

process.on('unhandledRejection', err => {
console.error(err.message);
process.exitCode = 1;
});
main(...process.argv.slice(2));
56 changes: 56 additions & 0 deletions samples/generated/v1/dataset_service.get_dataset.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// Copyright 2021 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
//
// 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.

'use strict';

function main(name) {
// [START aiplatform_get_dataset_sample]
/**
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Required. The name of the Dataset resource.
*/
// const name = 'abc123'
/**
* Mask specifying which fields to read.
*/
// const readMask = ''

// Imports the Aiplatform library
const {DatasetServiceClient} = require('@google-cloud/aiplatform').v1;

// Instantiates a client
const aiplatformClient = new DatasetServiceClient();

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

// Run request
const response = await aiplatformClient.getDataset(request);
console.log(response);
}

getDataset();
// [END aiplatform_get_dataset_sample]
}

process.on('unhandledRejection', err => {
console.error(err.message);
process.exitCode = 1;
});
main(...process.argv.slice(2));
61 changes: 61 additions & 0 deletions samples/generated/v1/dataset_service.import_data.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
// Copyright 2021 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
//
// 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.

'use strict';

function main(name, importConfigs) {
// [START aiplatform_import_data_sample]
/**
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Required. The name of the Dataset resource.
* Format:
* `projects/{project}/locations/{location}/datasets/{dataset}`
*/
// const name = 'abc123'
/**
* Required. The desired input locations. The contents of all input locations will be
* imported in one batch.
*/
// const importConfigs = 1234

// Imports the Aiplatform library
const {DatasetServiceClient} = require('@google-cloud/aiplatform').v1;

// Instantiates a client
const aiplatformClient = new DatasetServiceClient();

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

// Run request
const [operation] = await aiplatformClient.importData(request);
const [response] = await operation.promise();
console.log(response);
}

importData();
// [END aiplatform_import_data_sample]
}

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

0 comments on commit b50db96

Please sign in to comment.