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

feat: Update Notebooks API for clients libraries #154

Merged
merged 2 commits into from
Apr 20, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
🦉 Updates from OwlBot post-processor
  • Loading branch information
gcf-owl-bot[bot] committed Apr 19, 2022
commit 41957857ecfde2853f44af13d0eb793012cdac8e
14 changes: 14 additions & 0 deletions google/cloud/notebooks/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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",
Expand All @@ -117,6 +126,8 @@
"GetRuntimeRequest",
"ListRuntimesRequest",
"ListRuntimesResponse",
"RefreshRuntimeTokenInternalRequest",
"RefreshRuntimeTokenInternalResponse",
"ReportRuntimeEventRequest",
"ResetRuntimeRequest",
"StartRuntimeRequest",
Expand Down Expand Up @@ -170,7 +181,10 @@
"StopInstanceRequest",
"TriggerScheduleRequest",
"UpdateInstanceConfigRequest",
"UpdateInstanceMetadataItemsRequest",
"UpdateInstanceMetadataItemsResponse",
"UpdateShieldedInstanceConfigRequest",
"UpgradeInstanceInternalRequest",
"UpgradeInstanceRequest",
"UpgradeType",
)
10 changes: 10 additions & 0 deletions google/cloud/notebooks_v1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -135,6 +140,8 @@
"ManagedNotebookServiceClient",
"NotebookServiceClient",
"OperationMetadata",
"RefreshRuntimeTokenInternalRequest",
"RefreshRuntimeTokenInternalResponse",
"RegisterInstanceRequest",
"ReportInstanceInfoRequest",
"ReportRuntimeEventRequest",
Expand All @@ -159,9 +166,12 @@
"SwitchRuntimeRequest",
"TriggerScheduleRequest",
"UpdateInstanceConfigRequest",
"UpdateInstanceMetadataItemsRequest",
"UpdateInstanceMetadataItemsResponse",
"UpdateShieldedInstanceConfigRequest",
"UpgradeInstanceInternalRequest",
"UpgradeInstanceRequest",
"UpgradeType",
"VirtualMachine",
"VirtualMachineConfig",
"VmImage",
Expand Down
20 changes: 20 additions & 0 deletions google/cloud/notebooks_v1/gapic_metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@
"list_runtimes"
]
},
"RefreshRuntimeTokenInternal": {
"methods": [
"refresh_runtime_token_internal"
]
},
"ReportRuntimeEvent": {
"methods": [
"report_runtime_event"
Expand Down Expand Up @@ -80,6 +85,11 @@
"list_runtimes"
]
},
"RefreshRuntimeTokenInternal": {
"methods": [
"refresh_runtime_token_internal"
]
},
"ReportRuntimeEvent": {
"methods": [
"report_runtime_event"
Expand Down Expand Up @@ -259,6 +269,11 @@
"update_instance_config"
]
},
"UpdateInstanceMetadataItems": {
"methods": [
"update_instance_metadata_items"
]
},
"UpdateShieldedInstanceConfig": {
"methods": [
"update_shielded_instance_config"
Expand Down Expand Up @@ -424,6 +439,11 @@
"update_instance_config"
]
},
"UpdateInstanceMetadataItems": {
"methods": [
"update_instance_metadata_items"
]
},
"UpdateShieldedInstanceConfig": {
"methods": [
"update_shielded_instance_config"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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

Expand Down
111 changes: 110 additions & 1 deletion google/cloud/notebooks_v1/services/managed_notebook_service/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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

Expand Down
Loading