Skip to content

Commit 0cce649

Browse files
committed
add samples and update noxfile
1 parent a0b9aee commit 0cce649

31 files changed

Lines changed: 3862 additions & 0 deletions

File tree

packages/google-cloud-datastore/noxfile.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@
3535
RUFF_VERSION = "ruff==0.14.14"
3636
LINT_PATHS = ["docs", "google", "tests", "noxfile.py", "setup.py"]
3737

38+
# Add samples to the list of directories to format if the directory exists.
39+
if os.path.isdir("samples"):
40+
LINT_PATHS.append("samples")
41+
3842
DEFAULT_PYTHON_VERSION = "3.14"
3943

4044
UNIT_TEST_PYTHON_VERSIONS: List[str] = [
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# -*- coding: utf-8 -*-
2+
# Copyright 2025 Google LLC
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#
16+
# Generated code. DO NOT EDIT!
17+
#
18+
# Snippet for CreateIndex
19+
# NOTE: This snippet has been automatically generated for illustrative purposes only.
20+
# It may require modifications to work in your environment.
21+
22+
# To install the latest published package dependency, execute the following:
23+
# python3 -m pip install google-cloud-datastore
24+
25+
26+
# [START datastore_v1_generated_DatastoreAdmin_CreateIndex_async]
27+
# This snippet has been automatically generated and should be regarded as a
28+
# code template only.
29+
# It will require modifications to work:
30+
# - It may require correct/in-range values for request initialization.
31+
# - It may require specifying regional endpoints when creating the service
32+
# client as shown in:
33+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
34+
from google.cloud import datastore_admin_v1
35+
36+
37+
async def sample_create_index():
38+
# Create a client
39+
client = datastore_admin_v1.DatastoreAdminAsyncClient()
40+
41+
# Initialize request argument(s)
42+
request = datastore_admin_v1.CreateIndexRequest()
43+
44+
# Make the request
45+
operation = client.create_index(request=request)
46+
47+
print("Waiting for operation to complete...")
48+
49+
response = (await operation).result()
50+
51+
# Handle the response
52+
print(response)
53+
54+
55+
# [END datastore_v1_generated_DatastoreAdmin_CreateIndex_async]
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# -*- coding: utf-8 -*-
2+
# Copyright 2025 Google LLC
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#
16+
# Generated code. DO NOT EDIT!
17+
#
18+
# Snippet for CreateIndex
19+
# NOTE: This snippet has been automatically generated for illustrative purposes only.
20+
# It may require modifications to work in your environment.
21+
22+
# To install the latest published package dependency, execute the following:
23+
# python3 -m pip install google-cloud-datastore
24+
25+
26+
# [START datastore_v1_generated_DatastoreAdmin_CreateIndex_sync]
27+
# This snippet has been automatically generated and should be regarded as a
28+
# code template only.
29+
# It will require modifications to work:
30+
# - It may require correct/in-range values for request initialization.
31+
# - It may require specifying regional endpoints when creating the service
32+
# client as shown in:
33+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
34+
from google.cloud import datastore_admin_v1
35+
36+
37+
def sample_create_index():
38+
# Create a client
39+
client = datastore_admin_v1.DatastoreAdminClient()
40+
41+
# Initialize request argument(s)
42+
request = datastore_admin_v1.CreateIndexRequest()
43+
44+
# Make the request
45+
operation = client.create_index(request=request)
46+
47+
print("Waiting for operation to complete...")
48+
49+
response = operation.result()
50+
51+
# Handle the response
52+
print(response)
53+
54+
55+
# [END datastore_v1_generated_DatastoreAdmin_CreateIndex_sync]
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# -*- coding: utf-8 -*-
2+
# Copyright 2025 Google LLC
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#
16+
# Generated code. DO NOT EDIT!
17+
#
18+
# Snippet for DeleteIndex
19+
# NOTE: This snippet has been automatically generated for illustrative purposes only.
20+
# It may require modifications to work in your environment.
21+
22+
# To install the latest published package dependency, execute the following:
23+
# python3 -m pip install google-cloud-datastore
24+
25+
26+
# [START datastore_v1_generated_DatastoreAdmin_DeleteIndex_async]
27+
# This snippet has been automatically generated and should be regarded as a
28+
# code template only.
29+
# It will require modifications to work:
30+
# - It may require correct/in-range values for request initialization.
31+
# - It may require specifying regional endpoints when creating the service
32+
# client as shown in:
33+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
34+
from google.cloud import datastore_admin_v1
35+
36+
37+
async def sample_delete_index():
38+
# Create a client
39+
client = datastore_admin_v1.DatastoreAdminAsyncClient()
40+
41+
# Initialize request argument(s)
42+
request = datastore_admin_v1.DeleteIndexRequest()
43+
44+
# Make the request
45+
operation = client.delete_index(request=request)
46+
47+
print("Waiting for operation to complete...")
48+
49+
response = (await operation).result()
50+
51+
# Handle the response
52+
print(response)
53+
54+
55+
# [END datastore_v1_generated_DatastoreAdmin_DeleteIndex_async]
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# -*- coding: utf-8 -*-
2+
# Copyright 2025 Google LLC
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#
16+
# Generated code. DO NOT EDIT!
17+
#
18+
# Snippet for DeleteIndex
19+
# NOTE: This snippet has been automatically generated for illustrative purposes only.
20+
# It may require modifications to work in your environment.
21+
22+
# To install the latest published package dependency, execute the following:
23+
# python3 -m pip install google-cloud-datastore
24+
25+
26+
# [START datastore_v1_generated_DatastoreAdmin_DeleteIndex_sync]
27+
# This snippet has been automatically generated and should be regarded as a
28+
# code template only.
29+
# It will require modifications to work:
30+
# - It may require correct/in-range values for request initialization.
31+
# - It may require specifying regional endpoints when creating the service
32+
# client as shown in:
33+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
34+
from google.cloud import datastore_admin_v1
35+
36+
37+
def sample_delete_index():
38+
# Create a client
39+
client = datastore_admin_v1.DatastoreAdminClient()
40+
41+
# Initialize request argument(s)
42+
request = datastore_admin_v1.DeleteIndexRequest()
43+
44+
# Make the request
45+
operation = client.delete_index(request=request)
46+
47+
print("Waiting for operation to complete...")
48+
49+
response = operation.result()
50+
51+
# Handle the response
52+
print(response)
53+
54+
55+
# [END datastore_v1_generated_DatastoreAdmin_DeleteIndex_sync]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# -*- coding: utf-8 -*-
2+
# Copyright 2025 Google LLC
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#
16+
# Generated code. DO NOT EDIT!
17+
#
18+
# Snippet for ExportEntities
19+
# NOTE: This snippet has been automatically generated for illustrative purposes only.
20+
# It may require modifications to work in your environment.
21+
22+
# To install the latest published package dependency, execute the following:
23+
# python3 -m pip install google-cloud-datastore
24+
25+
26+
# [START datastore_v1_generated_DatastoreAdmin_ExportEntities_async]
27+
# This snippet has been automatically generated and should be regarded as a
28+
# code template only.
29+
# It will require modifications to work:
30+
# - It may require correct/in-range values for request initialization.
31+
# - It may require specifying regional endpoints when creating the service
32+
# client as shown in:
33+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
34+
from google.cloud import datastore_admin_v1
35+
36+
37+
async def sample_export_entities():
38+
# Create a client
39+
client = datastore_admin_v1.DatastoreAdminAsyncClient()
40+
41+
# Initialize request argument(s)
42+
request = datastore_admin_v1.ExportEntitiesRequest(
43+
project_id="project_id_value",
44+
output_url_prefix="output_url_prefix_value",
45+
)
46+
47+
# Make the request
48+
operation = client.export_entities(request=request)
49+
50+
print("Waiting for operation to complete...")
51+
52+
response = (await operation).result()
53+
54+
# Handle the response
55+
print(response)
56+
57+
58+
# [END datastore_v1_generated_DatastoreAdmin_ExportEntities_async]
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# -*- coding: utf-8 -*-
2+
# Copyright 2025 Google LLC
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#
16+
# Generated code. DO NOT EDIT!
17+
#
18+
# Snippet for ExportEntities
19+
# NOTE: This snippet has been automatically generated for illustrative purposes only.
20+
# It may require modifications to work in your environment.
21+
22+
# To install the latest published package dependency, execute the following:
23+
# python3 -m pip install google-cloud-datastore
24+
25+
26+
# [START datastore_v1_generated_DatastoreAdmin_ExportEntities_sync]
27+
# This snippet has been automatically generated and should be regarded as a
28+
# code template only.
29+
# It will require modifications to work:
30+
# - It may require correct/in-range values for request initialization.
31+
# - It may require specifying regional endpoints when creating the service
32+
# client as shown in:
33+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
34+
from google.cloud import datastore_admin_v1
35+
36+
37+
def sample_export_entities():
38+
# Create a client
39+
client = datastore_admin_v1.DatastoreAdminClient()
40+
41+
# Initialize request argument(s)
42+
request = datastore_admin_v1.ExportEntitiesRequest(
43+
project_id="project_id_value",
44+
output_url_prefix="output_url_prefix_value",
45+
)
46+
47+
# Make the request
48+
operation = client.export_entities(request=request)
49+
50+
print("Waiting for operation to complete...")
51+
52+
response = operation.result()
53+
54+
# Handle the response
55+
print(response)
56+
57+
58+
# [END datastore_v1_generated_DatastoreAdmin_ExportEntities_sync]

0 commit comments

Comments
 (0)