Skip to content
This repository has been archived by the owner on Sep 5, 2023. It is now read-only.

chore: use gapic-generator-python 0.53.4 #110

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@
from typing import Dict, Sequence, Tuple, Type, Union
import pkg_resources

import google.api_core.client_options as ClientOptions # type: ignore
from google.api_core.client_options import ClientOptions # type: ignore
from google.api_core import exceptions as core_exceptions # type: ignore
from google.api_core import gapic_v1 # type: ignore
from google.api_core import retry as retries # type: ignore
from google.auth import credentials as ga_credentials # type: ignore
from google.oauth2 import service_account # type: ignore

OptionalRetry = Union[retries.Retry, object]

from google.api_core import operation # type: ignore
from google.api_core import operation_async # type: ignore
from google.cloud.notebooks_v1.services.managed_notebook_service import pagers
Expand Down Expand Up @@ -173,17 +175,17 @@ def __init__(

async def list_runtimes(
self,
request: managed_service.ListRuntimesRequest = None,
request: Union[managed_service.ListRuntimesRequest, dict] = None,
*,
parent: str = None,
retry: retries.Retry = gapic_v1.method.DEFAULT,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> pagers.ListRuntimesAsyncPager:
r"""Lists Runtimes in a given project and location.

Args:
request (:class:`google.cloud.notebooks_v1.types.ListRuntimesRequest`):
request (Union[google.cloud.notebooks_v1.types.ListRuntimesRequest, dict]):
The request object. Request for listing Managed Notebook
Runtimes.
parent (:class:`str`):
Expand Down Expand Up @@ -253,18 +255,18 @@ async def list_runtimes(

async def get_runtime(
self,
request: managed_service.GetRuntimeRequest = None,
request: Union[managed_service.GetRuntimeRequest, dict] = None,
*,
name: str = None,
retry: retries.Retry = gapic_v1.method.DEFAULT,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> runtime.Runtime:
r"""Gets details of a single Runtime. The location must
be a regional endpoint rather than zonal.

Args:
request (:class:`google.cloud.notebooks_v1.types.GetRuntimeRequest`):
request (Union[google.cloud.notebooks_v1.types.GetRuntimeRequest, dict]):
The request object. Request for getting a Managed
Notebook Runtime.
name (:class:`str`):
Expand Down Expand Up @@ -325,20 +327,20 @@ async def get_runtime(

async def create_runtime(
self,
request: managed_service.CreateRuntimeRequest = None,
request: Union[managed_service.CreateRuntimeRequest, dict] = None,
*,
parent: str = None,
runtime_id: str = None,
runtime: gcn_runtime.Runtime = None,
retry: retries.Retry = gapic_v1.method.DEFAULT,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> operation_async.AsyncOperation:
r"""Creates a new Runtime in a given project and
location.

Args:
request (:class:`google.cloud.notebooks_v1.types.CreateRuntimeRequest`):
request (Union[google.cloud.notebooks_v1.types.CreateRuntimeRequest, dict]):
The request object. Request for creating a Managed
Notebook Runtime.
parent (:class:`str`):
Expand Down Expand Up @@ -426,17 +428,17 @@ async def create_runtime(

async def delete_runtime(
self,
request: managed_service.DeleteRuntimeRequest = None,
request: Union[managed_service.DeleteRuntimeRequest, dict] = None,
*,
name: str = None,
retry: retries.Retry = gapic_v1.method.DEFAULT,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> operation_async.AsyncOperation:
r"""Deletes a single Runtime.

Args:
request (:class:`google.cloud.notebooks_v1.types.DeleteRuntimeRequest`):
request (Union[google.cloud.notebooks_v1.types.DeleteRuntimeRequest, dict]):
The request object. Request for deleting a Managed
Notebook Runtime.
name (:class:`str`):
Expand Down Expand Up @@ -518,10 +520,10 @@ async def delete_runtime(

async def start_runtime(
self,
request: managed_service.StartRuntimeRequest = None,
request: Union[managed_service.StartRuntimeRequest, dict] = None,
*,
name: str = None,
retry: retries.Retry = gapic_v1.method.DEFAULT,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> operation_async.AsyncOperation:
Expand All @@ -534,7 +536,7 @@ async def start_runtime(
resume-instance

Args:
request (:class:`google.cloud.notebooks_v1.types.StartRuntimeRequest`):
request (Union[google.cloud.notebooks_v1.types.StartRuntimeRequest, dict]):
The request object. Request for starting a Managed
Notebook Runtime.
name (:class:`str`):
Expand Down Expand Up @@ -606,10 +608,10 @@ async def start_runtime(

async def stop_runtime(
self,
request: managed_service.StopRuntimeRequest = None,
request: Union[managed_service.StopRuntimeRequest, dict] = None,
*,
name: str = None,
retry: retries.Retry = gapic_v1.method.DEFAULT,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> operation_async.AsyncOperation:
Expand All @@ -622,7 +624,7 @@ async def stop_runtime(
resume-instance

Args:
request (:class:`google.cloud.notebooks_v1.types.StopRuntimeRequest`):
request (Union[google.cloud.notebooks_v1.types.StopRuntimeRequest, dict]):
The request object. Request for stopping a Managed
Notebook Runtime.
name (:class:`str`):
Expand Down Expand Up @@ -694,17 +696,17 @@ async def stop_runtime(

async def switch_runtime(
self,
request: managed_service.SwitchRuntimeRequest = None,
request: Union[managed_service.SwitchRuntimeRequest, dict] = None,
*,
name: str = None,
retry: retries.Retry = gapic_v1.method.DEFAULT,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> operation_async.AsyncOperation:
r"""Switch a Managed Notebook Runtime.

Args:
request (:class:`google.cloud.notebooks_v1.types.SwitchRuntimeRequest`):
request (Union[google.cloud.notebooks_v1.types.SwitchRuntimeRequest, dict]):
The request object. Request for switching a Managed
Notebook Runtime.
name (:class:`str`):
Expand Down Expand Up @@ -776,17 +778,17 @@ async def switch_runtime(

async def reset_runtime(
self,
request: managed_service.ResetRuntimeRequest = None,
request: Union[managed_service.ResetRuntimeRequest, dict] = None,
*,
name: str = None,
retry: retries.Retry = gapic_v1.method.DEFAULT,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> operation_async.AsyncOperation:
r"""Resets a Managed Notebook Runtime.

Args:
request (:class:`google.cloud.notebooks_v1.types.ResetRuntimeRequest`):
request (Union[google.cloud.notebooks_v1.types.ResetRuntimeRequest, dict]):
The request object. Request for reseting a Managed
Notebook Runtime.
name (:class:`str`):
Expand Down Expand Up @@ -858,17 +860,17 @@ async def reset_runtime(

async def report_runtime_event(
self,
request: managed_service.ReportRuntimeEventRequest = None,
request: Union[managed_service.ReportRuntimeEventRequest, dict] = None,
*,
name: str = None,
retry: retries.Retry = gapic_v1.method.DEFAULT,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> operation_async.AsyncOperation:
r"""Report and process a runtime event.

Args:
request (:class:`google.cloud.notebooks_v1.types.ReportRuntimeEventRequest`):
request (Union[google.cloud.notebooks_v1.types.ReportRuntimeEventRequest, dict]):
The request object. Request for reporting a Managed
Notebook Event.
name (:class:`str`):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
from google.auth.exceptions import MutualTLSChannelError # type: ignore
from google.oauth2 import service_account # type: ignore

OptionalRetry = Union[retries.Retry, object]

from google.api_core import operation # type: ignore
from google.api_core import operation_async # type: ignore
from google.cloud.notebooks_v1.services.managed_notebook_service import pagers
Expand Down Expand Up @@ -361,7 +363,7 @@ def list_runtimes(
request: Union[managed_service.ListRuntimesRequest, dict] = None,
*,
parent: str = None,
retry: retries.Retry = gapic_v1.method.DEFAULT,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> pagers.ListRuntimesPager:
Expand Down Expand Up @@ -441,7 +443,7 @@ def get_runtime(
request: Union[managed_service.GetRuntimeRequest, dict] = None,
*,
name: str = None,
retry: retries.Retry = gapic_v1.method.DEFAULT,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> runtime.Runtime:
Expand Down Expand Up @@ -515,7 +517,7 @@ def create_runtime(
parent: str = None,
runtime_id: str = None,
runtime: gcn_runtime.Runtime = None,
retry: retries.Retry = gapic_v1.method.DEFAULT,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> operation.Operation:
Expand Down Expand Up @@ -614,7 +616,7 @@ def delete_runtime(
request: Union[managed_service.DeleteRuntimeRequest, dict] = None,
*,
name: str = None,
retry: retries.Retry = gapic_v1.method.DEFAULT,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> operation.Operation:
Expand Down Expand Up @@ -706,7 +708,7 @@ def start_runtime(
request: Union[managed_service.StartRuntimeRequest, dict] = None,
*,
name: str = None,
retry: retries.Retry = gapic_v1.method.DEFAULT,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> operation.Operation:
Expand Down Expand Up @@ -794,7 +796,7 @@ def stop_runtime(
request: Union[managed_service.StopRuntimeRequest, dict] = None,
*,
name: str = None,
retry: retries.Retry = gapic_v1.method.DEFAULT,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> operation.Operation:
Expand Down Expand Up @@ -882,7 +884,7 @@ def switch_runtime(
request: Union[managed_service.SwitchRuntimeRequest, dict] = None,
*,
name: str = None,
retry: retries.Retry = gapic_v1.method.DEFAULT,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> operation.Operation:
Expand Down Expand Up @@ -964,7 +966,7 @@ def reset_runtime(
request: Union[managed_service.ResetRuntimeRequest, dict] = None,
*,
name: str = None,
retry: retries.Retry = gapic_v1.method.DEFAULT,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> operation.Operation:
Expand Down Expand Up @@ -1046,7 +1048,7 @@ def report_runtime_event(
request: Union[managed_service.ReportRuntimeEventRequest, dict] = None,
*,
name: str = None,
retry: retries.Retry = gapic_v1.method.DEFAULT,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> operation.Operation:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
#
import abc
from typing import Awaitable, Callable, Dict, Optional, Sequence, Union
import packaging.version
import pkg_resources

import google.auth # type: ignore
Expand All @@ -38,15 +37,6 @@
except pkg_resources.DistributionNotFound:
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo()

try:
# google.auth.__version__ was added in 1.26.0
_GOOGLE_AUTH_VERSION = google.auth.__version__
except AttributeError:
try: # try pkg_resources if it is available
_GOOGLE_AUTH_VERSION = pkg_resources.get_distribution("google-auth").version
except pkg_resources.DistributionNotFound: # pragma: NO COVER
_GOOGLE_AUTH_VERSION = None


class ManagedNotebookServiceTransport(abc.ABC):
"""Abstract transport class for ManagedNotebookService."""
Expand Down Expand Up @@ -96,7 +86,7 @@ def __init__(
host += ":443"
self._host = host

scopes_kwargs = self._get_scopes_kwargs(self._host, scopes)
scopes_kwargs = {"scopes": scopes, "default_scopes": self.AUTH_SCOPES}

# Save the scopes.
self._scopes = scopes
Expand Down Expand Up @@ -129,29 +119,6 @@ def __init__(
# Save the credentials.
self._credentials = credentials

# TODO(busunkim): This method is in the base transport
# to avoid duplicating code across the transport classes. These functions
# should be deleted once the minimum required versions of google-auth is increased.

# TODO: Remove this function once google-auth >= 1.25.0 is required
@classmethod
def _get_scopes_kwargs(
cls, host: str, scopes: Optional[Sequence[str]]
) -> Dict[str, Optional[Sequence[str]]]:
"""Returns scopes kwargs to pass to google-auth methods depending on the google-auth version"""

scopes_kwargs = {}

if _GOOGLE_AUTH_VERSION and (
packaging.version.parse(_GOOGLE_AUTH_VERSION)
>= packaging.version.parse("1.25.0")
):
scopes_kwargs = {"scopes": scopes, "default_scopes": cls.AUTH_SCOPES}
else:
scopes_kwargs = {"scopes": scopes or cls.AUTH_SCOPES}

return scopes_kwargs

def _prep_wrapped_messages(self, client_info):
# Precompute the wrapped methods.
self._wrapped_methods = {
Expand Down Expand Up @@ -196,7 +163,7 @@ def close(self):
raise NotImplementedError()

@property
def operations_client(self) -> operations_v1.OperationsClient:
def operations_client(self):
"""Return the client designed to process long-running operations."""
raise NotImplementedError()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def __init__(
self._grpc_channel = None
self._ssl_channel_credentials = ssl_channel_credentials
self._stubs: Dict[str, Callable] = {}
self._operations_client = None
self._operations_client: Optional[operations_v1.OperationsClient] = None

if api_mtls_endpoint:
warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
from google.api_core import operations_v1 # type: ignore
from google.auth import credentials as ga_credentials # type: ignore
from google.auth.transport.grpc import SslCredentials # type: ignore
import packaging.version

import grpc # type: ignore
from grpc.experimental import aio # type: ignore
Expand Down Expand Up @@ -160,7 +159,7 @@ def __init__(
self._grpc_channel = None
self._ssl_channel_credentials = ssl_channel_credentials
self._stubs: Dict[str, Callable] = {}
self._operations_client = None
self._operations_client: Optional[operations_v1.OperationsAsyncClient] = None

if api_mtls_endpoint:
warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning)
Expand Down