diff --git a/google/cloud/notebooks/__init__.py b/google/cloud/notebooks/__init__.py index fe8bb9b..b970bf1 100644 --- a/google/cloud/notebooks/__init__.py +++ b/google/cloud/notebooks/__init__.py @@ -41,6 +41,12 @@ from google.cloud.notebooks_v1.types.managed_service import GetRuntimeRequest from google.cloud.notebooks_v1.types.managed_service import ListRuntimesRequest from google.cloud.notebooks_v1.types.managed_service import ListRuntimesResponse +from google.cloud.notebooks_v1.types.managed_service import ( + RefreshRuntimeTokenInternalRequest, +) +from google.cloud.notebooks_v1.types.managed_service import ( + RefreshRuntimeTokenInternalResponse, +) from google.cloud.notebooks_v1.types.managed_service import ReportRuntimeEventRequest from google.cloud.notebooks_v1.types.managed_service import ResetRuntimeRequest from google.cloud.notebooks_v1.types.managed_service import StartRuntimeRequest @@ -94,9 +100,12 @@ from google.cloud.notebooks_v1.types.service import StopInstanceRequest from google.cloud.notebooks_v1.types.service import TriggerScheduleRequest from google.cloud.notebooks_v1.types.service import UpdateInstanceConfigRequest +from google.cloud.notebooks_v1.types.service import UpdateInstanceMetadataItemsRequest +from google.cloud.notebooks_v1.types.service import UpdateInstanceMetadataItemsResponse from google.cloud.notebooks_v1.types.service import UpdateShieldedInstanceConfigRequest from google.cloud.notebooks_v1.types.service import UpgradeInstanceInternalRequest from google.cloud.notebooks_v1.types.service import UpgradeInstanceRequest +from google.cloud.notebooks_v1.types.service import UpgradeType __all__ = ( "ManagedNotebookServiceClient", @@ -117,6 +126,8 @@ "GetRuntimeRequest", "ListRuntimesRequest", "ListRuntimesResponse", + "RefreshRuntimeTokenInternalRequest", + "RefreshRuntimeTokenInternalResponse", "ReportRuntimeEventRequest", "ResetRuntimeRequest", "StartRuntimeRequest", @@ -170,7 +181,10 @@ "StopInstanceRequest", "TriggerScheduleRequest", "UpdateInstanceConfigRequest", + "UpdateInstanceMetadataItemsRequest", + "UpdateInstanceMetadataItemsResponse", "UpdateShieldedInstanceConfigRequest", "UpgradeInstanceInternalRequest", "UpgradeInstanceRequest", + "UpgradeType", ) diff --git a/google/cloud/notebooks_v1/__init__.py b/google/cloud/notebooks_v1/__init__.py index a323e40..20a1119 100644 --- a/google/cloud/notebooks_v1/__init__.py +++ b/google/cloud/notebooks_v1/__init__.py @@ -33,6 +33,8 @@ from .types.managed_service import GetRuntimeRequest from .types.managed_service import ListRuntimesRequest from .types.managed_service import ListRuntimesResponse +from .types.managed_service import RefreshRuntimeTokenInternalRequest +from .types.managed_service import RefreshRuntimeTokenInternalResponse from .types.managed_service import ReportRuntimeEventRequest from .types.managed_service import ResetRuntimeRequest from .types.managed_service import StartRuntimeRequest @@ -86,9 +88,12 @@ from .types.service import StopInstanceRequest from .types.service import TriggerScheduleRequest from .types.service import UpdateInstanceConfigRequest +from .types.service import UpdateInstanceMetadataItemsRequest +from .types.service import UpdateInstanceMetadataItemsResponse from .types.service import UpdateShieldedInstanceConfigRequest from .types.service import UpgradeInstanceInternalRequest from .types.service import UpgradeInstanceRequest +from .types.service import UpgradeType __all__ = ( "ManagedNotebookServiceAsyncClient", @@ -135,6 +140,8 @@ "ManagedNotebookServiceClient", "NotebookServiceClient", "OperationMetadata", + "RefreshRuntimeTokenInternalRequest", + "RefreshRuntimeTokenInternalResponse", "RegisterInstanceRequest", "ReportInstanceInfoRequest", "ReportRuntimeEventRequest", @@ -159,9 +166,12 @@ "SwitchRuntimeRequest", "TriggerScheduleRequest", "UpdateInstanceConfigRequest", + "UpdateInstanceMetadataItemsRequest", + "UpdateInstanceMetadataItemsResponse", "UpdateShieldedInstanceConfigRequest", "UpgradeInstanceInternalRequest", "UpgradeInstanceRequest", + "UpgradeType", "VirtualMachine", "VirtualMachineConfig", "VmImage", diff --git a/google/cloud/notebooks_v1/gapic_metadata.json b/google/cloud/notebooks_v1/gapic_metadata.json index 9c93633..aa528ae 100644 --- a/google/cloud/notebooks_v1/gapic_metadata.json +++ b/google/cloud/notebooks_v1/gapic_metadata.json @@ -30,6 +30,11 @@ "list_runtimes" ] }, + "RefreshRuntimeTokenInternal": { + "methods": [ + "refresh_runtime_token_internal" + ] + }, "ReportRuntimeEvent": { "methods": [ "report_runtime_event" @@ -80,6 +85,11 @@ "list_runtimes" ] }, + "RefreshRuntimeTokenInternal": { + "methods": [ + "refresh_runtime_token_internal" + ] + }, "ReportRuntimeEvent": { "methods": [ "report_runtime_event" @@ -259,6 +269,11 @@ "update_instance_config" ] }, + "UpdateInstanceMetadataItems": { + "methods": [ + "update_instance_metadata_items" + ] + }, "UpdateShieldedInstanceConfig": { "methods": [ "update_shielded_instance_config" @@ -424,6 +439,11 @@ "update_instance_config" ] }, + "UpdateInstanceMetadataItems": { + "methods": [ + "update_instance_metadata_items" + ] + }, "UpdateShieldedInstanceConfig": { "methods": [ "update_shielded_instance_config" diff --git a/google/cloud/notebooks_v1/services/managed_notebook_service/async_client.py b/google/cloud/notebooks_v1/services/managed_notebook_service/async_client.py index 69dab7f..7fa559b 100644 --- a/google/cloud/notebooks_v1/services/managed_notebook_service/async_client.py +++ b/google/cloud/notebooks_v1/services/managed_notebook_service/async_client.py @@ -1040,7 +1040,7 @@ def sample_reset_runtime(): Args: request (Union[google.cloud.notebooks_v1.types.ResetRuntimeRequest, dict]): - The request object. Request for reseting a Managed + The request object. Request for resetting a Managed Notebook Runtime. name (:class:`str`): Required. Format: @@ -1225,6 +1225,113 @@ def sample_report_runtime_event(): # Done; return the response. return response + async def refresh_runtime_token_internal( + self, + request: Union[managed_service.RefreshRuntimeTokenInternalRequest, dict] = None, + *, + name: str = None, + vm_id: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> managed_service.RefreshRuntimeTokenInternalResponse: + r"""Gets an access token for the consumer service account + that the customer attached to the runtime. Only + accessible from the tenant instance. + + .. code-block:: python + + from google.cloud import notebooks_v1 + + def sample_refresh_runtime_token_internal(): + # Create a client + client = notebooks_v1.ManagedNotebookServiceClient() + + # Initialize request argument(s) + request = notebooks_v1.RefreshRuntimeTokenInternalRequest( + name="name_value", + vm_id="vm_id_value", + ) + + # Make the request + response = client.refresh_runtime_token_internal(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.notebooks_v1.types.RefreshRuntimeTokenInternalRequest, dict]): + The request object. Request for getting a new access + token. + name (:class:`str`): + Required. Format: + ``projects/{project_id}/locations/{location}/runtimes/{runtime_id}`` + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + vm_id (:class:`str`): + Required. The VM hardware token for + authenticating the VM. + https://cloud.google.com/compute/docs/instances/verifying-instance-identity + + This corresponds to the ``vm_id`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + 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: + google.cloud.notebooks_v1.types.RefreshRuntimeTokenInternalResponse: + Response with a new access token. + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name, vm_id]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + request = managed_service.RefreshRuntimeTokenInternalRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + if vm_id is not None: + request.vm_id = vm_id + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.refresh_runtime_token_internal, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + async def __aenter__(self): return self diff --git a/google/cloud/notebooks_v1/services/managed_notebook_service/client.py b/google/cloud/notebooks_v1/services/managed_notebook_service/client.py index 6481630..704adf6 100644 --- a/google/cloud/notebooks_v1/services/managed_notebook_service/client.py +++ b/google/cloud/notebooks_v1/services/managed_notebook_service/client.py @@ -1261,7 +1261,7 @@ def sample_reset_runtime(): Args: request (Union[google.cloud.notebooks_v1.types.ResetRuntimeRequest, dict]): - The request object. Request for reseting a Managed + The request object. Request for resetting a Managed Notebook Runtime. name (str): Required. Format: @@ -1446,6 +1446,115 @@ def sample_report_runtime_event(): # Done; return the response. return response + def refresh_runtime_token_internal( + self, + request: Union[managed_service.RefreshRuntimeTokenInternalRequest, dict] = None, + *, + name: str = None, + vm_id: str = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> managed_service.RefreshRuntimeTokenInternalResponse: + r"""Gets an access token for the consumer service account + that the customer attached to the runtime. Only + accessible from the tenant instance. + + .. code-block:: python + + from google.cloud import notebooks_v1 + + def sample_refresh_runtime_token_internal(): + # Create a client + client = notebooks_v1.ManagedNotebookServiceClient() + + # Initialize request argument(s) + request = notebooks_v1.RefreshRuntimeTokenInternalRequest( + name="name_value", + vm_id="vm_id_value", + ) + + # Make the request + response = client.refresh_runtime_token_internal(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.notebooks_v1.types.RefreshRuntimeTokenInternalRequest, dict]): + The request object. Request for getting a new access + token. + name (str): + Required. Format: + ``projects/{project_id}/locations/{location}/runtimes/{runtime_id}`` + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + vm_id (str): + Required. The VM hardware token for + authenticating the VM. + https://cloud.google.com/compute/docs/instances/verifying-instance-identity + + This corresponds to the ``vm_id`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + 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: + google.cloud.notebooks_v1.types.RefreshRuntimeTokenInternalResponse: + Response with a new access token. + """ + # Create or coerce a protobuf request object. + # Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + has_flattened_params = any([name, vm_id]) + if request is not None and has_flattened_params: + raise ValueError( + "If the `request` argument is set, then none of " + "the individual field arguments should be set." + ) + + # Minor optimization to avoid making a copy if the user passes + # in a managed_service.RefreshRuntimeTokenInternalRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, managed_service.RefreshRuntimeTokenInternalRequest): + request = managed_service.RefreshRuntimeTokenInternalRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + if vm_id is not None: + request.vm_id = vm_id + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[ + self._transport.refresh_runtime_token_internal + ] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + def __enter__(self): return self diff --git a/google/cloud/notebooks_v1/services/managed_notebook_service/transports/base.py b/google/cloud/notebooks_v1/services/managed_notebook_service/transports/base.py index 1fe2753..d21d786 100644 --- a/google/cloud/notebooks_v1/services/managed_notebook_service/transports/base.py +++ b/google/cloud/notebooks_v1/services/managed_notebook_service/transports/base.py @@ -169,6 +169,11 @@ def _prep_wrapped_messages(self, client_info): default_timeout=60.0, client_info=client_info, ), + self.refresh_runtime_token_internal: gapic_v1.method.wrap_method( + self.refresh_runtime_token_internal, + default_timeout=None, + client_info=client_info, + ), } def close(self): @@ -269,6 +274,18 @@ def report_runtime_event( ]: raise NotImplementedError() + @property + def refresh_runtime_token_internal( + self, + ) -> Callable[ + [managed_service.RefreshRuntimeTokenInternalRequest], + Union[ + managed_service.RefreshRuntimeTokenInternalResponse, + Awaitable[managed_service.RefreshRuntimeTokenInternalResponse], + ], + ]: + raise NotImplementedError() + @property def kind(self) -> str: raise NotImplementedError() diff --git a/google/cloud/notebooks_v1/services/managed_notebook_service/transports/grpc.py b/google/cloud/notebooks_v1/services/managed_notebook_service/transports/grpc.py index 5a0c1a3..3462808 100644 --- a/google/cloud/notebooks_v1/services/managed_notebook_service/transports/grpc.py +++ b/google/cloud/notebooks_v1/services/managed_notebook_service/transports/grpc.py @@ -493,6 +493,39 @@ def report_runtime_event( ) return self._stubs["report_runtime_event"] + @property + def refresh_runtime_token_internal( + self, + ) -> Callable[ + [managed_service.RefreshRuntimeTokenInternalRequest], + managed_service.RefreshRuntimeTokenInternalResponse, + ]: + r"""Return a callable for the refresh runtime token internal method over gRPC. + + Gets an access token for the consumer service account + that the customer attached to the runtime. Only + accessible from the tenant instance. + + Returns: + Callable[[~.RefreshRuntimeTokenInternalRequest], + ~.RefreshRuntimeTokenInternalResponse]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "refresh_runtime_token_internal" not in self._stubs: + self._stubs[ + "refresh_runtime_token_internal" + ] = self.grpc_channel.unary_unary( + "/google.cloud.notebooks.v1.ManagedNotebookService/RefreshRuntimeTokenInternal", + request_serializer=managed_service.RefreshRuntimeTokenInternalRequest.serialize, + response_deserializer=managed_service.RefreshRuntimeTokenInternalResponse.deserialize, + ) + return self._stubs["refresh_runtime_token_internal"] + def close(self): self.grpc_channel.close() diff --git a/google/cloud/notebooks_v1/services/managed_notebook_service/transports/grpc_asyncio.py b/google/cloud/notebooks_v1/services/managed_notebook_service/transports/grpc_asyncio.py index b2332e2..fbe84fc 100644 --- a/google/cloud/notebooks_v1/services/managed_notebook_service/transports/grpc_asyncio.py +++ b/google/cloud/notebooks_v1/services/managed_notebook_service/transports/grpc_asyncio.py @@ -511,6 +511,39 @@ def report_runtime_event( ) return self._stubs["report_runtime_event"] + @property + def refresh_runtime_token_internal( + self, + ) -> Callable[ + [managed_service.RefreshRuntimeTokenInternalRequest], + Awaitable[managed_service.RefreshRuntimeTokenInternalResponse], + ]: + r"""Return a callable for the refresh runtime token internal method over gRPC. + + Gets an access token for the consumer service account + that the customer attached to the runtime. Only + accessible from the tenant instance. + + Returns: + Callable[[~.RefreshRuntimeTokenInternalRequest], + Awaitable[~.RefreshRuntimeTokenInternalResponse]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "refresh_runtime_token_internal" not in self._stubs: + self._stubs[ + "refresh_runtime_token_internal" + ] = self.grpc_channel.unary_unary( + "/google.cloud.notebooks.v1.ManagedNotebookService/RefreshRuntimeTokenInternal", + request_serializer=managed_service.RefreshRuntimeTokenInternalRequest.serialize, + response_deserializer=managed_service.RefreshRuntimeTokenInternalResponse.deserialize, + ) + return self._stubs["refresh_runtime_token_internal"] + def close(self): return self.grpc_channel.close() diff --git a/google/cloud/notebooks_v1/services/notebook_service/async_client.py b/google/cloud/notebooks_v1/services/notebook_service/async_client.py index c3828d8..93d13f0 100644 --- a/google/cloud/notebooks_v1/services/notebook_service/async_client.py +++ b/google/cloud/notebooks_v1/services/notebook_service/async_client.py @@ -66,6 +66,8 @@ class NotebookServiceAsyncClient: parse_instance_path = staticmethod(NotebookServiceClient.parse_instance_path) schedule_path = staticmethod(NotebookServiceClient.schedule_path) parse_schedule_path = staticmethod(NotebookServiceClient.parse_schedule_path) + tensorboard_path = staticmethod(NotebookServiceClient.tensorboard_path) + parse_tensorboard_path = staticmethod(NotebookServiceClient.parse_tensorboard_path) common_billing_account_path = staticmethod( NotebookServiceClient.common_billing_account_path ) @@ -1097,6 +1099,79 @@ def sample_set_instance_labels(): # Done; return the response. return response + async def update_instance_metadata_items( + self, + request: Union[service.UpdateInstanceMetadataItemsRequest, dict] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> service.UpdateInstanceMetadataItemsResponse: + r"""Add/update metadata items for an instance. + + .. code-block:: python + + from google.cloud import notebooks_v1 + + def sample_update_instance_metadata_items(): + # Create a client + client = notebooks_v1.NotebookServiceClient() + + # Initialize request argument(s) + request = notebooks_v1.UpdateInstanceMetadataItemsRequest( + name="name_value", + ) + + # Make the request + response = client.update_instance_metadata_items(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.notebooks_v1.types.UpdateInstanceMetadataItemsRequest, dict]): + The request object. Request for adding/changing metadata + items for an instance. + 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: + google.cloud.notebooks_v1.types.UpdateInstanceMetadataItemsResponse: + Response for adding/changing metadata + items for an instance. + + """ + # Create or coerce a protobuf request object. + request = service.UpdateInstanceMetadataItemsRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.update_instance_metadata_items, + default_timeout=None, + client_info=DEFAULT_CLIENT_INFO, + ) + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + async def delete_instance( self, request: Union[service.DeleteInstanceRequest, dict] = None, @@ -1428,7 +1503,7 @@ def sample_reset_instance(): Args: request (Union[google.cloud.notebooks_v1.types.ResetInstanceRequest, dict]): - The request object. Request for reseting a notebook + The request object. Request for resetting a notebook instance retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. @@ -3345,8 +3420,8 @@ async def create_execution( timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operation_async.AsyncOperation: - r"""Creates a new Scheduled Notebook in a given project - and location. + r"""Creates a new Execution in a given project and + location. .. code-block:: python diff --git a/google/cloud/notebooks_v1/services/notebook_service/client.py b/google/cloud/notebooks_v1/services/notebook_service/client.py index eacaf0a..4ceff4c 100644 --- a/google/cloud/notebooks_v1/services/notebook_service/client.py +++ b/google/cloud/notebooks_v1/services/notebook_service/client.py @@ -254,6 +254,30 @@ def parse_schedule_path(path: str) -> Dict[str, str]: ) return m.groupdict() if m else {} + @staticmethod + def tensorboard_path( + project: str, + location: str, + tensorboard: str, + ) -> str: + """Returns a fully-qualified tensorboard string.""" + return ( + "projects/{project}/locations/{location}/tensorboards/{tensorboard}".format( + project=project, + location=location, + tensorboard=tensorboard, + ) + ) + + @staticmethod + def parse_tensorboard_path(path: str) -> Dict[str, str]: + """Parses a tensorboard path into its component segments.""" + m = re.match( + r"^projects/(?P.+?)/locations/(?P.+?)/tensorboards/(?P.+?)$", + path, + ) + return m.groupdict() if m else {} + @staticmethod def common_billing_account_path( billing_account: str, @@ -1383,6 +1407,82 @@ def sample_set_instance_labels(): # Done; return the response. return response + def update_instance_metadata_items( + self, + request: Union[service.UpdateInstanceMetadataItemsRequest, dict] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: float = None, + metadata: Sequence[Tuple[str, str]] = (), + ) -> service.UpdateInstanceMetadataItemsResponse: + r"""Add/update metadata items for an instance. + + .. code-block:: python + + from google.cloud import notebooks_v1 + + def sample_update_instance_metadata_items(): + # Create a client + client = notebooks_v1.NotebookServiceClient() + + # Initialize request argument(s) + request = notebooks_v1.UpdateInstanceMetadataItemsRequest( + name="name_value", + ) + + # Make the request + response = client.update_instance_metadata_items(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.notebooks_v1.types.UpdateInstanceMetadataItemsRequest, dict]): + The request object. Request for adding/changing metadata + items for an instance. + 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: + google.cloud.notebooks_v1.types.UpdateInstanceMetadataItemsResponse: + Response for adding/changing metadata + items for an instance. + + """ + # Create or coerce a protobuf request object. + # Minor optimization to avoid making a copy if the user passes + # in a service.UpdateInstanceMetadataItemsRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, service.UpdateInstanceMetadataItemsRequest): + request = service.UpdateInstanceMetadataItemsRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[ + self._transport.update_instance_metadata_items + ] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + def delete_instance( self, request: Union[service.DeleteInstanceRequest, dict] = None, @@ -1716,7 +1816,7 @@ def sample_reset_instance(): Args: request (Union[google.cloud.notebooks_v1.types.ResetInstanceRequest, dict]): - The request object. Request for reseting a notebook + The request object. Request for resetting a notebook instance retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. @@ -3642,8 +3742,8 @@ def create_execution( timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operation.Operation: - r"""Creates a new Scheduled Notebook in a given project - and location. + r"""Creates a new Execution in a given project and + location. .. code-block:: python diff --git a/google/cloud/notebooks_v1/services/notebook_service/transports/base.py b/google/cloud/notebooks_v1/services/notebook_service/transports/base.py index b08983a..0b33130 100644 --- a/google/cloud/notebooks_v1/services/notebook_service/transports/base.py +++ b/google/cloud/notebooks_v1/services/notebook_service/transports/base.py @@ -172,6 +172,11 @@ def _prep_wrapped_messages(self, client_info): default_timeout=60.0, client_info=client_info, ), + self.update_instance_metadata_items: gapic_v1.method.wrap_method( + self.update_instance_metadata_items, + default_timeout=None, + client_info=client_info, + ), self.delete_instance: gapic_v1.method.wrap_method( self.delete_instance, default_timeout=60.0, @@ -384,6 +389,18 @@ def set_instance_labels( ]: raise NotImplementedError() + @property + def update_instance_metadata_items( + self, + ) -> Callable[ + [service.UpdateInstanceMetadataItemsRequest], + Union[ + service.UpdateInstanceMetadataItemsResponse, + Awaitable[service.UpdateInstanceMetadataItemsResponse], + ], + ]: + raise NotImplementedError() + @property def delete_instance( self, diff --git a/google/cloud/notebooks_v1/services/notebook_service/transports/grpc.py b/google/cloud/notebooks_v1/services/notebook_service/transports/grpc.py index 898cb56..3489c8e 100644 --- a/google/cloud/notebooks_v1/services/notebook_service/transports/grpc.py +++ b/google/cloud/notebooks_v1/services/notebook_service/transports/grpc.py @@ -492,6 +492,37 @@ def set_instance_labels( ) return self._stubs["set_instance_labels"] + @property + def update_instance_metadata_items( + self, + ) -> Callable[ + [service.UpdateInstanceMetadataItemsRequest], + service.UpdateInstanceMetadataItemsResponse, + ]: + r"""Return a callable for the update instance metadata items method over gRPC. + + Add/update metadata items for an instance. + + Returns: + Callable[[~.UpdateInstanceMetadataItemsRequest], + ~.UpdateInstanceMetadataItemsResponse]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "update_instance_metadata_items" not in self._stubs: + self._stubs[ + "update_instance_metadata_items" + ] = self.grpc_channel.unary_unary( + "/google.cloud.notebooks.v1.NotebookService/UpdateInstanceMetadataItems", + request_serializer=service.UpdateInstanceMetadataItemsRequest.serialize, + response_deserializer=service.UpdateInstanceMetadataItemsResponse.deserialize, + ) + return self._stubs["update_instance_metadata_items"] + @property def delete_instance( self, @@ -1080,8 +1111,8 @@ def create_execution( ) -> Callable[[service.CreateExecutionRequest], operations_pb2.Operation]: r"""Return a callable for the create execution method over gRPC. - Creates a new Scheduled Notebook in a given project - and location. + Creates a new Execution in a given project and + location. Returns: Callable[[~.CreateExecutionRequest], diff --git a/google/cloud/notebooks_v1/services/notebook_service/transports/grpc_asyncio.py b/google/cloud/notebooks_v1/services/notebook_service/transports/grpc_asyncio.py index 1c22631..22721b0 100644 --- a/google/cloud/notebooks_v1/services/notebook_service/transports/grpc_asyncio.py +++ b/google/cloud/notebooks_v1/services/notebook_service/transports/grpc_asyncio.py @@ -512,6 +512,37 @@ def set_instance_labels( ) return self._stubs["set_instance_labels"] + @property + def update_instance_metadata_items( + self, + ) -> Callable[ + [service.UpdateInstanceMetadataItemsRequest], + Awaitable[service.UpdateInstanceMetadataItemsResponse], + ]: + r"""Return a callable for the update instance metadata items method over gRPC. + + Add/update metadata items for an instance. + + Returns: + Callable[[~.UpdateInstanceMetadataItemsRequest], + Awaitable[~.UpdateInstanceMetadataItemsResponse]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "update_instance_metadata_items" not in self._stubs: + self._stubs[ + "update_instance_metadata_items" + ] = self.grpc_channel.unary_unary( + "/google.cloud.notebooks.v1.NotebookService/UpdateInstanceMetadataItems", + request_serializer=service.UpdateInstanceMetadataItemsRequest.serialize, + response_deserializer=service.UpdateInstanceMetadataItemsResponse.deserialize, + ) + return self._stubs["update_instance_metadata_items"] + @property def delete_instance( self, @@ -1127,8 +1158,8 @@ def create_execution( ]: r"""Return a callable for the create execution method over gRPC. - Creates a new Scheduled Notebook in a given project - and location. + Creates a new Execution in a given project and + location. Returns: Callable[[~.CreateExecutionRequest], diff --git a/google/cloud/notebooks_v1/types/__init__.py b/google/cloud/notebooks_v1/types/__init__.py index cdf9511..c16c18a 100644 --- a/google/cloud/notebooks_v1/types/__init__.py +++ b/google/cloud/notebooks_v1/types/__init__.py @@ -38,6 +38,8 @@ GetRuntimeRequest, ListRuntimesRequest, ListRuntimesResponse, + RefreshRuntimeTokenInternalRequest, + RefreshRuntimeTokenInternalResponse, ReportRuntimeEventRequest, ResetRuntimeRequest, StartRuntimeRequest, @@ -97,9 +99,12 @@ StopInstanceRequest, TriggerScheduleRequest, UpdateInstanceConfigRequest, + UpdateInstanceMetadataItemsRequest, + UpdateInstanceMetadataItemsResponse, UpdateShieldedInstanceConfigRequest, UpgradeInstanceInternalRequest, UpgradeInstanceRequest, + UpgradeType, ) __all__ = ( @@ -117,6 +122,8 @@ "GetRuntimeRequest", "ListRuntimesRequest", "ListRuntimesResponse", + "RefreshRuntimeTokenInternalRequest", + "RefreshRuntimeTokenInternalResponse", "ReportRuntimeEventRequest", "ResetRuntimeRequest", "StartRuntimeRequest", @@ -170,7 +177,10 @@ "StopInstanceRequest", "TriggerScheduleRequest", "UpdateInstanceConfigRequest", + "UpdateInstanceMetadataItemsRequest", + "UpdateInstanceMetadataItemsResponse", "UpdateShieldedInstanceConfigRequest", "UpgradeInstanceInternalRequest", "UpgradeInstanceRequest", + "UpgradeType", ) diff --git a/google/cloud/notebooks_v1/types/event.py b/google/cloud/notebooks_v1/types/event.py index 23ff640..975908b 100644 --- a/google/cloud/notebooks_v1/types/event.py +++ b/google/cloud/notebooks_v1/types/event.py @@ -35,12 +35,18 @@ class Event(proto.Message): Event report time. type_ (google.cloud.notebooks_v1.types.Event.EventType): Event type. + details (Mapping[str, str]): + Optional. Event details. This field is used + to pass event information. """ class EventType(proto.Enum): - r"""The definition of the even types.""" + r"""The definition of the event types.""" EVENT_TYPE_UNSPECIFIED = 0 IDLE = 1 + HEARTBEAT = 2 + HEALTH = 3 + MAINTENANCE = 4 report_time = proto.Field( proto.MESSAGE, @@ -52,6 +58,11 @@ class EventType(proto.Enum): number=2, enum=EventType, ) + details = proto.MapField( + proto.STRING, + proto.STRING, + number=3, + ) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/notebooks_v1/types/execution.py b/google/cloud/notebooks_v1/types/execution.py index 2773538..7d5caf4 100644 --- a/google/cloud/notebooks_v1/types/execution.py +++ b/google/cloud/notebooks_v1/types/execution.py @@ -30,6 +30,11 @@ class ExecutionTemplate(proto.Message): r"""The description a notebook execution workload. + This message has `oneof`_ fields (mutually exclusive fields). + For each oneof, at most one member field can be set at the same time. + Setting any member of the oneof automatically clears all other + members. + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields Attributes: @@ -83,8 +88,9 @@ class ExecutionTemplate(proto.Message): - ``complex_model_l_v100`` Finally, if you want to use a TPU for training, specify - ``cloud_tpu`` in this field. Learn more about the [special - configuration options for training with TPU. + ``cloud_tpu`` in this field. Learn more about the `special + configuration options for training with + TPU `__. accelerator_config (google.cloud.notebooks_v1.types.ExecutionTemplate.SchedulerAcceleratorConfig): Configuration (count and accelerator type) for hardware running notebook execution. @@ -98,7 +104,7 @@ class ExecutionTemplate(proto.Message): input_notebook_file (str): Path to the notebook file to execute. Must be in a Google Cloud Storage bucket. Format: - ``gs://{project_id}/{folder}/{notebook_file_name}`` Ex: + ``gs://{bucket_name}/{folder}/{notebook_file_name}`` Ex: ``gs://notebook_user/scheduled_notebooks/sentiment_notebook.ipynb`` container_image_uri (str): Container Image URI to a DLVM @@ -109,7 +115,7 @@ class ExecutionTemplate(proto.Message): output_notebook_folder (str): Path to the notebook folder to write to. Must be in a Google Cloud Storage bucket path. Format: - ``gs://{project_id}/{folder}`` Ex: + ``gs://{bucket_name}/{folder}`` Ex: ``gs://notebook_user/scheduled_notebooks`` params_yaml_file (str): Parameters to be overridden in the notebook during @@ -132,6 +138,20 @@ class ExecutionTemplate(proto.Message): executions. This field is a member of `oneof`_ ``job_parameters``. + vertex_ai_parameters (google.cloud.notebooks_v1.types.ExecutionTemplate.VertexAIParameters): + Parameters used in Vertex AI JobType + executions. + + This field is a member of `oneof`_ ``job_parameters``. + kernel_spec (str): + Name of the kernel spec to use. This must be + specified if the kernel spec name on the + execution target does not match the name in the + input notebook file. + tensorboard (str): + The name of a Vertex AI [Tensorboard] resource to which this + execution will upload Tensorboard logs. Format: + ``projects/{project}/locations/{location}/tensorboards/{tensorboard}`` """ class ScaleTier(proto.Enum): @@ -154,6 +174,7 @@ class SchedulerAcceleratorType(proto.Enum): NVIDIA_TESLA_V100 = 3 NVIDIA_TESLA_P4 = 4 NVIDIA_TESLA_T4 = 5 + NVIDIA_TESLA_A100 = 10 TPU_V2 = 6 TPU_V3 = 7 @@ -165,8 +186,9 @@ class JobType(proto.Enum): class SchedulerAcceleratorConfig(proto.Message): r"""Definition of a hardware accelerator. Note that not all combinations - of ``type`` and ``core_count`` are valid. Check GPUs on Compute - Engine to find a valid combination. TPUs are not supported. + of ``type`` and ``core_count`` are valid. Check `GPUs on Compute + Engine `__ to find a + valid combination. TPUs are not supported. Attributes: type_ (google.cloud.notebooks_v1.types.ExecutionTemplate.SchedulerAcceleratorType): @@ -199,6 +221,40 @@ class DataprocParameters(proto.Message): number=1, ) + class VertexAIParameters(proto.Message): + r"""Parameters used in Vertex AI JobType executions. + + Attributes: + network (str): + The full name of the Compute Engine + `network `__ + to which the Job should be peered. For example, + ``projects/12345/global/networks/myVPC``. + `Format `__ + is of the form + ``projects/{project}/global/networks/{network}``. Where + {project} is a project number, as in ``12345``, and + {network} is a network name. + + Private services access must already be configured for the + network. If left unspecified, the job is not peered with any + network. + env (Mapping[str, str]): + Environment variables. At most 100 environment variables can + be specified and unique. Example: + GCP_BUCKET=gs://my-bucket/samples/ + """ + + network = proto.Field( + proto.STRING, + number=1, + ) + env = proto.MapField( + proto.STRING, + proto.STRING, + number=2, + ) + scale_tier = proto.Field( proto.ENUM, number=1, @@ -253,6 +309,20 @@ class DataprocParameters(proto.Message): oneof="job_parameters", message=DataprocParameters, ) + vertex_ai_parameters = proto.Field( + proto.MESSAGE, + number=13, + oneof="job_parameters", + message=VertexAIParameters, + ) + kernel_spec = proto.Field( + proto.STRING, + number=14, + ) + tensorboard = proto.Field( + proto.STRING, + number=15, + ) class Execution(proto.Message): @@ -264,7 +334,7 @@ class Execution(proto.Message): spec, region, labels, etc. name (str): Output only. The resource name of the execute. Format: - ``projects/{project_id}/locations/{location}/execution/{execution_id}`` + ``projects/{project_id}/locations/{location}/executions/{execution_id}`` display_name (str): Output only. Name used for UI purposes. Name can only contain alphanumeric characters and underscores '_'. diff --git a/google/cloud/notebooks_v1/types/instance.py b/google/cloud/notebooks_v1/types/instance.py index f5d1997..fccdb1a 100644 --- a/google/cloud/notebooks_v1/types/instance.py +++ b/google/cloud/notebooks_v1/types/instance.py @@ -218,6 +218,13 @@ class Instance(proto.Message): field will apply the specified `Zonal Compute Reservation `__ to this notebook instance. + creator (str): + Output only. Email address of entity that + sent original CreateInstance request. + can_ip_forward (bool): + Optional. Flag to enable ip forwarding or + not, default false/off. + https://cloud.google.com/vpc/docs/using-routes#canipforward create_time (google.protobuf.timestamp_pb2.Timestamp): Output only. Instance creation time. update_time (google.protobuf.timestamp_pb2.Timestamp): @@ -253,6 +260,8 @@ class State(proto.Enum): UPGRADING = 7 INITIALIZING = 8 REGISTERING = 9 + SUSPENDING = 10 + SUSPENDED = 11 class DiskType(proto.Enum): r"""Possible disk types for notebook instances.""" @@ -260,6 +269,7 @@ class DiskType(proto.Enum): PD_STANDARD = 1 PD_SSD = 2 PD_BALANCED = 3 + PD_EXTREME = 4 class DiskEncryption(proto.Enum): r"""Definition of the disk encryption options.""" @@ -715,6 +725,14 @@ class Action(proto.Enum): number=34, message="ReservationAffinity", ) + creator = proto.Field( + proto.STRING, + number=36, + ) + can_ip_forward = proto.Field( + proto.BOOL, + number=39, + ) create_time = proto.Field( proto.MESSAGE, number=23, diff --git a/google/cloud/notebooks_v1/types/managed_service.py b/google/cloud/notebooks_v1/types/managed_service.py index 5f7ff41..49257f3 100644 --- a/google/cloud/notebooks_v1/types/managed_service.py +++ b/google/cloud/notebooks_v1/types/managed_service.py @@ -17,6 +17,7 @@ from google.cloud.notebooks_v1.types import event as gcn_event from google.cloud.notebooks_v1.types import runtime as gcn_runtime +from google.protobuf import timestamp_pb2 # type: ignore __protobuf__ = proto.module( @@ -32,6 +33,8 @@ "SwitchRuntimeRequest", "ResetRuntimeRequest", "ReportRuntimeEventRequest", + "RefreshRuntimeTokenInternalRequest", + "RefreshRuntimeTokenInternalResponse", }, ) @@ -126,6 +129,8 @@ class CreateRuntimeRequest(proto.Message): Runtime. runtime (google.cloud.notebooks_v1.types.Runtime): Required. The Runtime to be created. + request_id (str): + Idempotent request UUID. """ parent = proto.Field( @@ -141,6 +146,10 @@ class CreateRuntimeRequest(proto.Message): number=3, message=gcn_runtime.Runtime, ) + request_id = proto.Field( + proto.STRING, + number=4, + ) class DeleteRuntimeRequest(proto.Message): @@ -150,12 +159,18 @@ class DeleteRuntimeRequest(proto.Message): name (str): Required. Format: ``projects/{project_id}/locations/{location}/runtimes/{runtime_id}`` + request_id (str): + Idempotent request UUID. """ name = proto.Field( proto.STRING, number=1, ) + request_id = proto.Field( + proto.STRING, + number=2, + ) class StartRuntimeRequest(proto.Message): @@ -165,12 +180,18 @@ class StartRuntimeRequest(proto.Message): name (str): Required. Format: ``projects/{project_id}/locations/{location}/runtimes/{runtime_id}`` + request_id (str): + Idempotent request UUID. """ name = proto.Field( proto.STRING, number=1, ) + request_id = proto.Field( + proto.STRING, + number=2, + ) class StopRuntimeRequest(proto.Message): @@ -180,12 +201,18 @@ class StopRuntimeRequest(proto.Message): name (str): Required. Format: ``projects/{project_id}/locations/{location}/runtimes/{runtime_id}`` + request_id (str): + Idempotent request UUID. """ name = proto.Field( proto.STRING, number=1, ) + request_id = proto.Field( + proto.STRING, + number=2, + ) class SwitchRuntimeRequest(proto.Message): @@ -199,6 +226,8 @@ class SwitchRuntimeRequest(proto.Message): machine type. accelerator_config (google.cloud.notebooks_v1.types.RuntimeAcceleratorConfig): accelerator config. + request_id (str): + Idempotent request UUID. """ name = proto.Field( @@ -214,21 +243,31 @@ class SwitchRuntimeRequest(proto.Message): number=3, message=gcn_runtime.RuntimeAcceleratorConfig, ) + request_id = proto.Field( + proto.STRING, + number=4, + ) class ResetRuntimeRequest(proto.Message): - r"""Request for reseting a Managed Notebook Runtime. + r"""Request for resetting a Managed Notebook Runtime. Attributes: name (str): Required. Format: ``projects/{project_id}/locations/{location}/runtimes/{runtime_id}`` + request_id (str): + Idempotent request UUID. """ name = proto.Field( proto.STRING, number=1, ) + request_id = proto.Field( + proto.STRING, + number=2, + ) class ReportRuntimeEventRequest(proto.Message): @@ -261,4 +300,48 @@ class ReportRuntimeEventRequest(proto.Message): ) +class RefreshRuntimeTokenInternalRequest(proto.Message): + r"""Request for getting a new access token. + + Attributes: + name (str): + Required. Format: + ``projects/{project_id}/locations/{location}/runtimes/{runtime_id}`` + vm_id (str): + Required. The VM hardware token for + authenticating the VM. + https://cloud.google.com/compute/docs/instances/verifying-instance-identity + """ + + name = proto.Field( + proto.STRING, + number=1, + ) + vm_id = proto.Field( + proto.STRING, + number=2, + ) + + +class RefreshRuntimeTokenInternalResponse(proto.Message): + r"""Response with a new access token. + + Attributes: + access_token (str): + The OAuth 2.0 access token. + expire_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. Token expiration time. + """ + + access_token = proto.Field( + proto.STRING, + number=1, + ) + expire_time = proto.Field( + proto.MESSAGE, + number=2, + message=timestamp_pb2.Timestamp, + ) + + __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/notebooks_v1/types/runtime.py b/google/cloud/notebooks_v1/types/runtime.py index f07180c..63f38e8 100644 --- a/google/cloud/notebooks_v1/types/runtime.py +++ b/google/cloud/notebooks_v1/types/runtime.py @@ -86,6 +86,8 @@ class HealthState(proto.Enum): HEALTH_STATE_UNSPECIFIED = 0 HEALTHY = 1 UNHEALTHY = 2 + AGENT_NOT_INSTALLED = 3 + AGENT_NOT_RUNNING = 4 name = proto.Field( proto.STRING, @@ -144,6 +146,7 @@ class RuntimeAcceleratorConfig(proto.Message): - ``nvidia-tesla-k80`` - ``nvidia-tesla-p100`` - ``nvidia-tesla-v100`` + - ``nvidia-tesla-p4`` - ``nvidia-tesla-t4`` - ``nvidia-tesla-a100`` @@ -403,6 +406,7 @@ class DiskType(proto.Enum): PD_STANDARD = 1 PD_SSD = 2 PD_BALANCED = 3 + PD_EXTREME = 4 description = proto.Field( proto.STRING, @@ -448,6 +452,7 @@ class RuntimeAccessType(proto.Enum): """ RUNTIME_ACCESS_TYPE_UNSPECIFIED = 0 SINGLE_USER = 1 + SERVICE_ACCOUNT = 2 access_type = proto.Field( proto.ENUM, @@ -471,7 +476,7 @@ class RuntimeSoftwareConfig(proto.Message): - ``idle_shutdown: true`` - ``idle_shutdown_timeout: 180`` - - ``report-system-health: true`` + - ``enable_health_monitoring: true`` Attributes: notebook_upgrade_schedule (str): @@ -493,6 +498,7 @@ class RuntimeSoftwareConfig(proto.Message): runtime. Default: 180 minutes install_gpu_driver (bool): Install Nvidia Driver automatically. + Default: True custom_gpu_driver_path (str): Specify a custom Cloud Storage path where the GPU driver is stored. If not specified, we'll @@ -501,6 +507,14 @@ class RuntimeSoftwareConfig(proto.Message): Path to a Bash script that automatically runs after a notebook instance fully boots up. The path must be a URL or Cloud Storage path (``gs://path-to-file/file-name``). + kernels (Sequence[google.cloud.notebooks_v1.types.ContainerImage]): + Optional. Use a list of container images to + use as Kernels in the notebook instance. + upgradeable (bool): + Output only. Bool indicating whether an newer + image is available in an image family. + + This field is a member of `oneof`_ ``_upgradeable``. """ notebook_upgrade_schedule = proto.Field( @@ -533,6 +547,16 @@ class RuntimeSoftwareConfig(proto.Message): proto.STRING, number=7, ) + kernels = proto.RepeatedField( + proto.MESSAGE, + number=8, + message=environment.ContainerImage, + ) + upgradeable = proto.Field( + proto.BOOL, + number=9, + optional=True, + ) class RuntimeMetrics(proto.Message): @@ -642,7 +666,7 @@ class VirtualMachineConfig(proto.Message): - ``e2-standard-8`` container_images (Sequence[google.cloud.notebooks_v1.types.ContainerImage]): Optional. Use a list of container images to - start the notebook instance. + use as Kernels in the notebook instance. data_disk (google.cloud.notebooks_v1.types.LocalDisk): Required. Data disk option configuration settings. @@ -713,6 +737,25 @@ class VirtualMachineConfig(proto.Message): nic_type (google.cloud.notebooks_v1.types.VirtualMachineConfig.NicType): Optional. The type of vNIC to be used on this interface. This may be gVNIC or VirtioNet. + reserved_ip_range (str): + Optional. Reserved IP Range name is used for VPC Peering. + The subnetwork allocation will use the range *name* if it's + assigned. + + | Example: managed-notebooks-range-c + PEERING_RANGE_NAME_3=managed-notebooks-range-c gcloud + compute addresses create $PEERING_RANGE_NAME_3 + | --global + | --prefix-length=24 + | --description="Google Cloud Managed Notebooks Range 24 c" + | --network=$NETWORK + | --addresses=192.168.0.0 + | --purpose=VPC_PEERING + + Field value will be: ``managed-notebooks-range-c`` + boot_image (google.cloud.notebooks_v1.types.VirtualMachineConfig.BootImage): + Optional. Boot image metadata used for + runtime upgradeability. """ class NicType(proto.Enum): @@ -721,6 +764,12 @@ class NicType(proto.Enum): VIRTIO_NET = 1 GVNIC = 2 + class BootImage(proto.Message): + r"""Definition of the boot image used by the Runtime. + Used to facilitate runtime upgradeability. + + """ + zone = proto.Field( proto.STRING, number=1, @@ -790,6 +839,15 @@ class NicType(proto.Enum): number=17, enum=NicType, ) + reserved_ip_range = proto.Field( + proto.STRING, + number=18, + ) + boot_image = proto.Field( + proto.MESSAGE, + number=19, + message=BootImage, + ) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/notebooks_v1/types/schedule.py b/google/cloud/notebooks_v1/types/schedule.py index d190a66..a3c1d22 100644 --- a/google/cloud/notebooks_v1/types/schedule.py +++ b/google/cloud/notebooks_v1/types/schedule.py @@ -43,8 +43,8 @@ class Schedule(proto.Message): state (google.cloud.notebooks_v1.types.Schedule.State): cron_schedule (str): - Cron-tab formatted schedule by which the job will execute - Format: minute, hour, day of month, month, day of week e.g. + Cron-tab formatted schedule by which the job will execute. + Format: minute, hour, day of month, month, day of week, e.g. 0 0 \* \* WED = every Wednesday More examples: https://crontab.guru/examples.html time_zone (str): diff --git a/google/cloud/notebooks_v1/types/service.py b/google/cloud/notebooks_v1/types/service.py index 5dc030a..93c3530 100644 --- a/google/cloud/notebooks_v1/types/service.py +++ b/google/cloud/notebooks_v1/types/service.py @@ -26,6 +26,7 @@ __protobuf__ = proto.module( package="google.cloud.notebooks.v1", manifest={ + "UpgradeType", "OperationMetadata", "ListInstancesRequest", "ListInstancesResponse", @@ -36,6 +37,8 @@ "SetInstanceMachineTypeRequest", "UpdateInstanceConfigRequest", "SetInstanceLabelsRequest", + "UpdateInstanceMetadataItemsRequest", + "UpdateInstanceMetadataItemsResponse", "UpdateShieldedInstanceConfigRequest", "DeleteInstanceRequest", "StartInstanceRequest", @@ -69,6 +72,17 @@ ) +class UpgradeType(proto.Enum): + r"""Definition of the types of upgrade that can be used on this + instance. + """ + UPGRADE_TYPE_UNSPECIFIED = 0 + UPGRADE_FRAMEWORK = 1 + UPGRADE_OS = 2 + UPGRADE_CUDA = 3 + UPGRADE_ALL = 4 + + class OperationMetadata(proto.Message): r"""Represents the metadata of the long-running operation. @@ -365,6 +379,45 @@ class SetInstanceLabelsRequest(proto.Message): ) +class UpdateInstanceMetadataItemsRequest(proto.Message): + r"""Request for adding/changing metadata items for an instance. + + Attributes: + name (str): + Required. Format: + ``projects/{project_id}/locations/{location}/instances/{instance_id}`` + items (Mapping[str, str]): + Metadata items to add/update for the + instance. + """ + + name = proto.Field( + proto.STRING, + number=1, + ) + items = proto.MapField( + proto.STRING, + proto.STRING, + number=2, + ) + + +class UpdateInstanceMetadataItemsResponse(proto.Message): + r"""Response for adding/changing metadata items for an instance. + + Attributes: + items (Mapping[str, str]): + Map of items that were added/updated to/in + the metadata. + """ + + items = proto.MapField( + proto.STRING, + proto.STRING, + number=1, + ) + + class UpdateShieldedInstanceConfigRequest(proto.Message): r"""Request for updating the Shielded Instance config for a notebook instance. You can only use this method on a stopped @@ -435,7 +488,7 @@ class StopInstanceRequest(proto.Message): class ResetInstanceRequest(proto.Message): - r"""Request for reseting a notebook instance + r"""Request for resetting a notebook instance Attributes: name (str): @@ -488,12 +541,21 @@ class IsInstanceUpgradeableRequest(proto.Message): notebook_instance (str): Required. Format: ``projects/{project_id}/locations/{location}/instances/{instance_id}`` + type_ (google.cloud.notebooks_v1.types.UpgradeType): + Optional. The optional UpgradeType. Setting + this field will search for additional compute + images to upgrade this instance. """ notebook_instance = proto.Field( proto.STRING, number=1, ) + type_ = proto.Field( + proto.ENUM, + number=2, + enum="UpgradeType", + ) class IsInstanceUpgradeableResponse(proto.Message): @@ -589,12 +651,21 @@ class UpgradeInstanceRequest(proto.Message): name (str): Required. Format: ``projects/{project_id}/locations/{location}/instances/{instance_id}`` + type_ (google.cloud.notebooks_v1.types.UpgradeType): + Optional. The optional UpgradeType. Setting + this field will search for additional compute + images to upgrade this instance. """ name = proto.Field( proto.STRING, number=1, ) + type_ = proto.Field( + proto.ENUM, + number=2, + enum="UpgradeType", + ) class RollbackInstanceRequest(proto.Message): @@ -631,6 +702,10 @@ class UpgradeInstanceInternalRequest(proto.Message): Required. The VM hardware token for authenticating the VM. https://cloud.google.com/compute/docs/instances/verifying-instance-identity + type_ (google.cloud.notebooks_v1.types.UpgradeType): + Optional. The optional UpgradeType. Setting + this field will search for additional compute + images to upgrade this instance. """ name = proto.Field( @@ -641,6 +716,11 @@ class UpgradeInstanceInternalRequest(proto.Message): proto.STRING, number=2, ) + type_ = proto.Field( + proto.ENUM, + number=3, + enum="UpgradeType", + ) class ListEnvironmentsRequest(proto.Message): diff --git a/samples/generated_samples/notebooks_v1_generated_managed_notebook_service_refresh_runtime_token_internal_async.py b/samples/generated_samples/notebooks_v1_generated_managed_notebook_service_refresh_runtime_token_internal_async.py new file mode 100644 index 0000000..f1710eb --- /dev/null +++ b/samples/generated_samples/notebooks_v1_generated_managed_notebook_service_refresh_runtime_token_internal_async.py @@ -0,0 +1,46 @@ +# -*- 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 RefreshRuntimeTokenInternal +# 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-cloud-notebooks + + +# [START notebooks_v1_generated_ManagedNotebookService_RefreshRuntimeTokenInternal_async] +from google.cloud import notebooks_v1 + + +async def sample_refresh_runtime_token_internal(): + # Create a client + client = notebooks_v1.ManagedNotebookServiceAsyncClient() + + # Initialize request argument(s) + request = notebooks_v1.RefreshRuntimeTokenInternalRequest( + name="name_value", + vm_id="vm_id_value", + ) + + # Make the request + response = await client.refresh_runtime_token_internal(request=request) + + # Handle the response + print(response) + +# [END notebooks_v1_generated_ManagedNotebookService_RefreshRuntimeTokenInternal_async] diff --git a/samples/generated_samples/notebooks_v1_generated_managed_notebook_service_refresh_runtime_token_internal_sync.py b/samples/generated_samples/notebooks_v1_generated_managed_notebook_service_refresh_runtime_token_internal_sync.py new file mode 100644 index 0000000..98ce73a --- /dev/null +++ b/samples/generated_samples/notebooks_v1_generated_managed_notebook_service_refresh_runtime_token_internal_sync.py @@ -0,0 +1,46 @@ +# -*- 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 RefreshRuntimeTokenInternal +# 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-cloud-notebooks + + +# [START notebooks_v1_generated_ManagedNotebookService_RefreshRuntimeTokenInternal_sync] +from google.cloud import notebooks_v1 + + +def sample_refresh_runtime_token_internal(): + # Create a client + client = notebooks_v1.ManagedNotebookServiceClient() + + # Initialize request argument(s) + request = notebooks_v1.RefreshRuntimeTokenInternalRequest( + name="name_value", + vm_id="vm_id_value", + ) + + # Make the request + response = client.refresh_runtime_token_internal(request=request) + + # Handle the response + print(response) + +# [END notebooks_v1_generated_ManagedNotebookService_RefreshRuntimeTokenInternal_sync] diff --git a/samples/generated_samples/notebooks_v1_generated_notebook_service_update_instance_metadata_items_async.py b/samples/generated_samples/notebooks_v1_generated_notebook_service_update_instance_metadata_items_async.py new file mode 100644 index 0000000..35902da --- /dev/null +++ b/samples/generated_samples/notebooks_v1_generated_notebook_service_update_instance_metadata_items_async.py @@ -0,0 +1,45 @@ +# -*- 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 UpdateInstanceMetadataItems +# 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-cloud-notebooks + + +# [START notebooks_v1_generated_NotebookService_UpdateInstanceMetadataItems_async] +from google.cloud import notebooks_v1 + + +async def sample_update_instance_metadata_items(): + # Create a client + client = notebooks_v1.NotebookServiceAsyncClient() + + # Initialize request argument(s) + request = notebooks_v1.UpdateInstanceMetadataItemsRequest( + name="name_value", + ) + + # Make the request + response = await client.update_instance_metadata_items(request=request) + + # Handle the response + print(response) + +# [END notebooks_v1_generated_NotebookService_UpdateInstanceMetadataItems_async] diff --git a/samples/generated_samples/notebooks_v1_generated_notebook_service_update_instance_metadata_items_sync.py b/samples/generated_samples/notebooks_v1_generated_notebook_service_update_instance_metadata_items_sync.py new file mode 100644 index 0000000..df7f94c --- /dev/null +++ b/samples/generated_samples/notebooks_v1_generated_notebook_service_update_instance_metadata_items_sync.py @@ -0,0 +1,45 @@ +# -*- 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 UpdateInstanceMetadataItems +# 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-cloud-notebooks + + +# [START notebooks_v1_generated_NotebookService_UpdateInstanceMetadataItems_sync] +from google.cloud import notebooks_v1 + + +def sample_update_instance_metadata_items(): + # Create a client + client = notebooks_v1.NotebookServiceClient() + + # Initialize request argument(s) + request = notebooks_v1.UpdateInstanceMetadataItemsRequest( + name="name_value", + ) + + # Make the request + response = client.update_instance_metadata_items(request=request) + + # Handle the response + print(response) + +# [END notebooks_v1_generated_NotebookService_UpdateInstanceMetadataItems_sync] diff --git a/samples/generated_samples/snippet_metadata_notebooks_v1.json b/samples/generated_samples/snippet_metadata_notebooks_v1.json index c483548..057e1ef 100644 --- a/samples/generated_samples/snippet_metadata_notebooks_v1.json +++ b/samples/generated_samples/snippet_metadata_notebooks_v1.json @@ -670,6 +670,175 @@ ], "title": "notebooks_v1_generated_managed_notebook_service_list_runtimes_sync.py" }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.notebooks_v1.ManagedNotebookServiceAsyncClient", + "shortName": "ManagedNotebookServiceAsyncClient" + }, + "fullName": "google.cloud.notebooks_v1.ManagedNotebookServiceAsyncClient.refresh_runtime_token_internal", + "method": { + "fullName": "google.cloud.notebooks.v1.ManagedNotebookService.RefreshRuntimeTokenInternal", + "service": { + "fullName": "google.cloud.notebooks.v1.ManagedNotebookService", + "shortName": "ManagedNotebookService" + }, + "shortName": "RefreshRuntimeTokenInternal" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.notebooks_v1.types.RefreshRuntimeTokenInternalRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "vm_id", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.notebooks_v1.types.RefreshRuntimeTokenInternalResponse", + "shortName": "refresh_runtime_token_internal" + }, + "description": "Sample for RefreshRuntimeTokenInternal", + "file": "notebooks_v1_generated_managed_notebook_service_refresh_runtime_token_internal_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "notebooks_v1_generated_ManagedNotebookService_RefreshRuntimeTokenInternal_async", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 39, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 42, + "start": 40, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 43, + "type": "RESPONSE_HANDLING" + } + ], + "title": "notebooks_v1_generated_managed_notebook_service_refresh_runtime_token_internal_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.notebooks_v1.ManagedNotebookServiceClient", + "shortName": "ManagedNotebookServiceClient" + }, + "fullName": "google.cloud.notebooks_v1.ManagedNotebookServiceClient.refresh_runtime_token_internal", + "method": { + "fullName": "google.cloud.notebooks.v1.ManagedNotebookService.RefreshRuntimeTokenInternal", + "service": { + "fullName": "google.cloud.notebooks.v1.ManagedNotebookService", + "shortName": "ManagedNotebookService" + }, + "shortName": "RefreshRuntimeTokenInternal" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.notebooks_v1.types.RefreshRuntimeTokenInternalRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "vm_id", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.notebooks_v1.types.RefreshRuntimeTokenInternalResponse", + "shortName": "refresh_runtime_token_internal" + }, + "description": "Sample for RefreshRuntimeTokenInternal", + "file": "notebooks_v1_generated_managed_notebook_service_refresh_runtime_token_internal_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "notebooks_v1_generated_ManagedNotebookService_RefreshRuntimeTokenInternal_sync", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 39, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 42, + "start": 40, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 43, + "type": "RESPONSE_HANDLING" + } + ], + "title": "notebooks_v1_generated_managed_notebook_service_refresh_runtime_token_internal_sync.py" + }, { "canonical": true, "clientMethod": { @@ -6112,6 +6281,159 @@ ], "title": "notebooks_v1_generated_notebook_service_update_instance_config_sync.py" }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.notebooks_v1.NotebookServiceAsyncClient", + "shortName": "NotebookServiceAsyncClient" + }, + "fullName": "google.cloud.notebooks_v1.NotebookServiceAsyncClient.update_instance_metadata_items", + "method": { + "fullName": "google.cloud.notebooks.v1.NotebookService.UpdateInstanceMetadataItems", + "service": { + "fullName": "google.cloud.notebooks.v1.NotebookService", + "shortName": "NotebookService" + }, + "shortName": "UpdateInstanceMetadataItems" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.notebooks_v1.types.UpdateInstanceMetadataItemsRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.notebooks_v1.types.UpdateInstanceMetadataItemsResponse", + "shortName": "update_instance_metadata_items" + }, + "description": "Sample for UpdateInstanceMetadataItems", + "file": "notebooks_v1_generated_notebook_service_update_instance_metadata_items_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "notebooks_v1_generated_NotebookService_UpdateInstanceMetadataItems_async", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ], + "title": "notebooks_v1_generated_notebook_service_update_instance_metadata_items_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.notebooks_v1.NotebookServiceClient", + "shortName": "NotebookServiceClient" + }, + "fullName": "google.cloud.notebooks_v1.NotebookServiceClient.update_instance_metadata_items", + "method": { + "fullName": "google.cloud.notebooks.v1.NotebookService.UpdateInstanceMetadataItems", + "service": { + "fullName": "google.cloud.notebooks.v1.NotebookService", + "shortName": "NotebookService" + }, + "shortName": "UpdateInstanceMetadataItems" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.notebooks_v1.types.UpdateInstanceMetadataItemsRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.notebooks_v1.types.UpdateInstanceMetadataItemsResponse", + "shortName": "update_instance_metadata_items" + }, + "description": "Sample for UpdateInstanceMetadataItems", + "file": "notebooks_v1_generated_notebook_service_update_instance_metadata_items_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "notebooks_v1_generated_NotebookService_UpdateInstanceMetadataItems_sync", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ], + "title": "notebooks_v1_generated_notebook_service_update_instance_metadata_items_sync.py" + }, { "canonical": true, "clientMethod": { diff --git a/scripts/fixup_notebooks_v1_keywords.py b/scripts/fixup_notebooks_v1_keywords.py index fdc3ca0..23711ef 100644 --- a/scripts/fixup_notebooks_v1_keywords.py +++ b/scripts/fixup_notebooks_v1_keywords.py @@ -42,12 +42,12 @@ class notebooksCallTransformer(cst.CSTTransformer): 'create_environment': ('parent', 'environment_id', 'environment', ), 'create_execution': ('parent', 'execution_id', 'execution', ), 'create_instance': ('parent', 'instance_id', 'instance', ), - 'create_runtime': ('parent', 'runtime_id', 'runtime', ), + 'create_runtime': ('parent', 'runtime_id', 'runtime', 'request_id', ), 'create_schedule': ('parent', 'schedule_id', 'schedule', ), 'delete_environment': ('name', ), 'delete_execution': ('name', ), 'delete_instance': ('name', ), - 'delete_runtime': ('name', ), + 'delete_runtime': ('name', 'request_id', ), 'delete_schedule': ('name', ), 'get_environment': ('name', ), 'get_execution': ('name', ), @@ -55,31 +55,33 @@ class notebooksCallTransformer(cst.CSTTransformer): 'get_instance_health': ('name', ), 'get_runtime': ('name', ), 'get_schedule': ('name', ), - 'is_instance_upgradeable': ('notebook_instance', ), + 'is_instance_upgradeable': ('notebook_instance', 'type_', ), 'list_environments': ('parent', 'page_size', 'page_token', ), 'list_executions': ('parent', 'page_size', 'page_token', 'filter', 'order_by', ), 'list_instances': ('parent', 'page_size', 'page_token', ), 'list_runtimes': ('parent', 'page_size', 'page_token', ), 'list_schedules': ('parent', 'page_size', 'page_token', 'filter', 'order_by', ), + 'refresh_runtime_token_internal': ('name', 'vm_id', ), 'register_instance': ('parent', 'instance_id', ), 'report_instance_info': ('name', 'vm_id', 'metadata', ), 'report_runtime_event': ('name', 'vm_id', 'event', ), 'reset_instance': ('name', ), - 'reset_runtime': ('name', ), + 'reset_runtime': ('name', 'request_id', ), 'rollback_instance': ('name', 'target_snapshot', ), 'set_instance_accelerator': ('name', 'type_', 'core_count', ), 'set_instance_labels': ('name', 'labels', ), 'set_instance_machine_type': ('name', 'machine_type', ), 'start_instance': ('name', ), - 'start_runtime': ('name', ), + 'start_runtime': ('name', 'request_id', ), 'stop_instance': ('name', ), - 'stop_runtime': ('name', ), - 'switch_runtime': ('name', 'machine_type', 'accelerator_config', ), + 'stop_runtime': ('name', 'request_id', ), + 'switch_runtime': ('name', 'machine_type', 'accelerator_config', 'request_id', ), 'trigger_schedule': ('name', ), 'update_instance_config': ('name', 'config', ), + 'update_instance_metadata_items': ('name', 'items', ), 'update_shielded_instance_config': ('name', 'shielded_instance_config', ), - 'upgrade_instance': ('name', ), - 'upgrade_instance_internal': ('name', 'vm_id', ), + 'upgrade_instance': ('name', 'type_', ), + 'upgrade_instance_internal': ('name', 'vm_id', 'type_', ), } def leave_Call(self, original: cst.Call, updated: cst.Call) -> cst.CSTNode: diff --git a/tests/unit/gapic/notebooks_v1/test_managed_notebook_service.py b/tests/unit/gapic/notebooks_v1/test_managed_notebook_service.py index 5c306f5..61f3ba1 100644 --- a/tests/unit/gapic/notebooks_v1/test_managed_notebook_service.py +++ b/tests/unit/gapic/notebooks_v1/test_managed_notebook_service.py @@ -2963,6 +2963,263 @@ async def test_report_runtime_event_flattened_error_async(): ) +@pytest.mark.parametrize( + "request_type", + [ + managed_service.RefreshRuntimeTokenInternalRequest, + dict, + ], +) +def test_refresh_runtime_token_internal(request_type, transport: str = "grpc"): + client = ManagedNotebookServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.refresh_runtime_token_internal), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = managed_service.RefreshRuntimeTokenInternalResponse( + access_token="access_token_value", + ) + response = client.refresh_runtime_token_internal(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == managed_service.RefreshRuntimeTokenInternalRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, managed_service.RefreshRuntimeTokenInternalResponse) + assert response.access_token == "access_token_value" + + +def test_refresh_runtime_token_internal_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = ManagedNotebookServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.refresh_runtime_token_internal), "__call__" + ) as call: + client.refresh_runtime_token_internal() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == managed_service.RefreshRuntimeTokenInternalRequest() + + +@pytest.mark.asyncio +async def test_refresh_runtime_token_internal_async( + transport: str = "grpc_asyncio", + request_type=managed_service.RefreshRuntimeTokenInternalRequest, +): + client = ManagedNotebookServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.refresh_runtime_token_internal), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + managed_service.RefreshRuntimeTokenInternalResponse( + access_token="access_token_value", + ) + ) + response = await client.refresh_runtime_token_internal(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == managed_service.RefreshRuntimeTokenInternalRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, managed_service.RefreshRuntimeTokenInternalResponse) + assert response.access_token == "access_token_value" + + +@pytest.mark.asyncio +async def test_refresh_runtime_token_internal_async_from_dict(): + await test_refresh_runtime_token_internal_async(request_type=dict) + + +def test_refresh_runtime_token_internal_field_headers(): + client = ManagedNotebookServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = managed_service.RefreshRuntimeTokenInternalRequest() + + request.name = "name/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.refresh_runtime_token_internal), "__call__" + ) as call: + call.return_value = managed_service.RefreshRuntimeTokenInternalResponse() + client.refresh_runtime_token_internal(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "name=name/value", + ) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_refresh_runtime_token_internal_field_headers_async(): + client = ManagedNotebookServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = managed_service.RefreshRuntimeTokenInternalRequest() + + request.name = "name/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.refresh_runtime_token_internal), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + managed_service.RefreshRuntimeTokenInternalResponse() + ) + await client.refresh_runtime_token_internal(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "name=name/value", + ) in kw["metadata"] + + +def test_refresh_runtime_token_internal_flattened(): + client = ManagedNotebookServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.refresh_runtime_token_internal), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = managed_service.RefreshRuntimeTokenInternalResponse() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.refresh_runtime_token_internal( + name="name_value", + vm_id="vm_id_value", + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val + arg = args[0].vm_id + mock_val = "vm_id_value" + assert arg == mock_val + + +def test_refresh_runtime_token_internal_flattened_error(): + client = ManagedNotebookServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.refresh_runtime_token_internal( + managed_service.RefreshRuntimeTokenInternalRequest(), + name="name_value", + vm_id="vm_id_value", + ) + + +@pytest.mark.asyncio +async def test_refresh_runtime_token_internal_flattened_async(): + client = ManagedNotebookServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.refresh_runtime_token_internal), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = managed_service.RefreshRuntimeTokenInternalResponse() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + managed_service.RefreshRuntimeTokenInternalResponse() + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.refresh_runtime_token_internal( + name="name_value", + vm_id="vm_id_value", + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val + arg = args[0].vm_id + mock_val = "vm_id_value" + assert arg == mock_val + + +@pytest.mark.asyncio +async def test_refresh_runtime_token_internal_flattened_error_async(): + client = ManagedNotebookServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.refresh_runtime_token_internal( + managed_service.RefreshRuntimeTokenInternalRequest(), + name="name_value", + vm_id="vm_id_value", + ) + + def test_credentials_transport_error(): # It is an error to provide credentials and a transport instance. transport = transports.ManagedNotebookServiceGrpcTransport( @@ -3109,6 +3366,7 @@ def test_managed_notebook_service_base_transport(): "switch_runtime", "reset_runtime", "report_runtime_event", + "refresh_runtime_token_internal", ) for method in methods: with pytest.raises(NotImplementedError): diff --git a/tests/unit/gapic/notebooks_v1/test_notebook_service.py b/tests/unit/gapic/notebooks_v1/test_notebook_service.py index 2da1fff..efd85c0 100644 --- a/tests/unit/gapic/notebooks_v1/test_notebook_service.py +++ b/tests/unit/gapic/notebooks_v1/test_notebook_service.py @@ -1144,6 +1144,8 @@ def test_get_instance(request_type, transport: str = "grpc"): subnet="subnet_value", tags=["tags_value"], nic_type=instance.Instance.NicType.VIRTIO_NET, + creator="creator_value", + can_ip_forward=True, vm_image=environment.VmImage(project="project_value"), ) response = client.get_instance(request) @@ -1178,6 +1180,8 @@ def test_get_instance(request_type, transport: str = "grpc"): assert response.subnet == "subnet_value" assert response.tags == ["tags_value"] assert response.nic_type == instance.Instance.NicType.VIRTIO_NET + assert response.creator == "creator_value" + assert response.can_ip_forward is True def test_get_instance_empty_call(): @@ -1237,6 +1241,8 @@ async def test_get_instance_async( subnet="subnet_value", tags=["tags_value"], nic_type=instance.Instance.NicType.VIRTIO_NET, + creator="creator_value", + can_ip_forward=True, ) ) response = await client.get_instance(request) @@ -1271,6 +1277,8 @@ async def test_get_instance_async( assert response.subnet == "subnet_value" assert response.tags == ["tags_value"] assert response.nic_type == instance.Instance.NicType.VIRTIO_NET + assert response.creator == "creator_value" + assert response.can_ip_forward is True @pytest.mark.asyncio @@ -2588,6 +2596,161 @@ async def test_set_instance_labels_field_headers_async(): ) in kw["metadata"] +@pytest.mark.parametrize( + "request_type", + [ + service.UpdateInstanceMetadataItemsRequest, + dict, + ], +) +def test_update_instance_metadata_items(request_type, transport: str = "grpc"): + client = NotebookServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_instance_metadata_items), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = service.UpdateInstanceMetadataItemsResponse() + response = client.update_instance_metadata_items(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == service.UpdateInstanceMetadataItemsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, service.UpdateInstanceMetadataItemsResponse) + + +def test_update_instance_metadata_items_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = NotebookServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_instance_metadata_items), "__call__" + ) as call: + client.update_instance_metadata_items() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == service.UpdateInstanceMetadataItemsRequest() + + +@pytest.mark.asyncio +async def test_update_instance_metadata_items_async( + transport: str = "grpc_asyncio", + request_type=service.UpdateInstanceMetadataItemsRequest, +): + client = NotebookServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_instance_metadata_items), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + service.UpdateInstanceMetadataItemsResponse() + ) + response = await client.update_instance_metadata_items(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == service.UpdateInstanceMetadataItemsRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, service.UpdateInstanceMetadataItemsResponse) + + +@pytest.mark.asyncio +async def test_update_instance_metadata_items_async_from_dict(): + await test_update_instance_metadata_items_async(request_type=dict) + + +def test_update_instance_metadata_items_field_headers(): + client = NotebookServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.UpdateInstanceMetadataItemsRequest() + + request.name = "name/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_instance_metadata_items), "__call__" + ) as call: + call.return_value = service.UpdateInstanceMetadataItemsResponse() + client.update_instance_metadata_items(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "name=name/value", + ) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_update_instance_metadata_items_field_headers_async(): + client = NotebookServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = service.UpdateInstanceMetadataItemsRequest() + + request.name = "name/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_instance_metadata_items), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + service.UpdateInstanceMetadataItemsResponse() + ) + await client.update_instance_metadata_items(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "name=name/value", + ) in kw["metadata"] + + @pytest.mark.parametrize( "request_type", [ @@ -8067,6 +8230,7 @@ def test_notebook_service_base_transport(): "update_instance_config", "update_shielded_instance_config", "set_instance_labels", + "update_instance_metadata_items", "delete_instance", "start_instance", "stop_instance", @@ -8550,8 +8714,36 @@ def test_parse_schedule_path(): assert expected == actual +def test_tensorboard_path(): + project = "winkle" + location = "nautilus" + tensorboard = "scallop" + expected = ( + "projects/{project}/locations/{location}/tensorboards/{tensorboard}".format( + project=project, + location=location, + tensorboard=tensorboard, + ) + ) + actual = NotebookServiceClient.tensorboard_path(project, location, tensorboard) + assert expected == actual + + +def test_parse_tensorboard_path(): + expected = { + "project": "abalone", + "location": "squid", + "tensorboard": "clam", + } + path = NotebookServiceClient.tensorboard_path(**expected) + + # Check that the path construction is reversible. + actual = NotebookServiceClient.parse_tensorboard_path(path) + assert expected == actual + + def test_common_billing_account_path(): - billing_account = "winkle" + billing_account = "whelk" expected = "billingAccounts/{billing_account}".format( billing_account=billing_account, ) @@ -8561,7 +8753,7 @@ def test_common_billing_account_path(): def test_parse_common_billing_account_path(): expected = { - "billing_account": "nautilus", + "billing_account": "octopus", } path = NotebookServiceClient.common_billing_account_path(**expected) @@ -8571,7 +8763,7 @@ def test_parse_common_billing_account_path(): def test_common_folder_path(): - folder = "scallop" + folder = "oyster" expected = "folders/{folder}".format( folder=folder, ) @@ -8581,7 +8773,7 @@ def test_common_folder_path(): def test_parse_common_folder_path(): expected = { - "folder": "abalone", + "folder": "nudibranch", } path = NotebookServiceClient.common_folder_path(**expected) @@ -8591,7 +8783,7 @@ def test_parse_common_folder_path(): def test_common_organization_path(): - organization = "squid" + organization = "cuttlefish" expected = "organizations/{organization}".format( organization=organization, ) @@ -8601,7 +8793,7 @@ def test_common_organization_path(): def test_parse_common_organization_path(): expected = { - "organization": "clam", + "organization": "mussel", } path = NotebookServiceClient.common_organization_path(**expected) @@ -8611,7 +8803,7 @@ def test_parse_common_organization_path(): def test_common_project_path(): - project = "whelk" + project = "winkle" expected = "projects/{project}".format( project=project, ) @@ -8621,7 +8813,7 @@ def test_common_project_path(): def test_parse_common_project_path(): expected = { - "project": "octopus", + "project": "nautilus", } path = NotebookServiceClient.common_project_path(**expected) @@ -8631,8 +8823,8 @@ def test_parse_common_project_path(): def test_common_location_path(): - project = "oyster" - location = "nudibranch" + project = "scallop" + location = "abalone" expected = "projects/{project}/locations/{location}".format( project=project, location=location, @@ -8643,8 +8835,8 @@ def test_common_location_path(): def test_parse_common_location_path(): expected = { - "project": "cuttlefish", - "location": "mussel", + "project": "squid", + "location": "clam", } path = NotebookServiceClient.common_location_path(**expected)