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

Commit c4a526e

Browse files
feat: Update Notebooks API for clients libraries (#154)
* feat: Update Notebooks API for clients libraries PiperOrigin-RevId: 442854284 Source-Link: googleapis/googleapis@38b542a Source-Link: https://github.com/googleapis/googleapis-gen/commit/048bf8eee882a32fdb250e3aa21ff83bdde026cc 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>
1 parent 01e43b0 commit c4a526e

29 files changed

+1930
-47
lines changed

google/cloud/notebooks/__init__.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@
4141
from google.cloud.notebooks_v1.types.managed_service import GetRuntimeRequest
4242
from google.cloud.notebooks_v1.types.managed_service import ListRuntimesRequest
4343
from google.cloud.notebooks_v1.types.managed_service import ListRuntimesResponse
44+
from google.cloud.notebooks_v1.types.managed_service import (
45+
RefreshRuntimeTokenInternalRequest,
46+
)
47+
from google.cloud.notebooks_v1.types.managed_service import (
48+
RefreshRuntimeTokenInternalResponse,
49+
)
4450
from google.cloud.notebooks_v1.types.managed_service import ReportRuntimeEventRequest
4551
from google.cloud.notebooks_v1.types.managed_service import ResetRuntimeRequest
4652
from google.cloud.notebooks_v1.types.managed_service import StartRuntimeRequest
@@ -94,9 +100,12 @@
94100
from google.cloud.notebooks_v1.types.service import StopInstanceRequest
95101
from google.cloud.notebooks_v1.types.service import TriggerScheduleRequest
96102
from google.cloud.notebooks_v1.types.service import UpdateInstanceConfigRequest
103+
from google.cloud.notebooks_v1.types.service import UpdateInstanceMetadataItemsRequest
104+
from google.cloud.notebooks_v1.types.service import UpdateInstanceMetadataItemsResponse
97105
from google.cloud.notebooks_v1.types.service import UpdateShieldedInstanceConfigRequest
98106
from google.cloud.notebooks_v1.types.service import UpgradeInstanceInternalRequest
99107
from google.cloud.notebooks_v1.types.service import UpgradeInstanceRequest
108+
from google.cloud.notebooks_v1.types.service import UpgradeType
100109

101110
__all__ = (
102111
"ManagedNotebookServiceClient",
@@ -117,6 +126,8 @@
117126
"GetRuntimeRequest",
118127
"ListRuntimesRequest",
119128
"ListRuntimesResponse",
129+
"RefreshRuntimeTokenInternalRequest",
130+
"RefreshRuntimeTokenInternalResponse",
120131
"ReportRuntimeEventRequest",
121132
"ResetRuntimeRequest",
122133
"StartRuntimeRequest",
@@ -170,7 +181,10 @@
170181
"StopInstanceRequest",
171182
"TriggerScheduleRequest",
172183
"UpdateInstanceConfigRequest",
184+
"UpdateInstanceMetadataItemsRequest",
185+
"UpdateInstanceMetadataItemsResponse",
173186
"UpdateShieldedInstanceConfigRequest",
174187
"UpgradeInstanceInternalRequest",
175188
"UpgradeInstanceRequest",
189+
"UpgradeType",
176190
)

google/cloud/notebooks_v1/__init__.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@
3333
from .types.managed_service import GetRuntimeRequest
3434
from .types.managed_service import ListRuntimesRequest
3535
from .types.managed_service import ListRuntimesResponse
36+
from .types.managed_service import RefreshRuntimeTokenInternalRequest
37+
from .types.managed_service import RefreshRuntimeTokenInternalResponse
3638
from .types.managed_service import ReportRuntimeEventRequest
3739
from .types.managed_service import ResetRuntimeRequest
3840
from .types.managed_service import StartRuntimeRequest
@@ -86,9 +88,12 @@
8688
from .types.service import StopInstanceRequest
8789
from .types.service import TriggerScheduleRequest
8890
from .types.service import UpdateInstanceConfigRequest
91+
from .types.service import UpdateInstanceMetadataItemsRequest
92+
from .types.service import UpdateInstanceMetadataItemsResponse
8993
from .types.service import UpdateShieldedInstanceConfigRequest
9094
from .types.service import UpgradeInstanceInternalRequest
9195
from .types.service import UpgradeInstanceRequest
96+
from .types.service import UpgradeType
9297

9398
__all__ = (
9499
"ManagedNotebookServiceAsyncClient",
@@ -135,6 +140,8 @@
135140
"ManagedNotebookServiceClient",
136141
"NotebookServiceClient",
137142
"OperationMetadata",
143+
"RefreshRuntimeTokenInternalRequest",
144+
"RefreshRuntimeTokenInternalResponse",
138145
"RegisterInstanceRequest",
139146
"ReportInstanceInfoRequest",
140147
"ReportRuntimeEventRequest",
@@ -159,9 +166,12 @@
159166
"SwitchRuntimeRequest",
160167
"TriggerScheduleRequest",
161168
"UpdateInstanceConfigRequest",
169+
"UpdateInstanceMetadataItemsRequest",
170+
"UpdateInstanceMetadataItemsResponse",
162171
"UpdateShieldedInstanceConfigRequest",
163172
"UpgradeInstanceInternalRequest",
164173
"UpgradeInstanceRequest",
174+
"UpgradeType",
165175
"VirtualMachine",
166176
"VirtualMachineConfig",
167177
"VmImage",

google/cloud/notebooks_v1/gapic_metadata.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@
3030
"list_runtimes"
3131
]
3232
},
33+
"RefreshRuntimeTokenInternal": {
34+
"methods": [
35+
"refresh_runtime_token_internal"
36+
]
37+
},
3338
"ReportRuntimeEvent": {
3439
"methods": [
3540
"report_runtime_event"
@@ -80,6 +85,11 @@
8085
"list_runtimes"
8186
]
8287
},
88+
"RefreshRuntimeTokenInternal": {
89+
"methods": [
90+
"refresh_runtime_token_internal"
91+
]
92+
},
8393
"ReportRuntimeEvent": {
8494
"methods": [
8595
"report_runtime_event"
@@ -259,6 +269,11 @@
259269
"update_instance_config"
260270
]
261271
},
272+
"UpdateInstanceMetadataItems": {
273+
"methods": [
274+
"update_instance_metadata_items"
275+
]
276+
},
262277
"UpdateShieldedInstanceConfig": {
263278
"methods": [
264279
"update_shielded_instance_config"
@@ -424,6 +439,11 @@
424439
"update_instance_config"
425440
]
426441
},
442+
"UpdateInstanceMetadataItems": {
443+
"methods": [
444+
"update_instance_metadata_items"
445+
]
446+
},
427447
"UpdateShieldedInstanceConfig": {
428448
"methods": [
429449
"update_shielded_instance_config"

google/cloud/notebooks_v1/services/managed_notebook_service/async_client.py

Lines changed: 108 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1040,7 +1040,7 @@ def sample_reset_runtime():
10401040
10411041
Args:
10421042
request (Union[google.cloud.notebooks_v1.types.ResetRuntimeRequest, dict]):
1043-
The request object. Request for reseting a Managed
1043+
The request object. Request for resetting a Managed
10441044
Notebook Runtime.
10451045
name (:class:`str`):
10461046
Required. Format:
@@ -1225,6 +1225,113 @@ def sample_report_runtime_event():
12251225
# Done; return the response.
12261226
return response
12271227

1228+
async def refresh_runtime_token_internal(
1229+
self,
1230+
request: Union[managed_service.RefreshRuntimeTokenInternalRequest, dict] = None,
1231+
*,
1232+
name: str = None,
1233+
vm_id: str = None,
1234+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
1235+
timeout: float = None,
1236+
metadata: Sequence[Tuple[str, str]] = (),
1237+
) -> managed_service.RefreshRuntimeTokenInternalResponse:
1238+
r"""Gets an access token for the consumer service account
1239+
that the customer attached to the runtime. Only
1240+
accessible from the tenant instance.
1241+
1242+
.. code-block:: python
1243+
1244+
from google.cloud import notebooks_v1
1245+
1246+
def sample_refresh_runtime_token_internal():
1247+
# Create a client
1248+
client = notebooks_v1.ManagedNotebookServiceClient()
1249+
1250+
# Initialize request argument(s)
1251+
request = notebooks_v1.RefreshRuntimeTokenInternalRequest(
1252+
name="name_value",
1253+
vm_id="vm_id_value",
1254+
)
1255+
1256+
# Make the request
1257+
response = client.refresh_runtime_token_internal(request=request)
1258+
1259+
# Handle the response
1260+
print(response)
1261+
1262+
Args:
1263+
request (Union[google.cloud.notebooks_v1.types.RefreshRuntimeTokenInternalRequest, dict]):
1264+
The request object. Request for getting a new access
1265+
token.
1266+
name (:class:`str`):
1267+
Required. Format:
1268+
``projects/{project_id}/locations/{location}/runtimes/{runtime_id}``
1269+
1270+
This corresponds to the ``name`` field
1271+
on the ``request`` instance; if ``request`` is provided, this
1272+
should not be set.
1273+
vm_id (:class:`str`):
1274+
Required. The VM hardware token for
1275+
authenticating the VM.
1276+
https://cloud.google.com/compute/docs/instances/verifying-instance-identity
1277+
1278+
This corresponds to the ``vm_id`` field
1279+
on the ``request`` instance; if ``request`` is provided, this
1280+
should not be set.
1281+
retry (google.api_core.retry.Retry): Designation of what errors, if any,
1282+
should be retried.
1283+
timeout (float): The timeout for this request.
1284+
metadata (Sequence[Tuple[str, str]]): Strings which should be
1285+
sent along with the request as metadata.
1286+
1287+
Returns:
1288+
google.cloud.notebooks_v1.types.RefreshRuntimeTokenInternalResponse:
1289+
Response with a new access token.
1290+
"""
1291+
# Create or coerce a protobuf request object.
1292+
# Quick check: If we got a request object, we should *not* have
1293+
# gotten any keyword arguments that map to the request.
1294+
has_flattened_params = any([name, vm_id])
1295+
if request is not None and has_flattened_params:
1296+
raise ValueError(
1297+
"If the `request` argument is set, then none of "
1298+
"the individual field arguments should be set."
1299+
)
1300+
1301+
request = managed_service.RefreshRuntimeTokenInternalRequest(request)
1302+
1303+
# If we have keyword arguments corresponding to fields on the
1304+
# request, apply these.
1305+
if name is not None:
1306+
request.name = name
1307+
if vm_id is not None:
1308+
request.vm_id = vm_id
1309+
1310+
# Wrap the RPC method; this adds retry and timeout information,
1311+
# and friendly error handling.
1312+
rpc = gapic_v1.method_async.wrap_method(
1313+
self._client._transport.refresh_runtime_token_internal,
1314+
default_timeout=None,
1315+
client_info=DEFAULT_CLIENT_INFO,
1316+
)
1317+
1318+
# Certain fields should be provided within the metadata header;
1319+
# add these here.
1320+
metadata = tuple(metadata) + (
1321+
gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
1322+
)
1323+
1324+
# Send the request.
1325+
response = await rpc(
1326+
request,
1327+
retry=retry,
1328+
timeout=timeout,
1329+
metadata=metadata,
1330+
)
1331+
1332+
# Done; return the response.
1333+
return response
1334+
12281335
async def __aenter__(self):
12291336
return self
12301337

google/cloud/notebooks_v1/services/managed_notebook_service/client.py

Lines changed: 110 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1261,7 +1261,7 @@ def sample_reset_runtime():
12611261
12621262
Args:
12631263
request (Union[google.cloud.notebooks_v1.types.ResetRuntimeRequest, dict]):
1264-
The request object. Request for reseting a Managed
1264+
The request object. Request for resetting a Managed
12651265
Notebook Runtime.
12661266
name (str):
12671267
Required. Format:
@@ -1446,6 +1446,115 @@ def sample_report_runtime_event():
14461446
# Done; return the response.
14471447
return response
14481448

1449+
def refresh_runtime_token_internal(
1450+
self,
1451+
request: Union[managed_service.RefreshRuntimeTokenInternalRequest, dict] = None,
1452+
*,
1453+
name: str = None,
1454+
vm_id: str = None,
1455+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
1456+
timeout: float = None,
1457+
metadata: Sequence[Tuple[str, str]] = (),
1458+
) -> managed_service.RefreshRuntimeTokenInternalResponse:
1459+
r"""Gets an access token for the consumer service account
1460+
that the customer attached to the runtime. Only
1461+
accessible from the tenant instance.
1462+
1463+
.. code-block:: python
1464+
1465+
from google.cloud import notebooks_v1
1466+
1467+
def sample_refresh_runtime_token_internal():
1468+
# Create a client
1469+
client = notebooks_v1.ManagedNotebookServiceClient()
1470+
1471+
# Initialize request argument(s)
1472+
request = notebooks_v1.RefreshRuntimeTokenInternalRequest(
1473+
name="name_value",
1474+
vm_id="vm_id_value",
1475+
)
1476+
1477+
# Make the request
1478+
response = client.refresh_runtime_token_internal(request=request)
1479+
1480+
# Handle the response
1481+
print(response)
1482+
1483+
Args:
1484+
request (Union[google.cloud.notebooks_v1.types.RefreshRuntimeTokenInternalRequest, dict]):
1485+
The request object. Request for getting a new access
1486+
token.
1487+
name (str):
1488+
Required. Format:
1489+
``projects/{project_id}/locations/{location}/runtimes/{runtime_id}``
1490+
1491+
This corresponds to the ``name`` field
1492+
on the ``request`` instance; if ``request`` is provided, this
1493+
should not be set.
1494+
vm_id (str):
1495+
Required. The VM hardware token for
1496+
authenticating the VM.
1497+
https://cloud.google.com/compute/docs/instances/verifying-instance-identity
1498+
1499+
This corresponds to the ``vm_id`` field
1500+
on the ``request`` instance; if ``request`` is provided, this
1501+
should not be set.
1502+
retry (google.api_core.retry.Retry): Designation of what errors, if any,
1503+
should be retried.
1504+
timeout (float): The timeout for this request.
1505+
metadata (Sequence[Tuple[str, str]]): Strings which should be
1506+
sent along with the request as metadata.
1507+
1508+
Returns:
1509+
google.cloud.notebooks_v1.types.RefreshRuntimeTokenInternalResponse:
1510+
Response with a new access token.
1511+
"""
1512+
# Create or coerce a protobuf request object.
1513+
# Quick check: If we got a request object, we should *not* have
1514+
# gotten any keyword arguments that map to the request.
1515+
has_flattened_params = any([name, vm_id])
1516+
if request is not None and has_flattened_params:
1517+
raise ValueError(
1518+
"If the `request` argument is set, then none of "
1519+
"the individual field arguments should be set."
1520+
)
1521+
1522+
# Minor optimization to avoid making a copy if the user passes
1523+
# in a managed_service.RefreshRuntimeTokenInternalRequest.
1524+
# There's no risk of modifying the input as we've already verified
1525+
# there are no flattened fields.
1526+
if not isinstance(request, managed_service.RefreshRuntimeTokenInternalRequest):
1527+
request = managed_service.RefreshRuntimeTokenInternalRequest(request)
1528+
# If we have keyword arguments corresponding to fields on the
1529+
# request, apply these.
1530+
if name is not None:
1531+
request.name = name
1532+
if vm_id is not None:
1533+
request.vm_id = vm_id
1534+
1535+
# Wrap the RPC method; this adds retry and timeout information,
1536+
# and friendly error handling.
1537+
rpc = self._transport._wrapped_methods[
1538+
self._transport.refresh_runtime_token_internal
1539+
]
1540+
1541+
# Certain fields should be provided within the metadata header;
1542+
# add these here.
1543+
metadata = tuple(metadata) + (
1544+
gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
1545+
)
1546+
1547+
# Send the request.
1548+
response = rpc(
1549+
request,
1550+
retry=retry,
1551+
timeout=timeout,
1552+
metadata=metadata,
1553+
)
1554+
1555+
# Done; return the response.
1556+
return response
1557+
14491558
def __enter__(self):
14501559
return self
14511560

0 commit comments

Comments
 (0)