Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: add generated snippets #532

Merged
merged 8 commits into from
Feb 26, 2022
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,30 @@ async def create_index(
metadata for the operation will be the type
[IndexOperationMetadata][google.firestore.admin.v1.IndexOperationMetadata].


.. code-block::

from google.cloud import firestore_admin_v1

def sample_create_index():
# Create a client
client = firestore_admin_v1.FirestoreAdminClient()

# Initialize request argument(s)
request = firestore_admin_v1.CreateIndexRequest(
parent="parent_value",
)

# Make the request
operation = client.create_index(request=request)

print("Waiting for operation to complete...")

response = operation.result()

# Handle the response
print(response)

Args:
request (Union[google.cloud.firestore_admin_v1.types.CreateIndexRequest, dict]):
The request object. The request for
Expand Down Expand Up @@ -358,6 +382,26 @@ async def list_indexes(
) -> pagers.ListIndexesAsyncPager:
r"""Lists composite indexes.

.. code-block::

from google.cloud import firestore_admin_v1

def sample_list_indexes():
# Create a client
client = firestore_admin_v1.FirestoreAdminClient()

# Initialize request argument(s)
request = firestore_admin_v1.ListIndexesRequest(
parent="parent_value",
)

# Make the request
page_result = client.list_indexes(request=request)

# Handle the response
for response in page_result:
print(response)

Args:
request (Union[google.cloud.firestore_admin_v1.types.ListIndexesRequest, dict]):
The request object. The request for
Expand Down Expand Up @@ -449,6 +493,25 @@ async def get_index(
) -> index.Index:
r"""Gets a composite index.

.. code-block::

from google.cloud import firestore_admin_v1

def sample_get_index():
# Create a client
client = firestore_admin_v1.FirestoreAdminClient()

# Initialize request argument(s)
request = firestore_admin_v1.GetIndexRequest(
name="name_value",
)

# Make the request
response = client.get_index(request=request)

# Handle the response
print(response)

Args:
request (Union[google.cloud.firestore_admin_v1.types.GetIndexRequest, dict]):
The request object. The request for
Expand Down Expand Up @@ -532,6 +595,22 @@ async def delete_index(
) -> None:
r"""Deletes a composite index.

.. code-block::

from google.cloud import firestore_admin_v1

def sample_delete_index():
# Create a client
client = firestore_admin_v1.FirestoreAdminClient()

# Initialize request argument(s)
request = firestore_admin_v1.DeleteIndexRequest(
name="name_value",
)

# Make the request
client.delete_index(request=request)

Args:
request (Union[google.cloud.firestore_admin_v1.types.DeleteIndexRequest, dict]):
The request object. The request for
Expand Down Expand Up @@ -607,6 +686,25 @@ async def get_field(
) -> field.Field:
r"""Gets the metadata and configuration for a Field.

.. code-block::

from google.cloud import firestore_admin_v1

def sample_get_field():
# Create a client
client = firestore_admin_v1.FirestoreAdminClient()

# Initialize request argument(s)
request = firestore_admin_v1.GetFieldRequest(
name="name_value",
)

# Make the request
response = client.get_field(request=request)

# Handle the response
print(response)

Args:
request (Union[google.cloud.firestore_admin_v1.types.GetFieldRequest, dict]):
The request object. The request for
Expand Down Expand Up @@ -707,6 +805,33 @@ async def update_field(
the special ``Field`` with resource name:
``projects/{project_id}/databases/{database_id}/collectionGroups/__default__/fields/*``.


.. code-block::

from google.cloud import firestore_admin_v1

def sample_update_field():
# Create a client
client = firestore_admin_v1.FirestoreAdminClient()

# Initialize request argument(s)
field = firestore_admin_v1.Field()
field.name = "name_value"

request = firestore_admin_v1.UpdateFieldRequest(
field=field,
)

# Make the request
operation = client.update_field(request=request)

print("Waiting for operation to complete...")

response = operation.result()

# Handle the response
print(response)

Args:
request (Union[google.cloud.firestore_admin_v1.types.UpdateFieldRequest, dict]):
The request object. The request for
Expand Down Expand Up @@ -801,6 +926,27 @@ async def list_fields(
with the filter set to ``indexConfig.usesAncestorConfig:false``
.


.. code-block::

from google.cloud import firestore_admin_v1

def sample_list_fields():
# Create a client
client = firestore_admin_v1.FirestoreAdminClient()

# Initialize request argument(s)
request = firestore_admin_v1.ListFieldsRequest(
parent="parent_value",
)

# Make the request
page_result = client.list_fields(request=request)

# Handle the response
for response in page_result:
print(response)

Args:
request (Union[google.cloud.firestore_admin_v1.types.ListFieldsRequest, dict]):
The request object. The request for
Expand Down Expand Up @@ -905,6 +1051,30 @@ async def export_documents(
refer to:
https://cloud.google.com/firestore/docs/manage-data/export-import


.. code-block::

from google.cloud import firestore_admin_v1

def sample_export_documents():
# Create a client
client = firestore_admin_v1.FirestoreAdminClient()

# Initialize request argument(s)
request = firestore_admin_v1.ExportDocumentsRequest(
name="name_value",
)

# Make the request
operation = client.export_documents(request=request)

print("Waiting for operation to complete...")

response = operation.result()

# Handle the response
print(response)

Args:
request (Union[google.cloud.firestore_admin_v1.types.ExportDocumentsRequest, dict]):
The request object. The request for
Expand Down Expand Up @@ -995,6 +1165,30 @@ async def import_documents(
cancelled, it is possible that a subset of the data has
already been imported to Cloud Firestore.


.. code-block::

from google.cloud import firestore_admin_v1

def sample_import_documents():
# Create a client
client = firestore_admin_v1.FirestoreAdminClient()

# Initialize request argument(s)
request = firestore_admin_v1.ImportDocumentsRequest(
name="name_value",
)

# Make the request
operation = client.import_documents(request=request)

print("Waiting for operation to complete...")

response = operation.result()

# Handle the response
print(response)

Args:
request (Union[google.cloud.firestore_admin_v1.types.ImportDocumentsRequest, dict]):
The request object. The request for
Expand Down Expand Up @@ -1087,6 +1281,25 @@ async def get_database(
) -> database.Database:
r"""Gets information about a database.

.. code-block::

from google.cloud import firestore_admin_v1

def sample_get_database():
# Create a client
client = firestore_admin_v1.FirestoreAdminClient()

# Initialize request argument(s)
request = firestore_admin_v1.GetDatabaseRequest(
name="name_value",
)

# Make the request
response = client.get_database(request=request)

# Handle the response
print(response)

Args:
request (Union[google.cloud.firestore_admin_v1.types.GetDatabaseRequest, dict]):
The request object. The request for
Expand Down Expand Up @@ -1160,6 +1373,25 @@ async def list_databases(
) -> firestore_admin.ListDatabasesResponse:
r"""List all the databases in the project.

.. code-block::

from google.cloud import firestore_admin_v1

def sample_list_databases():
# Create a client
client = firestore_admin_v1.FirestoreAdminClient()

# Initialize request argument(s)
request = firestore_admin_v1.ListDatabasesRequest(
parent="parent_value",
)

# Make the request
response = client.list_databases(request=request)

# Handle the response
print(response)

Args:
request (Union[google.cloud.firestore_admin_v1.types.ListDatabasesRequest, dict]):
The request object. A request to list the Firestore
Expand Down Expand Up @@ -1230,6 +1462,28 @@ async def update_database(
) -> operation_async.AsyncOperation:
r"""Updates a database.

.. code-block::

from google.cloud import firestore_admin_v1

def sample_update_database():
# Create a client
client = firestore_admin_v1.FirestoreAdminClient()

# Initialize request argument(s)
request = firestore_admin_v1.UpdateDatabaseRequest(
)

# Make the request
operation = client.update_database(request=request)

print("Waiting for operation to complete...")

response = operation.result()

# Handle the response
print(response)

Args:
request (Union[google.cloud.firestore_admin_v1.types.UpdateDatabaseRequest, dict]):
The request object. The request for
Expand Down
Loading