Skip to content

Commit

Permalink
Integrate Python GAPIC Microgenerator in googleapis.
Browse files Browse the repository at this point in the history
This PR uses using documentai as an example.
Depends on googleapis/gapic-generator-python#402

PiperOrigin-RevId: 309824146

Source-Author: Google APIs <noreply@google.com>
Source-Date: Mon May 4 15:06:44 2020 -0700
Source-Repo: googleapis/googleapis
Source-Sha: e0f9d9e1f9de890db765be46f45ca8490723e3eb
Source-Link: googleapis/googleapis@e0f9d9e
  • Loading branch information
yoshi-automation committed May 7, 2020
1 parent a0cbf40 commit 36e6fa1
Show file tree
Hide file tree
Showing 37 changed files with 2,851 additions and 3,094 deletions.
8 changes: 4 additions & 4 deletions google/cloud/firestore_admin_v1/gapic/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ class ChangeType(enum.IntEnum):
class Index(object):
class QueryScope(enum.IntEnum):
"""
Query Scope defines the scope at which a query is run. This is specified
on a StructuredQuery's ``from`` field.
Query Scope defines the scope at which a query is run. This is
specified on a StructuredQuery's ``from`` field.
Attributes:
QUERY_SCOPE_UNSPECIFIED (int): The query scope is unspecified. Not a valid option.
Expand All @@ -85,8 +85,8 @@ class QueryScope(enum.IntEnum):

class State(enum.IntEnum):
"""
The state of an index. During index creation, an index will be in the
``CREATING`` state. If the index is created successfully, it will
The state of an index. During index creation, an index will be in
the ``CREATING`` state. If the index is created successfully, it will
transition to the ``READY`` state. If the index creation encounters a
problem, the index will transition to the ``NEEDS_REPAIR`` state.
Expand Down
625 changes: 344 additions & 281 deletions google/cloud/firestore_admin_v1/gapic/firestore_admin_client.py

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"interfaces": {
"google.firestore.admin.v1.FirestoreAdmin": {
"retry_codes": {
"idempotent": ["DEADLINE_EXCEEDED", "INTERNAL", "UNAVAILABLE"],
"idempotent": ["DEADLINE_EXCEEDED", "UNAVAILABLE"],
"non_idempotent": [],
},
"retry_params": {
Expand All @@ -17,6 +17,16 @@
}
},
"methods": {
"DeleteIndex": {
"timeout_millis": 60000,
"retry_codes_name": "idempotent",
"retry_params_name": "default",
},
"UpdateField": {
"timeout_millis": 60000,
"retry_codes_name": "non_idempotent",
"retry_params_name": "default",
},
"CreateIndex": {
"timeout_millis": 60000,
"retry_codes_name": "non_idempotent",
Expand All @@ -32,32 +42,22 @@
"retry_codes_name": "idempotent",
"retry_params_name": "default",
},
"DeleteIndex": {
"GetField": {
"timeout_millis": 60000,
"retry_codes_name": "idempotent",
"retry_params_name": "default",
},
"ImportDocuments": {
"ListFields": {
"timeout_millis": 60000,
"retry_codes_name": "non_idempotent",
"retry_codes_name": "idempotent",
"retry_params_name": "default",
},
"ExportDocuments": {
"timeout_millis": 60000,
"retry_codes_name": "non_idempotent",
"retry_params_name": "default",
},
"GetField": {
"timeout_millis": 60000,
"retry_codes_name": "idempotent",
"retry_params_name": "default",
},
"ListFields": {
"timeout_millis": 60000,
"retry_codes_name": "idempotent",
"retry_params_name": "default",
},
"UpdateField": {
"ImportDocuments": {
"timeout_millis": 60000,
"retry_codes_name": "non_idempotent",
"retry_params_name": "default",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@


import google.api_core.grpc_helpers
import google.api_core.operations_v1

from google.cloud.firestore_admin_v1.proto import firestore_admin_pb2_grpc

Expand Down Expand Up @@ -78,6 +79,13 @@ def __init__(
"firestore_admin_stub": firestore_admin_pb2_grpc.FirestoreAdminStub(channel)
}

# Because this API includes a method that returns a
# long-running operation (proto: google.longrunning.Operation),
# instantiate an LRO client.
self._operations_client = google.api_core.operations_v1.OperationsClient(
channel
)

@classmethod
def create_channel(
cls, address="firestore.googleapis.com:443", credentials=None, **kwargs
Expand Down Expand Up @@ -111,96 +119,84 @@ def channel(self):
return self._channel

@property
def create_index(self):
"""Return the gRPC stub for :meth:`FirestoreAdminClient.create_index`.
def delete_index(self):
"""Return the gRPC stub for :meth:`FirestoreAdminClient.delete_index`.
Creates a composite index. This returns a
``google.longrunning.Operation`` which may be used to track the status
of the creation. The metadata for the operation will be the type
``IndexOperationMetadata``.
Deletes a composite index.
Returns:
Callable: A callable which accepts the appropriate
deserialized request object and returns a
deserialized response object.
"""
return self._stubs["firestore_admin_stub"].CreateIndex
return self._stubs["firestore_admin_stub"].DeleteIndex

@property
def list_indexes(self):
"""Return the gRPC stub for :meth:`FirestoreAdminClient.list_indexes`.
Lists composite indexes.
def update_field(self):
"""Return the gRPC stub for :meth:`FirestoreAdminClient.update_field`.
Returns:
Callable: A callable which accepts the appropriate
deserialized request object and returns a
deserialized response object.
"""
return self._stubs["firestore_admin_stub"].ListIndexes
Updates a field configuration. Currently, field updates apply only
to single field index configuration. However, calls to
``FirestoreAdmin.UpdateField`` should provide a field mask to avoid
changing any configuration that the caller isn't aware of. The field
mask should be specified as: ``{ paths: "index_config" }``.
@property
def get_index(self):
"""Return the gRPC stub for :meth:`FirestoreAdminClient.get_index`.
This call returns a ``google.longrunning.Operation`` which may be used
to track the status of the field update. The metadata for the operation
will be the type ``FieldOperationMetadata``.
Gets a composite index.
To configure the default field settings for the database, use the
special ``Field`` with resource name:
``projects/{project_id}/databases/{database_id}/collectionGroups/__default__/fields/*``.
Returns:
Callable: A callable which accepts the appropriate
deserialized request object and returns a
deserialized response object.
"""
return self._stubs["firestore_admin_stub"].GetIndex
return self._stubs["firestore_admin_stub"].UpdateField

@property
def delete_index(self):
"""Return the gRPC stub for :meth:`FirestoreAdminClient.delete_index`.
def create_index(self):
"""Return the gRPC stub for :meth:`FirestoreAdminClient.create_index`.
Deletes a composite index.
Creates a composite index. This returns a
``google.longrunning.Operation`` which may be used to track the status
of the creation. The metadata for the operation will be the type
``IndexOperationMetadata``.
Returns:
Callable: A callable which accepts the appropriate
deserialized request object and returns a
deserialized response object.
"""
return self._stubs["firestore_admin_stub"].DeleteIndex
return self._stubs["firestore_admin_stub"].CreateIndex

@property
def import_documents(self):
"""Return the gRPC stub for :meth:`FirestoreAdminClient.import_documents`.
def list_indexes(self):
"""Return the gRPC stub for :meth:`FirestoreAdminClient.list_indexes`.
Imports documents into Google Cloud Firestore. Existing documents with the
same name are overwritten. The import occurs in the background and its
progress can be monitored and managed via the Operation resource that is
created. If an ImportDocuments operation is cancelled, it is possible
that a subset of the data has already been imported to Cloud Firestore.
Lists composite indexes.
Returns:
Callable: A callable which accepts the appropriate
deserialized request object and returns a
deserialized response object.
"""
return self._stubs["firestore_admin_stub"].ImportDocuments
return self._stubs["firestore_admin_stub"].ListIndexes

@property
def export_documents(self):
"""Return the gRPC stub for :meth:`FirestoreAdminClient.export_documents`.
def get_index(self):
"""Return the gRPC stub for :meth:`FirestoreAdminClient.get_index`.
Exports a copy of all or a subset of documents from Google Cloud Firestore
to another storage system, such as Google Cloud Storage. Recent updates to
documents may not be reflected in the export. The export occurs in the
background and its progress can be monitored and managed via the
Operation resource that is created. The output of an export may only be
used once the associated operation is done. If an export operation is
cancelled before completion it may leave partial data behind in Google
Cloud Storage.
Gets a composite index.
Returns:
Callable: A callable which accepts the appropriate
deserialized request object and returns a
deserialized response object.
"""
return self._stubs["firestore_admin_stub"].ExportDocuments
return self._stubs["firestore_admin_stub"].GetIndex

@property
def get_field(self):
Expand Down Expand Up @@ -234,26 +230,38 @@ def list_fields(self):
return self._stubs["firestore_admin_stub"].ListFields

@property
def update_field(self):
"""Return the gRPC stub for :meth:`FirestoreAdminClient.update_field`.
def export_documents(self):
"""Return the gRPC stub for :meth:`FirestoreAdminClient.export_documents`.
Updates a field configuration. Currently, field updates apply only to
single field index configuration. However, calls to
``FirestoreAdmin.UpdateField`` should provide a field mask to avoid
changing any configuration that the caller isn't aware of. The field
mask should be specified as: ``{ paths: "index_config" }``.
Exports a copy of all or a subset of documents from Google Cloud Firestore
to another storage system, such as Google Cloud Storage. Recent updates to
documents may not be reflected in the export. The export occurs in the
background and its progress can be monitored and managed via the
Operation resource that is created. The output of an export may only be
used once the associated operation is done. If an export operation is
cancelled before completion it may leave partial data behind in Google
Cloud Storage.
This call returns a ``google.longrunning.Operation`` which may be used
to track the status of the field update. The metadata for the operation
will be the type ``FieldOperationMetadata``.
Returns:
Callable: A callable which accepts the appropriate
deserialized request object and returns a
deserialized response object.
"""
return self._stubs["firestore_admin_stub"].ExportDocuments

To configure the default field settings for the database, use the
special ``Field`` with resource name:
``projects/{project_id}/databases/{database_id}/collectionGroups/__default__/fields/*``.
@property
def import_documents(self):
"""Return the gRPC stub for :meth:`FirestoreAdminClient.import_documents`.
Imports documents into Google Cloud Firestore. Existing documents with the
same name are overwritten. The import occurs in the background and its
progress can be monitored and managed via the Operation resource that is
created. If an ImportDocuments operation is cancelled, it is possible
that a subset of the data has already been imported to Cloud Firestore.
Returns:
Callable: A callable which accepts the appropriate
deserialized request object and returns a
deserialized response object.
"""
return self._stubs["firestore_admin_stub"].UpdateField
return self._stubs["firestore_admin_stub"].ImportDocuments
Loading

0 comments on commit 36e6fa1

Please sign in to comment.