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

Commit

Permalink
feat: Update Notebooks API for clients libraries (#154)
Browse files Browse the repository at this point in the history
* feat: Update Notebooks API for clients libraries

PiperOrigin-RevId: 442854284

Source-Link: googleapis/googleapis@38b542a

Source-Link: googleapis/googleapis-gen@048bf8e
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiMDQ4YmY4ZWVlODgyYTMyZmRiMjUwZTNhYTIxZmY4M2JkZGUwMjZjYyJ9

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
  • Loading branch information
gcf-owl-bot[bot] and gcf-owl-bot[bot] committed Apr 20, 2022
1 parent 01e43b0 commit c4a526e
Show file tree
Hide file tree
Showing 29 changed files with 1,930 additions and 47 deletions.
14 changes: 14 additions & 0 deletions google/cloud/notebooks/__init__.py
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
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
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
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
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

0 comments on commit c4a526e

Please sign in to comment.