Skip to content

Commit b855629

Browse files
feat: [google-cloud-batch] Update description on allowed_locations in LocationPolicy field (#12677)
BEGIN_COMMIT_OVERRIDE feat: Update description on allowed_locations in LocationPolicy field --- feat: Add UpdateJob API to update the job spec, only task_count is supported now docs: updated comments END_COMMIT_OVERRIDE - [ ] Regenerate this pull request now. --- feat: Add UpdateJob API to update the job spec, only task_count is supported now docs: updated comments PiperOrigin-RevId: 631869976 Source-Link: googleapis/googleapis@090d9a1 Source-Link: googleapis/googleapis-gen@d19bc03 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLWJhdGNoLy5Pd2xCb3QueWFtbCIsImgiOiJkMTliYzAzNDI4ZGJkYzdiY2NiYWU4NzUyZGVkMTljODU4ZmExNmY2In0= --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com> Co-authored-by: ohmayr <omairnaveed@ymail.com>
1 parent e3c48d7 commit b855629

20 files changed

Lines changed: 3404 additions & 1663 deletions

packages/google-cloud-batch/google/cloud/batch/gapic_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515
#
16-
__version__ = "0.17.19" # {x-release-please-version}
16+
__version__ = "0.0.0" # {x-release-please-version}

packages/google-cloud-batch/google/cloud/batch_v1/gapic_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515
#
16-
__version__ = "0.17.19" # {x-release-please-version}
16+
__version__ = "0.0.0" # {x-release-please-version}

packages/google-cloud-batch/google/cloud/batch_v1alpha/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
ListTasksRequest,
3535
ListTasksResponse,
3636
OperationMetadata,
37+
UpdateJobRequest,
3738
UpdateResourceAllowanceRequest,
3839
)
3940
from .types.job import (
@@ -113,6 +114,7 @@
113114
"TaskResourceUsage",
114115
"TaskSpec",
115116
"TaskStatus",
117+
"UpdateJobRequest",
116118
"UpdateResourceAllowanceRequest",
117119
"UsageResourceAllowance",
118120
"UsageResourceAllowanceSpec",

packages/google-cloud-batch/google/cloud/batch_v1alpha/gapic_metadata.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@
6060
"list_tasks"
6161
]
6262
},
63+
"UpdateJob": {
64+
"methods": [
65+
"update_job"
66+
]
67+
},
6368
"UpdateResourceAllowance": {
6469
"methods": [
6570
"update_resource_allowance"
@@ -120,6 +125,11 @@
120125
"list_tasks"
121126
]
122127
},
128+
"UpdateJob": {
129+
"methods": [
130+
"update_job"
131+
]
132+
},
123133
"UpdateResourceAllowance": {
124134
"methods": [
125135
"update_resource_allowance"
@@ -180,6 +190,11 @@
180190
"list_tasks"
181191
]
182192
},
193+
"UpdateJob": {
194+
"methods": [
195+
"update_job"
196+
]
197+
},
183198
"UpdateResourceAllowance": {
184199
"methods": [
185200
"update_resource_allowance"

packages/google-cloud-batch/google/cloud/batch_v1alpha/gapic_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515
#
16-
__version__ = "0.17.19" # {x-release-please-version}
16+
__version__ = "0.0.0" # {x-release-please-version}

packages/google-cloud-batch/google/cloud/batch_v1alpha/services/batch_service/async_client.py

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -633,6 +633,121 @@ async def sample_delete_job():
633633
# Done; return the response.
634634
return response
635635

636+
async def update_job(
637+
self,
638+
request: Optional[Union[batch.UpdateJobRequest, dict]] = None,
639+
*,
640+
job: Optional[gcb_job.Job] = None,
641+
update_mask: Optional[field_mask_pb2.FieldMask] = None,
642+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
643+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
644+
metadata: Sequence[Tuple[str, str]] = (),
645+
) -> gcb_job.Job:
646+
r"""Update a Job.
647+
648+
.. code-block:: python
649+
650+
# This snippet has been automatically generated and should be regarded as a
651+
# code template only.
652+
# It will require modifications to work:
653+
# - It may require correct/in-range values for request initialization.
654+
# - It may require specifying regional endpoints when creating the service
655+
# client as shown in:
656+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
657+
from google.cloud import batch_v1alpha
658+
659+
async def sample_update_job():
660+
# Create a client
661+
client = batch_v1alpha.BatchServiceAsyncClient()
662+
663+
# Initialize request argument(s)
664+
request = batch_v1alpha.UpdateJobRequest(
665+
)
666+
667+
# Make the request
668+
response = await client.update_job(request=request)
669+
670+
# Handle the response
671+
print(response)
672+
673+
Args:
674+
request (Optional[Union[google.cloud.batch_v1alpha.types.UpdateJobRequest, dict]]):
675+
The request object. UpdateJob Request.
676+
job (:class:`google.cloud.batch_v1alpha.types.Job`):
677+
Required. The Job to update. Only fields specified in
678+
``update_mask`` are updated.
679+
680+
This corresponds to the ``job`` field
681+
on the ``request`` instance; if ``request`` is provided, this
682+
should not be set.
683+
update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`):
684+
Required. Mask of fields to update.
685+
686+
UpdateJob request now only supports update on
687+
``task_count`` field in a job's first task group. Other
688+
fields will be ignored.
689+
690+
This corresponds to the ``update_mask`` field
691+
on the ``request`` instance; if ``request`` is provided, this
692+
should not be set.
693+
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
694+
should be retried.
695+
timeout (float): The timeout for this request.
696+
metadata (Sequence[Tuple[str, str]]): Strings which should be
697+
sent along with the request as metadata.
698+
699+
Returns:
700+
google.cloud.batch_v1alpha.types.Job:
701+
The Cloud Batch Job description.
702+
"""
703+
# Create or coerce a protobuf request object.
704+
# - Quick check: If we got a request object, we should *not* have
705+
# gotten any keyword arguments that map to the request.
706+
has_flattened_params = any([job, update_mask])
707+
if request is not None and has_flattened_params:
708+
raise ValueError(
709+
"If the `request` argument is set, then none of "
710+
"the individual field arguments should be set."
711+
)
712+
713+
# - Use the request object if provided (there's no risk of modifying the input as
714+
# there are no flattened fields), or create one.
715+
if not isinstance(request, batch.UpdateJobRequest):
716+
request = batch.UpdateJobRequest(request)
717+
718+
# If we have keyword arguments corresponding to fields on the
719+
# request, apply these.
720+
if job is not None:
721+
request.job = job
722+
if update_mask is not None:
723+
request.update_mask = update_mask
724+
725+
# Wrap the RPC method; this adds retry and timeout information,
726+
# and friendly error handling.
727+
rpc = self._client._transport._wrapped_methods[
728+
self._client._transport.update_job
729+
]
730+
731+
# Certain fields should be provided within the metadata header;
732+
# add these here.
733+
metadata = tuple(metadata) + (
734+
gapic_v1.routing_header.to_grpc_metadata((("job.name", request.job.name),)),
735+
)
736+
737+
# Validate the universe domain.
738+
self._client._validate_universe_domain()
739+
740+
# Send the request.
741+
response = await rpc(
742+
request,
743+
retry=retry,
744+
timeout=timeout,
745+
metadata=metadata,
746+
)
747+
748+
# Done; return the response.
749+
return response
750+
636751
async def list_jobs(
637752
self,
638753
request: Optional[Union[batch.ListJobsRequest, dict]] = None,

packages/google-cloud-batch/google/cloud/batch_v1alpha/services/batch_service/client.py

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1109,6 +1109,118 @@ def sample_delete_job():
11091109
# Done; return the response.
11101110
return response
11111111

1112+
def update_job(
1113+
self,
1114+
request: Optional[Union[batch.UpdateJobRequest, dict]] = None,
1115+
*,
1116+
job: Optional[gcb_job.Job] = None,
1117+
update_mask: Optional[field_mask_pb2.FieldMask] = None,
1118+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
1119+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
1120+
metadata: Sequence[Tuple[str, str]] = (),
1121+
) -> gcb_job.Job:
1122+
r"""Update a Job.
1123+
1124+
.. code-block:: python
1125+
1126+
# This snippet has been automatically generated and should be regarded as a
1127+
# code template only.
1128+
# It will require modifications to work:
1129+
# - It may require correct/in-range values for request initialization.
1130+
# - It may require specifying regional endpoints when creating the service
1131+
# client as shown in:
1132+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
1133+
from google.cloud import batch_v1alpha
1134+
1135+
def sample_update_job():
1136+
# Create a client
1137+
client = batch_v1alpha.BatchServiceClient()
1138+
1139+
# Initialize request argument(s)
1140+
request = batch_v1alpha.UpdateJobRequest(
1141+
)
1142+
1143+
# Make the request
1144+
response = client.update_job(request=request)
1145+
1146+
# Handle the response
1147+
print(response)
1148+
1149+
Args:
1150+
request (Union[google.cloud.batch_v1alpha.types.UpdateJobRequest, dict]):
1151+
The request object. UpdateJob Request.
1152+
job (google.cloud.batch_v1alpha.types.Job):
1153+
Required. The Job to update. Only fields specified in
1154+
``update_mask`` are updated.
1155+
1156+
This corresponds to the ``job`` field
1157+
on the ``request`` instance; if ``request`` is provided, this
1158+
should not be set.
1159+
update_mask (google.protobuf.field_mask_pb2.FieldMask):
1160+
Required. Mask of fields to update.
1161+
1162+
UpdateJob request now only supports update on
1163+
``task_count`` field in a job's first task group. Other
1164+
fields will be ignored.
1165+
1166+
This corresponds to the ``update_mask`` field
1167+
on the ``request`` instance; if ``request`` is provided, this
1168+
should not be set.
1169+
retry (google.api_core.retry.Retry): Designation of what errors, if any,
1170+
should be retried.
1171+
timeout (float): The timeout for this request.
1172+
metadata (Sequence[Tuple[str, str]]): Strings which should be
1173+
sent along with the request as metadata.
1174+
1175+
Returns:
1176+
google.cloud.batch_v1alpha.types.Job:
1177+
The Cloud Batch Job description.
1178+
"""
1179+
# Create or coerce a protobuf request object.
1180+
# - Quick check: If we got a request object, we should *not* have
1181+
# gotten any keyword arguments that map to the request.
1182+
has_flattened_params = any([job, update_mask])
1183+
if request is not None and has_flattened_params:
1184+
raise ValueError(
1185+
"If the `request` argument is set, then none of "
1186+
"the individual field arguments should be set."
1187+
)
1188+
1189+
# - Use the request object if provided (there's no risk of modifying the input as
1190+
# there are no flattened fields), or create one.
1191+
if not isinstance(request, batch.UpdateJobRequest):
1192+
request = batch.UpdateJobRequest(request)
1193+
# If we have keyword arguments corresponding to fields on the
1194+
# request, apply these.
1195+
if job is not None:
1196+
request.job = job
1197+
if update_mask is not None:
1198+
request.update_mask = update_mask
1199+
1200+
# Wrap the RPC method; this adds retry and timeout information,
1201+
# and friendly error handling.
1202+
rpc = self._transport._wrapped_methods[self._transport.update_job]
1203+
1204+
# Certain fields should be provided within the metadata header;
1205+
# add these here.
1206+
metadata = tuple(metadata) + (
1207+
gapic_v1.routing_header.to_grpc_metadata((("job.name", request.job.name),)),
1208+
)
1209+
1210+
# Validate the universe domain.
1211+
self._validate_universe_domain()
1212+
1213+
# Send the request.
1214+
response = rpc(
1215+
request,
1216+
retry=retry,
1217+
timeout=timeout,
1218+
metadata=metadata,
1219+
)
1220+
1221+
# Done; return the response.
1222+
return response
1223+
11121224
def list_jobs(
11131225
self,
11141226
request: Optional[Union[batch.ListJobsRequest, dict]] = None,

packages/google-cloud-batch/google/cloud/batch_v1alpha/services/batch_service/transports/base.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,11 @@ def _prep_wrapped_messages(self, client_info):
159159
default_timeout=60.0,
160160
client_info=client_info,
161161
),
162+
self.update_job: gapic_v1.method.wrap_method(
163+
self.update_job,
164+
default_timeout=60.0,
165+
client_info=client_info,
166+
),
162167
self.list_jobs: gapic_v1.method.wrap_method(
163168
self.list_jobs,
164169
default_retry=retries.Retry(
@@ -281,6 +286,12 @@ def delete_job(
281286
]:
282287
raise NotImplementedError()
283288

289+
@property
290+
def update_job(
291+
self,
292+
) -> Callable[[batch.UpdateJobRequest], Union[gcb_job.Job, Awaitable[gcb_job.Job]]]:
293+
raise NotImplementedError()
294+
284295
@property
285296
def list_jobs(
286297
self,

packages/google-cloud-batch/google/cloud/batch_v1alpha/services/batch_service/transports/grpc.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,30 @@ def delete_job(
333333
)
334334
return self._stubs["delete_job"]
335335

336+
@property
337+
def update_job(self) -> Callable[[batch.UpdateJobRequest], gcb_job.Job]:
338+
r"""Return a callable for the update job method over gRPC.
339+
340+
Update a Job.
341+
342+
Returns:
343+
Callable[[~.UpdateJobRequest],
344+
~.Job]:
345+
A function that, when called, will call the underlying RPC
346+
on the server.
347+
"""
348+
# Generate a "stub function" on-the-fly which will actually make
349+
# the request.
350+
# gRPC handles serialization and deserialization, so we just need
351+
# to pass in the functions for each.
352+
if "update_job" not in self._stubs:
353+
self._stubs["update_job"] = self.grpc_channel.unary_unary(
354+
"/google.cloud.batch.v1alpha.BatchService/UpdateJob",
355+
request_serializer=batch.UpdateJobRequest.serialize,
356+
response_deserializer=gcb_job.Job.deserialize,
357+
)
358+
return self._stubs["update_job"]
359+
336360
@property
337361
def list_jobs(self) -> Callable[[batch.ListJobsRequest], batch.ListJobsResponse]:
338362
r"""Return a callable for the list jobs method over gRPC.

0 commit comments

Comments
 (0)