diff --git a/packages/google-cloud-bigquery-migration/.coveragerc b/packages/google-cloud-bigquery-migration/.coveragerc index 0654319ea3a2..0c2439ce0fbf 100644 --- a/packages/google-cloud-bigquery-migration/.coveragerc +++ b/packages/google-cloud-bigquery-migration/.coveragerc @@ -4,7 +4,7 @@ branch = True [report] show_missing = True omit = - google/cloud/bigquery/migration/__init__.py + google/cloud/bigquery_migration/__init__.py exclude_lines = # Re-enable the standard pragma pragma: NO COVER diff --git a/packages/google-cloud-bigquery-migration/docs/migration_v2alpha/migration_service.rst b/packages/google-cloud-bigquery-migration/docs/bigquery_migration_v2alpha/migration_service.rst similarity index 57% rename from packages/google-cloud-bigquery-migration/docs/migration_v2alpha/migration_service.rst rename to packages/google-cloud-bigquery-migration/docs/bigquery_migration_v2alpha/migration_service.rst index bf74826580a7..e676817164a0 100644 --- a/packages/google-cloud-bigquery-migration/docs/migration_v2alpha/migration_service.rst +++ b/packages/google-cloud-bigquery-migration/docs/bigquery_migration_v2alpha/migration_service.rst @@ -1,10 +1,10 @@ MigrationService ---------------------------------- -.. automodule:: google.cloud.bigquery.migration_v2alpha.services.migration_service +.. automodule:: google.cloud.bigquery_migration_v2alpha.services.migration_service :members: :inherited-members: -.. automodule:: google.cloud.bigquery.migration_v2alpha.services.migration_service.pagers +.. automodule:: google.cloud.bigquery_migration_v2alpha.services.migration_service.pagers :members: :inherited-members: diff --git a/packages/google-cloud-bigquery-migration/docs/migration_v2alpha/services.rst b/packages/google-cloud-bigquery-migration/docs/bigquery_migration_v2alpha/services.rst similarity index 100% rename from packages/google-cloud-bigquery-migration/docs/migration_v2alpha/services.rst rename to packages/google-cloud-bigquery-migration/docs/bigquery_migration_v2alpha/services.rst diff --git a/packages/google-cloud-bigquery-migration/docs/migration_v2alpha/types.rst b/packages/google-cloud-bigquery-migration/docs/bigquery_migration_v2alpha/types.rst similarity index 72% rename from packages/google-cloud-bigquery-migration/docs/migration_v2alpha/types.rst rename to packages/google-cloud-bigquery-migration/docs/bigquery_migration_v2alpha/types.rst index cf262b71bb08..3024de857553 100644 --- a/packages/google-cloud-bigquery-migration/docs/migration_v2alpha/types.rst +++ b/packages/google-cloud-bigquery-migration/docs/bigquery_migration_v2alpha/types.rst @@ -1,7 +1,7 @@ Types for Google Cloud Bigquery Migration v2alpha API ===================================================== -.. automodule:: google.cloud.bigquery.migration_v2alpha.types +.. automodule:: google.cloud.bigquery_migration_v2alpha.types :members: :undoc-members: :show-inheritance: diff --git a/packages/google-cloud-bigquery-migration/docs/index.rst b/packages/google-cloud-bigquery-migration/docs/index.rst index 2f7845367b0a..cadfd1bc1b49 100644 --- a/packages/google-cloud-bigquery-migration/docs/index.rst +++ b/packages/google-cloud-bigquery-migration/docs/index.rst @@ -7,8 +7,8 @@ API Reference .. toctree:: :maxdepth: 2 - migration_v2alpha/services - migration_v2alpha/types + bigquery_migration_v2alpha/services + bigquery_migration_v2alpha/types Changelog --------- @@ -18,4 +18,4 @@ For a list of all ``google-cloud-bigquery-migration`` releases: .. toctree:: :maxdepth: 2 - changelog \ No newline at end of file + changelog diff --git a/packages/google-cloud-bigquery-migration/google/cloud/bigquery/migration/__init__.py b/packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration/__init__.py similarity index 61% rename from packages/google-cloud-bigquery-migration/google/cloud/bigquery/migration/__init__.py rename to packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration/__init__.py index eefbf2845ac3..80e5483c3ce0 100644 --- a/packages/google-cloud-bigquery-migration/google/cloud/bigquery/migration/__init__.py +++ b/packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration/__init__.py @@ -14,60 +14,60 @@ # limitations under the License. # -from google.cloud.bigquery.migration_v2alpha.services.migration_service.client import ( +from google.cloud.bigquery_migration_v2alpha.services.migration_service.client import ( MigrationServiceClient, ) -from google.cloud.bigquery.migration_v2alpha.services.migration_service.async_client import ( +from google.cloud.bigquery_migration_v2alpha.services.migration_service.async_client import ( MigrationServiceAsyncClient, ) -from google.cloud.bigquery.migration_v2alpha.types.migration_entities import ( +from google.cloud.bigquery_migration_v2alpha.types.migration_entities import ( MigrationSubtask, ) -from google.cloud.bigquery.migration_v2alpha.types.migration_entities import ( +from google.cloud.bigquery_migration_v2alpha.types.migration_entities import ( MigrationTask, ) -from google.cloud.bigquery.migration_v2alpha.types.migration_entities import ( +from google.cloud.bigquery_migration_v2alpha.types.migration_entities import ( MigrationWorkflow, ) -from google.cloud.bigquery.migration_v2alpha.types.migration_error_details import ( +from google.cloud.bigquery_migration_v2alpha.types.migration_error_details import ( ErrorDetail, ) -from google.cloud.bigquery.migration_v2alpha.types.migration_error_details import ( +from google.cloud.bigquery_migration_v2alpha.types.migration_error_details import ( ErrorLocation, ) -from google.cloud.bigquery.migration_v2alpha.types.migration_error_details import ( +from google.cloud.bigquery_migration_v2alpha.types.migration_error_details import ( ResourceErrorDetail, ) -from google.cloud.bigquery.migration_v2alpha.types.migration_metrics import Point -from google.cloud.bigquery.migration_v2alpha.types.migration_metrics import TimeInterval -from google.cloud.bigquery.migration_v2alpha.types.migration_metrics import TimeSeries -from google.cloud.bigquery.migration_v2alpha.types.migration_metrics import TypedValue -from google.cloud.bigquery.migration_v2alpha.types.migration_service import ( +from google.cloud.bigquery_migration_v2alpha.types.migration_metrics import Point +from google.cloud.bigquery_migration_v2alpha.types.migration_metrics import TimeInterval +from google.cloud.bigquery_migration_v2alpha.types.migration_metrics import TimeSeries +from google.cloud.bigquery_migration_v2alpha.types.migration_metrics import TypedValue +from google.cloud.bigquery_migration_v2alpha.types.migration_service import ( CreateMigrationWorkflowRequest, ) -from google.cloud.bigquery.migration_v2alpha.types.migration_service import ( +from google.cloud.bigquery_migration_v2alpha.types.migration_service import ( DeleteMigrationWorkflowRequest, ) -from google.cloud.bigquery.migration_v2alpha.types.migration_service import ( +from google.cloud.bigquery_migration_v2alpha.types.migration_service import ( GetMigrationSubtaskRequest, ) -from google.cloud.bigquery.migration_v2alpha.types.migration_service import ( +from google.cloud.bigquery_migration_v2alpha.types.migration_service import ( GetMigrationWorkflowRequest, ) -from google.cloud.bigquery.migration_v2alpha.types.migration_service import ( +from google.cloud.bigquery_migration_v2alpha.types.migration_service import ( ListMigrationSubtasksRequest, ) -from google.cloud.bigquery.migration_v2alpha.types.migration_service import ( +from google.cloud.bigquery_migration_v2alpha.types.migration_service import ( ListMigrationSubtasksResponse, ) -from google.cloud.bigquery.migration_v2alpha.types.migration_service import ( +from google.cloud.bigquery_migration_v2alpha.types.migration_service import ( ListMigrationWorkflowsRequest, ) -from google.cloud.bigquery.migration_v2alpha.types.migration_service import ( +from google.cloud.bigquery_migration_v2alpha.types.migration_service import ( ListMigrationWorkflowsResponse, ) -from google.cloud.bigquery.migration_v2alpha.types.migration_service import ( +from google.cloud.bigquery_migration_v2alpha.types.migration_service import ( StartMigrationWorkflowRequest, ) diff --git a/packages/google-cloud-bigquery-migration/google/cloud/bigquery/migration/py.typed b/packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration/py.typed similarity index 100% rename from packages/google-cloud-bigquery-migration/google/cloud/bigquery/migration/py.typed rename to packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration/py.typed diff --git a/packages/google-cloud-bigquery-migration/google/cloud/bigquery/migration_v2alpha/__init__.py b/packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration_v2alpha/__init__.py similarity index 100% rename from packages/google-cloud-bigquery-migration/google/cloud/bigquery/migration_v2alpha/__init__.py rename to packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration_v2alpha/__init__.py diff --git a/packages/google-cloud-bigquery-migration/google/cloud/bigquery/migration_v2alpha/gapic_metadata.json b/packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration_v2alpha/gapic_metadata.json similarity index 97% rename from packages/google-cloud-bigquery-migration/google/cloud/bigquery/migration_v2alpha/gapic_metadata.json rename to packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration_v2alpha/gapic_metadata.json index 515d090a4548..2cdac01c5f79 100644 --- a/packages/google-cloud-bigquery-migration/google/cloud/bigquery/migration_v2alpha/gapic_metadata.json +++ b/packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration_v2alpha/gapic_metadata.json @@ -1,7 +1,7 @@ { "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", "language": "python", - "libraryPackage": "google.cloud.bigquery.migration_v2alpha", + "libraryPackage": "google.cloud.bigquery_migration_v2alpha", "protoPackage": "google.cloud.bigquery.migration.v2alpha", "schema": "1.0", "services": { diff --git a/packages/google-cloud-bigquery-migration/google/cloud/bigquery/migration_v2alpha/py.typed b/packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration_v2alpha/py.typed similarity index 100% rename from packages/google-cloud-bigquery-migration/google/cloud/bigquery/migration_v2alpha/py.typed rename to packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration_v2alpha/py.typed diff --git a/packages/google-cloud-bigquery-migration/google/cloud/bigquery/migration_v2alpha/services/__init__.py b/packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration_v2alpha/services/__init__.py similarity index 100% rename from packages/google-cloud-bigquery-migration/google/cloud/bigquery/migration_v2alpha/services/__init__.py rename to packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration_v2alpha/services/__init__.py diff --git a/packages/google-cloud-bigquery-migration/google/cloud/bigquery/migration_v2alpha/services/migration_service/__init__.py b/packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration_v2alpha/services/migration_service/__init__.py similarity index 100% rename from packages/google-cloud-bigquery-migration/google/cloud/bigquery/migration_v2alpha/services/migration_service/__init__.py rename to packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration_v2alpha/services/migration_service/__init__.py diff --git a/packages/google-cloud-bigquery-migration/google/cloud/bigquery/migration_v2alpha/services/migration_service/async_client.py b/packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration_v2alpha/services/migration_service/async_client.py similarity index 96% rename from packages/google-cloud-bigquery-migration/google/cloud/bigquery/migration_v2alpha/services/migration_service/async_client.py rename to packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration_v2alpha/services/migration_service/async_client.py index 4f1fe7b28442..93200fac0424 100644 --- a/packages/google-cloud-bigquery-migration/google/cloud/bigquery/migration_v2alpha/services/migration_service/async_client.py +++ b/packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration_v2alpha/services/migration_service/async_client.py @@ -26,11 +26,11 @@ from google.auth import credentials as ga_credentials # type: ignore from google.oauth2 import service_account # type: ignore -from google.cloud.bigquery.migration_v2alpha.services.migration_service import pagers -from google.cloud.bigquery.migration_v2alpha.types import migration_entities -from google.cloud.bigquery.migration_v2alpha.types import migration_error_details -from google.cloud.bigquery.migration_v2alpha.types import migration_metrics -from google.cloud.bigquery.migration_v2alpha.types import migration_service +from google.cloud.bigquery_migration_v2alpha.services.migration_service import pagers +from google.cloud.bigquery_migration_v2alpha.types import migration_entities +from google.cloud.bigquery_migration_v2alpha.types import migration_error_details +from google.cloud.bigquery_migration_v2alpha.types import migration_metrics +from google.cloud.bigquery_migration_v2alpha.types import migration_service from google.protobuf import timestamp_pb2 # type: ignore from google.rpc import error_details_pb2 # type: ignore from .transports.base import MigrationServiceTransport, DEFAULT_CLIENT_INFO @@ -187,7 +187,7 @@ async def create_migration_workflow( r"""Creates a migration workflow. Args: - request (:class:`google.cloud.bigquery.migration_v2alpha.types.CreateMigrationWorkflowRequest`): + request (:class:`google.cloud.bigquery_migration_v2alpha.types.CreateMigrationWorkflowRequest`): The request object. Request to create a migration workflow resource. parent (:class:`str`): @@ -198,7 +198,7 @@ async def create_migration_workflow( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - migration_workflow (:class:`google.cloud.bigquery.migration_v2alpha.types.MigrationWorkflow`): + migration_workflow (:class:`google.cloud.bigquery_migration_v2alpha.types.MigrationWorkflow`): Required. The migration workflow to create. @@ -212,7 +212,7 @@ async def create_migration_workflow( sent along with the request as metadata. Returns: - google.cloud.bigquery.migration_v2alpha.types.MigrationWorkflow: + google.cloud.bigquery_migration_v2alpha.types.MigrationWorkflow: A migration workflow which specifies what needs to be done for an EDW migration. @@ -269,7 +269,7 @@ async def get_migration_workflow( r"""Gets a previously created migration workflow. Args: - request (:class:`google.cloud.bigquery.migration_v2alpha.types.GetMigrationWorkflowRequest`): + request (:class:`google.cloud.bigquery_migration_v2alpha.types.GetMigrationWorkflowRequest`): The request object. A request to get a previously created migration workflow. name (:class:`str`): @@ -287,7 +287,7 @@ async def get_migration_workflow( sent along with the request as metadata. Returns: - google.cloud.bigquery.migration_v2alpha.types.MigrationWorkflow: + google.cloud.bigquery_migration_v2alpha.types.MigrationWorkflow: A migration workflow which specifies what needs to be done for an EDW migration. @@ -351,7 +351,7 @@ async def list_migration_workflows( r"""Lists previously created migration workflow. Args: - request (:class:`google.cloud.bigquery.migration_v2alpha.types.ListMigrationWorkflowsRequest`): + request (:class:`google.cloud.bigquery_migration_v2alpha.types.ListMigrationWorkflowsRequest`): The request object. A request to list previously created migration workflows. parent (:class:`str`): @@ -369,7 +369,7 @@ async def list_migration_workflows( sent along with the request as metadata. Returns: - google.cloud.bigquery.migration_v2alpha.services.migration_service.pagers.ListMigrationWorkflowsAsyncPager: + google.cloud.bigquery_migration_v2alpha.services.migration_service.pagers.ListMigrationWorkflowsAsyncPager: Response object for a ListMigrationWorkflows call. Iterating over this object will yield results and @@ -440,7 +440,7 @@ async def delete_migration_workflow( r"""Deletes a migration workflow by name. Args: - request (:class:`google.cloud.bigquery.migration_v2alpha.types.DeleteMigrationWorkflowRequest`): + request (:class:`google.cloud.bigquery_migration_v2alpha.types.DeleteMigrationWorkflowRequest`): The request object. A request to delete a previously created migration workflow. name (:class:`str`): @@ -509,7 +509,7 @@ async def start_migration_workflow( RUNNING. Args: - request (:class:`google.cloud.bigquery.migration_v2alpha.types.StartMigrationWorkflowRequest`): + request (:class:`google.cloud.bigquery_migration_v2alpha.types.StartMigrationWorkflowRequest`): The request object. A request to start a previously created migration workflow. name (:class:`str`): @@ -583,7 +583,7 @@ async def get_migration_subtask( r"""Gets a previously created migration subtask. Args: - request (:class:`google.cloud.bigquery.migration_v2alpha.types.GetMigrationSubtaskRequest`): + request (:class:`google.cloud.bigquery_migration_v2alpha.types.GetMigrationSubtaskRequest`): The request object. A request to get a previously created migration subtasks. name (:class:`str`): @@ -601,7 +601,7 @@ async def get_migration_subtask( sent along with the request as metadata. Returns: - google.cloud.bigquery.migration_v2alpha.types.MigrationSubtask: + google.cloud.bigquery_migration_v2alpha.types.MigrationSubtask: A subtask for a migration which carries details about the configuration of the subtask. The content of the @@ -668,7 +668,7 @@ async def list_migration_subtasks( r"""Lists previously created migration subtasks. Args: - request (:class:`google.cloud.bigquery.migration_v2alpha.types.ListMigrationSubtasksRequest`): + request (:class:`google.cloud.bigquery_migration_v2alpha.types.ListMigrationSubtasksRequest`): The request object. A request to list previously created migration subtasks. parent (:class:`str`): @@ -685,7 +685,7 @@ async def list_migration_subtasks( sent along with the request as metadata. Returns: - google.cloud.bigquery.migration_v2alpha.services.migration_service.pagers.ListMigrationSubtasksAsyncPager: + google.cloud.bigquery_migration_v2alpha.services.migration_service.pagers.ListMigrationSubtasksAsyncPager: Response object for a ListMigrationSubtasks call. Iterating over this object will yield results and diff --git a/packages/google-cloud-bigquery-migration/google/cloud/bigquery/migration_v2alpha/services/migration_service/client.py b/packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration_v2alpha/services/migration_service/client.py similarity index 97% rename from packages/google-cloud-bigquery-migration/google/cloud/bigquery/migration_v2alpha/services/migration_service/client.py rename to packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration_v2alpha/services/migration_service/client.py index bd57bfb28263..0a70fb7a90dd 100644 --- a/packages/google-cloud-bigquery-migration/google/cloud/bigquery/migration_v2alpha/services/migration_service/client.py +++ b/packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration_v2alpha/services/migration_service/client.py @@ -30,11 +30,11 @@ from google.auth.exceptions import MutualTLSChannelError # type: ignore from google.oauth2 import service_account # type: ignore -from google.cloud.bigquery.migration_v2alpha.services.migration_service import pagers -from google.cloud.bigquery.migration_v2alpha.types import migration_entities -from google.cloud.bigquery.migration_v2alpha.types import migration_error_details -from google.cloud.bigquery.migration_v2alpha.types import migration_metrics -from google.cloud.bigquery.migration_v2alpha.types import migration_service +from google.cloud.bigquery_migration_v2alpha.services.migration_service import pagers +from google.cloud.bigquery_migration_v2alpha.types import migration_entities +from google.cloud.bigquery_migration_v2alpha.types import migration_error_details +from google.cloud.bigquery_migration_v2alpha.types import migration_metrics +from google.cloud.bigquery_migration_v2alpha.types import migration_service from google.protobuf import timestamp_pb2 # type: ignore from google.rpc import error_details_pb2 # type: ignore from .transports.base import MigrationServiceTransport, DEFAULT_CLIENT_INFO @@ -386,7 +386,7 @@ def create_migration_workflow( r"""Creates a migration workflow. Args: - request (Union[google.cloud.bigquery.migration_v2alpha.types.CreateMigrationWorkflowRequest, dict]): + request (Union[google.cloud.bigquery_migration_v2alpha.types.CreateMigrationWorkflowRequest, dict]): The request object. Request to create a migration workflow resource. parent (str): @@ -397,7 +397,7 @@ def create_migration_workflow( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - migration_workflow (google.cloud.bigquery.migration_v2alpha.types.MigrationWorkflow): + migration_workflow (google.cloud.bigquery_migration_v2alpha.types.MigrationWorkflow): Required. The migration workflow to create. @@ -411,7 +411,7 @@ def create_migration_workflow( sent along with the request as metadata. Returns: - google.cloud.bigquery.migration_v2alpha.types.MigrationWorkflow: + google.cloud.bigquery_migration_v2alpha.types.MigrationWorkflow: A migration workflow which specifies what needs to be done for an EDW migration. @@ -470,7 +470,7 @@ def get_migration_workflow( r"""Gets a previously created migration workflow. Args: - request (Union[google.cloud.bigquery.migration_v2alpha.types.GetMigrationWorkflowRequest, dict]): + request (Union[google.cloud.bigquery_migration_v2alpha.types.GetMigrationWorkflowRequest, dict]): The request object. A request to get a previously created migration workflow. name (str): @@ -488,7 +488,7 @@ def get_migration_workflow( sent along with the request as metadata. Returns: - google.cloud.bigquery.migration_v2alpha.types.MigrationWorkflow: + google.cloud.bigquery_migration_v2alpha.types.MigrationWorkflow: A migration workflow which specifies what needs to be done for an EDW migration. @@ -543,7 +543,7 @@ def list_migration_workflows( r"""Lists previously created migration workflow. Args: - request (Union[google.cloud.bigquery.migration_v2alpha.types.ListMigrationWorkflowsRequest, dict]): + request (Union[google.cloud.bigquery_migration_v2alpha.types.ListMigrationWorkflowsRequest, dict]): The request object. A request to list previously created migration workflows. parent (str): @@ -561,7 +561,7 @@ def list_migration_workflows( sent along with the request as metadata. Returns: - google.cloud.bigquery.migration_v2alpha.services.migration_service.pagers.ListMigrationWorkflowsPager: + google.cloud.bigquery_migration_v2alpha.services.migration_service.pagers.ListMigrationWorkflowsPager: Response object for a ListMigrationWorkflows call. Iterating over this object will yield results and @@ -623,7 +623,7 @@ def delete_migration_workflow( r"""Deletes a migration workflow by name. Args: - request (Union[google.cloud.bigquery.migration_v2alpha.types.DeleteMigrationWorkflowRequest, dict]): + request (Union[google.cloud.bigquery_migration_v2alpha.types.DeleteMigrationWorkflowRequest, dict]): The request object. A request to delete a previously created migration workflow. name (str): @@ -694,7 +694,7 @@ def start_migration_workflow( RUNNING. Args: - request (Union[google.cloud.bigquery.migration_v2alpha.types.StartMigrationWorkflowRequest, dict]): + request (Union[google.cloud.bigquery_migration_v2alpha.types.StartMigrationWorkflowRequest, dict]): The request object. A request to start a previously created migration workflow. name (str): @@ -759,7 +759,7 @@ def get_migration_subtask( r"""Gets a previously created migration subtask. Args: - request (Union[google.cloud.bigquery.migration_v2alpha.types.GetMigrationSubtaskRequest, dict]): + request (Union[google.cloud.bigquery_migration_v2alpha.types.GetMigrationSubtaskRequest, dict]): The request object. A request to get a previously created migration subtasks. name (str): @@ -777,7 +777,7 @@ def get_migration_subtask( sent along with the request as metadata. Returns: - google.cloud.bigquery.migration_v2alpha.types.MigrationSubtask: + google.cloud.bigquery_migration_v2alpha.types.MigrationSubtask: A subtask for a migration which carries details about the configuration of the subtask. The content of the @@ -835,7 +835,7 @@ def list_migration_subtasks( r"""Lists previously created migration subtasks. Args: - request (Union[google.cloud.bigquery.migration_v2alpha.types.ListMigrationSubtasksRequest, dict]): + request (Union[google.cloud.bigquery_migration_v2alpha.types.ListMigrationSubtasksRequest, dict]): The request object. A request to list previously created migration subtasks. parent (str): @@ -852,7 +852,7 @@ def list_migration_subtasks( sent along with the request as metadata. Returns: - google.cloud.bigquery.migration_v2alpha.services.migration_service.pagers.ListMigrationSubtasksPager: + google.cloud.bigquery_migration_v2alpha.services.migration_service.pagers.ListMigrationSubtasksPager: Response object for a ListMigrationSubtasks call. Iterating over this object will yield results and diff --git a/packages/google-cloud-bigquery-migration/google/cloud/bigquery/migration_v2alpha/services/migration_service/pagers.py b/packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration_v2alpha/services/migration_service/pagers.py similarity index 90% rename from packages/google-cloud-bigquery-migration/google/cloud/bigquery/migration_v2alpha/services/migration_service/pagers.py rename to packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration_v2alpha/services/migration_service/pagers.py index fcfa97daef05..22e74aec22d0 100644 --- a/packages/google-cloud-bigquery-migration/google/cloud/bigquery/migration_v2alpha/services/migration_service/pagers.py +++ b/packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration_v2alpha/services/migration_service/pagers.py @@ -24,15 +24,15 @@ Optional, ) -from google.cloud.bigquery.migration_v2alpha.types import migration_entities -from google.cloud.bigquery.migration_v2alpha.types import migration_service +from google.cloud.bigquery_migration_v2alpha.types import migration_entities +from google.cloud.bigquery_migration_v2alpha.types import migration_service class ListMigrationWorkflowsPager: """A pager for iterating through ``list_migration_workflows`` requests. This class thinly wraps an initial - :class:`google.cloud.bigquery.migration_v2alpha.types.ListMigrationWorkflowsResponse` object, and + :class:`google.cloud.bigquery_migration_v2alpha.types.ListMigrationWorkflowsResponse` object, and provides an ``__iter__`` method to iterate through its ``migration_workflows`` field. @@ -41,7 +41,7 @@ class ListMigrationWorkflowsPager: through the ``migration_workflows`` field on the corresponding responses. - All the usual :class:`google.cloud.bigquery.migration_v2alpha.types.ListMigrationWorkflowsResponse` + All the usual :class:`google.cloud.bigquery_migration_v2alpha.types.ListMigrationWorkflowsResponse` attributes are available on the pager. If multiple requests are made, only the most recent response is retained, and thus used for attribute lookup. """ @@ -59,9 +59,9 @@ def __init__( Args: method (Callable): The method that was originally called, and which instantiated this pager. - request (google.cloud.bigquery.migration_v2alpha.types.ListMigrationWorkflowsRequest): + request (google.cloud.bigquery_migration_v2alpha.types.ListMigrationWorkflowsRequest): The initial request object. - response (google.cloud.bigquery.migration_v2alpha.types.ListMigrationWorkflowsResponse): + response (google.cloud.bigquery_migration_v2alpha.types.ListMigrationWorkflowsResponse): The initial response object. metadata (Sequence[Tuple[str, str]]): Strings which should be sent along with the request as metadata. @@ -94,7 +94,7 @@ class ListMigrationWorkflowsAsyncPager: """A pager for iterating through ``list_migration_workflows`` requests. This class thinly wraps an initial - :class:`google.cloud.bigquery.migration_v2alpha.types.ListMigrationWorkflowsResponse` object, and + :class:`google.cloud.bigquery_migration_v2alpha.types.ListMigrationWorkflowsResponse` object, and provides an ``__aiter__`` method to iterate through its ``migration_workflows`` field. @@ -103,7 +103,7 @@ class ListMigrationWorkflowsAsyncPager: through the ``migration_workflows`` field on the corresponding responses. - All the usual :class:`google.cloud.bigquery.migration_v2alpha.types.ListMigrationWorkflowsResponse` + All the usual :class:`google.cloud.bigquery_migration_v2alpha.types.ListMigrationWorkflowsResponse` attributes are available on the pager. If multiple requests are made, only the most recent response is retained, and thus used for attribute lookup. """ @@ -123,9 +123,9 @@ def __init__( Args: method (Callable): The method that was originally called, and which instantiated this pager. - request (google.cloud.bigquery.migration_v2alpha.types.ListMigrationWorkflowsRequest): + request (google.cloud.bigquery_migration_v2alpha.types.ListMigrationWorkflowsRequest): The initial request object. - response (google.cloud.bigquery.migration_v2alpha.types.ListMigrationWorkflowsResponse): + response (google.cloud.bigquery_migration_v2alpha.types.ListMigrationWorkflowsResponse): The initial response object. metadata (Sequence[Tuple[str, str]]): Strings which should be sent along with the request as metadata. @@ -164,7 +164,7 @@ class ListMigrationSubtasksPager: """A pager for iterating through ``list_migration_subtasks`` requests. This class thinly wraps an initial - :class:`google.cloud.bigquery.migration_v2alpha.types.ListMigrationSubtasksResponse` object, and + :class:`google.cloud.bigquery_migration_v2alpha.types.ListMigrationSubtasksResponse` object, and provides an ``__iter__`` method to iterate through its ``migration_subtasks`` field. @@ -173,7 +173,7 @@ class ListMigrationSubtasksPager: through the ``migration_subtasks`` field on the corresponding responses. - All the usual :class:`google.cloud.bigquery.migration_v2alpha.types.ListMigrationSubtasksResponse` + All the usual :class:`google.cloud.bigquery_migration_v2alpha.types.ListMigrationSubtasksResponse` attributes are available on the pager. If multiple requests are made, only the most recent response is retained, and thus used for attribute lookup. """ @@ -191,9 +191,9 @@ def __init__( Args: method (Callable): The method that was originally called, and which instantiated this pager. - request (google.cloud.bigquery.migration_v2alpha.types.ListMigrationSubtasksRequest): + request (google.cloud.bigquery_migration_v2alpha.types.ListMigrationSubtasksRequest): The initial request object. - response (google.cloud.bigquery.migration_v2alpha.types.ListMigrationSubtasksResponse): + response (google.cloud.bigquery_migration_v2alpha.types.ListMigrationSubtasksResponse): The initial response object. metadata (Sequence[Tuple[str, str]]): Strings which should be sent along with the request as metadata. @@ -226,7 +226,7 @@ class ListMigrationSubtasksAsyncPager: """A pager for iterating through ``list_migration_subtasks`` requests. This class thinly wraps an initial - :class:`google.cloud.bigquery.migration_v2alpha.types.ListMigrationSubtasksResponse` object, and + :class:`google.cloud.bigquery_migration_v2alpha.types.ListMigrationSubtasksResponse` object, and provides an ``__aiter__`` method to iterate through its ``migration_subtasks`` field. @@ -235,7 +235,7 @@ class ListMigrationSubtasksAsyncPager: through the ``migration_subtasks`` field on the corresponding responses. - All the usual :class:`google.cloud.bigquery.migration_v2alpha.types.ListMigrationSubtasksResponse` + All the usual :class:`google.cloud.bigquery_migration_v2alpha.types.ListMigrationSubtasksResponse` attributes are available on the pager. If multiple requests are made, only the most recent response is retained, and thus used for attribute lookup. """ @@ -255,9 +255,9 @@ def __init__( Args: method (Callable): The method that was originally called, and which instantiated this pager. - request (google.cloud.bigquery.migration_v2alpha.types.ListMigrationSubtasksRequest): + request (google.cloud.bigquery_migration_v2alpha.types.ListMigrationSubtasksRequest): The initial request object. - response (google.cloud.bigquery.migration_v2alpha.types.ListMigrationSubtasksResponse): + response (google.cloud.bigquery_migration_v2alpha.types.ListMigrationSubtasksResponse): The initial response object. metadata (Sequence[Tuple[str, str]]): Strings which should be sent along with the request as metadata. diff --git a/packages/google-cloud-bigquery-migration/google/cloud/bigquery/migration_v2alpha/services/migration_service/transports/__init__.py b/packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration_v2alpha/services/migration_service/transports/__init__.py similarity index 100% rename from packages/google-cloud-bigquery-migration/google/cloud/bigquery/migration_v2alpha/services/migration_service/transports/__init__.py rename to packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration_v2alpha/services/migration_service/transports/__init__.py diff --git a/packages/google-cloud-bigquery-migration/google/cloud/bigquery/migration_v2alpha/services/migration_service/transports/base.py b/packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration_v2alpha/services/migration_service/transports/base.py similarity index 98% rename from packages/google-cloud-bigquery-migration/google/cloud/bigquery/migration_v2alpha/services/migration_service/transports/base.py rename to packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration_v2alpha/services/migration_service/transports/base.py index 6136fafb2843..a37def0b91ef 100644 --- a/packages/google-cloud-bigquery-migration/google/cloud/bigquery/migration_v2alpha/services/migration_service/transports/base.py +++ b/packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration_v2alpha/services/migration_service/transports/base.py @@ -26,8 +26,8 @@ from google.auth import credentials as ga_credentials # type: ignore from google.oauth2 import service_account # type: ignore -from google.cloud.bigquery.migration_v2alpha.types import migration_entities -from google.cloud.bigquery.migration_v2alpha.types import migration_service +from google.cloud.bigquery_migration_v2alpha.types import migration_entities +from google.cloud.bigquery_migration_v2alpha.types import migration_service from google.protobuf import empty_pb2 # type: ignore try: diff --git a/packages/google-cloud-bigquery-migration/google/cloud/bigquery/migration_v2alpha/services/migration_service/transports/grpc.py b/packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration_v2alpha/services/migration_service/transports/grpc.py similarity index 99% rename from packages/google-cloud-bigquery-migration/google/cloud/bigquery/migration_v2alpha/services/migration_service/transports/grpc.py rename to packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration_v2alpha/services/migration_service/transports/grpc.py index c8bd5beb52a7..359b9684837c 100644 --- a/packages/google-cloud-bigquery-migration/google/cloud/bigquery/migration_v2alpha/services/migration_service/transports/grpc.py +++ b/packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration_v2alpha/services/migration_service/transports/grpc.py @@ -24,8 +24,8 @@ import grpc # type: ignore -from google.cloud.bigquery.migration_v2alpha.types import migration_entities -from google.cloud.bigquery.migration_v2alpha.types import migration_service +from google.cloud.bigquery_migration_v2alpha.types import migration_entities +from google.cloud.bigquery_migration_v2alpha.types import migration_service from google.protobuf import empty_pb2 # type: ignore from .base import MigrationServiceTransport, DEFAULT_CLIENT_INFO diff --git a/packages/google-cloud-bigquery-migration/google/cloud/bigquery/migration_v2alpha/services/migration_service/transports/grpc_asyncio.py b/packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration_v2alpha/services/migration_service/transports/grpc_asyncio.py similarity index 99% rename from packages/google-cloud-bigquery-migration/google/cloud/bigquery/migration_v2alpha/services/migration_service/transports/grpc_asyncio.py rename to packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration_v2alpha/services/migration_service/transports/grpc_asyncio.py index 82d69f9ccb2f..3384e26d9086 100644 --- a/packages/google-cloud-bigquery-migration/google/cloud/bigquery/migration_v2alpha/services/migration_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration_v2alpha/services/migration_service/transports/grpc_asyncio.py @@ -25,8 +25,8 @@ import grpc # type: ignore from grpc.experimental import aio # type: ignore -from google.cloud.bigquery.migration_v2alpha.types import migration_entities -from google.cloud.bigquery.migration_v2alpha.types import migration_service +from google.cloud.bigquery_migration_v2alpha.types import migration_entities +from google.cloud.bigquery_migration_v2alpha.types import migration_service from google.protobuf import empty_pb2 # type: ignore from .base import MigrationServiceTransport, DEFAULT_CLIENT_INFO from .grpc import MigrationServiceGrpcTransport diff --git a/packages/google-cloud-bigquery-migration/google/cloud/bigquery/migration_v2alpha/types/__init__.py b/packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration_v2alpha/types/__init__.py similarity index 100% rename from packages/google-cloud-bigquery-migration/google/cloud/bigquery/migration_v2alpha/types/__init__.py rename to packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration_v2alpha/types/__init__.py diff --git a/packages/google-cloud-bigquery-migration/google/cloud/bigquery/migration_v2alpha/types/migration_entities.py b/packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration_v2alpha/types/migration_entities.py similarity index 93% rename from packages/google-cloud-bigquery-migration/google/cloud/bigquery/migration_v2alpha/types/migration_entities.py rename to packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration_v2alpha/types/migration_entities.py index 0ce56d4cce3d..1e992241cf9c 100644 --- a/packages/google-cloud-bigquery-migration/google/cloud/bigquery/migration_v2alpha/types/migration_entities.py +++ b/packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration_v2alpha/types/migration_entities.py @@ -15,8 +15,8 @@ # import proto # type: ignore -from google.cloud.bigquery.migration_v2alpha.types import migration_error_details -from google.cloud.bigquery.migration_v2alpha.types import migration_metrics +from google.cloud.bigquery_migration_v2alpha.types import migration_error_details +from google.cloud.bigquery_migration_v2alpha.types import migration_metrics from google.protobuf import any_pb2 # type: ignore from google.protobuf import timestamp_pb2 # type: ignore from google.rpc import error_details_pb2 # type: ignore @@ -42,12 +42,12 @@ class MigrationWorkflow(proto.Message): The display name of the workflow. This can be set to give a workflow a descriptive name. There is no guarantee or enforcement of uniqueness. - tasks (Sequence[google.cloud.bigquery.migration_v2alpha.types.MigrationWorkflow.TasksEntry]): + tasks (Sequence[google.cloud.bigquery_migration_v2alpha.types.MigrationWorkflow.TasksEntry]): The tasks in a workflow in a named map. The name (i.e. key) has no meaning and is merely a convenient way to address a specific task in a workflow. - state (google.cloud.bigquery.migration_v2alpha.types.MigrationWorkflow.State): + state (google.cloud.bigquery_migration_v2alpha.types.MigrationWorkflow.State): Output only. That status of the workflow. create_time (google.protobuf.timestamp_pb2.Timestamp): Time when the workflow was created. @@ -91,7 +91,7 @@ class MigrationTask(proto.Message): The details of the task. The type URL must be one of the supported task details messages and correspond to the Task's type. - state (google.cloud.bigquery.migration_v2alpha.types.MigrationTask.State): + state (google.cloud.bigquery_migration_v2alpha.types.MigrationTask.State): Output only. The current state of the task. processing_error (google.rpc.error_details_pb2.ErrorInfo): Output only. An explanation that may be @@ -148,13 +148,13 @@ class MigrationSubtask(proto.Message): orchestrator or worker) to ensure it only creates subtasks for which there are compatible workers polling for Subtasks. - state (google.cloud.bigquery.migration_v2alpha.types.MigrationSubtask.State): + state (google.cloud.bigquery_migration_v2alpha.types.MigrationSubtask.State): Output only. The current state of the subtask. processing_error (google.rpc.error_details_pb2.ErrorInfo): Output only. An explanation that may be populated when the task is in FAILED state. - resource_error_details (Sequence[google.cloud.bigquery.migration_v2alpha.types.ResourceErrorDetail]): + resource_error_details (Sequence[google.cloud.bigquery_migration_v2alpha.types.ResourceErrorDetail]): Output only. Provides details to errors and issues encountered while processing the subtask. Presence of error details does not mean that the @@ -169,7 +169,7 @@ class MigrationSubtask(proto.Message): Time when the subtask was created. last_update_time (google.protobuf.timestamp_pb2.Timestamp): Time when the subtask was last updated. - metrics (Sequence[google.cloud.bigquery.migration_v2alpha.types.TimeSeries]): + metrics (Sequence[google.cloud.bigquery_migration_v2alpha.types.TimeSeries]): The metrics for the subtask. """ diff --git a/packages/google-cloud-bigquery-migration/google/cloud/bigquery/migration_v2alpha/types/migration_error_details.py b/packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration_v2alpha/types/migration_error_details.py similarity index 95% rename from packages/google-cloud-bigquery-migration/google/cloud/bigquery/migration_v2alpha/types/migration_error_details.py rename to packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration_v2alpha/types/migration_error_details.py index c7d99e19d811..1880b2b4b7ac 100644 --- a/packages/google-cloud-bigquery-migration/google/cloud/bigquery/migration_v2alpha/types/migration_error_details.py +++ b/packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration_v2alpha/types/migration_error_details.py @@ -30,7 +30,7 @@ class ResourceErrorDetail(proto.Message): resource_info (google.rpc.error_details_pb2.ResourceInfo): Required. Information about the resource where the error is located. - error_details (Sequence[google.cloud.bigquery.migration_v2alpha.types.ErrorDetail]): + error_details (Sequence[google.cloud.bigquery_migration_v2alpha.types.ErrorDetail]): Required. The error details for the resource. error_count (int): Required. How many errors there are in total for the @@ -51,7 +51,7 @@ class ErrorDetail(proto.Message): encountered when processing a subtask. Attributes: - location (google.cloud.bigquery.migration_v2alpha.types.ErrorLocation): + location (google.cloud.bigquery_migration_v2alpha.types.ErrorLocation): Optional. The exact location within the resource (if applicable). error_info (google.rpc.error_details_pb2.ErrorInfo): diff --git a/packages/google-cloud-bigquery-migration/google/cloud/bigquery/migration_v2alpha/types/migration_metrics.py b/packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration_v2alpha/types/migration_metrics.py similarity index 96% rename from packages/google-cloud-bigquery-migration/google/cloud/bigquery/migration_v2alpha/types/migration_metrics.py rename to packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration_v2alpha/types/migration_metrics.py index 30851946924e..6f08b9ee90ee 100644 --- a/packages/google-cloud-bigquery-migration/google/cloud/bigquery/migration_v2alpha/types/migration_metrics.py +++ b/packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration_v2alpha/types/migration_metrics.py @@ -43,7 +43,7 @@ class TimeSeries(proto.Message): must be auto-created, then this field specifies the metric kind of the new descriptor and must be either ``GAUGE`` (the default) or ``CUMULATIVE``. - points (Sequence[google.cloud.bigquery.migration_v2alpha.types.Point]): + points (Sequence[google.cloud.bigquery_migration_v2alpha.types.Point]): Required. The data points of this time series. When listing time series, points are returned in reverse time order. @@ -68,7 +68,7 @@ class TimeSeries(proto.Message): class Point(proto.Message): r"""A single data point in a time series. Attributes: - interval (google.cloud.bigquery.migration_v2alpha.types.TimeInterval): + interval (google.cloud.bigquery_migration_v2alpha.types.TimeInterval): The time interval to which the data point applies. For ``GAUGE`` metrics, the start time does not need to be supplied, but if it is supplied, it must equal the end time. @@ -80,7 +80,7 @@ class Point(proto.Message): time and increasing end times, until an event resets the cumulative value to zero and sets a new start time for the following points. - value (google.cloud.bigquery.migration_v2alpha.types.TypedValue): + value (google.cloud.bigquery_migration_v2alpha.types.TypedValue): The value of the data point. """ diff --git a/packages/google-cloud-bigquery-migration/google/cloud/bigquery/migration_v2alpha/types/migration_service.py b/packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration_v2alpha/types/migration_service.py similarity index 96% rename from packages/google-cloud-bigquery-migration/google/cloud/bigquery/migration_v2alpha/types/migration_service.py rename to packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration_v2alpha/types/migration_service.py index 531063bf4ab2..279bc193f083 100644 --- a/packages/google-cloud-bigquery-migration/google/cloud/bigquery/migration_v2alpha/types/migration_service.py +++ b/packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration_v2alpha/types/migration_service.py @@ -15,7 +15,7 @@ # import proto # type: ignore -from google.cloud.bigquery.migration_v2alpha.types import migration_entities +from google.cloud.bigquery_migration_v2alpha.types import migration_entities from google.protobuf import field_mask_pb2 # type: ignore @@ -41,7 +41,7 @@ class CreateMigrationWorkflowRequest(proto.Message): parent (str): Required. The name of the project to which this migration workflow belongs. Example: ``projects/foo/locations/bar`` - migration_workflow (google.cloud.bigquery.migration_v2alpha.types.MigrationWorkflow): + migration_workflow (google.cloud.bigquery_migration_v2alpha.types.MigrationWorkflow): Required. The migration workflow to create. """ @@ -96,7 +96,7 @@ class ListMigrationWorkflowsRequest(proto.Message): class ListMigrationWorkflowsResponse(proto.Message): r"""Response object for a ``ListMigrationWorkflows`` call. Attributes: - migration_workflows (Sequence[google.cloud.bigquery.migration_v2alpha.types.MigrationWorkflow]): + migration_workflows (Sequence[google.cloud.bigquery_migration_v2alpha.types.MigrationWorkflow]): The migration workflows for the specified project / location. next_page_token (str): @@ -189,7 +189,7 @@ class ListMigrationSubtasksRequest(proto.Message): class ListMigrationSubtasksResponse(proto.Message): r"""Response object for a ``ListMigrationSubtasks`` call. Attributes: - migration_subtasks (Sequence[google.cloud.bigquery.migration_v2alpha.types.MigrationSubtask]): + migration_subtasks (Sequence[google.cloud.bigquery_migration_v2alpha.types.MigrationSubtask]): The migration subtasks for the specified task. next_page_token (str): diff --git a/packages/google-cloud-bigquery-migration/scripts/fixup_bigquery_migration_v2alpha_keywords.py b/packages/google-cloud-bigquery-migration/scripts/fixup_bigquery_migration_v2alpha_keywords.py new file mode 100644 index 000000000000..629a81e9bbf1 --- /dev/null +++ b/packages/google-cloud-bigquery-migration/scripts/fixup_bigquery_migration_v2alpha_keywords.py @@ -0,0 +1,182 @@ +#! /usr/bin/env python3 +# -*- coding: utf-8 -*- +# Copyright 2020 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 argparse +import os +import libcst as cst +import pathlib +import sys +from typing import (Any, Callable, Dict, List, Sequence, Tuple) + + +def partition( + predicate: Callable[[Any], bool], + iterator: Sequence[Any] +) -> Tuple[List[Any], List[Any]]: + """A stable, out-of-place partition.""" + results = ([], []) + + for i in iterator: + results[int(predicate(i))].append(i) + + # Returns trueList, falseList + return results[1], results[0] + + +class bigquery_migrationCallTransformer(cst.CSTTransformer): + CTRL_PARAMS: Tuple[str] = ('retry', 'timeout', 'metadata') + METHOD_TO_PARAMS: Dict[str, Tuple[str]] = { + 'create_migration_workflow': ('parent', 'migration_workflow', ), + 'delete_migration_workflow': ('name', ), + 'get_migration_subtask': ('name', 'read_mask', ), + 'get_migration_workflow': ('name', 'read_mask', ), + 'list_migration_subtasks': ('parent', 'read_mask', 'page_size', 'page_token', 'filter', ), + 'list_migration_workflows': ('parent', 'read_mask', 'page_size', 'page_token', ), + 'start_migration_workflow': ('name', ), + } + + def leave_Call(self, original: cst.Call, updated: cst.Call) -> cst.CSTNode: + try: + key = original.func.attr.value + kword_params = self.METHOD_TO_PARAMS[key] + except (AttributeError, KeyError): + # Either not a method from the API or too convoluted to be sure. + return updated + + # If the existing code is valid, keyword args come after positional args. + # Therefore, all positional args must map to the first parameters. + args, kwargs = partition(lambda a: not bool(a.keyword), updated.args) + if any(k.keyword.value == "request" for k in kwargs): + # We've already fixed this file, don't fix it again. + return updated + + kwargs, ctrl_kwargs = partition( + lambda a: a.keyword.value not in self.CTRL_PARAMS, + kwargs + ) + + args, ctrl_args = args[:len(kword_params)], args[len(kword_params):] + ctrl_kwargs.extend(cst.Arg(value=a.value, keyword=cst.Name(value=ctrl)) + for a, ctrl in zip(ctrl_args, self.CTRL_PARAMS)) + + request_arg = cst.Arg( + value=cst.Dict([ + cst.DictElement( + cst.SimpleString("'{}'".format(name)), +cst.Element(value=arg.value) + ) + # Note: the args + kwargs looks silly, but keep in mind that + # the control parameters had to be stripped out, and that + # those could have been passed positionally or by keyword. + for name, arg in zip(kword_params, args + kwargs)]), + keyword=cst.Name("request") + ) + + return updated.with_changes( + args=[request_arg] + ctrl_kwargs + ) + + +def fix_files( + in_dir: pathlib.Path, + out_dir: pathlib.Path, + *, + transformer=bigquery_migrationCallTransformer(), +): + """Duplicate the input dir to the output dir, fixing file method calls. + + Preconditions: + * in_dir is a real directory + * out_dir is a real, empty directory + """ + pyfile_gen = ( + pathlib.Path(os.path.join(root, f)) + for root, _, files in os.walk(in_dir) + for f in files if os.path.splitext(f)[1] == ".py" + ) + + for fpath in pyfile_gen: + with open(fpath, 'r') as f: + src = f.read() + + # Parse the code and insert method call fixes. + tree = cst.parse_module(src) + updated = tree.visit(transformer) + + # Create the path and directory structure for the new file. + updated_path = out_dir.joinpath(fpath.relative_to(in_dir)) + updated_path.parent.mkdir(parents=True, exist_ok=True) + + # Generate the updated source file at the corresponding path. + with open(updated_path, 'w') as f: + f.write(updated.code) + + +if __name__ == '__main__': + parser = argparse.ArgumentParser( + description="""Fix up source that uses the bigquery_migration client library. + +The existing sources are NOT overwritten but are copied to output_dir with changes made. + +Note: This tool operates at a best-effort level at converting positional + parameters in client method calls to keyword based parameters. + Cases where it WILL FAIL include + A) * or ** expansion in a method call. + B) Calls via function or method alias (includes free function calls) + C) Indirect or dispatched calls (e.g. the method is looked up dynamically) + + These all constitute false negatives. The tool will also detect false + positives when an API method shares a name with another method. +""") + parser.add_argument( + '-d', + '--input-directory', + required=True, + dest='input_dir', + help='the input directory to walk for python files to fix up', + ) + parser.add_argument( + '-o', + '--output-directory', + required=True, + dest='output_dir', + help='the directory to output files fixed via un-flattening', + ) + args = parser.parse_args() + input_dir = pathlib.Path(args.input_dir) + output_dir = pathlib.Path(args.output_dir) + if not input_dir.is_dir(): + print( + f"input directory '{input_dir}' does not exist or is not a directory", + file=sys.stderr, + ) + sys.exit(-1) + + if not output_dir.is_dir(): + print( + f"output directory '{output_dir}' does not exist or is not a directory", + file=sys.stderr, + ) + sys.exit(-1) + + if os.listdir(output_dir): + print( + f"output directory '{output_dir}' is not empty", + file=sys.stderr, + ) + sys.exit(-1) + + fix_files(input_dir, output_dir) diff --git a/packages/google-cloud-bigquery-migration/setup.py b/packages/google-cloud-bigquery-migration/setup.py index 31d3b4547d3d..6ec2c952370d 100644 --- a/packages/google-cloud-bigquery-migration/setup.py +++ b/packages/google-cloud-bigquery-migration/setup.py @@ -34,7 +34,7 @@ license="Apache 2.0", url="https://github.com/googleapis/python-bigquery-migration", packages=setuptools.PEP420PackageFinder.find(), - namespace_packages=("google", "google.cloud", "google.cloud.bigquery"), + namespace_packages=("google", "google.cloud"), platforms="Posix; MacOS X; Windows", include_package_data=True, install_requires=( diff --git a/packages/google-cloud-bigquery-migration/tests/unit/gapic/migration_v2alpha/__init__.py b/packages/google-cloud-bigquery-migration/tests/unit/gapic/bigquery_migration_v2alpha/__init__.py similarity index 100% rename from packages/google-cloud-bigquery-migration/tests/unit/gapic/migration_v2alpha/__init__.py rename to packages/google-cloud-bigquery-migration/tests/unit/gapic/bigquery_migration_v2alpha/__init__.py diff --git a/packages/google-cloud-bigquery-migration/tests/unit/gapic/migration_v2alpha/test_migration_service.py b/packages/google-cloud-bigquery-migration/tests/unit/gapic/bigquery_migration_v2alpha/test_migration_service.py similarity index 99% rename from packages/google-cloud-bigquery-migration/tests/unit/gapic/migration_v2alpha/test_migration_service.py rename to packages/google-cloud-bigquery-migration/tests/unit/gapic/bigquery_migration_v2alpha/test_migration_service.py index 3e4c6ffbd4da..75203c8be9b9 100644 --- a/packages/google-cloud-bigquery-migration/tests/unit/gapic/migration_v2alpha/test_migration_service.py +++ b/packages/google-cloud-bigquery-migration/tests/unit/gapic/bigquery_migration_v2alpha/test_migration_service.py @@ -31,23 +31,23 @@ from google.api_core import grpc_helpers_async from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError -from google.cloud.bigquery.migration_v2alpha.services.migration_service import ( +from google.cloud.bigquery_migration_v2alpha.services.migration_service import ( MigrationServiceAsyncClient, ) -from google.cloud.bigquery.migration_v2alpha.services.migration_service import ( +from google.cloud.bigquery_migration_v2alpha.services.migration_service import ( MigrationServiceClient, ) -from google.cloud.bigquery.migration_v2alpha.services.migration_service import pagers -from google.cloud.bigquery.migration_v2alpha.services.migration_service import ( +from google.cloud.bigquery_migration_v2alpha.services.migration_service import pagers +from google.cloud.bigquery_migration_v2alpha.services.migration_service import ( transports, ) -from google.cloud.bigquery.migration_v2alpha.services.migration_service.transports.base import ( +from google.cloud.bigquery_migration_v2alpha.services.migration_service.transports.base import ( _GOOGLE_AUTH_VERSION, ) -from google.cloud.bigquery.migration_v2alpha.types import migration_entities -from google.cloud.bigquery.migration_v2alpha.types import migration_error_details -from google.cloud.bigquery.migration_v2alpha.types import migration_metrics -from google.cloud.bigquery.migration_v2alpha.types import migration_service +from google.cloud.bigquery_migration_v2alpha.types import migration_entities +from google.cloud.bigquery_migration_v2alpha.types import migration_error_details +from google.cloud.bigquery_migration_v2alpha.types import migration_metrics +from google.cloud.bigquery_migration_v2alpha.types import migration_service from google.oauth2 import service_account from google.protobuf import any_pb2 # type: ignore from google.protobuf import field_mask_pb2 # type: ignore @@ -500,7 +500,7 @@ def test_migration_service_client_client_options_credentials_file( def test_migration_service_client_client_options_from_dict(): with mock.patch( - "google.cloud.bigquery.migration_v2alpha.services.migration_service.transports.MigrationServiceGrpcTransport.__init__" + "google.cloud.bigquery_migration_v2alpha.services.migration_service.transports.MigrationServiceGrpcTransport.__init__" ) as grpc_transport: grpc_transport.return_value = None client = MigrationServiceClient( @@ -2532,7 +2532,7 @@ def test_migration_service_base_transport_error(): def test_migration_service_base_transport(): # Instantiate the base transport. with mock.patch( - "google.cloud.bigquery.migration_v2alpha.services.migration_service.transports.MigrationServiceTransport.__init__" + "google.cloud.bigquery_migration_v2alpha.services.migration_service.transports.MigrationServiceTransport.__init__" ) as Transport: Transport.return_value = None transport = transports.MigrationServiceTransport( @@ -2561,7 +2561,7 @@ def test_migration_service_base_transport_with_credentials_file(): with mock.patch.object( google.auth, "load_credentials_from_file", autospec=True ) as load_creds, mock.patch( - "google.cloud.bigquery.migration_v2alpha.services.migration_service.transports.MigrationServiceTransport._prep_wrapped_messages" + "google.cloud.bigquery_migration_v2alpha.services.migration_service.transports.MigrationServiceTransport._prep_wrapped_messages" ) as Transport: Transport.return_value = None load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) @@ -2582,7 +2582,7 @@ def test_migration_service_base_transport_with_credentials_file_old_google_auth( with mock.patch.object( google.auth, "load_credentials_from_file", autospec=True ) as load_creds, mock.patch( - "google.cloud.bigquery.migration_v2alpha.services.migration_service.transports.MigrationServiceTransport._prep_wrapped_messages" + "google.cloud.bigquery_migration_v2alpha.services.migration_service.transports.MigrationServiceTransport._prep_wrapped_messages" ) as Transport: Transport.return_value = None load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) @@ -2599,7 +2599,7 @@ def test_migration_service_base_transport_with_credentials_file_old_google_auth( def test_migration_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.cloud.bigquery.migration_v2alpha.services.migration_service.transports.MigrationServiceTransport._prep_wrapped_messages" + "google.cloud.bigquery_migration_v2alpha.services.migration_service.transports.MigrationServiceTransport._prep_wrapped_messages" ) as Transport: Transport.return_value = None adc.return_value = (ga_credentials.AnonymousCredentials(), None)