feat: Add new gcloud commands, API clients, and third-party libraries across various services.

This commit is contained in:
2026-01-01 20:26:35 +01:00
parent 5e23cbece0
commit a19e592eb7
25221 changed files with 8324611 additions and 0 deletions

View File

@@ -0,0 +1,73 @@
# -*- coding: utf-8 -*- #
# Copyright 2015 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.
"""The command group for submitting cloud dataproc jobs."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.dataproc import flags
class Submit(base.Group):
"""Submit Dataproc jobs to execute on a cluster.
Submit Dataproc jobs to execute on a cluster.
## EXAMPLES
To submit a Hadoop MapReduce job, run:
$ {command} hadoop --cluster my-cluster --jar my_jar.jar -- arg1 arg2
To submit a Spark Scala or Java job, run:
$ {command} spark --cluster my-cluster --jar my_jar.jar -- arg1 arg2
To submit a PySpark job, run:
$ {command} pyspark --cluster my-cluster my_script.py -- arg1 arg2
To submit a Spark SQL job, run:
$ {command} spark-sql --cluster my-cluster --file my_queries.q
To submit a Pig job, run:
$ {command} pig --cluster my-cluster --file my_script.pig
To submit a Hive job, run:
$ {command} hive --cluster my-cluster --file my_queries.q
"""
@staticmethod
def Args(parser):
# Allow user specified Job ID, but don't expose it.
parser.add_argument(
'--id',
hidden=True,
help='Set the ID of the job, which is usually autogenerated')
flags.AddRegionFlag(parser)
base.ASYNC_FLAG.AddToParser(parser)
parser.add_argument(
'--bucket',
help=("The Cloud Storage bucket to stage files in. Defaults to the "
"cluster's configured bucket."))

View File

@@ -0,0 +1,67 @@
# -*- coding: utf-8 -*- #
# Copyright 2023 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.
"""Submit a Flink job to a cluster."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.dataproc import util
from googlecloudsdk.command_lib.dataproc.jobs import flink
from googlecloudsdk.command_lib.dataproc.jobs import submitter
class Flink(flink.FlinkBase, submitter.JobSubmitter):
# pylint: disable=line-too-long
r"""Submit a Flink job to a cluster.
Submit a Flink job to a cluster.
## EXAMPLES
To submit a Flink job that runs the main class of a jar, run:
$ {command} --cluster=my-cluster --region=us-central1 --jar=my_jar.jar -- arg1 arg2
To submit a Flink job that runs a specific class as an entrypoint:
$ {command} --cluster=my-cluster --region=us-central1 --class=org.my.main.Class \
--jars=my_jar.jar -- arg1 arg2
To submit a Flink job that runs a jar that is on the cluster, run:
$ {command} --cluster=my-cluster --region=us-central1 \
--jar=/usr/lib/flink/examples/streaming/TopSpeedWindowing.jar
"""
# pylint: enable=line-too-long
@staticmethod
def Args(parser):
flink.FlinkBase.Args(parser)
submitter.JobSubmitter.Args(parser)
driver_group = parser.add_argument_group(required=True, mutex=True)
util.AddJvmDriverFlags(driver_group)
def ConfigureJob(self, messages, job, args):
flink.FlinkBase.ConfigureJob(
messages,
job,
self.files_by_type,
self.BuildLoggingConfig(messages, args.driver_log_levels),
args,
)
submitter.JobSubmitter.ConfigureJob(messages, job, args)

View File

@@ -0,0 +1,61 @@
# -*- coding: utf-8 -*- #
# Copyright 2015 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.
"""Submit a Hadoop job to a cluster."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.dataproc import util
from googlecloudsdk.command_lib.dataproc.jobs import hadoop
from googlecloudsdk.command_lib.dataproc.jobs import submitter
class Hadoop(hadoop.HadoopBase, submitter.JobSubmitter):
r"""Submit a Hadoop job to a cluster.
Submit a Hadoop job to a cluster.
## EXAMPLES
To submit a Hadoop job that runs the main class of a jar, run:
$ {command} --cluster=my-cluster --jar=my_jar.jar -- arg1 arg2
To submit a Hadoop job that runs a specific class of a jar, run:
$ {command} --cluster=my-cluster --class=org.my.main.Class \
--jars=my_jar1.jar,my_jar2.jar -- arg1 arg2
To submit a Hadoop job that runs a jar that is already on the cluster, run:
$ {command} --cluster=my-cluster \
--jar=file:///usr/lib/hadoop-op/hadoop-op-examples.jar \
-- wordcount gs://my_bucket/my_file.txt gs://my_bucket/output
"""
@classmethod
def Args(cls, parser):
hadoop.HadoopBase.Args(parser)
submitter.JobSubmitter.Args(parser)
driver_group = parser.add_argument_group(required=True, mutex=True)
util.AddJvmDriverFlags(driver_group)
def ConfigureJob(self, messages, job, args):
hadoop.HadoopBase.ConfigureJob(
messages, job, self.files_by_type,
self.BuildLoggingConfig(messages, args.driver_log_levels), args)
submitter.JobSubmitter.ConfigureJob(messages, job, args)

View File

@@ -0,0 +1,51 @@
# -*- coding: utf-8 -*- #
# Copyright 2015 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.
"""Submit a Hive job to a cluster."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.command_lib.dataproc.jobs import hive
from googlecloudsdk.command_lib.dataproc.jobs import submitter
class Hive(hive.HiveBase, submitter.JobSubmitter):
"""Submit a Hive job to a cluster.
Submit a Hive job to a cluster.
## EXAMPLES
To submit a Hive job with a local script, run:
$ {command} --cluster=my-cluster --file=my_queries.q
To submit a Hive job with inline queries, run:
$ {command} --cluster=my-cluster
-e="CREATE EXTERNAL TABLE foo(bar int) LOCATION 'gs://my_bucket/'"
-e="SELECT * FROM foo WHERE bar > 2"
"""
@classmethod
def Args(cls, parser):
hive.HiveBase.Args(parser)
submitter.JobSubmitter.Args(parser)
def ConfigureJob(self, messages, job, args):
hive.HiveBase.ConfigureJob(messages, job, self.files_by_type, args)
submitter.JobSubmitter.ConfigureJob(messages, job, args)

View File

@@ -0,0 +1,56 @@
# -*- coding: utf-8 -*- #
# Copyright 2015 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.
"""Submit a Pig job to a cluster."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.command_lib.dataproc.jobs import pig
from googlecloudsdk.command_lib.dataproc.jobs import submitter
class Pig(pig.PigBase, submitter.JobSubmitter):
"""Submit a Pig job to a cluster.
Submit a Pig job to a cluster.
## EXAMPLES
To submit a Pig job with a local script, run:
$ {command} --cluster=my-cluster --file=my_queries.pig
To submit a Pig job with inline queries, run:
$ {command} --cluster=my-cluster
-e="LNS = LOAD 'gs://my_bucket/my_file.txt' AS (line)"
-e="WORDS = FOREACH LNS GENERATE FLATTEN(TOKENIZE(line)) AS word"
-e="GROUPS = GROUP WORDS BY word"
-e="WORD_COUNTS = FOREACH GROUPS GENERATE group, COUNT(WORDS)"
-e="DUMP WORD_COUNTS"
"""
@staticmethod
def Args(parser):
pig.PigBase.Args(parser)
submitter.JobSubmitter.Args(parser)
def ConfigureJob(self, messages, job, args):
pig.PigBase.ConfigureJob(messages, job, self.files_by_type,
self.BuildLoggingConfig(
messages, args.driver_log_levels), args)
submitter.JobSubmitter.ConfigureJob(messages, job, args)

View File

@@ -0,0 +1,50 @@
# -*- coding: utf-8 -*- #
# Copyright 2019 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.
"""Submit a Presto job to a cluster."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.command_lib.dataproc.jobs import presto
from googlecloudsdk.command_lib.dataproc.jobs import submitter
class Presto(presto.PrestoBase, submitter.JobSubmitter):
r"""Submit a Presto job to a cluster.
Submit a Presto job to a cluster
## EXAMPLES
To submit a Presto job with a local script, run:
$ {command} --cluster=my-cluster --file=my_script.R
To submit a Presto job with inline queries, run:
$ {command} --cluster=my-cluster -e="SELECT * FROM foo WHERE bar > 2"
"""
@staticmethod
def Args(parser):
presto.PrestoBase.Args(parser)
submitter.JobSubmitter.Args(parser)
def ConfigureJob(self, messages, job, args):
presto.PrestoBase.ConfigureJob(
messages, job, self.files_by_type,
self.BuildLoggingConfig(messages, args.driver_log_levels), args)
submitter.JobSubmitter.ConfigureJob(messages, job, args)

View File

@@ -0,0 +1,70 @@
# -*- coding: utf-8 -*- #
# Copyright 2023 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.
"""Submit a PyFlink job to a cluster."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.command_lib.dataproc.jobs import pyflink
from googlecloudsdk.command_lib.dataproc.jobs import submitter
class PyFlink(pyflink.PyFlinkBase, submitter.JobSubmitter):
# pylint: disable=line-too-long
r"""Submit a PyFlink job to a cluster.
Submit a PyFlink job to a cluster.
## EXAMPLES
Submit a PyFlink job.
$ gcloud dataproc jobs submit pyflink my-pyflink.py --region=us-central1
Submit a PyFlink job with additional source and resource files.
$ gcloud dataproc jobs submit pyflink my-pyflink.py \
--region=us-central1 \
--py-files=my-python-file1.py,my-python-file2.py
Submit a PyFlink job with a jar file.
$ gcloud dataproc jobs submit pyflink my-pyflink.py \
--region=us-central1 \
--jars=my-jar-file.jar
Submit a PyFlink job with 'python-files' and 'python-module'.
$ gcloud dataproc jobs submit pyflink my-pyflink.py \
--region=us-central1 \
--py-files=my-python-file1.py,my-python-file2.py
--py-module=my-module
"""
# pylint: enable=line-too-long
@staticmethod
def Args(parser):
pyflink.PyFlinkBase.Args(parser)
submitter.JobSubmitter.Args(parser)
def ConfigureJob(self, messages, job, args):
pyflink.PyFlinkBase.ConfigureJob(messages, job, self.files_by_type,
self.BuildLoggingConfig(
messages, args.driver_log_levels),
args)
submitter.JobSubmitter.ConfigureJob(messages, job, args)

View File

@@ -0,0 +1,54 @@
# -*- coding: utf-8 -*- #
# Copyright 2015 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.
"""Submit a PySpark job to a cluster."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.command_lib.dataproc.jobs import pyspark
from googlecloudsdk.command_lib.dataproc.jobs import submitter
class PySpark(pyspark.PySparkBase, submitter.JobSubmitter):
# pylint: disable=line-too-long
"""Submit a PySpark job to a cluster.
Submit a PySpark job to a cluster.
## EXAMPLES
To submit a PySpark job with a local script and custom flags, run:
$ {command} --cluster=my-cluster my_script.py -- --custom-flag
To submit a Spark job that runs a script that is already on the cluster, run:
$ {command} --cluster=my-cluster file:///usr/lib/spark/examples/src/main/python/pi.py -- 100
"""
# pylint: enable=line-too-long
@staticmethod
def Args(parser):
pyspark.PySparkBase.Args(parser)
submitter.JobSubmitter.Args(parser)
def ConfigureJob(self, messages, job, args):
pyspark.PySparkBase.ConfigureJob(messages, job, self.files_by_type,
self.BuildLoggingConfig(
messages, args.driver_log_levels),
args)
submitter.JobSubmitter.ConfigureJob(messages, job, args)

View File

@@ -0,0 +1,64 @@
# -*- coding: utf-8 -*- #
# Copyright 2015 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.
"""Submit a Spark job to a cluster."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.dataproc import util
from googlecloudsdk.command_lib.dataproc.jobs import spark
from googlecloudsdk.command_lib.dataproc.jobs import submitter
class Spark(spark.SparkBase, submitter.JobSubmitter):
# pylint: disable=line-too-long
r"""Submit a Spark job to a cluster.
Submit a Spark job to a cluster.
## EXAMPLES
To submit a Spark job that runs the main class of a jar, run:
$ {command} --cluster=my-cluster --region=us-central1 --jar=my_jar.jar -- arg1 arg2
To submit a Spark job that runs a specific class of a jar, run:
$ {command} --cluster=my-cluster --region=us-central1 --class=org.my.main.Class \
--jars=my_jar1.jar,my_jar2.jar -- arg1 arg2
To submit a Spark job that runs a jar that is already on the cluster, run:
$ {command} --cluster=my-cluster --region=us-central1 \
--class=org.apache.spark.examples.SparkPi \
--jars=file:///usr/lib/spark/examples/jars/spark-examples.jar \
-- 1000
"""
# pylint: enable=line-too-long
@staticmethod
def Args(parser):
spark.SparkBase.Args(parser)
submitter.JobSubmitter.Args(parser)
driver_group = parser.add_argument_group(required=True, mutex=True)
util.AddJvmDriverFlags(driver_group)
def ConfigureJob(self, messages, job, args):
spark.SparkBase.ConfigureJob(messages, job, self.files_by_type,
self.BuildLoggingConfig(
messages, args.driver_log_levels), args)
submitter.JobSubmitter.ConfigureJob(messages, job, args)

View File

@@ -0,0 +1,52 @@
# -*- coding: utf-8 -*- #
# Copyright 2015 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.
"""Submit a SparkR job to a cluster."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.command_lib.dataproc.jobs import spark_r
from googlecloudsdk.command_lib.dataproc.jobs import submitter
class SparkR(spark_r.SparkRBase, submitter.JobSubmitter):
r"""Submit a SparkR job to a cluster.
Submit a SparkR job to a cluster.
## EXAMPLES
To submit a SparkR job with a local script, run:
$ {command} --cluster=my-cluster my_script.R
To submit a Spark job that runs a script already on the cluster, run:
$ {command} --cluster=my-cluster file:///.../my_script.R \
-- gs://my_bucket/data.csv
"""
@staticmethod
def Args(parser):
spark_r.SparkRBase.Args(parser)
submitter.JobSubmitter.Args(parser)
def ConfigureJob(self, messages, job, args):
spark_r.SparkRBase.ConfigureJob(
messages, job, self.files_by_type,
self.BuildLoggingConfig(messages, args.driver_log_levels), args)
submitter.JobSubmitter.ConfigureJob(messages, job, args)

View File

@@ -0,0 +1,54 @@
# -*- coding: utf-8 -*- #
# Copyright 2015 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.
"""Submit a Spark SQL job to a cluster."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.command_lib.dataproc.jobs import spark_sql
from googlecloudsdk.command_lib.dataproc.jobs import submitter
class SparkSql(spark_sql.SparkSqlBase, submitter.JobSubmitter):
"""Submit a Spark SQL job to a cluster.
Submit a Spark SQL job to a cluster.
## EXAMPLES
To submit a Spark SQL job with a local script, run:
$ {command} --cluster=my-cluster --file=my_queries.ql
To submit a Spark SQL job with inline queries, run:
$ {command} --cluster=my-cluster
-e="CREATE EXTERNAL TABLE foo(bar int) LOCATION 'gs://my_bucket/'"
-e="SELECT * FROM foo WHERE bar > 2"
"""
@staticmethod
def Args(parser):
spark_sql.SparkSqlBase.Args(parser)
submitter.JobSubmitter.Args(parser)
def ConfigureJob(self, messages, job, args):
spark_sql.SparkSqlBase.ConfigureJob(messages, job, self.files_by_type,
self.BuildLoggingConfig(
messages, args.driver_log_levels),
args)
submitter.JobSubmitter.ConfigureJob(messages, job, args)

View File

@@ -0,0 +1,50 @@
# -*- 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.
"""Submit a Trino job to a cluster."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.command_lib.dataproc.jobs import submitter
from googlecloudsdk.command_lib.dataproc.jobs import trino
class Trino(trino.TrinoBase, submitter.JobSubmitter):
r"""Submit a Trino job to a cluster.
Submit a Trino job to a cluster
## EXAMPLES
To submit a Trino job with a local script, run:
$ {command} --cluster=my-cluster --file=my_script.R
To submit a Trino job with inline queries, run:
$ {command} --cluster=my-cluster -e="SELECT * FROM foo WHERE bar > 2"
"""
@staticmethod
def Args(parser):
trino.TrinoBase.Args(parser)
submitter.JobSubmitter.Args(parser)
def ConfigureJob(self, messages, job, args):
trino.TrinoBase.ConfigureJob(
messages, job, self.files_by_type,
self.BuildLoggingConfig(messages, args.driver_log_levels), args)
submitter.JobSubmitter.ConfigureJob(messages, job, args)