Skip to content

Commit

Permalink
feat: [google-cloud-batch] add block_project_ssh_keys field to the v1…
Browse files Browse the repository at this point in the history
…alpha job API to block project level ssh keys access to Batch created VMs (#12982)

- [ ] Regenerate this pull request now.

BEGIN_COMMIT_OVERRIDE
feat: add block_project_ssh_keys field to the v1alpha job API to block
project level ssh keys access to Batch created VMs
feat: remove visibility restriction of cancel job api, allow in v1alpha
docs: Refine usage scope for field `task_execution` and `task_state` in
`status_events`
END_COMMIT_OVERRIDE

---
feat: remove visibility restriction of cancel job api, allow in v1alpha

---
feat: update Go Datastore import path
feat: update Go Bigtable import path

---
docs: Refine usage scope for field `task_execution` and `task_state` in
`status_events`
PiperOrigin-RevId: 659840586

Source-Link:
googleapis/googleapis@d4acb64

Source-Link:
googleapis/googleapis-gen@024a490
Copy-Tag:
eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLWJhdGNoLy5Pd2xCb3QueWFtbCIsImgiOiIwMjRhNDkwMDFkYjE2ZjBhNmIyNmIwNGRiYTBlMDBlNzkwNmJiNjdjIn0=

BEGIN_NESTED_COMMIT
docs: [google-cloud-batch] Refine usage scope for fields
`task_execution` and `task_state` in StatusEvent
PiperOrigin-RevId: 659685089

Source-Link:
googleapis/googleapis@00ed8aa

Source-Link:
googleapis/googleapis-gen@85a9862
Copy-Tag:
eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLWJhdGNoLy5Pd2xCb3QueWFtbCIsImgiOiI4NWE5ODYyN2Y5ZTkwZWEyY2IwZTFjMDZlM2E0MTk1OTk0MmNhOTMwIn0=
END_NESTED_COMMIT

---------

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
Co-authored-by: ohmayr <omairnaveed@ymail.com>
  • Loading branch information
3 people authored Aug 8, 2024
1 parent 477c8e4 commit 56ec4fc
Show file tree
Hide file tree
Showing 23 changed files with 3,494 additions and 2,023 deletions.
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
__version__ = "0.17.23" # {x-release-please-version}
__version__ = "0.0.0" # {x-release-please-version}
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
__version__ = "0.17.23" # {x-release-please-version}
__version__ = "0.0.0" # {x-release-please-version}
14 changes: 9 additions & 5 deletions packages/google-cloud-batch/google/cloud/batch_v1/types/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class ComputeResource(proto.Message):


class StatusEvent(proto.Message):
r"""Status event
r"""Status event.
Attributes:
type_ (str):
Expand All @@ -119,9 +119,13 @@ class StatusEvent(proto.Message):
event_time (google.protobuf.timestamp_pb2.Timestamp):
The time this event occurred.
task_execution (google.cloud.batch_v1.types.TaskExecution):
Task Execution
Task Execution.
This field is only defined for task-level status
events where the task fails.
task_state (google.cloud.batch_v1.types.TaskStatus.State):
Task State
Task State.
This field is only defined for task-level status
events.
"""

type_: str = proto.Field(
Expand Down Expand Up @@ -179,11 +183,11 @@ class TaskExecution(proto.Message):


class TaskStatus(proto.Message):
r"""Status of a task
r"""Status of a task.
Attributes:
state (google.cloud.batch_v1.types.TaskStatus.State):
Task state
Task state.
status_events (MutableSequence[google.cloud.batch_v1.types.StatusEvent]):
Detailed info about why the state is reached.
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

from .services.batch_service import BatchServiceAsyncClient, BatchServiceClient
from .types.batch import (
CancelJobRequest,
CancelJobResponse,
CreateJobRequest,
CreateResourceAllowanceRequest,
DeleteJobRequest,
Expand Down Expand Up @@ -76,6 +78,8 @@
"AllocationPolicy",
"BatchServiceClient",
"CalendarPeriod",
"CancelJobRequest",
"CancelJobResponse",
"ComputeResource",
"CreateJobRequest",
"CreateResourceAllowanceRequest",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@
"grpc": {
"libraryClient": "BatchServiceClient",
"rpcs": {
"CancelJob": {
"methods": [
"cancel_job"
]
},
"CreateJob": {
"methods": [
"create_job"
Expand Down Expand Up @@ -75,6 +80,11 @@
"grpc-async": {
"libraryClient": "BatchServiceAsyncClient",
"rpcs": {
"CancelJob": {
"methods": [
"cancel_job"
]
},
"CreateJob": {
"methods": [
"create_job"
Expand Down Expand Up @@ -140,6 +150,11 @@
"rest": {
"libraryClient": "BatchServiceClient",
"rpcs": {
"CancelJob": {
"methods": [
"cancel_job"
]
},
"CreateJob": {
"methods": [
"create_job"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
__version__ = "0.17.23" # {x-release-please-version}
__version__ = "0.0.0" # {x-release-please-version}
Original file line number Diff line number Diff line change
Expand Up @@ -633,6 +633,124 @@ async def sample_delete_job():
# Done; return the response.
return response

async def cancel_job(
self,
request: Optional[Union[batch.CancelJobRequest, dict]] = None,
*,
name: Optional[str] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> operation_async.AsyncOperation:
r"""Cancel a Job.
.. code-block:: python
# This snippet has been automatically generated and should be regarded as a
# code template only.
# It will require modifications to work:
# - It may require correct/in-range values for request initialization.
# - It may require specifying regional endpoints when creating the service
# client as shown in:
# https://googleapis.dev/python/google-api-core/latest/client_options.html
from google.cloud import batch_v1alpha
async def sample_cancel_job():
# Create a client
client = batch_v1alpha.BatchServiceAsyncClient()
# Initialize request argument(s)
request = batch_v1alpha.CancelJobRequest(
name="name_value",
)
# Make the request
operation = client.cancel_job(request=request)
print("Waiting for operation to complete...")
response = (await operation).result()
# Handle the response
print(response)
Args:
request (Optional[Union[google.cloud.batch_v1alpha.types.CancelJobRequest, dict]]):
The request object. CancelJob Request.
name (:class:`str`):
Required. Job name.
This corresponds to the ``name`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
retry (google.api_core.retry_async.AsyncRetry): 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.api_core.operation_async.AsyncOperation:
An object representing a long-running operation.
The result type for the operation will be
:class:`google.cloud.batch_v1alpha.types.CancelJobResponse`
Response to the CancelJob request.
"""
# 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])
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."
)

# - Use the request object if provided (there's no risk of modifying the input as
# there are no flattened fields), or create one.
if not isinstance(request, batch.CancelJobRequest):
request = batch.CancelJobRequest(request)

# If we have keyword arguments corresponding to fields on the
# request, apply these.
if name is not None:
request.name = name

# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = self._client._transport._wrapped_methods[
self._client._transport.cancel_job
]

# 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),)),
)

# Validate the universe domain.
self._client._validate_universe_domain()

# Send the request.
response = await rpc(
request,
retry=retry,
timeout=timeout,
metadata=metadata,
)

# Wrap the response in an operation future.
response = operation_async.from_gapic(
response,
self._client._transport.operations_client,
batch.CancelJobResponse,
metadata_type=batch.OperationMetadata,
)

# Done; return the response.
return response

async def update_job(
self,
request: Optional[Union[batch.UpdateJobRequest, dict]] = None,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1109,6 +1109,121 @@ def sample_delete_job():
# Done; return the response.
return response

def cancel_job(
self,
request: Optional[Union[batch.CancelJobRequest, dict]] = None,
*,
name: Optional[str] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> operation.Operation:
r"""Cancel a Job.
.. code-block:: python
# This snippet has been automatically generated and should be regarded as a
# code template only.
# It will require modifications to work:
# - It may require correct/in-range values for request initialization.
# - It may require specifying regional endpoints when creating the service
# client as shown in:
# https://googleapis.dev/python/google-api-core/latest/client_options.html
from google.cloud import batch_v1alpha
def sample_cancel_job():
# Create a client
client = batch_v1alpha.BatchServiceClient()
# Initialize request argument(s)
request = batch_v1alpha.CancelJobRequest(
name="name_value",
)
# Make the request
operation = client.cancel_job(request=request)
print("Waiting for operation to complete...")
response = operation.result()
# Handle the response
print(response)
Args:
request (Union[google.cloud.batch_v1alpha.types.CancelJobRequest, dict]):
The request object. CancelJob Request.
name (str):
Required. Job name.
This corresponds to the ``name`` 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.api_core.operation.Operation:
An object representing a long-running operation.
The result type for the operation will be
:class:`google.cloud.batch_v1alpha.types.CancelJobResponse`
Response to the CancelJob request.
"""
# 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])
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."
)

# - Use the request object if provided (there's no risk of modifying the input as
# there are no flattened fields), or create one.
if not isinstance(request, batch.CancelJobRequest):
request = batch.CancelJobRequest(request)
# If we have keyword arguments corresponding to fields on the
# request, apply these.
if name is not None:
request.name = name

# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = self._transport._wrapped_methods[self._transport.cancel_job]

# 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),)),
)

# Validate the universe domain.
self._validate_universe_domain()

# Send the request.
response = rpc(
request,
retry=retry,
timeout=timeout,
metadata=metadata,
)

# Wrap the response in an operation future.
response = operation.from_gapic(
response,
self._transport.operations_client,
batch.CancelJobResponse,
metadata_type=batch.OperationMetadata,
)

# Done; return the response.
return response

def update_job(
self,
request: Optional[Union[batch.UpdateJobRequest, dict]] = None,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,11 @@ def _prep_wrapped_messages(self, client_info):
default_timeout=60.0,
client_info=client_info,
),
self.cancel_job: gapic_v1.method.wrap_method(
self.cancel_job,
default_timeout=60.0,
client_info=client_info,
),
self.update_job: gapic_v1.method.wrap_method(
self.update_job,
default_timeout=60.0,
Expand Down Expand Up @@ -288,6 +293,15 @@ def delete_job(
]:
raise NotImplementedError()

@property
def cancel_job(
self,
) -> Callable[
[batch.CancelJobRequest],
Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]],
]:
raise NotImplementedError()

@property
def update_job(
self,
Expand Down
Loading

0 comments on commit 56ec4fc

Please sign in to comment.