diff --git a/packages/google-area120-tables/google/area120/tables_v1alpha1/gapic_metadata.json b/packages/google-area120-tables/google/area120/tables_v1alpha1/gapic_metadata.json index 287c7aaa7e24..c59c4471f838 100644 --- a/packages/google-area120-tables/google/area120/tables_v1alpha1/gapic_metadata.json +++ b/packages/google-area120-tables/google/area120/tables_v1alpha1/gapic_metadata.json @@ -136,6 +136,71 @@ ] } } + }, + "rest": { + "libraryClient": "TablesServiceClient", + "rpcs": { + "BatchCreateRows": { + "methods": [ + "batch_create_rows" + ] + }, + "BatchDeleteRows": { + "methods": [ + "batch_delete_rows" + ] + }, + "BatchUpdateRows": { + "methods": [ + "batch_update_rows" + ] + }, + "CreateRow": { + "methods": [ + "create_row" + ] + }, + "DeleteRow": { + "methods": [ + "delete_row" + ] + }, + "GetRow": { + "methods": [ + "get_row" + ] + }, + "GetTable": { + "methods": [ + "get_table" + ] + }, + "GetWorkspace": { + "methods": [ + "get_workspace" + ] + }, + "ListRows": { + "methods": [ + "list_rows" + ] + }, + "ListTables": { + "methods": [ + "list_tables" + ] + }, + "ListWorkspaces": { + "methods": [ + "list_workspaces" + ] + }, + "UpdateRow": { + "methods": [ + "update_row" + ] + } + } } } } diff --git a/packages/google-area120-tables/google/area120/tables_v1alpha1/services/tables_service/client.py b/packages/google-area120-tables/google/area120/tables_v1alpha1/services/tables_service/client.py index 9d82e48199f9..a4467bee14d3 100644 --- a/packages/google-area120-tables/google/area120/tables_v1alpha1/services/tables_service/client.py +++ b/packages/google-area120-tables/google/area120/tables_v1alpha1/services/tables_service/client.py @@ -42,6 +42,7 @@ from .transports.base import DEFAULT_CLIENT_INFO, TablesServiceTransport from .transports.grpc import TablesServiceGrpcTransport from .transports.grpc_asyncio import TablesServiceGrpcAsyncIOTransport +from .transports.rest import TablesServiceRestTransport class TablesServiceClientMeta(type): @@ -55,6 +56,7 @@ class TablesServiceClientMeta(type): _transport_registry = OrderedDict() # type: Dict[str, Type[TablesServiceTransport]] _transport_registry["grpc"] = TablesServiceGrpcTransport _transport_registry["grpc_asyncio"] = TablesServiceGrpcAsyncIOTransport + _transport_registry["rest"] = TablesServiceRestTransport def get_transport_class( cls, @@ -387,6 +389,9 @@ def __init__( transport (Union[str, TablesServiceTransport]): The transport to use. If set to None, a transport is chosen automatically. + NOTE: "rest" transport functionality is currently in a + beta state (preview). We welcome your feedback via an + issue in this library's source repository. client_options (google.api_core.client_options.ClientOptions): Custom options for the client. It won't take effect if a ``transport`` instance is provided. (1) The ``api_endpoint`` property can be used to override the diff --git a/packages/google-area120-tables/google/area120/tables_v1alpha1/services/tables_service/transports/__init__.py b/packages/google-area120-tables/google/area120/tables_v1alpha1/services/tables_service/transports/__init__.py index 966b2054ed65..2dd46fb49416 100644 --- a/packages/google-area120-tables/google/area120/tables_v1alpha1/services/tables_service/transports/__init__.py +++ b/packages/google-area120-tables/google/area120/tables_v1alpha1/services/tables_service/transports/__init__.py @@ -19,14 +19,18 @@ from .base import TablesServiceTransport from .grpc import TablesServiceGrpcTransport from .grpc_asyncio import TablesServiceGrpcAsyncIOTransport +from .rest import TablesServiceRestInterceptor, TablesServiceRestTransport # Compile a registry of transports. _transport_registry = OrderedDict() # type: Dict[str, Type[TablesServiceTransport]] _transport_registry["grpc"] = TablesServiceGrpcTransport _transport_registry["grpc_asyncio"] = TablesServiceGrpcAsyncIOTransport +_transport_registry["rest"] = TablesServiceRestTransport __all__ = ( "TablesServiceTransport", "TablesServiceGrpcTransport", "TablesServiceGrpcAsyncIOTransport", + "TablesServiceRestTransport", + "TablesServiceRestInterceptor", ) diff --git a/packages/google-area120-tables/google/area120/tables_v1alpha1/services/tables_service/transports/rest.py b/packages/google-area120-tables/google/area120/tables_v1alpha1/services/tables_service/transports/rest.py new file mode 100644 index 000000000000..65e4ce8777c4 --- /dev/null +++ b/packages/google-area120-tables/google/area120/tables_v1alpha1/services/tables_service/transports/rest.py @@ -0,0 +1,1632 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 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. +# + +import dataclasses +import json # type: ignore +import re +from typing import Callable, Dict, List, Optional, Sequence, Tuple, Union +import warnings + +from google.api_core import gapic_v1, path_template, rest_helpers, rest_streaming +from google.api_core import exceptions as core_exceptions +from google.api_core import retry as retries +from google.auth import credentials as ga_credentials # type: ignore +from google.auth.transport.grpc import SslCredentials # type: ignore +from google.auth.transport.requests import AuthorizedSession # type: ignore +from google.protobuf import json_format +import grpc # type: ignore +from requests import __version__ as requests_version + +try: + OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault] +except AttributeError: # pragma: NO COVER + OptionalRetry = Union[retries.Retry, object] # type: ignore + + +from google.protobuf import empty_pb2 # type: ignore + +from google.area120.tables_v1alpha1.types import tables + +from .base import DEFAULT_CLIENT_INFO as BASE_DEFAULT_CLIENT_INFO +from .base import TablesServiceTransport + +DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( + gapic_version=BASE_DEFAULT_CLIENT_INFO.gapic_version, + grpc_version=None, + rest_version=requests_version, +) + + +class TablesServiceRestInterceptor: + """Interceptor for TablesService. + + Interceptors are used to manipulate requests, request metadata, and responses + in arbitrary ways. + Example use cases include: + * Logging + * Verifying requests according to service or custom semantics + * Stripping extraneous information from responses + + These use cases and more can be enabled by injecting an + instance of a custom subclass when constructing the TablesServiceRestTransport. + + .. code-block:: python + class MyCustomTablesServiceInterceptor(TablesServiceRestInterceptor): + def pre_batch_create_rows(request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_batch_create_rows(response): + logging.log(f"Received response: {response}") + + def pre_batch_delete_rows(request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def pre_batch_update_rows(request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_batch_update_rows(response): + logging.log(f"Received response: {response}") + + def pre_create_row(request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_create_row(response): + logging.log(f"Received response: {response}") + + def pre_delete_row(request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def pre_get_row(request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_get_row(response): + logging.log(f"Received response: {response}") + + def pre_get_table(request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_get_table(response): + logging.log(f"Received response: {response}") + + def pre_get_workspace(request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_get_workspace(response): + logging.log(f"Received response: {response}") + + def pre_list_rows(request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_list_rows(response): + logging.log(f"Received response: {response}") + + def pre_list_tables(request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_list_tables(response): + logging.log(f"Received response: {response}") + + def pre_list_workspaces(request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_list_workspaces(response): + logging.log(f"Received response: {response}") + + def pre_update_row(request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_update_row(response): + logging.log(f"Received response: {response}") + + transport = TablesServiceRestTransport(interceptor=MyCustomTablesServiceInterceptor()) + client = TablesServiceClient(transport=transport) + + + """ + + def pre_batch_create_rows( + self, + request: tables.BatchCreateRowsRequest, + metadata: Sequence[Tuple[str, str]], + ) -> Tuple[tables.BatchCreateRowsRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for batch_create_rows + + Override in a subclass to manipulate the request or metadata + before they are sent to the TablesService server. + """ + return request, metadata + + def post_batch_create_rows( + self, response: tables.BatchCreateRowsResponse + ) -> tables.BatchCreateRowsResponse: + """Post-rpc interceptor for batch_create_rows + + Override in a subclass to manipulate the response + after it is returned by the TablesService server but before + it is returned to user code. + """ + return response + + def pre_batch_delete_rows( + self, + request: tables.BatchDeleteRowsRequest, + metadata: Sequence[Tuple[str, str]], + ) -> Tuple[tables.BatchDeleteRowsRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for batch_delete_rows + + Override in a subclass to manipulate the request or metadata + before they are sent to the TablesService server. + """ + return request, metadata + + def pre_batch_update_rows( + self, + request: tables.BatchUpdateRowsRequest, + metadata: Sequence[Tuple[str, str]], + ) -> Tuple[tables.BatchUpdateRowsRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for batch_update_rows + + Override in a subclass to manipulate the request or metadata + before they are sent to the TablesService server. + """ + return request, metadata + + def post_batch_update_rows( + self, response: tables.BatchUpdateRowsResponse + ) -> tables.BatchUpdateRowsResponse: + """Post-rpc interceptor for batch_update_rows + + Override in a subclass to manipulate the response + after it is returned by the TablesService server but before + it is returned to user code. + """ + return response + + def pre_create_row( + self, request: tables.CreateRowRequest, metadata: Sequence[Tuple[str, str]] + ) -> Tuple[tables.CreateRowRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for create_row + + Override in a subclass to manipulate the request or metadata + before they are sent to the TablesService server. + """ + return request, metadata + + def post_create_row(self, response: tables.Row) -> tables.Row: + """Post-rpc interceptor for create_row + + Override in a subclass to manipulate the response + after it is returned by the TablesService server but before + it is returned to user code. + """ + return response + + def pre_delete_row( + self, request: tables.DeleteRowRequest, metadata: Sequence[Tuple[str, str]] + ) -> Tuple[tables.DeleteRowRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for delete_row + + Override in a subclass to manipulate the request or metadata + before they are sent to the TablesService server. + """ + return request, metadata + + def pre_get_row( + self, request: tables.GetRowRequest, metadata: Sequence[Tuple[str, str]] + ) -> Tuple[tables.GetRowRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for get_row + + Override in a subclass to manipulate the request or metadata + before they are sent to the TablesService server. + """ + return request, metadata + + def post_get_row(self, response: tables.Row) -> tables.Row: + """Post-rpc interceptor for get_row + + Override in a subclass to manipulate the response + after it is returned by the TablesService server but before + it is returned to user code. + """ + return response + + def pre_get_table( + self, request: tables.GetTableRequest, metadata: Sequence[Tuple[str, str]] + ) -> Tuple[tables.GetTableRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for get_table + + Override in a subclass to manipulate the request or metadata + before they are sent to the TablesService server. + """ + return request, metadata + + def post_get_table(self, response: tables.Table) -> tables.Table: + """Post-rpc interceptor for get_table + + Override in a subclass to manipulate the response + after it is returned by the TablesService server but before + it is returned to user code. + """ + return response + + def pre_get_workspace( + self, request: tables.GetWorkspaceRequest, metadata: Sequence[Tuple[str, str]] + ) -> Tuple[tables.GetWorkspaceRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for get_workspace + + Override in a subclass to manipulate the request or metadata + before they are sent to the TablesService server. + """ + return request, metadata + + def post_get_workspace(self, response: tables.Workspace) -> tables.Workspace: + """Post-rpc interceptor for get_workspace + + Override in a subclass to manipulate the response + after it is returned by the TablesService server but before + it is returned to user code. + """ + return response + + def pre_list_rows( + self, request: tables.ListRowsRequest, metadata: Sequence[Tuple[str, str]] + ) -> Tuple[tables.ListRowsRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for list_rows + + Override in a subclass to manipulate the request or metadata + before they are sent to the TablesService server. + """ + return request, metadata + + def post_list_rows( + self, response: tables.ListRowsResponse + ) -> tables.ListRowsResponse: + """Post-rpc interceptor for list_rows + + Override in a subclass to manipulate the response + after it is returned by the TablesService server but before + it is returned to user code. + """ + return response + + def pre_list_tables( + self, request: tables.ListTablesRequest, metadata: Sequence[Tuple[str, str]] + ) -> Tuple[tables.ListTablesRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for list_tables + + Override in a subclass to manipulate the request or metadata + before they are sent to the TablesService server. + """ + return request, metadata + + def post_list_tables( + self, response: tables.ListTablesResponse + ) -> tables.ListTablesResponse: + """Post-rpc interceptor for list_tables + + Override in a subclass to manipulate the response + after it is returned by the TablesService server but before + it is returned to user code. + """ + return response + + def pre_list_workspaces( + self, request: tables.ListWorkspacesRequest, metadata: Sequence[Tuple[str, str]] + ) -> Tuple[tables.ListWorkspacesRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for list_workspaces + + Override in a subclass to manipulate the request or metadata + before they are sent to the TablesService server. + """ + return request, metadata + + def post_list_workspaces( + self, response: tables.ListWorkspacesResponse + ) -> tables.ListWorkspacesResponse: + """Post-rpc interceptor for list_workspaces + + Override in a subclass to manipulate the response + after it is returned by the TablesService server but before + it is returned to user code. + """ + return response + + def pre_update_row( + self, request: tables.UpdateRowRequest, metadata: Sequence[Tuple[str, str]] + ) -> Tuple[tables.UpdateRowRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for update_row + + Override in a subclass to manipulate the request or metadata + before they are sent to the TablesService server. + """ + return request, metadata + + def post_update_row(self, response: tables.Row) -> tables.Row: + """Post-rpc interceptor for update_row + + Override in a subclass to manipulate the response + after it is returned by the TablesService server but before + it is returned to user code. + """ + return response + + +@dataclasses.dataclass +class TablesServiceRestStub: + _session: AuthorizedSession + _host: str + _interceptor: TablesServiceRestInterceptor + + +class TablesServiceRestTransport(TablesServiceTransport): + """REST backend transport for TablesService. + + The Tables Service provides an API for reading and updating tables. + It defines the following resource model: + + - The API has a collection of + [Table][google.area120.tables.v1alpha1.Table] resources, named + ``tables/*`` + + - Each Table has a collection of + [Row][google.area120.tables.v1alpha1.Row] resources, named + ``tables/*/rows/*`` + + - The API has a collection of + [Workspace][google.area120.tables.v1alpha1.Workspace] resources, + named ``workspaces/*``. + + This class defines the same methods as the primary client, so the + primary client can load the underlying transport implementation + and call it. + + It sends JSON representations of protocol buffers over HTTP/1.1 + + NOTE: This REST transport functionality is currently in a beta + state (preview). We welcome your feedback via an issue in this + library's source repository. Thank you! + """ + + def __init__( + self, + *, + host: str = "area120tables.googleapis.com", + credentials: ga_credentials.Credentials = None, + credentials_file: str = None, + scopes: Sequence[str] = None, + client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None, + quota_project_id: Optional[str] = None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + always_use_jwt_access: Optional[bool] = False, + url_scheme: str = "https", + interceptor: Optional[TablesServiceRestInterceptor] = None, + api_audience: Optional[str] = None, + ) -> None: + """Instantiate the transport. + + NOTE: This REST transport functionality is currently in a beta + state (preview). We welcome your feedback via a GitHub issue in + this library's repository. Thank you! + + Args: + host (Optional[str]): + The hostname to connect to. + credentials (Optional[google.auth.credentials.Credentials]): The + authorization credentials to attach to requests. These + credentials identify the application to the service; if none + are specified, the client will attempt to ascertain the + credentials from the environment. + + credentials_file (Optional[str]): A file with credentials that can + be loaded with :func:`google.auth.load_credentials_from_file`. + This argument is ignored if ``channel`` is provided. + scopes (Optional(Sequence[str])): A list of scopes. This argument is + ignored if ``channel`` is provided. + client_cert_source_for_mtls (Callable[[], Tuple[bytes, bytes]]): Client + certificate to configure mutual TLS HTTP channel. It is ignored + if ``channel`` is provided. + quota_project_id (Optional[str]): An optional project to use for billing + and quota. + client_info (google.api_core.gapic_v1.client_info.ClientInfo): + The client info used to send a user-agent string along with + API requests. If ``None``, then default info will be used. + Generally, you only need to set this if you are developing + your own client library. + always_use_jwt_access (Optional[bool]): Whether self signed JWT should + be used for service account credentials. + url_scheme: the protocol scheme for the API endpoint. Normally + "https", but for testing or local servers, + "http" can be specified. + """ + # Run the base constructor + # TODO(yon-mg): resolve other ctor params i.e. scopes, quota, etc. + # TODO: When custom host (api_endpoint) is set, `scopes` must *also* be set on the + # credentials object + maybe_url_match = re.match("^(?Phttp(?:s)?://)?(?P.*)$", host) + if maybe_url_match is None: + raise ValueError( + f"Unexpected hostname structure: {host}" + ) # pragma: NO COVER + + url_match_items = maybe_url_match.groupdict() + + host = f"{url_scheme}://{host}" if not url_match_items["scheme"] else host + + super().__init__( + host=host, + credentials=credentials, + client_info=client_info, + always_use_jwt_access=always_use_jwt_access, + api_audience=api_audience, + ) + self._session = AuthorizedSession( + self._credentials, default_host=self.DEFAULT_HOST + ) + if client_cert_source_for_mtls: + self._session.configure_mtls_channel(client_cert_source_for_mtls) + self._interceptor = interceptor or TablesServiceRestInterceptor() + self._prep_wrapped_messages(client_info) + + class _BatchCreateRows(TablesServiceRestStub): + def __hash__(self): + return hash("BatchCreateRows") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, str] = {} + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + def __call__( + self, + request: tables.BatchCreateRowsRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> tables.BatchCreateRowsResponse: + r"""Call the batch create rows method over HTTP. + + Args: + request (~.tables.BatchCreateRowsRequest): + The request object. Request message for + TablesService.BatchCreateRows. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + ~.tables.BatchCreateRowsResponse: + Response message for + TablesService.BatchCreateRows. + + """ + + http_options: List[Dict[str, str]] = [ + { + "method": "post", + "uri": "/v1alpha1/{parent=tables/*}/rows:batchCreate", + "body": "*", + }, + ] + request, metadata = self._interceptor.pre_batch_create_rows( + request, metadata + ) + pb_request = tables.BatchCreateRowsRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + + # Jsonify the request body + + body = json_format.MessageToJson( + transcoded_request["body"], + including_default_value_fields=False, + use_integers_for_enums=False, + ) + uri = transcoded_request["uri"] + method = transcoded_request["method"] + + # Jsonify the query params + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + including_default_value_fields=False, + use_integers_for_enums=False, + ) + ) + query_params.update(self._get_unset_required_fields(query_params)) + + # Send the request + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(self._session, method)( + "{host}{uri}".format(host=self._host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = tables.BatchCreateRowsResponse() + pb_resp = tables.BatchCreateRowsResponse.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_batch_create_rows(resp) + return resp + + class _BatchDeleteRows(TablesServiceRestStub): + def __hash__(self): + return hash("BatchDeleteRows") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, str] = {} + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + def __call__( + self, + request: tables.BatchDeleteRowsRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ): + r"""Call the batch delete rows method over HTTP. + + Args: + request (~.tables.BatchDeleteRowsRequest): + The request object. Request message for + TablesService.BatchDeleteRows + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + + http_options: List[Dict[str, str]] = [ + { + "method": "post", + "uri": "/v1alpha1/{parent=tables/*}/rows:batchDelete", + "body": "*", + }, + ] + request, metadata = self._interceptor.pre_batch_delete_rows( + request, metadata + ) + pb_request = tables.BatchDeleteRowsRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + + # Jsonify the request body + + body = json_format.MessageToJson( + transcoded_request["body"], + including_default_value_fields=False, + use_integers_for_enums=False, + ) + uri = transcoded_request["uri"] + method = transcoded_request["method"] + + # Jsonify the query params + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + including_default_value_fields=False, + use_integers_for_enums=False, + ) + ) + query_params.update(self._get_unset_required_fields(query_params)) + + # Send the request + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(self._session, method)( + "{host}{uri}".format(host=self._host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + class _BatchUpdateRows(TablesServiceRestStub): + def __hash__(self): + return hash("BatchUpdateRows") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, str] = {} + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + def __call__( + self, + request: tables.BatchUpdateRowsRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> tables.BatchUpdateRowsResponse: + r"""Call the batch update rows method over HTTP. + + Args: + request (~.tables.BatchUpdateRowsRequest): + The request object. Request message for + TablesService.BatchUpdateRows. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + ~.tables.BatchUpdateRowsResponse: + Response message for + TablesService.BatchUpdateRows. + + """ + + http_options: List[Dict[str, str]] = [ + { + "method": "post", + "uri": "/v1alpha1/{parent=tables/*}/rows:batchUpdate", + "body": "*", + }, + ] + request, metadata = self._interceptor.pre_batch_update_rows( + request, metadata + ) + pb_request = tables.BatchUpdateRowsRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + + # Jsonify the request body + + body = json_format.MessageToJson( + transcoded_request["body"], + including_default_value_fields=False, + use_integers_for_enums=False, + ) + uri = transcoded_request["uri"] + method = transcoded_request["method"] + + # Jsonify the query params + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + including_default_value_fields=False, + use_integers_for_enums=False, + ) + ) + query_params.update(self._get_unset_required_fields(query_params)) + + # Send the request + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(self._session, method)( + "{host}{uri}".format(host=self._host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = tables.BatchUpdateRowsResponse() + pb_resp = tables.BatchUpdateRowsResponse.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_batch_update_rows(resp) + return resp + + class _CreateRow(TablesServiceRestStub): + def __hash__(self): + return hash("CreateRow") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, str] = {} + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + def __call__( + self, + request: tables.CreateRowRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> tables.Row: + r"""Call the create row method over HTTP. + + Args: + request (~.tables.CreateRowRequest): + The request object. Request message for + TablesService.CreateRow. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + ~.tables.Row: + A single row in a table. + """ + + http_options: List[Dict[str, str]] = [ + { + "method": "post", + "uri": "/v1alpha1/{parent=tables/*}/rows", + "body": "row", + }, + ] + request, metadata = self._interceptor.pre_create_row(request, metadata) + pb_request = tables.CreateRowRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + + # Jsonify the request body + + body = json_format.MessageToJson( + transcoded_request["body"], + including_default_value_fields=False, + use_integers_for_enums=False, + ) + uri = transcoded_request["uri"] + method = transcoded_request["method"] + + # Jsonify the query params + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + including_default_value_fields=False, + use_integers_for_enums=False, + ) + ) + query_params.update(self._get_unset_required_fields(query_params)) + + # Send the request + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(self._session, method)( + "{host}{uri}".format(host=self._host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = tables.Row() + pb_resp = tables.Row.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_row(resp) + return resp + + class _DeleteRow(TablesServiceRestStub): + def __hash__(self): + return hash("DeleteRow") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, str] = {} + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + def __call__( + self, + request: tables.DeleteRowRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ): + r"""Call the delete row method over HTTP. + + Args: + request (~.tables.DeleteRowRequest): + The request object. Request message for + TablesService.DeleteRow + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + + http_options: List[Dict[str, str]] = [ + { + "method": "delete", + "uri": "/v1alpha1/{name=tables/*/rows/*}", + }, + ] + request, metadata = self._interceptor.pre_delete_row(request, metadata) + pb_request = tables.DeleteRowRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + + uri = transcoded_request["uri"] + method = transcoded_request["method"] + + # Jsonify the query params + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + including_default_value_fields=False, + use_integers_for_enums=False, + ) + ) + query_params.update(self._get_unset_required_fields(query_params)) + + # Send the request + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(self._session, method)( + "{host}{uri}".format(host=self._host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + class _GetRow(TablesServiceRestStub): + def __hash__(self): + return hash("GetRow") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, str] = {} + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + def __call__( + self, + request: tables.GetRowRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> tables.Row: + r"""Call the get row method over HTTP. + + Args: + request (~.tables.GetRowRequest): + The request object. Request message for + TablesService.GetRow. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + ~.tables.Row: + A single row in a table. + """ + + http_options: List[Dict[str, str]] = [ + { + "method": "get", + "uri": "/v1alpha1/{name=tables/*/rows/*}", + }, + ] + request, metadata = self._interceptor.pre_get_row(request, metadata) + pb_request = tables.GetRowRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + + uri = transcoded_request["uri"] + method = transcoded_request["method"] + + # Jsonify the query params + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + including_default_value_fields=False, + use_integers_for_enums=False, + ) + ) + query_params.update(self._get_unset_required_fields(query_params)) + + # Send the request + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(self._session, method)( + "{host}{uri}".format(host=self._host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = tables.Row() + pb_resp = tables.Row.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_row(resp) + return resp + + class _GetTable(TablesServiceRestStub): + def __hash__(self): + return hash("GetTable") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, str] = {} + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + def __call__( + self, + request: tables.GetTableRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> tables.Table: + r"""Call the get table method over HTTP. + + Args: + request (~.tables.GetTableRequest): + The request object. Request message for + TablesService.GetTable. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + ~.tables.Table: + A single table. + """ + + http_options: List[Dict[str, str]] = [ + { + "method": "get", + "uri": "/v1alpha1/{name=tables/*}", + }, + ] + request, metadata = self._interceptor.pre_get_table(request, metadata) + pb_request = tables.GetTableRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + + uri = transcoded_request["uri"] + method = transcoded_request["method"] + + # Jsonify the query params + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + including_default_value_fields=False, + use_integers_for_enums=False, + ) + ) + query_params.update(self._get_unset_required_fields(query_params)) + + # Send the request + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(self._session, method)( + "{host}{uri}".format(host=self._host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = tables.Table() + pb_resp = tables.Table.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_table(resp) + return resp + + class _GetWorkspace(TablesServiceRestStub): + def __hash__(self): + return hash("GetWorkspace") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, str] = {} + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + def __call__( + self, + request: tables.GetWorkspaceRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> tables.Workspace: + r"""Call the get workspace method over HTTP. + + Args: + request (~.tables.GetWorkspaceRequest): + The request object. Request message for + TablesService.GetWorkspace. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + ~.tables.Workspace: + A single workspace. + """ + + http_options: List[Dict[str, str]] = [ + { + "method": "get", + "uri": "/v1alpha1/{name=workspaces/*}", + }, + ] + request, metadata = self._interceptor.pre_get_workspace(request, metadata) + pb_request = tables.GetWorkspaceRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + + uri = transcoded_request["uri"] + method = transcoded_request["method"] + + # Jsonify the query params + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + including_default_value_fields=False, + use_integers_for_enums=False, + ) + ) + query_params.update(self._get_unset_required_fields(query_params)) + + # Send the request + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(self._session, method)( + "{host}{uri}".format(host=self._host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = tables.Workspace() + pb_resp = tables.Workspace.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_workspace(resp) + return resp + + class _ListRows(TablesServiceRestStub): + def __hash__(self): + return hash("ListRows") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, str] = {} + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + def __call__( + self, + request: tables.ListRowsRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> tables.ListRowsResponse: + r"""Call the list rows method over HTTP. + + Args: + request (~.tables.ListRowsRequest): + The request object. Request message for + TablesService.ListRows. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + ~.tables.ListRowsResponse: + Response message for + TablesService.ListRows. + + """ + + http_options: List[Dict[str, str]] = [ + { + "method": "get", + "uri": "/v1alpha1/{parent=tables/*}/rows", + }, + ] + request, metadata = self._interceptor.pre_list_rows(request, metadata) + pb_request = tables.ListRowsRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + + uri = transcoded_request["uri"] + method = transcoded_request["method"] + + # Jsonify the query params + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + including_default_value_fields=False, + use_integers_for_enums=False, + ) + ) + query_params.update(self._get_unset_required_fields(query_params)) + + # Send the request + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(self._session, method)( + "{host}{uri}".format(host=self._host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = tables.ListRowsResponse() + pb_resp = tables.ListRowsResponse.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_rows(resp) + return resp + + class _ListTables(TablesServiceRestStub): + def __hash__(self): + return hash("ListTables") + + def __call__( + self, + request: tables.ListTablesRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> tables.ListTablesResponse: + r"""Call the list tables method over HTTP. + + Args: + request (~.tables.ListTablesRequest): + The request object. Request message for + TablesService.ListTables. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + ~.tables.ListTablesResponse: + Response message for + TablesService.ListTables. + + """ + + http_options: List[Dict[str, str]] = [ + { + "method": "get", + "uri": "/v1alpha1/tables", + }, + ] + request, metadata = self._interceptor.pre_list_tables(request, metadata) + pb_request = tables.ListTablesRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + + uri = transcoded_request["uri"] + method = transcoded_request["method"] + + # Jsonify the query params + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + including_default_value_fields=False, + use_integers_for_enums=False, + ) + ) + + # Send the request + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(self._session, method)( + "{host}{uri}".format(host=self._host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = tables.ListTablesResponse() + pb_resp = tables.ListTablesResponse.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_tables(resp) + return resp + + class _ListWorkspaces(TablesServiceRestStub): + def __hash__(self): + return hash("ListWorkspaces") + + def __call__( + self, + request: tables.ListWorkspacesRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> tables.ListWorkspacesResponse: + r"""Call the list workspaces method over HTTP. + + Args: + request (~.tables.ListWorkspacesRequest): + The request object. Request message for + TablesService.ListWorkspaces. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + ~.tables.ListWorkspacesResponse: + Response message for + TablesService.ListWorkspaces. + + """ + + http_options: List[Dict[str, str]] = [ + { + "method": "get", + "uri": "/v1alpha1/workspaces", + }, + ] + request, metadata = self._interceptor.pre_list_workspaces(request, metadata) + pb_request = tables.ListWorkspacesRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + + uri = transcoded_request["uri"] + method = transcoded_request["method"] + + # Jsonify the query params + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + including_default_value_fields=False, + use_integers_for_enums=False, + ) + ) + + # Send the request + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(self._session, method)( + "{host}{uri}".format(host=self._host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = tables.ListWorkspacesResponse() + pb_resp = tables.ListWorkspacesResponse.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_workspaces(resp) + return resp + + class _UpdateRow(TablesServiceRestStub): + def __hash__(self): + return hash("UpdateRow") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, str] = {} + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } + + def __call__( + self, + request: tables.UpdateRowRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> tables.Row: + r"""Call the update row method over HTTP. + + Args: + request (~.tables.UpdateRowRequest): + The request object. Request message for + TablesService.UpdateRow. + + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + + Returns: + ~.tables.Row: + A single row in a table. + """ + + http_options: List[Dict[str, str]] = [ + { + "method": "patch", + "uri": "/v1alpha1/{row.name=tables/*/rows/*}", + "body": "row", + }, + ] + request, metadata = self._interceptor.pre_update_row(request, metadata) + pb_request = tables.UpdateRowRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + + # Jsonify the request body + + body = json_format.MessageToJson( + transcoded_request["body"], + including_default_value_fields=False, + use_integers_for_enums=False, + ) + uri = transcoded_request["uri"] + method = transcoded_request["method"] + + # Jsonify the query params + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + including_default_value_fields=False, + use_integers_for_enums=False, + ) + ) + query_params.update(self._get_unset_required_fields(query_params)) + + # Send the request + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(self._session, method)( + "{host}{uri}".format(host=self._host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = tables.Row() + pb_resp = tables.Row.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_row(resp) + return resp + + @property + def batch_create_rows( + self, + ) -> Callable[[tables.BatchCreateRowsRequest], tables.BatchCreateRowsResponse]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._BatchCreateRows(self._session, self._host, self._interceptor) # type: ignore + + @property + def batch_delete_rows( + self, + ) -> Callable[[tables.BatchDeleteRowsRequest], empty_pb2.Empty]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._BatchDeleteRows(self._session, self._host, self._interceptor) # type: ignore + + @property + def batch_update_rows( + self, + ) -> Callable[[tables.BatchUpdateRowsRequest], tables.BatchUpdateRowsResponse]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._BatchUpdateRows(self._session, self._host, self._interceptor) # type: ignore + + @property + def create_row(self) -> Callable[[tables.CreateRowRequest], tables.Row]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._CreateRow(self._session, self._host, self._interceptor) # type: ignore + + @property + def delete_row(self) -> Callable[[tables.DeleteRowRequest], empty_pb2.Empty]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._DeleteRow(self._session, self._host, self._interceptor) # type: ignore + + @property + def get_row(self) -> Callable[[tables.GetRowRequest], tables.Row]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._GetRow(self._session, self._host, self._interceptor) # type: ignore + + @property + def get_table(self) -> Callable[[tables.GetTableRequest], tables.Table]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._GetTable(self._session, self._host, self._interceptor) # type: ignore + + @property + def get_workspace(self) -> Callable[[tables.GetWorkspaceRequest], tables.Workspace]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._GetWorkspace(self._session, self._host, self._interceptor) # type: ignore + + @property + def list_rows(self) -> Callable[[tables.ListRowsRequest], tables.ListRowsResponse]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._ListRows(self._session, self._host, self._interceptor) # type: ignore + + @property + def list_tables( + self, + ) -> Callable[[tables.ListTablesRequest], tables.ListTablesResponse]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._ListTables(self._session, self._host, self._interceptor) # type: ignore + + @property + def list_workspaces( + self, + ) -> Callable[[tables.ListWorkspacesRequest], tables.ListWorkspacesResponse]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._ListWorkspaces(self._session, self._host, self._interceptor) # type: ignore + + @property + def update_row(self) -> Callable[[tables.UpdateRowRequest], tables.Row]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._UpdateRow(self._session, self._host, self._interceptor) # type: ignore + + @property + def kind(self) -> str: + return "rest" + + def close(self): + self._session.close() + + +__all__ = ("TablesServiceRestTransport",) diff --git a/packages/google-area120-tables/samples/generated_samples/area120tables_v1alpha1_generated_tables_service_batch_create_rows_sync.py b/packages/google-area120-tables/samples/generated_samples/area120tables_v1alpha1_generated_tables_service_batch_create_rows_sync_39533718.py similarity index 97% rename from packages/google-area120-tables/samples/generated_samples/area120tables_v1alpha1_generated_tables_service_batch_create_rows_sync.py rename to packages/google-area120-tables/samples/generated_samples/area120tables_v1alpha1_generated_tables_service_batch_create_rows_sync_39533718.py index 3bc0ae3dad8c..758c3a39b8c4 100644 --- a/packages/google-area120-tables/samples/generated_samples/area120tables_v1alpha1_generated_tables_service_batch_create_rows_sync.py +++ b/packages/google-area120-tables/samples/generated_samples/area120tables_v1alpha1_generated_tables_service_batch_create_rows_sync_39533718.py @@ -23,7 +23,7 @@ # python3 -m pip install google-area120-tables -# [START area120tables_v1alpha1_generated_TablesService_BatchCreateRows_sync] +# [START area120tables_v1alpha1_generated_TablesService_BatchCreateRows_sync_39533718] # This snippet has been automatically generated and should be regarded as a # code template only. # It will require modifications to work: @@ -53,4 +53,4 @@ def sample_batch_create_rows(): # Handle the response print(response) -# [END area120tables_v1alpha1_generated_TablesService_BatchCreateRows_sync] +# [END area120tables_v1alpha1_generated_TablesService_BatchCreateRows_sync_39533718] diff --git a/packages/google-area120-tables/samples/generated_samples/area120tables_v1alpha1_generated_tables_service_batch_create_rows_sync_f62d407e.py b/packages/google-area120-tables/samples/generated_samples/area120tables_v1alpha1_generated_tables_service_batch_create_rows_sync_f62d407e.py new file mode 100644 index 000000000000..163ea05976cf --- /dev/null +++ b/packages/google-area120-tables/samples/generated_samples/area120tables_v1alpha1_generated_tables_service_batch_create_rows_sync_f62d407e.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for BatchCreateRows +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-area120-tables + + +# [START area120tables_v1alpha1_generated_TablesService_BatchCreateRows_sync_f62d407e] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.area120 import tables_v1alpha1 + + +def sample_batch_create_rows(): + # Create a client + client = tables_v1alpha1.TablesServiceClient() + + # Initialize request argument(s) + requests = tables_v1alpha1.CreateRowRequest() + requests.parent = "parent_value" + + request = tables_v1alpha1.BatchCreateRowsRequest( + parent="parent_value", + requests=requests, + ) + + # Make the request + response = client.batch_create_rows(request=request) + + # Handle the response + print(response) + +# [END area120tables_v1alpha1_generated_TablesService_BatchCreateRows_sync_f62d407e] diff --git a/packages/google-area120-tables/samples/generated_samples/area120tables_v1alpha1_generated_tables_service_batch_delete_rows_sync.py b/packages/google-area120-tables/samples/generated_samples/area120tables_v1alpha1_generated_tables_service_batch_delete_rows_sync_7474ee2a.py similarity index 97% rename from packages/google-area120-tables/samples/generated_samples/area120tables_v1alpha1_generated_tables_service_batch_delete_rows_sync.py rename to packages/google-area120-tables/samples/generated_samples/area120tables_v1alpha1_generated_tables_service_batch_delete_rows_sync_7474ee2a.py index da78952f0ad9..8279523ff15b 100644 --- a/packages/google-area120-tables/samples/generated_samples/area120tables_v1alpha1_generated_tables_service_batch_delete_rows_sync.py +++ b/packages/google-area120-tables/samples/generated_samples/area120tables_v1alpha1_generated_tables_service_batch_delete_rows_sync_7474ee2a.py @@ -23,7 +23,7 @@ # python3 -m pip install google-area120-tables -# [START area120tables_v1alpha1_generated_TablesService_BatchDeleteRows_sync] +# [START area120tables_v1alpha1_generated_TablesService_BatchDeleteRows_sync_7474ee2a] # This snippet has been automatically generated and should be regarded as a # code template only. # It will require modifications to work: @@ -48,4 +48,4 @@ def sample_batch_delete_rows(): client.batch_delete_rows(request=request) -# [END area120tables_v1alpha1_generated_TablesService_BatchDeleteRows_sync] +# [END area120tables_v1alpha1_generated_TablesService_BatchDeleteRows_sync_7474ee2a] diff --git a/packages/google-area120-tables/samples/generated_samples/area120tables_v1alpha1_generated_tables_service_batch_delete_rows_sync_7b157843.py b/packages/google-area120-tables/samples/generated_samples/area120tables_v1alpha1_generated_tables_service_batch_delete_rows_sync_7b157843.py new file mode 100644 index 000000000000..65de8070eb54 --- /dev/null +++ b/packages/google-area120-tables/samples/generated_samples/area120tables_v1alpha1_generated_tables_service_batch_delete_rows_sync_7b157843.py @@ -0,0 +1,51 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for BatchDeleteRows +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-area120-tables + + +# [START area120tables_v1alpha1_generated_TablesService_BatchDeleteRows_sync_7b157843] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.area120 import tables_v1alpha1 + + +def sample_batch_delete_rows(): + # Create a client + client = tables_v1alpha1.TablesServiceClient() + + # Initialize request argument(s) + request = tables_v1alpha1.BatchDeleteRowsRequest( + parent="parent_value", + names=['names_value1', 'names_value2'], + ) + + # Make the request + client.batch_delete_rows(request=request) + + +# [END area120tables_v1alpha1_generated_TablesService_BatchDeleteRows_sync_7b157843] diff --git a/packages/google-area120-tables/samples/generated_samples/area120tables_v1alpha1_generated_tables_service_batch_update_rows_sync.py b/packages/google-area120-tables/samples/generated_samples/area120tables_v1alpha1_generated_tables_service_batch_update_rows_sync_87153c6b.py similarity index 97% rename from packages/google-area120-tables/samples/generated_samples/area120tables_v1alpha1_generated_tables_service_batch_update_rows_sync.py rename to packages/google-area120-tables/samples/generated_samples/area120tables_v1alpha1_generated_tables_service_batch_update_rows_sync_87153c6b.py index e46aadb106f3..d935af11837a 100644 --- a/packages/google-area120-tables/samples/generated_samples/area120tables_v1alpha1_generated_tables_service_batch_update_rows_sync.py +++ b/packages/google-area120-tables/samples/generated_samples/area120tables_v1alpha1_generated_tables_service_batch_update_rows_sync_87153c6b.py @@ -23,7 +23,7 @@ # python3 -m pip install google-area120-tables -# [START area120tables_v1alpha1_generated_TablesService_BatchUpdateRows_sync] +# [START area120tables_v1alpha1_generated_TablesService_BatchUpdateRows_sync_87153c6b] # This snippet has been automatically generated and should be regarded as a # code template only. # It will require modifications to work: @@ -49,4 +49,4 @@ def sample_batch_update_rows(): # Handle the response print(response) -# [END area120tables_v1alpha1_generated_TablesService_BatchUpdateRows_sync] +# [END area120tables_v1alpha1_generated_TablesService_BatchUpdateRows_sync_87153c6b] diff --git a/packages/google-area120-tables/samples/generated_samples/area120tables_v1alpha1_generated_tables_service_batch_update_rows_sync_cfa5adec.py b/packages/google-area120-tables/samples/generated_samples/area120tables_v1alpha1_generated_tables_service_batch_update_rows_sync_cfa5adec.py new file mode 100644 index 000000000000..ab7ac0539ce8 --- /dev/null +++ b/packages/google-area120-tables/samples/generated_samples/area120tables_v1alpha1_generated_tables_service_batch_update_rows_sync_cfa5adec.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for BatchUpdateRows +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-area120-tables + + +# [START area120tables_v1alpha1_generated_TablesService_BatchUpdateRows_sync_cfa5adec] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.area120 import tables_v1alpha1 + + +def sample_batch_update_rows(): + # Create a client + client = tables_v1alpha1.TablesServiceClient() + + # Initialize request argument(s) + request = tables_v1alpha1.BatchUpdateRowsRequest( + parent="parent_value", + ) + + # Make the request + response = client.batch_update_rows(request=request) + + # Handle the response + print(response) + +# [END area120tables_v1alpha1_generated_TablesService_BatchUpdateRows_sync_cfa5adec] diff --git a/packages/google-area120-tables/samples/generated_samples/area120tables_v1alpha1_generated_tables_service_create_row_sync.py b/packages/google-area120-tables/samples/generated_samples/area120tables_v1alpha1_generated_tables_service_create_row_sync_77db3520.py similarity index 98% rename from packages/google-area120-tables/samples/generated_samples/area120tables_v1alpha1_generated_tables_service_create_row_sync.py rename to packages/google-area120-tables/samples/generated_samples/area120tables_v1alpha1_generated_tables_service_create_row_sync_77db3520.py index d81bf493cb6f..6fd725985599 100644 --- a/packages/google-area120-tables/samples/generated_samples/area120tables_v1alpha1_generated_tables_service_create_row_sync.py +++ b/packages/google-area120-tables/samples/generated_samples/area120tables_v1alpha1_generated_tables_service_create_row_sync_77db3520.py @@ -23,7 +23,7 @@ # python3 -m pip install google-area120-tables -# [START area120tables_v1alpha1_generated_TablesService_CreateRow_sync] +# [START area120tables_v1alpha1_generated_TablesService_CreateRow_sync_77db3520] # This snippet has been automatically generated and should be regarded as a # code template only. # It will require modifications to work: @@ -49,4 +49,4 @@ def sample_create_row(): # Handle the response print(response) -# [END area120tables_v1alpha1_generated_TablesService_CreateRow_sync] +# [END area120tables_v1alpha1_generated_TablesService_CreateRow_sync_77db3520] diff --git a/packages/google-area120-tables/samples/generated_samples/area120tables_v1alpha1_generated_tables_service_create_row_sync_e819d753.py b/packages/google-area120-tables/samples/generated_samples/area120tables_v1alpha1_generated_tables_service_create_row_sync_e819d753.py new file mode 100644 index 000000000000..5eb329655727 --- /dev/null +++ b/packages/google-area120-tables/samples/generated_samples/area120tables_v1alpha1_generated_tables_service_create_row_sync_e819d753.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateRow +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-area120-tables + + +# [START area120tables_v1alpha1_generated_TablesService_CreateRow_sync_e819d753] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.area120 import tables_v1alpha1 + + +def sample_create_row(): + # Create a client + client = tables_v1alpha1.TablesServiceClient() + + # Initialize request argument(s) + request = tables_v1alpha1.CreateRowRequest( + parent="parent_value", + ) + + # Make the request + response = client.create_row(request=request) + + # Handle the response + print(response) + +# [END area120tables_v1alpha1_generated_TablesService_CreateRow_sync_e819d753] diff --git a/packages/google-area120-tables/samples/generated_samples/area120tables_v1alpha1_generated_tables_service_delete_row_sync.py b/packages/google-area120-tables/samples/generated_samples/area120tables_v1alpha1_generated_tables_service_delete_row_sync_05eb7fec.py similarity index 98% rename from packages/google-area120-tables/samples/generated_samples/area120tables_v1alpha1_generated_tables_service_delete_row_sync.py rename to packages/google-area120-tables/samples/generated_samples/area120tables_v1alpha1_generated_tables_service_delete_row_sync_05eb7fec.py index a34a29c828e7..8c48138f6fb1 100644 --- a/packages/google-area120-tables/samples/generated_samples/area120tables_v1alpha1_generated_tables_service_delete_row_sync.py +++ b/packages/google-area120-tables/samples/generated_samples/area120tables_v1alpha1_generated_tables_service_delete_row_sync_05eb7fec.py @@ -23,7 +23,7 @@ # python3 -m pip install google-area120-tables -# [START area120tables_v1alpha1_generated_TablesService_DeleteRow_sync] +# [START area120tables_v1alpha1_generated_TablesService_DeleteRow_sync_05eb7fec] # This snippet has been automatically generated and should be regarded as a # code template only. # It will require modifications to work: @@ -47,4 +47,4 @@ def sample_delete_row(): client.delete_row(request=request) -# [END area120tables_v1alpha1_generated_TablesService_DeleteRow_sync] +# [END area120tables_v1alpha1_generated_TablesService_DeleteRow_sync_05eb7fec] diff --git a/packages/google-area120-tables/samples/generated_samples/area120tables_v1alpha1_generated_tables_service_delete_row_sync_97a7d0a3.py b/packages/google-area120-tables/samples/generated_samples/area120tables_v1alpha1_generated_tables_service_delete_row_sync_97a7d0a3.py new file mode 100644 index 000000000000..6c27f814dafb --- /dev/null +++ b/packages/google-area120-tables/samples/generated_samples/area120tables_v1alpha1_generated_tables_service_delete_row_sync_97a7d0a3.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteRow +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-area120-tables + + +# [START area120tables_v1alpha1_generated_TablesService_DeleteRow_sync_97a7d0a3] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.area120 import tables_v1alpha1 + + +def sample_delete_row(): + # Create a client + client = tables_v1alpha1.TablesServiceClient() + + # Initialize request argument(s) + request = tables_v1alpha1.DeleteRowRequest( + name="name_value", + ) + + # Make the request + client.delete_row(request=request) + + +# [END area120tables_v1alpha1_generated_TablesService_DeleteRow_sync_97a7d0a3] diff --git a/packages/google-area120-tables/samples/generated_samples/area120tables_v1alpha1_generated_tables_service_get_row_sync.py b/packages/google-area120-tables/samples/generated_samples/area120tables_v1alpha1_generated_tables_service_get_row_sync_a0db702e.py similarity index 98% rename from packages/google-area120-tables/samples/generated_samples/area120tables_v1alpha1_generated_tables_service_get_row_sync.py rename to packages/google-area120-tables/samples/generated_samples/area120tables_v1alpha1_generated_tables_service_get_row_sync_a0db702e.py index cfe48ec3b1d8..a2ef02c0220c 100644 --- a/packages/google-area120-tables/samples/generated_samples/area120tables_v1alpha1_generated_tables_service_get_row_sync.py +++ b/packages/google-area120-tables/samples/generated_samples/area120tables_v1alpha1_generated_tables_service_get_row_sync_a0db702e.py @@ -23,7 +23,7 @@ # python3 -m pip install google-area120-tables -# [START area120tables_v1alpha1_generated_TablesService_GetRow_sync] +# [START area120tables_v1alpha1_generated_TablesService_GetRow_sync_a0db702e] # This snippet has been automatically generated and should be regarded as a # code template only. # It will require modifications to work: @@ -49,4 +49,4 @@ def sample_get_row(): # Handle the response print(response) -# [END area120tables_v1alpha1_generated_TablesService_GetRow_sync] +# [END area120tables_v1alpha1_generated_TablesService_GetRow_sync_a0db702e] diff --git a/packages/google-area120-tables/samples/generated_samples/area120tables_v1alpha1_generated_tables_service_get_row_sync_eef24c74.py b/packages/google-area120-tables/samples/generated_samples/area120tables_v1alpha1_generated_tables_service_get_row_sync_eef24c74.py new file mode 100644 index 000000000000..bf57b45b6303 --- /dev/null +++ b/packages/google-area120-tables/samples/generated_samples/area120tables_v1alpha1_generated_tables_service_get_row_sync_eef24c74.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetRow +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-area120-tables + + +# [START area120tables_v1alpha1_generated_TablesService_GetRow_sync_eef24c74] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.area120 import tables_v1alpha1 + + +def sample_get_row(): + # Create a client + client = tables_v1alpha1.TablesServiceClient() + + # Initialize request argument(s) + request = tables_v1alpha1.GetRowRequest( + name="name_value", + ) + + # Make the request + response = client.get_row(request=request) + + # Handle the response + print(response) + +# [END area120tables_v1alpha1_generated_TablesService_GetRow_sync_eef24c74] diff --git a/packages/google-area120-tables/samples/generated_samples/area120tables_v1alpha1_generated_tables_service_get_table_sync.py b/packages/google-area120-tables/samples/generated_samples/area120tables_v1alpha1_generated_tables_service_get_table_sync_d3ea491d.py similarity index 98% rename from packages/google-area120-tables/samples/generated_samples/area120tables_v1alpha1_generated_tables_service_get_table_sync.py rename to packages/google-area120-tables/samples/generated_samples/area120tables_v1alpha1_generated_tables_service_get_table_sync_d3ea491d.py index d8a25deded4e..fcb720c5361f 100644 --- a/packages/google-area120-tables/samples/generated_samples/area120tables_v1alpha1_generated_tables_service_get_table_sync.py +++ b/packages/google-area120-tables/samples/generated_samples/area120tables_v1alpha1_generated_tables_service_get_table_sync_d3ea491d.py @@ -23,7 +23,7 @@ # python3 -m pip install google-area120-tables -# [START area120tables_v1alpha1_generated_TablesService_GetTable_sync] +# [START area120tables_v1alpha1_generated_TablesService_GetTable_sync_d3ea491d] # This snippet has been automatically generated and should be regarded as a # code template only. # It will require modifications to work: @@ -49,4 +49,4 @@ def sample_get_table(): # Handle the response print(response) -# [END area120tables_v1alpha1_generated_TablesService_GetTable_sync] +# [END area120tables_v1alpha1_generated_TablesService_GetTable_sync_d3ea491d] diff --git a/packages/google-area120-tables/samples/generated_samples/area120tables_v1alpha1_generated_tables_service_get_table_sync_f911c844.py b/packages/google-area120-tables/samples/generated_samples/area120tables_v1alpha1_generated_tables_service_get_table_sync_f911c844.py new file mode 100644 index 000000000000..d86d881c7909 --- /dev/null +++ b/packages/google-area120-tables/samples/generated_samples/area120tables_v1alpha1_generated_tables_service_get_table_sync_f911c844.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetTable +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-area120-tables + + +# [START area120tables_v1alpha1_generated_TablesService_GetTable_sync_f911c844] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.area120 import tables_v1alpha1 + + +def sample_get_table(): + # Create a client + client = tables_v1alpha1.TablesServiceClient() + + # Initialize request argument(s) + request = tables_v1alpha1.GetTableRequest( + name="name_value", + ) + + # Make the request + response = client.get_table(request=request) + + # Handle the response + print(response) + +# [END area120tables_v1alpha1_generated_TablesService_GetTable_sync_f911c844] diff --git a/packages/google-area120-tables/samples/generated_samples/area120tables_v1alpha1_generated_tables_service_get_workspace_sync.py b/packages/google-area120-tables/samples/generated_samples/area120tables_v1alpha1_generated_tables_service_get_workspace_sync_59e11e2a.py similarity index 97% rename from packages/google-area120-tables/samples/generated_samples/area120tables_v1alpha1_generated_tables_service_get_workspace_sync.py rename to packages/google-area120-tables/samples/generated_samples/area120tables_v1alpha1_generated_tables_service_get_workspace_sync_59e11e2a.py index 4c78f552a37f..caf4af2cce7c 100644 --- a/packages/google-area120-tables/samples/generated_samples/area120tables_v1alpha1_generated_tables_service_get_workspace_sync.py +++ b/packages/google-area120-tables/samples/generated_samples/area120tables_v1alpha1_generated_tables_service_get_workspace_sync_59e11e2a.py @@ -23,7 +23,7 @@ # python3 -m pip install google-area120-tables -# [START area120tables_v1alpha1_generated_TablesService_GetWorkspace_sync] +# [START area120tables_v1alpha1_generated_TablesService_GetWorkspace_sync_59e11e2a] # This snippet has been automatically generated and should be regarded as a # code template only. # It will require modifications to work: @@ -49,4 +49,4 @@ def sample_get_workspace(): # Handle the response print(response) -# [END area120tables_v1alpha1_generated_TablesService_GetWorkspace_sync] +# [END area120tables_v1alpha1_generated_TablesService_GetWorkspace_sync_59e11e2a] diff --git a/packages/google-area120-tables/samples/generated_samples/area120tables_v1alpha1_generated_tables_service_get_workspace_sync_5d902f1a.py b/packages/google-area120-tables/samples/generated_samples/area120tables_v1alpha1_generated_tables_service_get_workspace_sync_5d902f1a.py new file mode 100644 index 000000000000..d9ab5eaac85d --- /dev/null +++ b/packages/google-area120-tables/samples/generated_samples/area120tables_v1alpha1_generated_tables_service_get_workspace_sync_5d902f1a.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetWorkspace +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-area120-tables + + +# [START area120tables_v1alpha1_generated_TablesService_GetWorkspace_sync_5d902f1a] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.area120 import tables_v1alpha1 + + +def sample_get_workspace(): + # Create a client + client = tables_v1alpha1.TablesServiceClient() + + # Initialize request argument(s) + request = tables_v1alpha1.GetWorkspaceRequest( + name="name_value", + ) + + # Make the request + response = client.get_workspace(request=request) + + # Handle the response + print(response) + +# [END area120tables_v1alpha1_generated_TablesService_GetWorkspace_sync_5d902f1a] diff --git a/packages/google-area120-tables/samples/generated_samples/area120tables_v1alpha1_generated_tables_service_list_rows_sync.py b/packages/google-area120-tables/samples/generated_samples/area120tables_v1alpha1_generated_tables_service_list_rows_sync_1ed0c289.py similarity index 98% rename from packages/google-area120-tables/samples/generated_samples/area120tables_v1alpha1_generated_tables_service_list_rows_sync.py rename to packages/google-area120-tables/samples/generated_samples/area120tables_v1alpha1_generated_tables_service_list_rows_sync_1ed0c289.py index e3f48535f491..faeb81ba36f7 100644 --- a/packages/google-area120-tables/samples/generated_samples/area120tables_v1alpha1_generated_tables_service_list_rows_sync.py +++ b/packages/google-area120-tables/samples/generated_samples/area120tables_v1alpha1_generated_tables_service_list_rows_sync_1ed0c289.py @@ -23,7 +23,7 @@ # python3 -m pip install google-area120-tables -# [START area120tables_v1alpha1_generated_TablesService_ListRows_sync] +# [START area120tables_v1alpha1_generated_TablesService_ListRows_sync_1ed0c289] # This snippet has been automatically generated and should be regarded as a # code template only. # It will require modifications to work: @@ -50,4 +50,4 @@ def sample_list_rows(): for response in page_result: print(response) -# [END area120tables_v1alpha1_generated_TablesService_ListRows_sync] +# [END area120tables_v1alpha1_generated_TablesService_ListRows_sync_1ed0c289] diff --git a/packages/google-area120-tables/samples/generated_samples/area120tables_v1alpha1_generated_tables_service_list_rows_sync_77a08e84.py b/packages/google-area120-tables/samples/generated_samples/area120tables_v1alpha1_generated_tables_service_list_rows_sync_77a08e84.py new file mode 100644 index 000000000000..e716c3ed7eb1 --- /dev/null +++ b/packages/google-area120-tables/samples/generated_samples/area120tables_v1alpha1_generated_tables_service_list_rows_sync_77a08e84.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListRows +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-area120-tables + + +# [START area120tables_v1alpha1_generated_TablesService_ListRows_sync_77a08e84] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.area120 import tables_v1alpha1 + + +def sample_list_rows(): + # Create a client + client = tables_v1alpha1.TablesServiceClient() + + # Initialize request argument(s) + request = tables_v1alpha1.ListRowsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_rows(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END area120tables_v1alpha1_generated_TablesService_ListRows_sync_77a08e84] diff --git a/packages/google-area120-tables/samples/generated_samples/area120tables_v1alpha1_generated_tables_service_list_tables_sync.py b/packages/google-area120-tables/samples/generated_samples/area120tables_v1alpha1_generated_tables_service_list_tables_sync_5fad2c45.py similarity index 98% rename from packages/google-area120-tables/samples/generated_samples/area120tables_v1alpha1_generated_tables_service_list_tables_sync.py rename to packages/google-area120-tables/samples/generated_samples/area120tables_v1alpha1_generated_tables_service_list_tables_sync_5fad2c45.py index f60d4da24861..709eda112268 100644 --- a/packages/google-area120-tables/samples/generated_samples/area120tables_v1alpha1_generated_tables_service_list_tables_sync.py +++ b/packages/google-area120-tables/samples/generated_samples/area120tables_v1alpha1_generated_tables_service_list_tables_sync_5fad2c45.py @@ -23,7 +23,7 @@ # python3 -m pip install google-area120-tables -# [START area120tables_v1alpha1_generated_TablesService_ListTables_sync] +# [START area120tables_v1alpha1_generated_TablesService_ListTables_sync_5fad2c45] # This snippet has been automatically generated and should be regarded as a # code template only. # It will require modifications to work: @@ -49,4 +49,4 @@ def sample_list_tables(): for response in page_result: print(response) -# [END area120tables_v1alpha1_generated_TablesService_ListTables_sync] +# [END area120tables_v1alpha1_generated_TablesService_ListTables_sync_5fad2c45] diff --git a/packages/google-area120-tables/samples/generated_samples/area120tables_v1alpha1_generated_tables_service_list_tables_sync_c5f1b1cf.py b/packages/google-area120-tables/samples/generated_samples/area120tables_v1alpha1_generated_tables_service_list_tables_sync_c5f1b1cf.py new file mode 100644 index 000000000000..19ab474380df --- /dev/null +++ b/packages/google-area120-tables/samples/generated_samples/area120tables_v1alpha1_generated_tables_service_list_tables_sync_c5f1b1cf.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListTables +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-area120-tables + + +# [START area120tables_v1alpha1_generated_TablesService_ListTables_sync_c5f1b1cf] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.area120 import tables_v1alpha1 + + +def sample_list_tables(): + # Create a client + client = tables_v1alpha1.TablesServiceClient() + + # Initialize request argument(s) + request = tables_v1alpha1.ListTablesRequest( + ) + + # Make the request + page_result = client.list_tables(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END area120tables_v1alpha1_generated_TablesService_ListTables_sync_c5f1b1cf] diff --git a/packages/google-area120-tables/samples/generated_samples/area120tables_v1alpha1_generated_tables_service_list_workspaces_sync.py b/packages/google-area120-tables/samples/generated_samples/area120tables_v1alpha1_generated_tables_service_list_workspaces_sync_7760ff8a.py similarity index 97% rename from packages/google-area120-tables/samples/generated_samples/area120tables_v1alpha1_generated_tables_service_list_workspaces_sync.py rename to packages/google-area120-tables/samples/generated_samples/area120tables_v1alpha1_generated_tables_service_list_workspaces_sync_7760ff8a.py index 6d71814745d7..4348c7e82b2c 100644 --- a/packages/google-area120-tables/samples/generated_samples/area120tables_v1alpha1_generated_tables_service_list_workspaces_sync.py +++ b/packages/google-area120-tables/samples/generated_samples/area120tables_v1alpha1_generated_tables_service_list_workspaces_sync_7760ff8a.py @@ -23,7 +23,7 @@ # python3 -m pip install google-area120-tables -# [START area120tables_v1alpha1_generated_TablesService_ListWorkspaces_sync] +# [START area120tables_v1alpha1_generated_TablesService_ListWorkspaces_sync_7760ff8a] # This snippet has been automatically generated and should be regarded as a # code template only. # It will require modifications to work: @@ -49,4 +49,4 @@ def sample_list_workspaces(): for response in page_result: print(response) -# [END area120tables_v1alpha1_generated_TablesService_ListWorkspaces_sync] +# [END area120tables_v1alpha1_generated_TablesService_ListWorkspaces_sync_7760ff8a] diff --git a/packages/google-area120-tables/samples/generated_samples/area120tables_v1alpha1_generated_tables_service_list_workspaces_sync_a2b1737a.py b/packages/google-area120-tables/samples/generated_samples/area120tables_v1alpha1_generated_tables_service_list_workspaces_sync_a2b1737a.py new file mode 100644 index 000000000000..1f218a410778 --- /dev/null +++ b/packages/google-area120-tables/samples/generated_samples/area120tables_v1alpha1_generated_tables_service_list_workspaces_sync_a2b1737a.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListWorkspaces +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-area120-tables + + +# [START area120tables_v1alpha1_generated_TablesService_ListWorkspaces_sync_a2b1737a] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.area120 import tables_v1alpha1 + + +def sample_list_workspaces(): + # Create a client + client = tables_v1alpha1.TablesServiceClient() + + # Initialize request argument(s) + request = tables_v1alpha1.ListWorkspacesRequest( + ) + + # Make the request + page_result = client.list_workspaces(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END area120tables_v1alpha1_generated_TablesService_ListWorkspaces_sync_a2b1737a] diff --git a/packages/google-area120-tables/samples/generated_samples/area120tables_v1alpha1_generated_tables_service_update_row_sync.py b/packages/google-area120-tables/samples/generated_samples/area120tables_v1alpha1_generated_tables_service_update_row_sync_73e76548.py similarity index 98% rename from packages/google-area120-tables/samples/generated_samples/area120tables_v1alpha1_generated_tables_service_update_row_sync.py rename to packages/google-area120-tables/samples/generated_samples/area120tables_v1alpha1_generated_tables_service_update_row_sync_73e76548.py index 95212ab7c2c6..d1f4bbddf0c1 100644 --- a/packages/google-area120-tables/samples/generated_samples/area120tables_v1alpha1_generated_tables_service_update_row_sync.py +++ b/packages/google-area120-tables/samples/generated_samples/area120tables_v1alpha1_generated_tables_service_update_row_sync_73e76548.py @@ -23,7 +23,7 @@ # python3 -m pip install google-area120-tables -# [START area120tables_v1alpha1_generated_TablesService_UpdateRow_sync] +# [START area120tables_v1alpha1_generated_TablesService_UpdateRow_sync_73e76548] # This snippet has been automatically generated and should be regarded as a # code template only. # It will require modifications to work: @@ -48,4 +48,4 @@ def sample_update_row(): # Handle the response print(response) -# [END area120tables_v1alpha1_generated_TablesService_UpdateRow_sync] +# [END area120tables_v1alpha1_generated_TablesService_UpdateRow_sync_73e76548] diff --git a/packages/google-area120-tables/samples/generated_samples/area120tables_v1alpha1_generated_tables_service_update_row_sync_c2c5d709.py b/packages/google-area120-tables/samples/generated_samples/area120tables_v1alpha1_generated_tables_service_update_row_sync_c2c5d709.py new file mode 100644 index 000000000000..ec6f14af67b1 --- /dev/null +++ b/packages/google-area120-tables/samples/generated_samples/area120tables_v1alpha1_generated_tables_service_update_row_sync_c2c5d709.py @@ -0,0 +1,51 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateRow +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-area120-tables + + +# [START area120tables_v1alpha1_generated_TablesService_UpdateRow_sync_c2c5d709] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.area120 import tables_v1alpha1 + + +def sample_update_row(): + # Create a client + client = tables_v1alpha1.TablesServiceClient() + + # Initialize request argument(s) + request = tables_v1alpha1.UpdateRowRequest( + ) + + # Make the request + response = client.update_row(request=request) + + # Handle the response + print(response) + +# [END area120tables_v1alpha1_generated_TablesService_UpdateRow_sync_c2c5d709] diff --git a/packages/google-area120-tables/samples/generated_samples/snippet_metadata_tables_v1alpha1.json b/packages/google-area120-tables/samples/generated_samples/snippet_metadata_tables_v1alpha1.json index b18baaf60d0b..4eb615ea00ab 100644 --- a/packages/google-area120-tables/samples/generated_samples/snippet_metadata_tables_v1alpha1.json +++ b/packages/google-area120-tables/samples/generated_samples/snippet_metadata_tables_v1alpha1.json @@ -125,7 +125,7 @@ "shortName": "batch_create_rows" }, "description": "Sample for BatchCreateRows", - "file": "area120tables_v1alpha1_generated_tables_service_batch_create_rows_sync.py", + "file": "area120tables_v1alpha1_generated_tables_service_batch_create_rows_sync_f62d407e.py", "language": "PYTHON", "origin": "API_DEFINITION", "regionTag": "area120tables_v1alpha1_generated_TablesService_BatchCreateRows_sync", @@ -161,7 +161,83 @@ "type": "RESPONSE_HANDLING" } ], - "title": "area120tables_v1alpha1_generated_tables_service_batch_create_rows_sync.py" + "title": "area120tables_v1alpha1_generated_tables_service_batch_create_rows_sync_f62d407e.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.area120.tables_v1alpha1.TablesServiceClient", + "shortName": "TablesServiceClient" + }, + "fullName": "google.area120.tables_v1alpha1.TablesServiceClient.batch_create_rows", + "method": { + "fullName": "google.area120.tables.v1alpha1.TablesService.BatchCreateRows", + "service": { + "fullName": "google.area120.tables.v1alpha1.TablesService", + "shortName": "TablesService" + }, + "shortName": "BatchCreateRows" + }, + "parameters": [ + { + "name": "request", + "type": "google.area120.tables_v1alpha1.types.BatchCreateRowsRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.area120.tables_v1alpha1.types.BatchCreateRowsResponse", + "shortName": "batch_create_rows" + }, + "description": "Sample for BatchCreateRows", + "file": "area120tables_v1alpha1_generated_tables_service_batch_create_rows_sync_39533718.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "area120tables_v1alpha1_generated_TablesService_BatchCreateRows_sync", + "segments": [ + { + "end": 55, + "start": 27, + "type": "FULL" + }, + { + "end": 55, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 49, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 52, + "start": 50, + "type": "REQUEST_EXECUTION" + }, + { + "end": 56, + "start": 53, + "type": "RESPONSE_HANDLING" + } + ], + "title": "area120tables_v1alpha1_generated_tables_service_batch_create_rows_sync_39533718.py" }, { "canonical": true, @@ -256,7 +332,872 @@ "parameters": [ { "name": "request", - "type": "google.area120.tables_v1alpha1.types.BatchDeleteRowsRequest" + "type": "google.area120.tables_v1alpha1.types.BatchDeleteRowsRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "shortName": "batch_delete_rows" + }, + "description": "Sample for BatchDeleteRows", + "file": "area120tables_v1alpha1_generated_tables_service_batch_delete_rows_sync_7474ee2a.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "area120tables_v1alpha1_generated_TablesService_BatchDeleteRows_sync", + "segments": [ + { + "end": 50, + "start": 27, + "type": "FULL" + }, + { + "end": 50, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 46, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 47, + "type": "REQUEST_EXECUTION" + }, + { + "end": 51, + "type": "RESPONSE_HANDLING" + } + ], + "title": "area120tables_v1alpha1_generated_tables_service_batch_delete_rows_sync_7474ee2a.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.area120.tables_v1alpha1.TablesServiceClient", + "shortName": "TablesServiceClient" + }, + "fullName": "google.area120.tables_v1alpha1.TablesServiceClient.batch_delete_rows", + "method": { + "fullName": "google.area120.tables.v1alpha1.TablesService.BatchDeleteRows", + "service": { + "fullName": "google.area120.tables.v1alpha1.TablesService", + "shortName": "TablesService" + }, + "shortName": "BatchDeleteRows" + }, + "parameters": [ + { + "name": "request", + "type": "google.area120.tables_v1alpha1.types.BatchDeleteRowsRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "shortName": "batch_delete_rows" + }, + "description": "Sample for BatchDeleteRows", + "file": "area120tables_v1alpha1_generated_tables_service_batch_delete_rows_sync_7b157843.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "area120tables_v1alpha1_generated_TablesService_BatchDeleteRows_sync", + "segments": [ + { + "end": 50, + "start": 27, + "type": "FULL" + }, + { + "end": 50, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 46, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 47, + "type": "REQUEST_EXECUTION" + }, + { + "end": 51, + "type": "RESPONSE_HANDLING" + } + ], + "title": "area120tables_v1alpha1_generated_tables_service_batch_delete_rows_sync_7b157843.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.area120.tables_v1alpha1.TablesServiceAsyncClient", + "shortName": "TablesServiceAsyncClient" + }, + "fullName": "google.area120.tables_v1alpha1.TablesServiceAsyncClient.batch_update_rows", + "method": { + "fullName": "google.area120.tables.v1alpha1.TablesService.BatchUpdateRows", + "service": { + "fullName": "google.area120.tables.v1alpha1.TablesService", + "shortName": "TablesService" + }, + "shortName": "BatchUpdateRows" + }, + "parameters": [ + { + "name": "request", + "type": "google.area120.tables_v1alpha1.types.BatchUpdateRowsRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.area120.tables_v1alpha1.types.BatchUpdateRowsResponse", + "shortName": "batch_update_rows" + }, + "description": "Sample for BatchUpdateRows", + "file": "area120tables_v1alpha1_generated_tables_service_batch_update_rows_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "area120tables_v1alpha1_generated_TablesService_BatchUpdateRows_async", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "area120tables_v1alpha1_generated_tables_service_batch_update_rows_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.area120.tables_v1alpha1.TablesServiceClient", + "shortName": "TablesServiceClient" + }, + "fullName": "google.area120.tables_v1alpha1.TablesServiceClient.batch_update_rows", + "method": { + "fullName": "google.area120.tables.v1alpha1.TablesService.BatchUpdateRows", + "service": { + "fullName": "google.area120.tables.v1alpha1.TablesService", + "shortName": "TablesService" + }, + "shortName": "BatchUpdateRows" + }, + "parameters": [ + { + "name": "request", + "type": "google.area120.tables_v1alpha1.types.BatchUpdateRowsRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.area120.tables_v1alpha1.types.BatchUpdateRowsResponse", + "shortName": "batch_update_rows" + }, + "description": "Sample for BatchUpdateRows", + "file": "area120tables_v1alpha1_generated_tables_service_batch_update_rows_sync_87153c6b.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "area120tables_v1alpha1_generated_TablesService_BatchUpdateRows_sync", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "area120tables_v1alpha1_generated_tables_service_batch_update_rows_sync_87153c6b.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.area120.tables_v1alpha1.TablesServiceClient", + "shortName": "TablesServiceClient" + }, + "fullName": "google.area120.tables_v1alpha1.TablesServiceClient.batch_update_rows", + "method": { + "fullName": "google.area120.tables.v1alpha1.TablesService.BatchUpdateRows", + "service": { + "fullName": "google.area120.tables.v1alpha1.TablesService", + "shortName": "TablesService" + }, + "shortName": "BatchUpdateRows" + }, + "parameters": [ + { + "name": "request", + "type": "google.area120.tables_v1alpha1.types.BatchUpdateRowsRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.area120.tables_v1alpha1.types.BatchUpdateRowsResponse", + "shortName": "batch_update_rows" + }, + "description": "Sample for BatchUpdateRows", + "file": "area120tables_v1alpha1_generated_tables_service_batch_update_rows_sync_cfa5adec.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "area120tables_v1alpha1_generated_TablesService_BatchUpdateRows_sync", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "area120tables_v1alpha1_generated_tables_service_batch_update_rows_sync_cfa5adec.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.area120.tables_v1alpha1.TablesServiceAsyncClient", + "shortName": "TablesServiceAsyncClient" + }, + "fullName": "google.area120.tables_v1alpha1.TablesServiceAsyncClient.create_row", + "method": { + "fullName": "google.area120.tables.v1alpha1.TablesService.CreateRow", + "service": { + "fullName": "google.area120.tables.v1alpha1.TablesService", + "shortName": "TablesService" + }, + "shortName": "CreateRow" + }, + "parameters": [ + { + "name": "request", + "type": "google.area120.tables_v1alpha1.types.CreateRowRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "row", + "type": "google.area120.tables_v1alpha1.types.Row" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.area120.tables_v1alpha1.types.Row", + "shortName": "create_row" + }, + "description": "Sample for CreateRow", + "file": "area120tables_v1alpha1_generated_tables_service_create_row_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "area120tables_v1alpha1_generated_TablesService_CreateRow_async", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "area120tables_v1alpha1_generated_tables_service_create_row_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.area120.tables_v1alpha1.TablesServiceClient", + "shortName": "TablesServiceClient" + }, + "fullName": "google.area120.tables_v1alpha1.TablesServiceClient.create_row", + "method": { + "fullName": "google.area120.tables.v1alpha1.TablesService.CreateRow", + "service": { + "fullName": "google.area120.tables.v1alpha1.TablesService", + "shortName": "TablesService" + }, + "shortName": "CreateRow" + }, + "parameters": [ + { + "name": "request", + "type": "google.area120.tables_v1alpha1.types.CreateRowRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "row", + "type": "google.area120.tables_v1alpha1.types.Row" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.area120.tables_v1alpha1.types.Row", + "shortName": "create_row" + }, + "description": "Sample for CreateRow", + "file": "area120tables_v1alpha1_generated_tables_service_create_row_sync_e819d753.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "area120tables_v1alpha1_generated_TablesService_CreateRow_sync", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "area120tables_v1alpha1_generated_tables_service_create_row_sync_e819d753.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.area120.tables_v1alpha1.TablesServiceClient", + "shortName": "TablesServiceClient" + }, + "fullName": "google.area120.tables_v1alpha1.TablesServiceClient.create_row", + "method": { + "fullName": "google.area120.tables.v1alpha1.TablesService.CreateRow", + "service": { + "fullName": "google.area120.tables.v1alpha1.TablesService", + "shortName": "TablesService" + }, + "shortName": "CreateRow" + }, + "parameters": [ + { + "name": "request", + "type": "google.area120.tables_v1alpha1.types.CreateRowRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "row", + "type": "google.area120.tables_v1alpha1.types.Row" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.area120.tables_v1alpha1.types.Row", + "shortName": "create_row" + }, + "description": "Sample for CreateRow", + "file": "area120tables_v1alpha1_generated_tables_service_create_row_sync_77db3520.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "area120tables_v1alpha1_generated_TablesService_CreateRow_sync", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "area120tables_v1alpha1_generated_tables_service_create_row_sync_77db3520.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.area120.tables_v1alpha1.TablesServiceAsyncClient", + "shortName": "TablesServiceAsyncClient" + }, + "fullName": "google.area120.tables_v1alpha1.TablesServiceAsyncClient.delete_row", + "method": { + "fullName": "google.area120.tables.v1alpha1.TablesService.DeleteRow", + "service": { + "fullName": "google.area120.tables.v1alpha1.TablesService", + "shortName": "TablesService" + }, + "shortName": "DeleteRow" + }, + "parameters": [ + { + "name": "request", + "type": "google.area120.tables_v1alpha1.types.DeleteRowRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "shortName": "delete_row" + }, + "description": "Sample for DeleteRow", + "file": "area120tables_v1alpha1_generated_tables_service_delete_row_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "area120tables_v1alpha1_generated_TablesService_DeleteRow_async", + "segments": [ + { + "end": 49, + "start": 27, + "type": "FULL" + }, + { + "end": 49, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 50, + "type": "RESPONSE_HANDLING" + } + ], + "title": "area120tables_v1alpha1_generated_tables_service_delete_row_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.area120.tables_v1alpha1.TablesServiceClient", + "shortName": "TablesServiceClient" + }, + "fullName": "google.area120.tables_v1alpha1.TablesServiceClient.delete_row", + "method": { + "fullName": "google.area120.tables.v1alpha1.TablesService.DeleteRow", + "service": { + "fullName": "google.area120.tables.v1alpha1.TablesService", + "shortName": "TablesService" + }, + "shortName": "DeleteRow" + }, + "parameters": [ + { + "name": "request", + "type": "google.area120.tables_v1alpha1.types.DeleteRowRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "shortName": "delete_row" + }, + "description": "Sample for DeleteRow", + "file": "area120tables_v1alpha1_generated_tables_service_delete_row_sync_05eb7fec.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "area120tables_v1alpha1_generated_TablesService_DeleteRow_sync", + "segments": [ + { + "end": 49, + "start": 27, + "type": "FULL" + }, + { + "end": 49, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 50, + "type": "RESPONSE_HANDLING" + } + ], + "title": "area120tables_v1alpha1_generated_tables_service_delete_row_sync_05eb7fec.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.area120.tables_v1alpha1.TablesServiceClient", + "shortName": "TablesServiceClient" + }, + "fullName": "google.area120.tables_v1alpha1.TablesServiceClient.delete_row", + "method": { + "fullName": "google.area120.tables.v1alpha1.TablesService.DeleteRow", + "service": { + "fullName": "google.area120.tables.v1alpha1.TablesService", + "shortName": "TablesService" + }, + "shortName": "DeleteRow" + }, + "parameters": [ + { + "name": "request", + "type": "google.area120.tables_v1alpha1.types.DeleteRowRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "shortName": "delete_row" + }, + "description": "Sample for DeleteRow", + "file": "area120tables_v1alpha1_generated_tables_service_delete_row_sync_97a7d0a3.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "area120tables_v1alpha1_generated_TablesService_DeleteRow_sync", + "segments": [ + { + "end": 49, + "start": 27, + "type": "FULL" + }, + { + "end": 49, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 50, + "type": "RESPONSE_HANDLING" + } + ], + "title": "area120tables_v1alpha1_generated_tables_service_delete_row_sync_97a7d0a3.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.area120.tables_v1alpha1.TablesServiceAsyncClient", + "shortName": "TablesServiceAsyncClient" + }, + "fullName": "google.area120.tables_v1alpha1.TablesServiceAsyncClient.get_row", + "method": { + "fullName": "google.area120.tables.v1alpha1.TablesService.GetRow", + "service": { + "fullName": "google.area120.tables.v1alpha1.TablesService", + "shortName": "TablesService" + }, + "shortName": "GetRow" + }, + "parameters": [ + { + "name": "request", + "type": "google.area120.tables_v1alpha1.types.GetRowRequest" + }, + { + "name": "name", + "type": "str" }, { "name": "retry", @@ -271,21 +1212,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "shortName": "batch_delete_rows" + "resultType": "google.area120.tables_v1alpha1.types.Row", + "shortName": "get_row" }, - "description": "Sample for BatchDeleteRows", - "file": "area120tables_v1alpha1_generated_tables_service_batch_delete_rows_sync.py", + "description": "Sample for GetRow", + "file": "area120tables_v1alpha1_generated_tables_service_get_row_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "area120tables_v1alpha1_generated_TablesService_BatchDeleteRows_sync", + "regionTag": "area120tables_v1alpha1_generated_TablesService_GetRow_async", "segments": [ { - "end": 50, + "end": 51, "start": 27, "type": "FULL" }, { - "end": 50, + "end": 51, "start": 27, "type": "SHORT" }, @@ -295,42 +1237,47 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 46, + "end": 45, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "start": 47, + "end": 48, + "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 51, + "end": 52, + "start": 49, "type": "RESPONSE_HANDLING" } ], - "title": "area120tables_v1alpha1_generated_tables_service_batch_delete_rows_sync.py" + "title": "area120tables_v1alpha1_generated_tables_service_get_row_async.py" }, { "canonical": true, "clientMethod": { - "async": true, "client": { - "fullName": "google.area120.tables_v1alpha1.TablesServiceAsyncClient", - "shortName": "TablesServiceAsyncClient" + "fullName": "google.area120.tables_v1alpha1.TablesServiceClient", + "shortName": "TablesServiceClient" }, - "fullName": "google.area120.tables_v1alpha1.TablesServiceAsyncClient.batch_update_rows", + "fullName": "google.area120.tables_v1alpha1.TablesServiceClient.get_row", "method": { - "fullName": "google.area120.tables.v1alpha1.TablesService.BatchUpdateRows", + "fullName": "google.area120.tables.v1alpha1.TablesService.GetRow", "service": { "fullName": "google.area120.tables.v1alpha1.TablesService", "shortName": "TablesService" }, - "shortName": "BatchUpdateRows" + "shortName": "GetRow" }, "parameters": [ { "name": "request", - "type": "google.area120.tables_v1alpha1.types.BatchUpdateRowsRequest" + "type": "google.area120.tables_v1alpha1.types.GetRowRequest" + }, + { + "name": "name", + "type": "str" }, { "name": "retry", @@ -345,14 +1292,14 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.area120.tables_v1alpha1.types.BatchUpdateRowsResponse", - "shortName": "batch_update_rows" + "resultType": "google.area120.tables_v1alpha1.types.Row", + "shortName": "get_row" }, - "description": "Sample for BatchUpdateRows", - "file": "area120tables_v1alpha1_generated_tables_service_batch_update_rows_async.py", + "description": "Sample for GetRow", + "file": "area120tables_v1alpha1_generated_tables_service_get_row_sync_eef24c74.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "area120tables_v1alpha1_generated_TablesService_BatchUpdateRows_async", + "regionTag": "area120tables_v1alpha1_generated_TablesService_GetRow_sync", "segments": [ { "end": 51, @@ -385,7 +1332,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "area120tables_v1alpha1_generated_tables_service_batch_update_rows_async.py" + "title": "area120tables_v1alpha1_generated_tables_service_get_row_sync_eef24c74.py" }, { "canonical": true, @@ -394,19 +1341,23 @@ "fullName": "google.area120.tables_v1alpha1.TablesServiceClient", "shortName": "TablesServiceClient" }, - "fullName": "google.area120.tables_v1alpha1.TablesServiceClient.batch_update_rows", + "fullName": "google.area120.tables_v1alpha1.TablesServiceClient.get_row", "method": { - "fullName": "google.area120.tables.v1alpha1.TablesService.BatchUpdateRows", + "fullName": "google.area120.tables.v1alpha1.TablesService.GetRow", "service": { "fullName": "google.area120.tables.v1alpha1.TablesService", "shortName": "TablesService" }, - "shortName": "BatchUpdateRows" + "shortName": "GetRow" }, "parameters": [ { "name": "request", - "type": "google.area120.tables_v1alpha1.types.BatchUpdateRowsRequest" + "type": "google.area120.tables_v1alpha1.types.GetRowRequest" + }, + { + "name": "name", + "type": "str" }, { "name": "retry", @@ -421,14 +1372,14 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.area120.tables_v1alpha1.types.BatchUpdateRowsResponse", - "shortName": "batch_update_rows" + "resultType": "google.area120.tables_v1alpha1.types.Row", + "shortName": "get_row" }, - "description": "Sample for BatchUpdateRows", - "file": "area120tables_v1alpha1_generated_tables_service_batch_update_rows_sync.py", + "description": "Sample for GetRow", + "file": "area120tables_v1alpha1_generated_tables_service_get_row_sync_a0db702e.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "area120tables_v1alpha1_generated_TablesService_BatchUpdateRows_sync", + "regionTag": "area120tables_v1alpha1_generated_TablesService_GetRow_sync", "segments": [ { "end": 51, @@ -461,7 +1412,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "area120tables_v1alpha1_generated_tables_service_batch_update_rows_sync.py" + "title": "area120tables_v1alpha1_generated_tables_service_get_row_sync_a0db702e.py" }, { "canonical": true, @@ -471,28 +1422,24 @@ "fullName": "google.area120.tables_v1alpha1.TablesServiceAsyncClient", "shortName": "TablesServiceAsyncClient" }, - "fullName": "google.area120.tables_v1alpha1.TablesServiceAsyncClient.create_row", + "fullName": "google.area120.tables_v1alpha1.TablesServiceAsyncClient.get_table", "method": { - "fullName": "google.area120.tables.v1alpha1.TablesService.CreateRow", + "fullName": "google.area120.tables.v1alpha1.TablesService.GetTable", "service": { "fullName": "google.area120.tables.v1alpha1.TablesService", "shortName": "TablesService" }, - "shortName": "CreateRow" + "shortName": "GetTable" }, "parameters": [ { "name": "request", - "type": "google.area120.tables_v1alpha1.types.CreateRowRequest" + "type": "google.area120.tables_v1alpha1.types.GetTableRequest" }, { - "name": "parent", + "name": "name", "type": "str" }, - { - "name": "row", - "type": "google.area120.tables_v1alpha1.types.Row" - }, { "name": "retry", "type": "google.api_core.retry.Retry" @@ -506,14 +1453,14 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.area120.tables_v1alpha1.types.Row", - "shortName": "create_row" + "resultType": "google.area120.tables_v1alpha1.types.Table", + "shortName": "get_table" }, - "description": "Sample for CreateRow", - "file": "area120tables_v1alpha1_generated_tables_service_create_row_async.py", + "description": "Sample for GetTable", + "file": "area120tables_v1alpha1_generated_tables_service_get_table_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "area120tables_v1alpha1_generated_TablesService_CreateRow_async", + "regionTag": "area120tables_v1alpha1_generated_TablesService_GetTable_async", "segments": [ { "end": 51, @@ -546,7 +1493,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "area120tables_v1alpha1_generated_tables_service_create_row_async.py" + "title": "area120tables_v1alpha1_generated_tables_service_get_table_async.py" }, { "canonical": true, @@ -555,28 +1502,24 @@ "fullName": "google.area120.tables_v1alpha1.TablesServiceClient", "shortName": "TablesServiceClient" }, - "fullName": "google.area120.tables_v1alpha1.TablesServiceClient.create_row", + "fullName": "google.area120.tables_v1alpha1.TablesServiceClient.get_table", "method": { - "fullName": "google.area120.tables.v1alpha1.TablesService.CreateRow", + "fullName": "google.area120.tables.v1alpha1.TablesService.GetTable", "service": { "fullName": "google.area120.tables.v1alpha1.TablesService", "shortName": "TablesService" }, - "shortName": "CreateRow" + "shortName": "GetTable" }, "parameters": [ { "name": "request", - "type": "google.area120.tables_v1alpha1.types.CreateRowRequest" + "type": "google.area120.tables_v1alpha1.types.GetTableRequest" }, { - "name": "parent", + "name": "name", "type": "str" }, - { - "name": "row", - "type": "google.area120.tables_v1alpha1.types.Row" - }, { "name": "retry", "type": "google.api_core.retry.Retry" @@ -590,14 +1533,14 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.area120.tables_v1alpha1.types.Row", - "shortName": "create_row" + "resultType": "google.area120.tables_v1alpha1.types.Table", + "shortName": "get_table" }, - "description": "Sample for CreateRow", - "file": "area120tables_v1alpha1_generated_tables_service_create_row_sync.py", + "description": "Sample for GetTable", + "file": "area120tables_v1alpha1_generated_tables_service_get_table_sync_d3ea491d.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "area120tables_v1alpha1_generated_TablesService_CreateRow_sync", + "regionTag": "area120tables_v1alpha1_generated_TablesService_GetTable_sync", "segments": [ { "end": 51, @@ -630,29 +1573,28 @@ "type": "RESPONSE_HANDLING" } ], - "title": "area120tables_v1alpha1_generated_tables_service_create_row_sync.py" + "title": "area120tables_v1alpha1_generated_tables_service_get_table_sync_d3ea491d.py" }, { "canonical": true, "clientMethod": { - "async": true, "client": { - "fullName": "google.area120.tables_v1alpha1.TablesServiceAsyncClient", - "shortName": "TablesServiceAsyncClient" + "fullName": "google.area120.tables_v1alpha1.TablesServiceClient", + "shortName": "TablesServiceClient" }, - "fullName": "google.area120.tables_v1alpha1.TablesServiceAsyncClient.delete_row", + "fullName": "google.area120.tables_v1alpha1.TablesServiceClient.get_table", "method": { - "fullName": "google.area120.tables.v1alpha1.TablesService.DeleteRow", + "fullName": "google.area120.tables.v1alpha1.TablesService.GetTable", "service": { "fullName": "google.area120.tables.v1alpha1.TablesService", "shortName": "TablesService" }, - "shortName": "DeleteRow" + "shortName": "GetTable" }, "parameters": [ { "name": "request", - "type": "google.area120.tables_v1alpha1.types.DeleteRowRequest" + "type": "google.area120.tables_v1alpha1.types.GetTableRequest" }, { "name": "name", @@ -671,21 +1613,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "shortName": "delete_row" + "resultType": "google.area120.tables_v1alpha1.types.Table", + "shortName": "get_table" }, - "description": "Sample for DeleteRow", - "file": "area120tables_v1alpha1_generated_tables_service_delete_row_async.py", + "description": "Sample for GetTable", + "file": "area120tables_v1alpha1_generated_tables_service_get_table_sync_f911c844.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "area120tables_v1alpha1_generated_TablesService_DeleteRow_async", + "regionTag": "area120tables_v1alpha1_generated_TablesService_GetTable_sync", "segments": [ { - "end": 49, + "end": 51, "start": 27, "type": "FULL" }, { - "end": 49, + "end": 51, "start": 27, "type": "SHORT" }, @@ -700,36 +1643,39 @@ "type": "REQUEST_INITIALIZATION" }, { + "end": 48, "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 50, + "end": 52, + "start": 49, "type": "RESPONSE_HANDLING" } ], - "title": "area120tables_v1alpha1_generated_tables_service_delete_row_async.py" + "title": "area120tables_v1alpha1_generated_tables_service_get_table_sync_f911c844.py" }, { "canonical": true, "clientMethod": { + "async": true, "client": { - "fullName": "google.area120.tables_v1alpha1.TablesServiceClient", - "shortName": "TablesServiceClient" + "fullName": "google.area120.tables_v1alpha1.TablesServiceAsyncClient", + "shortName": "TablesServiceAsyncClient" }, - "fullName": "google.area120.tables_v1alpha1.TablesServiceClient.delete_row", + "fullName": "google.area120.tables_v1alpha1.TablesServiceAsyncClient.get_workspace", "method": { - "fullName": "google.area120.tables.v1alpha1.TablesService.DeleteRow", + "fullName": "google.area120.tables.v1alpha1.TablesService.GetWorkspace", "service": { "fullName": "google.area120.tables.v1alpha1.TablesService", "shortName": "TablesService" }, - "shortName": "DeleteRow" + "shortName": "GetWorkspace" }, "parameters": [ { "name": "request", - "type": "google.area120.tables_v1alpha1.types.DeleteRowRequest" + "type": "google.area120.tables_v1alpha1.types.GetWorkspaceRequest" }, { "name": "name", @@ -748,21 +1694,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "shortName": "delete_row" + "resultType": "google.area120.tables_v1alpha1.types.Workspace", + "shortName": "get_workspace" }, - "description": "Sample for DeleteRow", - "file": "area120tables_v1alpha1_generated_tables_service_delete_row_sync.py", + "description": "Sample for GetWorkspace", + "file": "area120tables_v1alpha1_generated_tables_service_get_workspace_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "area120tables_v1alpha1_generated_TablesService_DeleteRow_sync", + "regionTag": "area120tables_v1alpha1_generated_TablesService_GetWorkspace_async", "segments": [ { - "end": 49, + "end": 51, "start": 27, "type": "FULL" }, { - "end": 49, + "end": 51, "start": 27, "type": "SHORT" }, @@ -777,37 +1724,38 @@ "type": "REQUEST_INITIALIZATION" }, { + "end": 48, "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 50, + "end": 52, + "start": 49, "type": "RESPONSE_HANDLING" } ], - "title": "area120tables_v1alpha1_generated_tables_service_delete_row_sync.py" + "title": "area120tables_v1alpha1_generated_tables_service_get_workspace_async.py" }, { "canonical": true, "clientMethod": { - "async": true, "client": { - "fullName": "google.area120.tables_v1alpha1.TablesServiceAsyncClient", - "shortName": "TablesServiceAsyncClient" + "fullName": "google.area120.tables_v1alpha1.TablesServiceClient", + "shortName": "TablesServiceClient" }, - "fullName": "google.area120.tables_v1alpha1.TablesServiceAsyncClient.get_row", + "fullName": "google.area120.tables_v1alpha1.TablesServiceClient.get_workspace", "method": { - "fullName": "google.area120.tables.v1alpha1.TablesService.GetRow", + "fullName": "google.area120.tables.v1alpha1.TablesService.GetWorkspace", "service": { "fullName": "google.area120.tables.v1alpha1.TablesService", "shortName": "TablesService" }, - "shortName": "GetRow" + "shortName": "GetWorkspace" }, "parameters": [ { "name": "request", - "type": "google.area120.tables_v1alpha1.types.GetRowRequest" + "type": "google.area120.tables_v1alpha1.types.GetWorkspaceRequest" }, { "name": "name", @@ -826,14 +1774,14 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.area120.tables_v1alpha1.types.Row", - "shortName": "get_row" + "resultType": "google.area120.tables_v1alpha1.types.Workspace", + "shortName": "get_workspace" }, - "description": "Sample for GetRow", - "file": "area120tables_v1alpha1_generated_tables_service_get_row_async.py", + "description": "Sample for GetWorkspace", + "file": "area120tables_v1alpha1_generated_tables_service_get_workspace_sync_59e11e2a.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "area120tables_v1alpha1_generated_TablesService_GetRow_async", + "regionTag": "area120tables_v1alpha1_generated_TablesService_GetWorkspace_sync", "segments": [ { "end": 51, @@ -866,7 +1814,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "area120tables_v1alpha1_generated_tables_service_get_row_async.py" + "title": "area120tables_v1alpha1_generated_tables_service_get_workspace_sync_59e11e2a.py" }, { "canonical": true, @@ -875,19 +1823,19 @@ "fullName": "google.area120.tables_v1alpha1.TablesServiceClient", "shortName": "TablesServiceClient" }, - "fullName": "google.area120.tables_v1alpha1.TablesServiceClient.get_row", + "fullName": "google.area120.tables_v1alpha1.TablesServiceClient.get_workspace", "method": { - "fullName": "google.area120.tables.v1alpha1.TablesService.GetRow", + "fullName": "google.area120.tables.v1alpha1.TablesService.GetWorkspace", "service": { "fullName": "google.area120.tables.v1alpha1.TablesService", "shortName": "TablesService" }, - "shortName": "GetRow" + "shortName": "GetWorkspace" }, "parameters": [ { "name": "request", - "type": "google.area120.tables_v1alpha1.types.GetRowRequest" + "type": "google.area120.tables_v1alpha1.types.GetWorkspaceRequest" }, { "name": "name", @@ -906,14 +1854,14 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.area120.tables_v1alpha1.types.Row", - "shortName": "get_row" + "resultType": "google.area120.tables_v1alpha1.types.Workspace", + "shortName": "get_workspace" }, - "description": "Sample for GetRow", - "file": "area120tables_v1alpha1_generated_tables_service_get_row_sync.py", + "description": "Sample for GetWorkspace", + "file": "area120tables_v1alpha1_generated_tables_service_get_workspace_sync_5d902f1a.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "area120tables_v1alpha1_generated_TablesService_GetRow_sync", + "regionTag": "area120tables_v1alpha1_generated_TablesService_GetWorkspace_sync", "segments": [ { "end": 51, @@ -946,7 +1894,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "area120tables_v1alpha1_generated_tables_service_get_row_sync.py" + "title": "area120tables_v1alpha1_generated_tables_service_get_workspace_sync_5d902f1a.py" }, { "canonical": true, @@ -956,22 +1904,22 @@ "fullName": "google.area120.tables_v1alpha1.TablesServiceAsyncClient", "shortName": "TablesServiceAsyncClient" }, - "fullName": "google.area120.tables_v1alpha1.TablesServiceAsyncClient.get_table", + "fullName": "google.area120.tables_v1alpha1.TablesServiceAsyncClient.list_rows", "method": { - "fullName": "google.area120.tables.v1alpha1.TablesService.GetTable", + "fullName": "google.area120.tables.v1alpha1.TablesService.ListRows", "service": { "fullName": "google.area120.tables.v1alpha1.TablesService", "shortName": "TablesService" }, - "shortName": "GetTable" + "shortName": "ListRows" }, "parameters": [ { "name": "request", - "type": "google.area120.tables_v1alpha1.types.GetTableRequest" + "type": "google.area120.tables_v1alpha1.types.ListRowsRequest" }, { - "name": "name", + "name": "parent", "type": "str" }, { @@ -987,22 +1935,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.area120.tables_v1alpha1.types.Table", - "shortName": "get_table" + "resultType": "google.area120.tables_v1alpha1.services.tables_service.pagers.ListRowsAsyncPager", + "shortName": "list_rows" }, - "description": "Sample for GetTable", - "file": "area120tables_v1alpha1_generated_tables_service_get_table_async.py", + "description": "Sample for ListRows", + "file": "area120tables_v1alpha1_generated_tables_service_list_rows_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "area120tables_v1alpha1_generated_TablesService_GetTable_async", + "regionTag": "area120tables_v1alpha1_generated_TablesService_ListRows_async", "segments": [ { - "end": 51, + "end": 52, "start": 27, "type": "FULL" }, { - "end": 51, + "end": 52, "start": 27, "type": "SHORT" }, @@ -1022,12 +1970,12 @@ "type": "REQUEST_EXECUTION" }, { - "end": 52, + "end": 53, "start": 49, "type": "RESPONSE_HANDLING" } ], - "title": "area120tables_v1alpha1_generated_tables_service_get_table_async.py" + "title": "area120tables_v1alpha1_generated_tables_service_list_rows_async.py" }, { "canonical": true, @@ -1036,22 +1984,22 @@ "fullName": "google.area120.tables_v1alpha1.TablesServiceClient", "shortName": "TablesServiceClient" }, - "fullName": "google.area120.tables_v1alpha1.TablesServiceClient.get_table", + "fullName": "google.area120.tables_v1alpha1.TablesServiceClient.list_rows", "method": { - "fullName": "google.area120.tables.v1alpha1.TablesService.GetTable", + "fullName": "google.area120.tables.v1alpha1.TablesService.ListRows", "service": { "fullName": "google.area120.tables.v1alpha1.TablesService", "shortName": "TablesService" }, - "shortName": "GetTable" + "shortName": "ListRows" }, "parameters": [ { "name": "request", - "type": "google.area120.tables_v1alpha1.types.GetTableRequest" + "type": "google.area120.tables_v1alpha1.types.ListRowsRequest" }, { - "name": "name", + "name": "parent", "type": "str" }, { @@ -1067,22 +2015,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.area120.tables_v1alpha1.types.Table", - "shortName": "get_table" + "resultType": "google.area120.tables_v1alpha1.services.tables_service.pagers.ListRowsPager", + "shortName": "list_rows" }, - "description": "Sample for GetTable", - "file": "area120tables_v1alpha1_generated_tables_service_get_table_sync.py", + "description": "Sample for ListRows", + "file": "area120tables_v1alpha1_generated_tables_service_list_rows_sync_77a08e84.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "area120tables_v1alpha1_generated_TablesService_GetTable_sync", + "regionTag": "area120tables_v1alpha1_generated_TablesService_ListRows_sync", "segments": [ { - "end": 51, + "end": 52, "start": 27, "type": "FULL" }, { - "end": 51, + "end": 52, "start": 27, "type": "SHORT" }, @@ -1102,37 +2050,36 @@ "type": "REQUEST_EXECUTION" }, { - "end": 52, + "end": 53, "start": 49, "type": "RESPONSE_HANDLING" } ], - "title": "area120tables_v1alpha1_generated_tables_service_get_table_sync.py" + "title": "area120tables_v1alpha1_generated_tables_service_list_rows_sync_77a08e84.py" }, { "canonical": true, "clientMethod": { - "async": true, "client": { - "fullName": "google.area120.tables_v1alpha1.TablesServiceAsyncClient", - "shortName": "TablesServiceAsyncClient" + "fullName": "google.area120.tables_v1alpha1.TablesServiceClient", + "shortName": "TablesServiceClient" }, - "fullName": "google.area120.tables_v1alpha1.TablesServiceAsyncClient.get_workspace", + "fullName": "google.area120.tables_v1alpha1.TablesServiceClient.list_rows", "method": { - "fullName": "google.area120.tables.v1alpha1.TablesService.GetWorkspace", + "fullName": "google.area120.tables.v1alpha1.TablesService.ListRows", "service": { "fullName": "google.area120.tables.v1alpha1.TablesService", "shortName": "TablesService" }, - "shortName": "GetWorkspace" + "shortName": "ListRows" }, "parameters": [ { "name": "request", - "type": "google.area120.tables_v1alpha1.types.GetWorkspaceRequest" + "type": "google.area120.tables_v1alpha1.types.ListRowsRequest" }, { - "name": "name", + "name": "parent", "type": "str" }, { @@ -1148,22 +2095,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.area120.tables_v1alpha1.types.Workspace", - "shortName": "get_workspace" + "resultType": "google.area120.tables_v1alpha1.services.tables_service.pagers.ListRowsPager", + "shortName": "list_rows" }, - "description": "Sample for GetWorkspace", - "file": "area120tables_v1alpha1_generated_tables_service_get_workspace_async.py", + "description": "Sample for ListRows", + "file": "area120tables_v1alpha1_generated_tables_service_list_rows_sync_1ed0c289.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "area120tables_v1alpha1_generated_TablesService_GetWorkspace_async", + "regionTag": "area120tables_v1alpha1_generated_TablesService_ListRows_sync", "segments": [ { - "end": 51, + "end": 52, "start": 27, "type": "FULL" }, { - "end": 51, + "end": 52, "start": 27, "type": "SHORT" }, @@ -1183,37 +2130,34 @@ "type": "REQUEST_EXECUTION" }, { - "end": 52, + "end": 53, "start": 49, "type": "RESPONSE_HANDLING" } ], - "title": "area120tables_v1alpha1_generated_tables_service_get_workspace_async.py" + "title": "area120tables_v1alpha1_generated_tables_service_list_rows_sync_1ed0c289.py" }, { "canonical": true, "clientMethod": { + "async": true, "client": { - "fullName": "google.area120.tables_v1alpha1.TablesServiceClient", - "shortName": "TablesServiceClient" + "fullName": "google.area120.tables_v1alpha1.TablesServiceAsyncClient", + "shortName": "TablesServiceAsyncClient" }, - "fullName": "google.area120.tables_v1alpha1.TablesServiceClient.get_workspace", + "fullName": "google.area120.tables_v1alpha1.TablesServiceAsyncClient.list_tables", "method": { - "fullName": "google.area120.tables.v1alpha1.TablesService.GetWorkspace", + "fullName": "google.area120.tables.v1alpha1.TablesService.ListTables", "service": { "fullName": "google.area120.tables.v1alpha1.TablesService", "shortName": "TablesService" }, - "shortName": "GetWorkspace" + "shortName": "ListTables" }, "parameters": [ { "name": "request", - "type": "google.area120.tables_v1alpha1.types.GetWorkspaceRequest" - }, - { - "name": "name", - "type": "str" + "type": "google.area120.tables_v1alpha1.types.ListTablesRequest" }, { "name": "retry", @@ -1228,14 +2172,14 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.area120.tables_v1alpha1.types.Workspace", - "shortName": "get_workspace" + "resultType": "google.area120.tables_v1alpha1.services.tables_service.pagers.ListTablesAsyncPager", + "shortName": "list_tables" }, - "description": "Sample for GetWorkspace", - "file": "area120tables_v1alpha1_generated_tables_service_get_workspace_sync.py", + "description": "Sample for ListTables", + "file": "area120tables_v1alpha1_generated_tables_service_list_tables_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "area120tables_v1alpha1_generated_TablesService_GetWorkspace_sync", + "regionTag": "area120tables_v1alpha1_generated_TablesService_ListTables_async", "segments": [ { "end": 51, @@ -1253,48 +2197,43 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 45, + "end": 44, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 48, - "start": 46, + "end": 47, + "start": 45, "type": "REQUEST_EXECUTION" }, { "end": 52, - "start": 49, + "start": 48, "type": "RESPONSE_HANDLING" } ], - "title": "area120tables_v1alpha1_generated_tables_service_get_workspace_sync.py" + "title": "area120tables_v1alpha1_generated_tables_service_list_tables_async.py" }, { "canonical": true, "clientMethod": { - "async": true, "client": { - "fullName": "google.area120.tables_v1alpha1.TablesServiceAsyncClient", - "shortName": "TablesServiceAsyncClient" + "fullName": "google.area120.tables_v1alpha1.TablesServiceClient", + "shortName": "TablesServiceClient" }, - "fullName": "google.area120.tables_v1alpha1.TablesServiceAsyncClient.list_rows", + "fullName": "google.area120.tables_v1alpha1.TablesServiceClient.list_tables", "method": { - "fullName": "google.area120.tables.v1alpha1.TablesService.ListRows", + "fullName": "google.area120.tables.v1alpha1.TablesService.ListTables", "service": { "fullName": "google.area120.tables.v1alpha1.TablesService", "shortName": "TablesService" }, - "shortName": "ListRows" + "shortName": "ListTables" }, "parameters": [ { "name": "request", - "type": "google.area120.tables_v1alpha1.types.ListRowsRequest" - }, - { - "name": "parent", - "type": "str" + "type": "google.area120.tables_v1alpha1.types.ListTablesRequest" }, { "name": "retry", @@ -1309,22 +2248,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.area120.tables_v1alpha1.services.tables_service.pagers.ListRowsAsyncPager", - "shortName": "list_rows" + "resultType": "google.area120.tables_v1alpha1.services.tables_service.pagers.ListTablesPager", + "shortName": "list_tables" }, - "description": "Sample for ListRows", - "file": "area120tables_v1alpha1_generated_tables_service_list_rows_async.py", + "description": "Sample for ListTables", + "file": "area120tables_v1alpha1_generated_tables_service_list_tables_sync_5fad2c45.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "area120tables_v1alpha1_generated_TablesService_ListRows_async", + "regionTag": "area120tables_v1alpha1_generated_TablesService_ListTables_sync", "segments": [ { - "end": 52, + "end": 51, "start": 27, "type": "FULL" }, { - "end": 52, + "end": 51, "start": 27, "type": "SHORT" }, @@ -1334,22 +2273,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 45, + "end": 44, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 48, - "start": 46, + "end": 47, + "start": 45, "type": "REQUEST_EXECUTION" }, { - "end": 53, - "start": 49, + "end": 52, + "start": 48, "type": "RESPONSE_HANDLING" } ], - "title": "area120tables_v1alpha1_generated_tables_service_list_rows_async.py" + "title": "area120tables_v1alpha1_generated_tables_service_list_tables_sync_5fad2c45.py" }, { "canonical": true, @@ -1358,23 +2297,19 @@ "fullName": "google.area120.tables_v1alpha1.TablesServiceClient", "shortName": "TablesServiceClient" }, - "fullName": "google.area120.tables_v1alpha1.TablesServiceClient.list_rows", + "fullName": "google.area120.tables_v1alpha1.TablesServiceClient.list_tables", "method": { - "fullName": "google.area120.tables.v1alpha1.TablesService.ListRows", + "fullName": "google.area120.tables.v1alpha1.TablesService.ListTables", "service": { "fullName": "google.area120.tables.v1alpha1.TablesService", "shortName": "TablesService" }, - "shortName": "ListRows" + "shortName": "ListTables" }, "parameters": [ { "name": "request", - "type": "google.area120.tables_v1alpha1.types.ListRowsRequest" - }, - { - "name": "parent", - "type": "str" + "type": "google.area120.tables_v1alpha1.types.ListTablesRequest" }, { "name": "retry", @@ -1389,22 +2324,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.area120.tables_v1alpha1.services.tables_service.pagers.ListRowsPager", - "shortName": "list_rows" + "resultType": "google.area120.tables_v1alpha1.services.tables_service.pagers.ListTablesPager", + "shortName": "list_tables" }, - "description": "Sample for ListRows", - "file": "area120tables_v1alpha1_generated_tables_service_list_rows_sync.py", + "description": "Sample for ListTables", + "file": "area120tables_v1alpha1_generated_tables_service_list_tables_sync_c5f1b1cf.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "area120tables_v1alpha1_generated_TablesService_ListRows_sync", + "regionTag": "area120tables_v1alpha1_generated_TablesService_ListTables_sync", "segments": [ { - "end": 52, + "end": 51, "start": 27, "type": "FULL" }, { - "end": 52, + "end": 51, "start": 27, "type": "SHORT" }, @@ -1414,22 +2349,22 @@ "type": "CLIENT_INITIALIZATION" }, { - "end": 45, + "end": 44, "start": 41, "type": "REQUEST_INITIALIZATION" }, { - "end": 48, - "start": 46, + "end": 47, + "start": 45, "type": "REQUEST_EXECUTION" }, { - "end": 53, - "start": 49, + "end": 52, + "start": 48, "type": "RESPONSE_HANDLING" } ], - "title": "area120tables_v1alpha1_generated_tables_service_list_rows_sync.py" + "title": "area120tables_v1alpha1_generated_tables_service_list_tables_sync_c5f1b1cf.py" }, { "canonical": true, @@ -1439,19 +2374,19 @@ "fullName": "google.area120.tables_v1alpha1.TablesServiceAsyncClient", "shortName": "TablesServiceAsyncClient" }, - "fullName": "google.area120.tables_v1alpha1.TablesServiceAsyncClient.list_tables", + "fullName": "google.area120.tables_v1alpha1.TablesServiceAsyncClient.list_workspaces", "method": { - "fullName": "google.area120.tables.v1alpha1.TablesService.ListTables", + "fullName": "google.area120.tables.v1alpha1.TablesService.ListWorkspaces", "service": { "fullName": "google.area120.tables.v1alpha1.TablesService", "shortName": "TablesService" }, - "shortName": "ListTables" + "shortName": "ListWorkspaces" }, "parameters": [ { "name": "request", - "type": "google.area120.tables_v1alpha1.types.ListTablesRequest" + "type": "google.area120.tables_v1alpha1.types.ListWorkspacesRequest" }, { "name": "retry", @@ -1466,14 +2401,14 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.area120.tables_v1alpha1.services.tables_service.pagers.ListTablesAsyncPager", - "shortName": "list_tables" + "resultType": "google.area120.tables_v1alpha1.services.tables_service.pagers.ListWorkspacesAsyncPager", + "shortName": "list_workspaces" }, - "description": "Sample for ListTables", - "file": "area120tables_v1alpha1_generated_tables_service_list_tables_async.py", + "description": "Sample for ListWorkspaces", + "file": "area120tables_v1alpha1_generated_tables_service_list_workspaces_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "area120tables_v1alpha1_generated_TablesService_ListTables_async", + "regionTag": "area120tables_v1alpha1_generated_TablesService_ListWorkspaces_async", "segments": [ { "end": 51, @@ -1506,7 +2441,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "area120tables_v1alpha1_generated_tables_service_list_tables_async.py" + "title": "area120tables_v1alpha1_generated_tables_service_list_workspaces_async.py" }, { "canonical": true, @@ -1515,19 +2450,19 @@ "fullName": "google.area120.tables_v1alpha1.TablesServiceClient", "shortName": "TablesServiceClient" }, - "fullName": "google.area120.tables_v1alpha1.TablesServiceClient.list_tables", + "fullName": "google.area120.tables_v1alpha1.TablesServiceClient.list_workspaces", "method": { - "fullName": "google.area120.tables.v1alpha1.TablesService.ListTables", + "fullName": "google.area120.tables.v1alpha1.TablesService.ListWorkspaces", "service": { "fullName": "google.area120.tables.v1alpha1.TablesService", "shortName": "TablesService" }, - "shortName": "ListTables" + "shortName": "ListWorkspaces" }, "parameters": [ { "name": "request", - "type": "google.area120.tables_v1alpha1.types.ListTablesRequest" + "type": "google.area120.tables_v1alpha1.types.ListWorkspacesRequest" }, { "name": "retry", @@ -1542,14 +2477,14 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.area120.tables_v1alpha1.services.tables_service.pagers.ListTablesPager", - "shortName": "list_tables" + "resultType": "google.area120.tables_v1alpha1.services.tables_service.pagers.ListWorkspacesPager", + "shortName": "list_workspaces" }, - "description": "Sample for ListTables", - "file": "area120tables_v1alpha1_generated_tables_service_list_tables_sync.py", + "description": "Sample for ListWorkspaces", + "file": "area120tables_v1alpha1_generated_tables_service_list_workspaces_sync_7760ff8a.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "area120tables_v1alpha1_generated_TablesService_ListTables_sync", + "regionTag": "area120tables_v1alpha1_generated_TablesService_ListWorkspaces_sync", "segments": [ { "end": 51, @@ -1582,17 +2517,16 @@ "type": "RESPONSE_HANDLING" } ], - "title": "area120tables_v1alpha1_generated_tables_service_list_tables_sync.py" + "title": "area120tables_v1alpha1_generated_tables_service_list_workspaces_sync_7760ff8a.py" }, { "canonical": true, "clientMethod": { - "async": true, "client": { - "fullName": "google.area120.tables_v1alpha1.TablesServiceAsyncClient", - "shortName": "TablesServiceAsyncClient" + "fullName": "google.area120.tables_v1alpha1.TablesServiceClient", + "shortName": "TablesServiceClient" }, - "fullName": "google.area120.tables_v1alpha1.TablesServiceAsyncClient.list_workspaces", + "fullName": "google.area120.tables_v1alpha1.TablesServiceClient.list_workspaces", "method": { "fullName": "google.area120.tables.v1alpha1.TablesService.ListWorkspaces", "service": { @@ -1619,14 +2553,14 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.area120.tables_v1alpha1.services.tables_service.pagers.ListWorkspacesAsyncPager", + "resultType": "google.area120.tables_v1alpha1.services.tables_service.pagers.ListWorkspacesPager", "shortName": "list_workspaces" }, "description": "Sample for ListWorkspaces", - "file": "area120tables_v1alpha1_generated_tables_service_list_workspaces_async.py", + "file": "area120tables_v1alpha1_generated_tables_service_list_workspaces_sync_a2b1737a.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "area120tables_v1alpha1_generated_TablesService_ListWorkspaces_async", + "regionTag": "area120tables_v1alpha1_generated_TablesService_ListWorkspaces_sync", "segments": [ { "end": 51, @@ -1659,28 +2593,37 @@ "type": "RESPONSE_HANDLING" } ], - "title": "area120tables_v1alpha1_generated_tables_service_list_workspaces_async.py" + "title": "area120tables_v1alpha1_generated_tables_service_list_workspaces_sync_a2b1737a.py" }, { "canonical": true, "clientMethod": { + "async": true, "client": { - "fullName": "google.area120.tables_v1alpha1.TablesServiceClient", - "shortName": "TablesServiceClient" + "fullName": "google.area120.tables_v1alpha1.TablesServiceAsyncClient", + "shortName": "TablesServiceAsyncClient" }, - "fullName": "google.area120.tables_v1alpha1.TablesServiceClient.list_workspaces", + "fullName": "google.area120.tables_v1alpha1.TablesServiceAsyncClient.update_row", "method": { - "fullName": "google.area120.tables.v1alpha1.TablesService.ListWorkspaces", + "fullName": "google.area120.tables.v1alpha1.TablesService.UpdateRow", "service": { "fullName": "google.area120.tables.v1alpha1.TablesService", "shortName": "TablesService" }, - "shortName": "ListWorkspaces" + "shortName": "UpdateRow" }, "parameters": [ { "name": "request", - "type": "google.area120.tables_v1alpha1.types.ListWorkspacesRequest" + "type": "google.area120.tables_v1alpha1.types.UpdateRowRequest" + }, + { + "name": "row", + "type": "google.area120.tables_v1alpha1.types.Row" + }, + { + "name": "update_mask", + "type": "google.protobuf.field_mask_pb2.FieldMask" }, { "name": "retry", @@ -1695,22 +2638,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.area120.tables_v1alpha1.services.tables_service.pagers.ListWorkspacesPager", - "shortName": "list_workspaces" + "resultType": "google.area120.tables_v1alpha1.types.Row", + "shortName": "update_row" }, - "description": "Sample for ListWorkspaces", - "file": "area120tables_v1alpha1_generated_tables_service_list_workspaces_sync.py", + "description": "Sample for UpdateRow", + "file": "area120tables_v1alpha1_generated_tables_service_update_row_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "area120tables_v1alpha1_generated_TablesService_ListWorkspaces_sync", + "regionTag": "area120tables_v1alpha1_generated_TablesService_UpdateRow_async", "segments": [ { - "end": 51, + "end": 50, "start": 27, "type": "FULL" }, { - "end": 51, + "end": 50, "start": 27, "type": "SHORT" }, @@ -1730,22 +2673,21 @@ "type": "REQUEST_EXECUTION" }, { - "end": 52, + "end": 51, "start": 48, "type": "RESPONSE_HANDLING" } ], - "title": "area120tables_v1alpha1_generated_tables_service_list_workspaces_sync.py" + "title": "area120tables_v1alpha1_generated_tables_service_update_row_async.py" }, { "canonical": true, "clientMethod": { - "async": true, "client": { - "fullName": "google.area120.tables_v1alpha1.TablesServiceAsyncClient", - "shortName": "TablesServiceAsyncClient" + "fullName": "google.area120.tables_v1alpha1.TablesServiceClient", + "shortName": "TablesServiceClient" }, - "fullName": "google.area120.tables_v1alpha1.TablesServiceAsyncClient.update_row", + "fullName": "google.area120.tables_v1alpha1.TablesServiceClient.update_row", "method": { "fullName": "google.area120.tables.v1alpha1.TablesService.UpdateRow", "service": { @@ -1784,10 +2726,10 @@ "shortName": "update_row" }, "description": "Sample for UpdateRow", - "file": "area120tables_v1alpha1_generated_tables_service_update_row_async.py", + "file": "area120tables_v1alpha1_generated_tables_service_update_row_sync_c2c5d709.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "area120tables_v1alpha1_generated_TablesService_UpdateRow_async", + "regionTag": "area120tables_v1alpha1_generated_TablesService_UpdateRow_sync", "segments": [ { "end": 50, @@ -1820,7 +2762,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "area120tables_v1alpha1_generated_tables_service_update_row_async.py" + "title": "area120tables_v1alpha1_generated_tables_service_update_row_sync_c2c5d709.py" }, { "canonical": true, @@ -1868,7 +2810,7 @@ "shortName": "update_row" }, "description": "Sample for UpdateRow", - "file": "area120tables_v1alpha1_generated_tables_service_update_row_sync.py", + "file": "area120tables_v1alpha1_generated_tables_service_update_row_sync_73e76548.py", "language": "PYTHON", "origin": "API_DEFINITION", "regionTag": "area120tables_v1alpha1_generated_TablesService_UpdateRow_sync", @@ -1904,7 +2846,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "area120tables_v1alpha1_generated_tables_service_update_row_sync.py" + "title": "area120tables_v1alpha1_generated_tables_service_update_row_sync_73e76548.py" } ] } diff --git a/packages/google-area120-tables/setup.py b/packages/google-area120-tables/setup.py index 6169dc0458ff..c9fd01143099 100644 --- a/packages/google-area120-tables/setup.py +++ b/packages/google-area120-tables/setup.py @@ -46,9 +46,9 @@ platforms="Posix; MacOS X; Windows", include_package_data=True, install_requires=( - "google-api-core[grpc] >= 1.32.0, <3.0.0dev,!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.*,!=2.4.*,!=2.5.*,!=2.6.*,!=2.7.*", + "google-api-core[grpc] >= 1.33.1, <3.0.0dev,!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.*,!=2.4.*,!=2.5.*,!=2.6.*,!=2.7.*", "proto-plus >= 1.22.0, <2.0.0dev", - "protobuf >= 3.19.0, <5.0.0dev", + "protobuf >= 3.20.1, <5.0.0dev", ), python_requires=">=3.7", classifiers=[ diff --git a/packages/google-area120-tables/testing/constraints-3.7.txt b/packages/google-area120-tables/testing/constraints-3.7.txt index 51901fbcf804..dfb70ba334d5 100644 --- a/packages/google-area120-tables/testing/constraints-3.7.txt +++ b/packages/google-area120-tables/testing/constraints-3.7.txt @@ -5,6 +5,6 @@ # # e.g., if setup.py has "foo >= 1.14.0, < 2.0.0dev", # Then this file should have foo==1.14.0 -google-api-core==1.32.0 +google-api-core==1.33.1 proto-plus==1.22.0 -protobuf==3.19.0 +protobuf==3.20.1 diff --git a/packages/google-area120-tables/tests/unit/gapic/tables_v1alpha1/test_tables_service.py b/packages/google-area120-tables/tests/unit/gapic/tables_v1alpha1/test_tables_service.py index 8bdfa773b45c..154cb804c67e 100644 --- a/packages/google-area120-tables/tests/unit/gapic/tables_v1alpha1/test_tables_service.py +++ b/packages/google-area120-tables/tests/unit/gapic/tables_v1alpha1/test_tables_service.py @@ -22,6 +22,8 @@ except ImportError: # pragma: NO COVER import mock +from collections.abc import Iterable +import json import math from google.api_core import gapic_v1, grpc_helpers, grpc_helpers_async, path_template @@ -32,12 +34,15 @@ from google.auth.exceptions import MutualTLSChannelError from google.oauth2 import service_account from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import json_format from google.protobuf import struct_pb2 # type: ignore import grpc from grpc.experimental import aio from proto.marshal.rules import wrappers from proto.marshal.rules.dates import DurationRule, TimestampRule import pytest +from requests import PreparedRequest, Request, Response +from requests.sessions import Session from google.area120.tables_v1alpha1.services.tables_service import ( TablesServiceAsyncClient, @@ -97,6 +102,7 @@ def test__get_default_mtls_endpoint(): [ (TablesServiceClient, "grpc"), (TablesServiceAsyncClient, "grpc_asyncio"), + (TablesServiceClient, "rest"), ], ) def test_tables_service_client_from_service_account_info(client_class, transport_name): @@ -110,7 +116,11 @@ def test_tables_service_client_from_service_account_info(client_class, transport assert client.transport._credentials == creds assert isinstance(client, client_class) - assert client.transport._host == ("area120tables.googleapis.com:443") + assert client.transport._host == ( + "area120tables.googleapis.com:443" + if transport_name in ["grpc", "grpc_asyncio"] + else "https://area120tables.googleapis.com" + ) @pytest.mark.parametrize( @@ -118,6 +128,7 @@ def test_tables_service_client_from_service_account_info(client_class, transport [ (transports.TablesServiceGrpcTransport, "grpc"), (transports.TablesServiceGrpcAsyncIOTransport, "grpc_asyncio"), + (transports.TablesServiceRestTransport, "rest"), ], ) def test_tables_service_client_service_account_always_use_jwt( @@ -143,6 +154,7 @@ def test_tables_service_client_service_account_always_use_jwt( [ (TablesServiceClient, "grpc"), (TablesServiceAsyncClient, "grpc_asyncio"), + (TablesServiceClient, "rest"), ], ) def test_tables_service_client_from_service_account_file(client_class, transport_name): @@ -163,13 +175,18 @@ def test_tables_service_client_from_service_account_file(client_class, transport assert client.transport._credentials == creds assert isinstance(client, client_class) - assert client.transport._host == ("area120tables.googleapis.com:443") + assert client.transport._host == ( + "area120tables.googleapis.com:443" + if transport_name in ["grpc", "grpc_asyncio"] + else "https://area120tables.googleapis.com" + ) def test_tables_service_client_get_transport_class(): transport = TablesServiceClient.get_transport_class() available_transports = [ transports.TablesServiceGrpcTransport, + transports.TablesServiceRestTransport, ] assert transport in available_transports @@ -186,6 +203,7 @@ def test_tables_service_client_get_transport_class(): transports.TablesServiceGrpcAsyncIOTransport, "grpc_asyncio", ), + (TablesServiceClient, transports.TablesServiceRestTransport, "rest"), ], ) @mock.patch.object( @@ -331,6 +349,8 @@ def test_tables_service_client_client_options( "grpc_asyncio", "false", ), + (TablesServiceClient, transports.TablesServiceRestTransport, "rest", "true"), + (TablesServiceClient, transports.TablesServiceRestTransport, "rest", "false"), ], ) @mock.patch.object( @@ -530,6 +550,7 @@ def test_tables_service_client_get_mtls_endpoint_and_cert_source(client_class): transports.TablesServiceGrpcAsyncIOTransport, "grpc_asyncio", ), + (TablesServiceClient, transports.TablesServiceRestTransport, "rest"), ], ) def test_tables_service_client_client_options_scopes( @@ -570,6 +591,7 @@ def test_tables_service_client_client_options_scopes( "grpc_asyncio", grpc_helpers_async, ), + (TablesServiceClient, transports.TablesServiceRestTransport, "rest", None), ], ) def test_tables_service_client_client_options_credentials_file( @@ -3503,214 +3525,3134 @@ async def test_batch_delete_rows_field_headers_async(): ) in kw["metadata"] -def test_credentials_transport_error(): - # It is an error to provide credentials and a transport instance. - transport = transports.TablesServiceGrpcTransport( +@pytest.mark.parametrize( + "request_type", + [ + tables.GetTableRequest, + dict, + ], +) +def test_get_table_rest(request_type): + client = TablesServiceClient( credentials=ga_credentials.AnonymousCredentials(), + transport="rest", ) - with pytest.raises(ValueError): - client = TablesServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, + + # send a request that will satisfy transcoding + request_init = {"name": "tables/sample1"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = tables.Table( + name="name_value", + display_name="display_name_value", ) - # It is an error to provide a credentials file and a transport instance. - transport = transports.TablesServiceGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - with pytest.raises(ValueError): - client = TablesServiceClient( - client_options={"credentials_file": "credentials.json"}, - transport=transport, + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = tables.Table.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + response = client.get_table(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, tables.Table) + assert response.name == "name_value" + assert response.display_name == "display_name_value" + + +def test_get_table_rest_required_fields(request_type=tables.GetTableRequest): + transport_class = transports.TablesServiceRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False, ) + ) - # It is an error to provide an api_key and a transport instance. - transport = transports.TablesServiceGrpcTransport( + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).get_table._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = "name_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).get_table._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" + + client = TablesServiceClient( credentials=ga_credentials.AnonymousCredentials(), + transport="rest", ) - options = client_options.ClientOptions() - options.api_key = "api_key" - with pytest.raises(ValueError): - client = TablesServiceClient( - client_options=options, - transport=transport, - ) + request = request_type(**request_init) - # It is an error to provide an api_key and a credential. - options = mock.Mock() - options.api_key = "api_key" - with pytest.raises(ValueError): - client = TablesServiceClient( - client_options=options, credentials=ga_credentials.AnonymousCredentials() - ) + # Designate an appropriate value for the returned response. + return_value = tables.Table() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "get", + "query_params": pb_request, + } + transcode.return_value = transcode_result - # It is an error to provide scopes and a transport instance. - transport = transports.TablesServiceGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), + response_value = Response() + response_value.status_code = 200 + + pb_return_value = tables.Table.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.get_table(request) + + expected_params = [] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_get_table_rest_unset_required_fields(): + transport = transports.TablesServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials ) - with pytest.raises(ValueError): - client = TablesServiceClient( - client_options={"scopes": ["1", "2"]}, - transport=transport, - ) + unset_fields = transport.get_table._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name",))) -def test_transport_instance(): - # A client may be instantiated with a custom transport instance. - transport = transports.TablesServiceGrpcTransport( + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_get_table_rest_interceptors(null_interceptor): + transport = transports.TablesServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.TablesServiceRestInterceptor(), ) client = TablesServiceClient(transport=transport) - assert client.transport is transport + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + transports.TablesServiceRestInterceptor, "post_get_table" + ) as post, mock.patch.object( + transports.TablesServiceRestInterceptor, "pre_get_table" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = tables.GetTableRequest.pb(tables.GetTableRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + req.return_value._content = tables.Table.to_json(tables.Table()) + + request = tables.GetTableRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = tables.Table() + client.get_table( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) -def test_transport_get_channel(): - # A client may be instantiated with a custom transport instance. - transport = transports.TablesServiceGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - channel = transport.grpc_channel - assert channel + pre.assert_called_once() + post.assert_called_once() - transport = transports.TablesServiceGrpcAsyncIOTransport( + +def test_get_table_rest_bad_request( + transport: str = "rest", request_type=tables.GetTableRequest +): + client = TablesServiceClient( credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) - channel = transport.grpc_channel - assert channel + # send a request that will satisfy transcoding + request_init = {"name": "tables/sample1"} + request = request_type(**request_init) -@pytest.mark.parametrize( - "transport_class", - [ - transports.TablesServiceGrpcTransport, - transports.TablesServiceGrpcAsyncIOTransport, - ], -) -def test_transport_adc(transport_class): - # Test default credentials are used if not provided. - with mock.patch.object(google.auth, "default") as adc: - adc.return_value = (ga_credentials.AnonymousCredentials(), None) - transport_class() - adc.assert_called_once() + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.get_table(request) -@pytest.mark.parametrize( - "transport_name", - [ - "grpc", - ], -) -def test_transport_kind(transport_name): - transport = TablesServiceClient.get_transport_class(transport_name)( +def test_get_table_rest_flattened(): + client = TablesServiceClient( credentials=ga_credentials.AnonymousCredentials(), + transport="rest", ) - assert transport.kind == transport_name + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = tables.Table() -def test_transport_grpc_default(): - # A client should use the gRPC transport by default. + # get arguments that satisfy an http rule for this method + sample_request = {"name": "tables/sample1"} + + # get truthy value for each flattened field + mock_args = dict( + name="name_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = tables.Table.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.get_table(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1alpha1/{name=tables/*}" % client.transport._host, args[1] + ) + + +def test_get_table_rest_flattened_error(transport: str = "rest"): client = TablesServiceClient( credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) - assert isinstance( - client.transport, - transports.TablesServiceGrpcTransport, + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_table( + tables.GetTableRequest(), + name="name_value", + ) + + +def test_get_table_rest_error(): + client = TablesServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) -def test_tables_service_base_transport_error(): - # Passing both a credentials object and credentials_file should raise an error - with pytest.raises(core_exceptions.DuplicateCredentialArgs): - transport = transports.TablesServiceTransport( - credentials=ga_credentials.AnonymousCredentials(), - credentials_file="credentials.json", - ) +@pytest.mark.parametrize( + "request_type", + [ + tables.ListTablesRequest, + dict, + ], +) +def test_list_tables_rest(request_type): + client = TablesServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + # send a request that will satisfy transcoding + request_init = {} + request = request_type(**request_init) -def test_tables_service_base_transport(): - # Instantiate the base transport. - with mock.patch( - "google.area120.tables_v1alpha1.services.tables_service.transports.TablesServiceTransport.__init__" - ) as Transport: - Transport.return_value = None - transport = transports.TablesServiceTransport( - credentials=ga_credentials.AnonymousCredentials(), + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = tables.ListTablesResponse( + next_page_token="next_page_token_value", ) - # Every method on the transport should just blindly - # raise NotImplementedError. - methods = ( - "get_table", - "list_tables", - "get_workspace", - "list_workspaces", - "get_row", - "list_rows", - "create_row", - "batch_create_rows", - "update_row", - "batch_update_rows", - "delete_row", - "batch_delete_rows", - ) - for method in methods: - with pytest.raises(NotImplementedError): - getattr(transport, method)(request=object()) + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = tables.ListTablesResponse.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) - with pytest.raises(NotImplementedError): - transport.close() + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + response = client.list_tables(request) - # Catch all for all remaining methods and properties - remainder = [ - "kind", - ] - for r in remainder: - with pytest.raises(NotImplementedError): - getattr(transport, r)() + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListTablesPager) + assert response.next_page_token == "next_page_token_value" -def test_tables_service_base_transport_with_credentials_file(): - # Instantiate the base transport with a credentials file +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_list_tables_rest_interceptors(null_interceptor): + transport = transports.TablesServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.TablesServiceRestInterceptor(), + ) + client = TablesServiceClient(transport=transport) with mock.patch.object( - google.auth, "load_credentials_from_file", autospec=True - ) as load_creds, mock.patch( - "google.area120.tables_v1alpha1.services.tables_service.transports.TablesServiceTransport._prep_wrapped_messages" - ) as Transport: - Transport.return_value = None - load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) - transport = transports.TablesServiceTransport( - credentials_file="credentials.json", - quota_project_id="octopus", + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + transports.TablesServiceRestInterceptor, "post_list_tables" + ) as post, mock.patch.object( + transports.TablesServiceRestInterceptor, "pre_list_tables" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = tables.ListTablesRequest.pb(tables.ListTablesRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + req.return_value._content = tables.ListTablesResponse.to_json( + tables.ListTablesResponse() ) - load_creds.assert_called_once_with( - "credentials.json", - scopes=None, - default_scopes=( - "https://www.googleapis.com/auth/drive", - "https://www.googleapis.com/auth/drive.file", - "https://www.googleapis.com/auth/drive.readonly", - "https://www.googleapis.com/auth/spreadsheets", - "https://www.googleapis.com/auth/spreadsheets.readonly", - "https://www.googleapis.com/auth/tables", - ), - quota_project_id="octopus", + + request = tables.ListTablesRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = tables.ListTablesResponse() + + client.list_tables( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], ) + pre.assert_called_once() + post.assert_called_once() -def test_tables_service_base_transport_with_adc(): - # Test the default credentials are used if credentials and credentials_file are None. - with mock.patch.object(google.auth, "default", autospec=True) as adc, mock.patch( - "google.area120.tables_v1alpha1.services.tables_service.transports.TablesServiceTransport._prep_wrapped_messages" - ) as Transport: - Transport.return_value = None - adc.return_value = (ga_credentials.AnonymousCredentials(), None) - transport = transports.TablesServiceTransport() - adc.assert_called_once() +def test_list_tables_rest_bad_request( + transport: str = "rest", request_type=tables.ListTablesRequest +): + client = TablesServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) -def test_tables_service_auth_adc(): - # If no credentials are provided, we should use ADC credentials. - with mock.patch.object(google.auth, "default", autospec=True) as adc: + # send a request that will satisfy transcoding + request_init = {} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.list_tables(request) + + +def test_list_tables_rest_pager(transport: str = "rest"): + client = TablesServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # TODO(kbandes): remove this mock unless there's a good reason for it. + # with mock.patch.object(path_template, 'transcode') as transcode: + # Set the response as a series of pages + response = ( + tables.ListTablesResponse( + tables=[ + tables.Table(), + tables.Table(), + tables.Table(), + ], + next_page_token="abc", + ), + tables.ListTablesResponse( + tables=[], + next_page_token="def", + ), + tables.ListTablesResponse( + tables=[ + tables.Table(), + ], + next_page_token="ghi", + ), + tables.ListTablesResponse( + tables=[ + tables.Table(), + tables.Table(), + ], + ), + ) + # Two responses for two calls + response = response + response + + # Wrap the values into proper Response objs + response = tuple(tables.ListTablesResponse.to_json(x) for x in response) + return_values = tuple(Response() for i in response) + for return_val, response_val in zip(return_values, response): + return_val._content = response_val.encode("UTF-8") + return_val.status_code = 200 + req.side_effect = return_values + + sample_request = {} + + pager = client.list_tables(request=sample_request) + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, tables.Table) for i in results) + + pages = list(client.list_tables(request=sample_request).pages) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token + + +@pytest.mark.parametrize( + "request_type", + [ + tables.GetWorkspaceRequest, + dict, + ], +) +def test_get_workspace_rest(request_type): + client = TablesServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = {"name": "workspaces/sample1"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = tables.Workspace( + name="name_value", + display_name="display_name_value", + ) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = tables.Workspace.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + response = client.get_workspace(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, tables.Workspace) + assert response.name == "name_value" + assert response.display_name == "display_name_value" + + +def test_get_workspace_rest_required_fields(request_type=tables.GetWorkspaceRequest): + transport_class = transports.TablesServiceRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False, + ) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).get_workspace._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = "name_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).get_workspace._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" + + client = TablesServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = tables.Workspace() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "get", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + pb_return_value = tables.Workspace.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.get_workspace(request) + + expected_params = [] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_get_workspace_rest_unset_required_fields(): + transport = transports.TablesServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.get_workspace._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name",))) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_get_workspace_rest_interceptors(null_interceptor): + transport = transports.TablesServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.TablesServiceRestInterceptor(), + ) + client = TablesServiceClient(transport=transport) + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + transports.TablesServiceRestInterceptor, "post_get_workspace" + ) as post, mock.patch.object( + transports.TablesServiceRestInterceptor, "pre_get_workspace" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = tables.GetWorkspaceRequest.pb(tables.GetWorkspaceRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + req.return_value._content = tables.Workspace.to_json(tables.Workspace()) + + request = tables.GetWorkspaceRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = tables.Workspace() + + client.get_workspace( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + + +def test_get_workspace_rest_bad_request( + transport: str = "rest", request_type=tables.GetWorkspaceRequest +): + client = TablesServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = {"name": "workspaces/sample1"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.get_workspace(request) + + +def test_get_workspace_rest_flattened(): + client = TablesServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = tables.Workspace() + + # get arguments that satisfy an http rule for this method + sample_request = {"name": "workspaces/sample1"} + + # get truthy value for each flattened field + mock_args = dict( + name="name_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = tables.Workspace.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.get_workspace(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1alpha1/{name=workspaces/*}" % client.transport._host, args[1] + ) + + +def test_get_workspace_rest_flattened_error(transport: str = "rest"): + client = TablesServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_workspace( + tables.GetWorkspaceRequest(), + name="name_value", + ) + + +def test_get_workspace_rest_error(): + client = TablesServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + +@pytest.mark.parametrize( + "request_type", + [ + tables.ListWorkspacesRequest, + dict, + ], +) +def test_list_workspaces_rest(request_type): + client = TablesServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = {} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = tables.ListWorkspacesResponse( + next_page_token="next_page_token_value", + ) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = tables.ListWorkspacesResponse.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + response = client.list_workspaces(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListWorkspacesPager) + assert response.next_page_token == "next_page_token_value" + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_list_workspaces_rest_interceptors(null_interceptor): + transport = transports.TablesServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.TablesServiceRestInterceptor(), + ) + client = TablesServiceClient(transport=transport) + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + transports.TablesServiceRestInterceptor, "post_list_workspaces" + ) as post, mock.patch.object( + transports.TablesServiceRestInterceptor, "pre_list_workspaces" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = tables.ListWorkspacesRequest.pb(tables.ListWorkspacesRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + req.return_value._content = tables.ListWorkspacesResponse.to_json( + tables.ListWorkspacesResponse() + ) + + request = tables.ListWorkspacesRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = tables.ListWorkspacesResponse() + + client.list_workspaces( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + + +def test_list_workspaces_rest_bad_request( + transport: str = "rest", request_type=tables.ListWorkspacesRequest +): + client = TablesServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = {} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.list_workspaces(request) + + +def test_list_workspaces_rest_pager(transport: str = "rest"): + client = TablesServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # TODO(kbandes): remove this mock unless there's a good reason for it. + # with mock.patch.object(path_template, 'transcode') as transcode: + # Set the response as a series of pages + response = ( + tables.ListWorkspacesResponse( + workspaces=[ + tables.Workspace(), + tables.Workspace(), + tables.Workspace(), + ], + next_page_token="abc", + ), + tables.ListWorkspacesResponse( + workspaces=[], + next_page_token="def", + ), + tables.ListWorkspacesResponse( + workspaces=[ + tables.Workspace(), + ], + next_page_token="ghi", + ), + tables.ListWorkspacesResponse( + workspaces=[ + tables.Workspace(), + tables.Workspace(), + ], + ), + ) + # Two responses for two calls + response = response + response + + # Wrap the values into proper Response objs + response = tuple(tables.ListWorkspacesResponse.to_json(x) for x in response) + return_values = tuple(Response() for i in response) + for return_val, response_val in zip(return_values, response): + return_val._content = response_val.encode("UTF-8") + return_val.status_code = 200 + req.side_effect = return_values + + sample_request = {} + + pager = client.list_workspaces(request=sample_request) + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, tables.Workspace) for i in results) + + pages = list(client.list_workspaces(request=sample_request).pages) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token + + +@pytest.mark.parametrize( + "request_type", + [ + tables.GetRowRequest, + dict, + ], +) +def test_get_row_rest(request_type): + client = TablesServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = {"name": "tables/sample1/rows/sample2"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = tables.Row( + name="name_value", + ) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = tables.Row.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + response = client.get_row(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, tables.Row) + assert response.name == "name_value" + + +def test_get_row_rest_required_fields(request_type=tables.GetRowRequest): + transport_class = transports.TablesServiceRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False, + ) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).get_row._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = "name_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).get_row._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("view",)) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" + + client = TablesServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = tables.Row() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "get", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + pb_return_value = tables.Row.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.get_row(request) + + expected_params = [] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_get_row_rest_unset_required_fields(): + transport = transports.TablesServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.get_row._get_unset_required_fields({}) + assert set(unset_fields) == (set(("view",)) & set(("name",))) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_get_row_rest_interceptors(null_interceptor): + transport = transports.TablesServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.TablesServiceRestInterceptor(), + ) + client = TablesServiceClient(transport=transport) + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + transports.TablesServiceRestInterceptor, "post_get_row" + ) as post, mock.patch.object( + transports.TablesServiceRestInterceptor, "pre_get_row" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = tables.GetRowRequest.pb(tables.GetRowRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + req.return_value._content = tables.Row.to_json(tables.Row()) + + request = tables.GetRowRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = tables.Row() + + client.get_row( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + + +def test_get_row_rest_bad_request( + transport: str = "rest", request_type=tables.GetRowRequest +): + client = TablesServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = {"name": "tables/sample1/rows/sample2"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.get_row(request) + + +def test_get_row_rest_flattened(): + client = TablesServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = tables.Row() + + # get arguments that satisfy an http rule for this method + sample_request = {"name": "tables/sample1/rows/sample2"} + + # get truthy value for each flattened field + mock_args = dict( + name="name_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = tables.Row.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.get_row(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1alpha1/{name=tables/*/rows/*}" % client.transport._host, args[1] + ) + + +def test_get_row_rest_flattened_error(transport: str = "rest"): + client = TablesServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_row( + tables.GetRowRequest(), + name="name_value", + ) + + +def test_get_row_rest_error(): + client = TablesServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + +@pytest.mark.parametrize( + "request_type", + [ + tables.ListRowsRequest, + dict, + ], +) +def test_list_rows_rest(request_type): + client = TablesServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = {"parent": "tables/sample1"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = tables.ListRowsResponse( + next_page_token="next_page_token_value", + ) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = tables.ListRowsResponse.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + response = client.list_rows(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListRowsPager) + assert response.next_page_token == "next_page_token_value" + + +def test_list_rows_rest_required_fields(request_type=tables.ListRowsRequest): + transport_class = transports.TablesServiceRestTransport + + request_init = {} + request_init["parent"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False, + ) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).list_rows._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["parent"] = "parent_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).list_rows._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set( + ( + "filter", + "page_size", + "page_token", + "view", + ) + ) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" + + client = TablesServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = tables.ListRowsResponse() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "get", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + pb_return_value = tables.ListRowsResponse.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.list_rows(request) + + expected_params = [] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_list_rows_rest_unset_required_fields(): + transport = transports.TablesServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.list_rows._get_unset_required_fields({}) + assert set(unset_fields) == ( + set( + ( + "filter", + "pageSize", + "pageToken", + "view", + ) + ) + & set(("parent",)) + ) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_list_rows_rest_interceptors(null_interceptor): + transport = transports.TablesServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.TablesServiceRestInterceptor(), + ) + client = TablesServiceClient(transport=transport) + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + transports.TablesServiceRestInterceptor, "post_list_rows" + ) as post, mock.patch.object( + transports.TablesServiceRestInterceptor, "pre_list_rows" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = tables.ListRowsRequest.pb(tables.ListRowsRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + req.return_value._content = tables.ListRowsResponse.to_json( + tables.ListRowsResponse() + ) + + request = tables.ListRowsRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = tables.ListRowsResponse() + + client.list_rows( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + + +def test_list_rows_rest_bad_request( + transport: str = "rest", request_type=tables.ListRowsRequest +): + client = TablesServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = {"parent": "tables/sample1"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.list_rows(request) + + +def test_list_rows_rest_flattened(): + client = TablesServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = tables.ListRowsResponse() + + # get arguments that satisfy an http rule for this method + sample_request = {"parent": "tables/sample1"} + + # get truthy value for each flattened field + mock_args = dict( + parent="parent_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = tables.ListRowsResponse.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.list_rows(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1alpha1/{parent=tables/*}/rows" % client.transport._host, args[1] + ) + + +def test_list_rows_rest_flattened_error(transport: str = "rest"): + client = TablesServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_rows( + tables.ListRowsRequest(), + parent="parent_value", + ) + + +def test_list_rows_rest_pager(transport: str = "rest"): + client = TablesServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # TODO(kbandes): remove this mock unless there's a good reason for it. + # with mock.patch.object(path_template, 'transcode') as transcode: + # Set the response as a series of pages + response = ( + tables.ListRowsResponse( + rows=[ + tables.Row(), + tables.Row(), + tables.Row(), + ], + next_page_token="abc", + ), + tables.ListRowsResponse( + rows=[], + next_page_token="def", + ), + tables.ListRowsResponse( + rows=[ + tables.Row(), + ], + next_page_token="ghi", + ), + tables.ListRowsResponse( + rows=[ + tables.Row(), + tables.Row(), + ], + ), + ) + # Two responses for two calls + response = response + response + + # Wrap the values into proper Response objs + response = tuple(tables.ListRowsResponse.to_json(x) for x in response) + return_values = tuple(Response() for i in response) + for return_val, response_val in zip(return_values, response): + return_val._content = response_val.encode("UTF-8") + return_val.status_code = 200 + req.side_effect = return_values + + sample_request = {"parent": "tables/sample1"} + + pager = client.list_rows(request=sample_request) + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, tables.Row) for i in results) + + pages = list(client.list_rows(request=sample_request).pages) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token + + +@pytest.mark.parametrize( + "request_type", + [ + tables.CreateRowRequest, + dict, + ], +) +def test_create_row_rest(request_type): + client = TablesServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = {"parent": "tables/sample1"} + request_init["row"] = {"name": "name_value", "values": {}} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = tables.Row( + name="name_value", + ) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = tables.Row.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + response = client.create_row(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, tables.Row) + assert response.name == "name_value" + + +def test_create_row_rest_required_fields(request_type=tables.CreateRowRequest): + transport_class = transports.TablesServiceRestTransport + + request_init = {} + request_init["parent"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False, + ) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).create_row._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["parent"] = "parent_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).create_row._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("view",)) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" + + client = TablesServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = tables.Row() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "post", + "query_params": pb_request, + } + transcode_result["body"] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + pb_return_value = tables.Row.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.create_row(request) + + expected_params = [] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_create_row_rest_unset_required_fields(): + transport = transports.TablesServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.create_row._get_unset_required_fields({}) + assert set(unset_fields) == ( + set(("view",)) + & set( + ( + "parent", + "row", + ) + ) + ) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_create_row_rest_interceptors(null_interceptor): + transport = transports.TablesServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.TablesServiceRestInterceptor(), + ) + client = TablesServiceClient(transport=transport) + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + transports.TablesServiceRestInterceptor, "post_create_row" + ) as post, mock.patch.object( + transports.TablesServiceRestInterceptor, "pre_create_row" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = tables.CreateRowRequest.pb(tables.CreateRowRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + req.return_value._content = tables.Row.to_json(tables.Row()) + + request = tables.CreateRowRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = tables.Row() + + client.create_row( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + + +def test_create_row_rest_bad_request( + transport: str = "rest", request_type=tables.CreateRowRequest +): + client = TablesServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = {"parent": "tables/sample1"} + request_init["row"] = {"name": "name_value", "values": {}} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.create_row(request) + + +def test_create_row_rest_flattened(): + client = TablesServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = tables.Row() + + # get arguments that satisfy an http rule for this method + sample_request = {"parent": "tables/sample1"} + + # get truthy value for each flattened field + mock_args = dict( + parent="parent_value", + row=tables.Row(name="name_value"), + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = tables.Row.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.create_row(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1alpha1/{parent=tables/*}/rows" % client.transport._host, args[1] + ) + + +def test_create_row_rest_flattened_error(transport: str = "rest"): + client = TablesServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.create_row( + tables.CreateRowRequest(), + parent="parent_value", + row=tables.Row(name="name_value"), + ) + + +def test_create_row_rest_error(): + client = TablesServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + +@pytest.mark.parametrize( + "request_type", + [ + tables.BatchCreateRowsRequest, + dict, + ], +) +def test_batch_create_rows_rest(request_type): + client = TablesServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = {"parent": "tables/sample1"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = tables.BatchCreateRowsResponse() + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = tables.BatchCreateRowsResponse.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + response = client.batch_create_rows(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, tables.BatchCreateRowsResponse) + + +def test_batch_create_rows_rest_required_fields( + request_type=tables.BatchCreateRowsRequest, +): + transport_class = transports.TablesServiceRestTransport + + request_init = {} + request_init["parent"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False, + ) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).batch_create_rows._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["parent"] = "parent_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).batch_create_rows._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" + + client = TablesServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = tables.BatchCreateRowsResponse() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "post", + "query_params": pb_request, + } + transcode_result["body"] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + pb_return_value = tables.BatchCreateRowsResponse.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.batch_create_rows(request) + + expected_params = [] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_batch_create_rows_rest_unset_required_fields(): + transport = transports.TablesServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.batch_create_rows._get_unset_required_fields({}) + assert set(unset_fields) == ( + set(()) + & set( + ( + "parent", + "requests", + ) + ) + ) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_batch_create_rows_rest_interceptors(null_interceptor): + transport = transports.TablesServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.TablesServiceRestInterceptor(), + ) + client = TablesServiceClient(transport=transport) + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + transports.TablesServiceRestInterceptor, "post_batch_create_rows" + ) as post, mock.patch.object( + transports.TablesServiceRestInterceptor, "pre_batch_create_rows" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = tables.BatchCreateRowsRequest.pb(tables.BatchCreateRowsRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + req.return_value._content = tables.BatchCreateRowsResponse.to_json( + tables.BatchCreateRowsResponse() + ) + + request = tables.BatchCreateRowsRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = tables.BatchCreateRowsResponse() + + client.batch_create_rows( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + + +def test_batch_create_rows_rest_bad_request( + transport: str = "rest", request_type=tables.BatchCreateRowsRequest +): + client = TablesServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = {"parent": "tables/sample1"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.batch_create_rows(request) + + +def test_batch_create_rows_rest_error(): + client = TablesServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + +@pytest.mark.parametrize( + "request_type", + [ + tables.UpdateRowRequest, + dict, + ], +) +def test_update_row_rest(request_type): + client = TablesServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = {"row": {"name": "tables/sample1/rows/sample2"}} + request_init["row"] = {"name": "tables/sample1/rows/sample2", "values": {}} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = tables.Row( + name="name_value", + ) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = tables.Row.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + response = client.update_row(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, tables.Row) + assert response.name == "name_value" + + +def test_update_row_rest_required_fields(request_type=tables.UpdateRowRequest): + transport_class = transports.TablesServiceRestTransport + + request_init = {} + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False, + ) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).update_row._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).update_row._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set( + ( + "update_mask", + "view", + ) + ) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + + client = TablesServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = tables.Row() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "patch", + "query_params": pb_request, + } + transcode_result["body"] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + pb_return_value = tables.Row.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.update_row(request) + + expected_params = [] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_update_row_rest_unset_required_fields(): + transport = transports.TablesServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.update_row._get_unset_required_fields({}) + assert set(unset_fields) == ( + set( + ( + "updateMask", + "view", + ) + ) + & set(("row",)) + ) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_update_row_rest_interceptors(null_interceptor): + transport = transports.TablesServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.TablesServiceRestInterceptor(), + ) + client = TablesServiceClient(transport=transport) + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + transports.TablesServiceRestInterceptor, "post_update_row" + ) as post, mock.patch.object( + transports.TablesServiceRestInterceptor, "pre_update_row" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = tables.UpdateRowRequest.pb(tables.UpdateRowRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + req.return_value._content = tables.Row.to_json(tables.Row()) + + request = tables.UpdateRowRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = tables.Row() + + client.update_row( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + + +def test_update_row_rest_bad_request( + transport: str = "rest", request_type=tables.UpdateRowRequest +): + client = TablesServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = {"row": {"name": "tables/sample1/rows/sample2"}} + request_init["row"] = {"name": "tables/sample1/rows/sample2", "values": {}} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.update_row(request) + + +def test_update_row_rest_flattened(): + client = TablesServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = tables.Row() + + # get arguments that satisfy an http rule for this method + sample_request = {"row": {"name": "tables/sample1/rows/sample2"}} + + # get truthy value for each flattened field + mock_args = dict( + row=tables.Row(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = tables.Row.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.update_row(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1alpha1/{row.name=tables/*/rows/*}" % client.transport._host, args[1] + ) + + +def test_update_row_rest_flattened_error(transport: str = "rest"): + client = TablesServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.update_row( + tables.UpdateRowRequest(), + row=tables.Row(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + + +def test_update_row_rest_error(): + client = TablesServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + +@pytest.mark.parametrize( + "request_type", + [ + tables.BatchUpdateRowsRequest, + dict, + ], +) +def test_batch_update_rows_rest(request_type): + client = TablesServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = {"parent": "tables/sample1"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = tables.BatchUpdateRowsResponse() + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + pb_return_value = tables.BatchUpdateRowsResponse.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + response = client.batch_update_rows(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, tables.BatchUpdateRowsResponse) + + +def test_batch_update_rows_rest_required_fields( + request_type=tables.BatchUpdateRowsRequest, +): + transport_class = transports.TablesServiceRestTransport + + request_init = {} + request_init["parent"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False, + ) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).batch_update_rows._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["parent"] = "parent_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).batch_update_rows._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" + + client = TablesServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = tables.BatchUpdateRowsResponse() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "post", + "query_params": pb_request, + } + transcode_result["body"] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + pb_return_value = tables.BatchUpdateRowsResponse.pb(return_value) + json_return_value = json_format.MessageToJson(pb_return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.batch_update_rows(request) + + expected_params = [] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_batch_update_rows_rest_unset_required_fields(): + transport = transports.TablesServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.batch_update_rows._get_unset_required_fields({}) + assert set(unset_fields) == ( + set(()) + & set( + ( + "parent", + "requests", + ) + ) + ) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_batch_update_rows_rest_interceptors(null_interceptor): + transport = transports.TablesServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.TablesServiceRestInterceptor(), + ) + client = TablesServiceClient(transport=transport) + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + transports.TablesServiceRestInterceptor, "post_batch_update_rows" + ) as post, mock.patch.object( + transports.TablesServiceRestInterceptor, "pre_batch_update_rows" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = tables.BatchUpdateRowsRequest.pb(tables.BatchUpdateRowsRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + req.return_value._content = tables.BatchUpdateRowsResponse.to_json( + tables.BatchUpdateRowsResponse() + ) + + request = tables.BatchUpdateRowsRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = tables.BatchUpdateRowsResponse() + + client.batch_update_rows( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + + +def test_batch_update_rows_rest_bad_request( + transport: str = "rest", request_type=tables.BatchUpdateRowsRequest +): + client = TablesServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = {"parent": "tables/sample1"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.batch_update_rows(request) + + +def test_batch_update_rows_rest_error(): + client = TablesServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + +@pytest.mark.parametrize( + "request_type", + [ + tables.DeleteRowRequest, + dict, + ], +) +def test_delete_row_rest(request_type): + client = TablesServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = {"name": "tables/sample1/rows/sample2"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = None + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = "" + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + response = client.delete_row(request) + + # Establish that the response is the type that we expect. + assert response is None + + +def test_delete_row_rest_required_fields(request_type=tables.DeleteRowRequest): + transport_class = transports.TablesServiceRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False, + ) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).delete_row._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = "name_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).delete_row._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" + + client = TablesServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = None + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "delete", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = "" + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.delete_row(request) + + expected_params = [] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_delete_row_rest_unset_required_fields(): + transport = transports.TablesServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.delete_row._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name",))) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_delete_row_rest_interceptors(null_interceptor): + transport = transports.TablesServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.TablesServiceRestInterceptor(), + ) + client = TablesServiceClient(transport=transport) + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + transports.TablesServiceRestInterceptor, "pre_delete_row" + ) as pre: + pre.assert_not_called() + pb_message = tables.DeleteRowRequest.pb(tables.DeleteRowRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + + request = tables.DeleteRowRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + + client.delete_row( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + + +def test_delete_row_rest_bad_request( + transport: str = "rest", request_type=tables.DeleteRowRequest +): + client = TablesServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = {"name": "tables/sample1/rows/sample2"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.delete_row(request) + + +def test_delete_row_rest_flattened(): + client = TablesServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = None + + # get arguments that satisfy an http rule for this method + sample_request = {"name": "tables/sample1/rows/sample2"} + + # get truthy value for each flattened field + mock_args = dict( + name="name_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = "" + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + client.delete_row(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1alpha1/{name=tables/*/rows/*}" % client.transport._host, args[1] + ) + + +def test_delete_row_rest_flattened_error(transport: str = "rest"): + client = TablesServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.delete_row( + tables.DeleteRowRequest(), + name="name_value", + ) + + +def test_delete_row_rest_error(): + client = TablesServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + +@pytest.mark.parametrize( + "request_type", + [ + tables.BatchDeleteRowsRequest, + dict, + ], +) +def test_batch_delete_rows_rest(request_type): + client = TablesServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = {"parent": "tables/sample1"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = None + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = "" + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + response = client.batch_delete_rows(request) + + # Establish that the response is the type that we expect. + assert response is None + + +def test_batch_delete_rows_rest_required_fields( + request_type=tables.BatchDeleteRowsRequest, +): + transport_class = transports.TablesServiceRestTransport + + request_init = {} + request_init["parent"] = "" + request_init["names"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False, + ) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).batch_delete_rows._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["parent"] = "parent_value" + jsonified_request["names"] = "names_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).batch_delete_rows._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" + assert "names" in jsonified_request + assert jsonified_request["names"] == "names_value" + + client = TablesServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = None + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "post", + "query_params": pb_request, + } + transcode_result["body"] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = "" + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + + response = client.batch_delete_rows(request) + + expected_params = [] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_batch_delete_rows_rest_unset_required_fields(): + transport = transports.TablesServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.batch_delete_rows._get_unset_required_fields({}) + assert set(unset_fields) == ( + set(()) + & set( + ( + "parent", + "names", + ) + ) + ) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_batch_delete_rows_rest_interceptors(null_interceptor): + transport = transports.TablesServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.TablesServiceRestInterceptor(), + ) + client = TablesServiceClient(transport=transport) + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + transports.TablesServiceRestInterceptor, "pre_batch_delete_rows" + ) as pre: + pre.assert_not_called() + pb_message = tables.BatchDeleteRowsRequest.pb(tables.BatchDeleteRowsRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + + request = tables.BatchDeleteRowsRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + + client.batch_delete_rows( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + + +def test_batch_delete_rows_rest_bad_request( + transport: str = "rest", request_type=tables.BatchDeleteRowsRequest +): + client = TablesServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = {"parent": "tables/sample1"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.batch_delete_rows(request) + + +def test_batch_delete_rows_rest_error(): + client = TablesServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + +def test_credentials_transport_error(): + # It is an error to provide credentials and a transport instance. + transport = transports.TablesServiceGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + with pytest.raises(ValueError): + client = TablesServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # It is an error to provide a credentials file and a transport instance. + transport = transports.TablesServiceGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + with pytest.raises(ValueError): + client = TablesServiceClient( + client_options={"credentials_file": "credentials.json"}, + transport=transport, + ) + + # It is an error to provide an api_key and a transport instance. + transport = transports.TablesServiceGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + options = client_options.ClientOptions() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = TablesServiceClient( + client_options=options, + transport=transport, + ) + + # It is an error to provide an api_key and a credential. + options = mock.Mock() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = TablesServiceClient( + client_options=options, credentials=ga_credentials.AnonymousCredentials() + ) + + # It is an error to provide scopes and a transport instance. + transport = transports.TablesServiceGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + with pytest.raises(ValueError): + client = TablesServiceClient( + client_options={"scopes": ["1", "2"]}, + transport=transport, + ) + + +def test_transport_instance(): + # A client may be instantiated with a custom transport instance. + transport = transports.TablesServiceGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + client = TablesServiceClient(transport=transport) + assert client.transport is transport + + +def test_transport_get_channel(): + # A client may be instantiated with a custom transport instance. + transport = transports.TablesServiceGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + channel = transport.grpc_channel + assert channel + + transport = transports.TablesServiceGrpcAsyncIOTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + channel = transport.grpc_channel + assert channel + + +@pytest.mark.parametrize( + "transport_class", + [ + transports.TablesServiceGrpcTransport, + transports.TablesServiceGrpcAsyncIOTransport, + transports.TablesServiceRestTransport, + ], +) +def test_transport_adc(transport_class): + # Test default credentials are used if not provided. + with mock.patch.object(google.auth, "default") as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport_class() + adc.assert_called_once() + + +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + "rest", + ], +) +def test_transport_kind(transport_name): + transport = TablesServiceClient.get_transport_class(transport_name)( + credentials=ga_credentials.AnonymousCredentials(), + ) + assert transport.kind == transport_name + + +def test_transport_grpc_default(): + # A client should use the gRPC transport by default. + client = TablesServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + assert isinstance( + client.transport, + transports.TablesServiceGrpcTransport, + ) + + +def test_tables_service_base_transport_error(): + # Passing both a credentials object and credentials_file should raise an error + with pytest.raises(core_exceptions.DuplicateCredentialArgs): + transport = transports.TablesServiceTransport( + credentials=ga_credentials.AnonymousCredentials(), + credentials_file="credentials.json", + ) + + +def test_tables_service_base_transport(): + # Instantiate the base transport. + with mock.patch( + "google.area120.tables_v1alpha1.services.tables_service.transports.TablesServiceTransport.__init__" + ) as Transport: + Transport.return_value = None + transport = transports.TablesServiceTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Every method on the transport should just blindly + # raise NotImplementedError. + methods = ( + "get_table", + "list_tables", + "get_workspace", + "list_workspaces", + "get_row", + "list_rows", + "create_row", + "batch_create_rows", + "update_row", + "batch_update_rows", + "delete_row", + "batch_delete_rows", + ) + for method in methods: + with pytest.raises(NotImplementedError): + getattr(transport, method)(request=object()) + + with pytest.raises(NotImplementedError): + transport.close() + + # Catch all for all remaining methods and properties + remainder = [ + "kind", + ] + for r in remainder: + with pytest.raises(NotImplementedError): + getattr(transport, r)() + + +def test_tables_service_base_transport_with_credentials_file(): + # Instantiate the base transport with a credentials file + with mock.patch.object( + google.auth, "load_credentials_from_file", autospec=True + ) as load_creds, mock.patch( + "google.area120.tables_v1alpha1.services.tables_service.transports.TablesServiceTransport._prep_wrapped_messages" + ) as Transport: + Transport.return_value = None + load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) + transport = transports.TablesServiceTransport( + credentials_file="credentials.json", + quota_project_id="octopus", + ) + load_creds.assert_called_once_with( + "credentials.json", + scopes=None, + default_scopes=( + "https://www.googleapis.com/auth/drive", + "https://www.googleapis.com/auth/drive.file", + "https://www.googleapis.com/auth/drive.readonly", + "https://www.googleapis.com/auth/spreadsheets", + "https://www.googleapis.com/auth/spreadsheets.readonly", + "https://www.googleapis.com/auth/tables", + ), + quota_project_id="octopus", + ) + + +def test_tables_service_base_transport_with_adc(): + # Test the default credentials are used if credentials and credentials_file are None. + with mock.patch.object(google.auth, "default", autospec=True) as adc, mock.patch( + "google.area120.tables_v1alpha1.services.tables_service.transports.TablesServiceTransport._prep_wrapped_messages" + ) as Transport: + Transport.return_value = None + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport = transports.TablesServiceTransport() + adc.assert_called_once() + + +def test_tables_service_auth_adc(): + # If no credentials are provided, we should use ADC credentials. + with mock.patch.object(google.auth, "default", autospec=True) as adc: adc.return_value = (ga_credentials.AnonymousCredentials(), None) TablesServiceClient() adc.assert_called_once_with( @@ -3759,6 +6701,7 @@ def test_tables_service_transport_auth_adc(transport_class): [ transports.TablesServiceGrpcTransport, transports.TablesServiceGrpcAsyncIOTransport, + transports.TablesServiceRestTransport, ], ) def test_tables_service_transport_auth_gdch_credentials(transport_class): @@ -3863,11 +6806,23 @@ def test_tables_service_grpc_transport_client_cert_source_for_mtls(transport_cla ) +def test_tables_service_http_transport_client_cert_source_for_mtls(): + cred = ga_credentials.AnonymousCredentials() + with mock.patch( + "google.auth.transport.requests.AuthorizedSession.configure_mtls_channel" + ) as mock_configure_mtls_channel: + transports.TablesServiceRestTransport( + credentials=cred, client_cert_source_for_mtls=client_cert_source_callback + ) + mock_configure_mtls_channel.assert_called_once_with(client_cert_source_callback) + + @pytest.mark.parametrize( "transport_name", [ "grpc", "grpc_asyncio", + "rest", ], ) def test_tables_service_host_no_port(transport_name): @@ -3878,7 +6833,11 @@ def test_tables_service_host_no_port(transport_name): ), transport=transport_name, ) - assert client.transport._host == ("area120tables.googleapis.com:443") + assert client.transport._host == ( + "area120tables.googleapis.com:443" + if transport_name in ["grpc", "grpc_asyncio"] + else "https://area120tables.googleapis.com" + ) @pytest.mark.parametrize( @@ -3886,6 +6845,7 @@ def test_tables_service_host_no_port(transport_name): [ "grpc", "grpc_asyncio", + "rest", ], ) def test_tables_service_host_with_port(transport_name): @@ -3896,7 +6856,66 @@ def test_tables_service_host_with_port(transport_name): ), transport=transport_name, ) - assert client.transport._host == ("area120tables.googleapis.com:8000") + assert client.transport._host == ( + "area120tables.googleapis.com:8000" + if transport_name in ["grpc", "grpc_asyncio"] + else "https://area120tables.googleapis.com:8000" + ) + + +@pytest.mark.parametrize( + "transport_name", + [ + "rest", + ], +) +def test_tables_service_client_transport_session_collision(transport_name): + creds1 = ga_credentials.AnonymousCredentials() + creds2 = ga_credentials.AnonymousCredentials() + client1 = TablesServiceClient( + credentials=creds1, + transport=transport_name, + ) + client2 = TablesServiceClient( + credentials=creds2, + transport=transport_name, + ) + session1 = client1.transport.get_table._session + session2 = client2.transport.get_table._session + assert session1 != session2 + session1 = client1.transport.list_tables._session + session2 = client2.transport.list_tables._session + assert session1 != session2 + session1 = client1.transport.get_workspace._session + session2 = client2.transport.get_workspace._session + assert session1 != session2 + session1 = client1.transport.list_workspaces._session + session2 = client2.transport.list_workspaces._session + assert session1 != session2 + session1 = client1.transport.get_row._session + session2 = client2.transport.get_row._session + assert session1 != session2 + session1 = client1.transport.list_rows._session + session2 = client2.transport.list_rows._session + assert session1 != session2 + session1 = client1.transport.create_row._session + session2 = client2.transport.create_row._session + assert session1 != session2 + session1 = client1.transport.batch_create_rows._session + session2 = client2.transport.batch_create_rows._session + assert session1 != session2 + session1 = client1.transport.update_row._session + session2 = client2.transport.update_row._session + assert session1 != session2 + session1 = client1.transport.batch_update_rows._session + session2 = client2.transport.batch_update_rows._session + assert session1 != session2 + session1 = client1.transport.delete_row._session + session2 = client2.transport.delete_row._session + assert session1 != session2 + session1 = client1.transport.batch_delete_rows._session + session2 = client2.transport.batch_delete_rows._session + assert session1 != session2 def test_tables_service_grpc_transport_channel(): @@ -4228,6 +7247,7 @@ async def test_transport_close_async(): def test_transport_close(): transports = { + "rest": "_session", "grpc": "_grpc_channel", } @@ -4245,6 +7265,7 @@ def test_transport_close(): def test_client_ctx(): transports = [ + "rest", "grpc", ] for transport in transports: