# -*- coding: utf-8 -*- # # Copyright 2022 Google LLC. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Command to submit a specified Batch job.""" from __future__ import absolute_import from __future__ import division from __future__ import unicode_literals import datetime from apitools.base.protorpclite.messages import DecodeError from apitools.base.py import encoding from googlecloudsdk.api_lib.batch import jobs from googlecloudsdk.calliope import arg_parsers from googlecloudsdk.calliope import base from googlecloudsdk.command_lib.batch import resource_args from googlecloudsdk.command_lib.util.apis import arg_utils from googlecloudsdk.core import exceptions from googlecloudsdk.core import log from googlecloudsdk.core import yaml from googlecloudsdk.core.util import files def _CommonArgs(parser): """Register flags for this command. Args: parser: An argparse.ArgumentParser-like object. It is mocked out in order to capture some information, but behaves like an ArgumentParser. Returns: network_group flag groups. """ network_group = parser.add_group() network_group.add_argument( '--network', required=True, type=str, help="""The URL for the network resource. Must specify subnetwork as well if network is specified""", ) network_group.add_argument( '--subnetwork', required=True, type=str, help="""The URL for the subnetwork resource. Must specify network as well if subnetwork is specified""", ) network_group.add_argument( '--no-external-ip-address', action='store_true', default=False, help="""Required if no external public IP address is attached to the VM. If no external public IP address, additional configuration is required to allow the VM to access Google Services.""", ) task_spec_group = parser.add_group(required=True) task_spec_group.add_argument( '--config', type=arg_parsers.FileContents(), help="""The file path of the job config file in either JSON or YAML format. It also supports direct input from stdin with '-' or HereDoc (in shells with HereDoc support like Bash) with '- <