Skip to content

Commit df8bd22

Browse files
sofislgcf-owl-bot[bot]gcf-merge-on-green[bot]
authored
docs(samples): add generated samples (#978)
* docs(samples): add generated samples * 🦉 Updates from OwlBot post-processor 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> Co-authored-by: gcf-merge-on-green[bot] <60162190+gcf-merge-on-green[bot]@users.noreply.github.com>
1 parent 7cadf1b commit df8bd22

16 files changed

Lines changed: 1667 additions & 3 deletions

handwritten/datastore/owlbot.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,3 @@
5858
s.copy(templates)
5959

6060
node.postprocess_gapic_library_hermetic()
61-
62-
# Remove generated samples from veneer library:
63-
shell.run(('rm', '-rf', 'samples/generated'), hide_output = False)
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
// Copyright 2022 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// https://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
//
15+
// ** This file is automatically generated by gapic-generator-typescript. **
16+
// ** https://github.com/googleapis/gapic-generator-typescript **
17+
// ** All changes to this file may be overwritten. **
18+
19+
20+
21+
'use strict';
22+
23+
function main(projectId, keys) {
24+
// [START datastore_v1_generated_Datastore_AllocateIds_async]
25+
/**
26+
* This snippet has been automatically generated and should be regarded as a code template only.
27+
* It will require modifications to work.
28+
* It may require correct/in-range values for request initialization.
29+
* TODO(developer): Uncomment these variables before running the sample.
30+
*/
31+
/**
32+
* Required. The ID of the project against which to make the request.
33+
*/
34+
// const projectId = 'abc123'
35+
/**
36+
* The ID of the database against which to make the request.
37+
* '(default)' is not allowed; please use empty string '' to refer the default
38+
* database.
39+
*/
40+
// const databaseId = 'abc123'
41+
/**
42+
* Required. A list of keys with incomplete key paths for which to allocate IDs.
43+
* No key may be reserved/read-only.
44+
*/
45+
// const keys = 1234
46+
47+
// Imports the Datastore library
48+
const {DatastoreClient} = require('@google-cloud/datastore').v1;
49+
50+
// Instantiates a client
51+
const datastoreClient = new DatastoreClient();
52+
53+
async function callAllocateIds() {
54+
// Construct request
55+
const request = {
56+
projectId,
57+
keys,
58+
};
59+
60+
// Run request
61+
const response = await datastoreClient.allocateIds(request);
62+
console.log(response);
63+
}
64+
65+
callAllocateIds();
66+
// [END datastore_v1_generated_Datastore_AllocateIds_async]
67+
}
68+
69+
process.on('unhandledRejection', err => {
70+
console.error(err.message);
71+
process.exitCode = 1;
72+
});
73+
main(...process.argv.slice(2));
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
// Copyright 2022 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// https://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
//
15+
// ** This file is automatically generated by gapic-generator-typescript. **
16+
// ** https://github.com/googleapis/gapic-generator-typescript **
17+
// ** All changes to this file may be overwritten. **
18+
19+
20+
21+
'use strict';
22+
23+
function main(projectId) {
24+
// [START datastore_v1_generated_Datastore_BeginTransaction_async]
25+
/**
26+
* This snippet has been automatically generated and should be regarded as a code template only.
27+
* It will require modifications to work.
28+
* It may require correct/in-range values for request initialization.
29+
* TODO(developer): Uncomment these variables before running the sample.
30+
*/
31+
/**
32+
* Required. The ID of the project against which to make the request.
33+
*/
34+
// const projectId = 'abc123'
35+
/**
36+
* The ID of the database against which to make the request.
37+
* '(default)' is not allowed; please use empty string '' to refer the default
38+
* database.
39+
*/
40+
// const databaseId = 'abc123'
41+
/**
42+
* Options for a new transaction.
43+
*/
44+
// const transactionOptions = {}
45+
46+
// Imports the Datastore library
47+
const {DatastoreClient} = require('@google-cloud/datastore').v1;
48+
49+
// Instantiates a client
50+
const datastoreClient = new DatastoreClient();
51+
52+
async function callBeginTransaction() {
53+
// Construct request
54+
const request = {
55+
projectId,
56+
};
57+
58+
// Run request
59+
const response = await datastoreClient.beginTransaction(request);
60+
console.log(response);
61+
}
62+
63+
callBeginTransaction();
64+
// [END datastore_v1_generated_Datastore_BeginTransaction_async]
65+
}
66+
67+
process.on('unhandledRejection', err => {
68+
console.error(err.message);
69+
process.exitCode = 1;
70+
});
71+
main(...process.argv.slice(2));
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
// Copyright 2022 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// https://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
//
15+
// ** This file is automatically generated by gapic-generator-typescript. **
16+
// ** https://github.com/googleapis/gapic-generator-typescript **
17+
// ** All changes to this file may be overwritten. **
18+
19+
20+
21+
'use strict';
22+
23+
function main(projectId) {
24+
// [START datastore_v1_generated_Datastore_Commit_async]
25+
/**
26+
* This snippet has been automatically generated and should be regarded as a code template only.
27+
* It will require modifications to work.
28+
* It may require correct/in-range values for request initialization.
29+
* TODO(developer): Uncomment these variables before running the sample.
30+
*/
31+
/**
32+
* Required. The ID of the project against which to make the request.
33+
*/
34+
// const projectId = 'abc123'
35+
/**
36+
* The ID of the database against which to make the request.
37+
* '(default)' is not allowed; please use empty string '' to refer the default
38+
* database.
39+
*/
40+
// const databaseId = 'abc123'
41+
/**
42+
* The type of commit to perform. Defaults to `TRANSACTIONAL`.
43+
*/
44+
// const mode = {}
45+
/**
46+
* The identifier of the transaction associated with the commit. A
47+
* transaction identifier is returned by a call to
48+
* Datastore.BeginTransaction google.datastore.v1.Datastore.BeginTransaction.
49+
*/
50+
// const transaction = 'Buffer.from('string')'
51+
/**
52+
* The mutations to perform.
53+
* When mode is `TRANSACTIONAL`, mutations affecting a single entity are
54+
* applied in order. The following sequences of mutations affecting a single
55+
* entity are not permitted in a single `Commit` request:
56+
* - `insert` followed by `insert`
57+
* - `update` followed by `insert`
58+
* - `upsert` followed by `insert`
59+
* - `delete` followed by `update`
60+
* When mode is `NON_TRANSACTIONAL`, no two mutations may affect a single
61+
* entity.
62+
*/
63+
// const mutations = 1234
64+
65+
// Imports the Datastore library
66+
const {DatastoreClient} = require('@google-cloud/datastore').v1;
67+
68+
// Instantiates a client
69+
const datastoreClient = new DatastoreClient();
70+
71+
async function callCommit() {
72+
// Construct request
73+
const request = {
74+
projectId,
75+
};
76+
77+
// Run request
78+
const response = await datastoreClient.commit(request);
79+
console.log(response);
80+
}
81+
82+
callCommit();
83+
// [END datastore_v1_generated_Datastore_Commit_async]
84+
}
85+
86+
process.on('unhandledRejection', err => {
87+
console.error(err.message);
88+
process.exitCode = 1;
89+
});
90+
main(...process.argv.slice(2));
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
// Copyright 2022 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// https://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
//
15+
// ** This file is automatically generated by gapic-generator-typescript. **
16+
// ** https://github.com/googleapis/gapic-generator-typescript **
17+
// ** All changes to this file may be overwritten. **
18+
19+
20+
21+
'use strict';
22+
23+
function main(projectId, keys) {
24+
// [START datastore_v1_generated_Datastore_Lookup_async]
25+
/**
26+
* This snippet has been automatically generated and should be regarded as a code template only.
27+
* It will require modifications to work.
28+
* It may require correct/in-range values for request initialization.
29+
* TODO(developer): Uncomment these variables before running the sample.
30+
*/
31+
/**
32+
* Required. The ID of the project against which to make the request.
33+
*/
34+
// const projectId = 'abc123'
35+
/**
36+
* The ID of the database against which to make the request.
37+
* '(default)' is not allowed; please use empty string '' to refer the default
38+
* database.
39+
*/
40+
// const databaseId = 'abc123'
41+
/**
42+
* The options for this lookup request.
43+
*/
44+
// const readOptions = {}
45+
/**
46+
* Required. Keys of entities to look up.
47+
*/
48+
// const keys = 1234
49+
50+
// Imports the Datastore library
51+
const {DatastoreClient} = require('@google-cloud/datastore').v1;
52+
53+
// Instantiates a client
54+
const datastoreClient = new DatastoreClient();
55+
56+
async function callLookup() {
57+
// Construct request
58+
const request = {
59+
projectId,
60+
keys,
61+
};
62+
63+
// Run request
64+
const response = await datastoreClient.lookup(request);
65+
console.log(response);
66+
}
67+
68+
callLookup();
69+
// [END datastore_v1_generated_Datastore_Lookup_async]
70+
}
71+
72+
process.on('unhandledRejection', err => {
73+
console.error(err.message);
74+
process.exitCode = 1;
75+
});
76+
main(...process.argv.slice(2));
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
// Copyright 2022 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// https://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
//
15+
// ** This file is automatically generated by gapic-generator-typescript. **
16+
// ** https://github.com/googleapis/gapic-generator-typescript **
17+
// ** All changes to this file may be overwritten. **
18+
19+
20+
21+
'use strict';
22+
23+
function main(projectId, keys) {
24+
// [START datastore_v1_generated_Datastore_ReserveIds_async]
25+
/**
26+
* This snippet has been automatically generated and should be regarded as a code template only.
27+
* It will require modifications to work.
28+
* It may require correct/in-range values for request initialization.
29+
* TODO(developer): Uncomment these variables before running the sample.
30+
*/
31+
/**
32+
* Required. The ID of the project against which to make the request.
33+
*/
34+
// const projectId = 'abc123'
35+
/**
36+
* The ID of the database against which to make the request.
37+
* '(default)' is not allowed; please use empty string '' to refer the default
38+
* database.
39+
*/
40+
// const databaseId = 'abc123'
41+
/**
42+
* Required. A list of keys with complete key paths whose numeric IDs should not be
43+
* auto-allocated.
44+
*/
45+
// const keys = 1234
46+
47+
// Imports the Datastore library
48+
const {DatastoreClient} = require('@google-cloud/datastore').v1;
49+
50+
// Instantiates a client
51+
const datastoreClient = new DatastoreClient();
52+
53+
async function callReserveIds() {
54+
// Construct request
55+
const request = {
56+
projectId,
57+
keys,
58+
};
59+
60+
// Run request
61+
const response = await datastoreClient.reserveIds(request);
62+
console.log(response);
63+
}
64+
65+
callReserveIds();
66+
// [END datastore_v1_generated_Datastore_ReserveIds_async]
67+
}
68+
69+
process.on('unhandledRejection', err => {
70+
console.error(err.message);
71+
process.exitCode = 1;
72+
});
73+
main(...process.argv.slice(2));

0 commit comments

Comments
 (0)