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,26 @@
# -*- coding: utf-8 -*- #
# Copyright 2025 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 the gemini cloud-assist CLI."""
from googlecloudsdk.calliope import base
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
@base.DefaultUniverseOnly
class GeminicloudassistAlpha(base.Group):
"""Manage Gemini Cloud Assist."""
category = base.UNCATEGORIZED_CATEGORY

View File

@@ -0,0 +1,38 @@
# -*- coding: utf-8 -*- #
# Copyright 2025 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 the investigations CLI."""
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.gemini import cloud_assist
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class InvestigationsAlpha(base.Group):
"""Create and manage Gemini Cloud Assist investigations."""
category = base.UNCATEGORIZED_CATEGORY
@staticmethod
def Args(parser):
parser.display_info.AddTransforms({
"investigation_markdown_short": cloud_assist.InvestigationMarkdownShort,
"investigation_markdown_detailed": (
cloud_assist.InvestigationMarkdownDetailed
),
"reformat_investigation": cloud_assist.ReformatInvestigation,
})

View File

@@ -0,0 +1,67 @@
# -*- coding: utf-8 -*- #
# Copyright 2025 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 add an IAM policy binding for an investigation."""
import textwrap
from googlecloudsdk.api_lib.gemini_cloud_assist import args as geminicloudassist_args
from googlecloudsdk.api_lib.gemini_cloud_assist import util as geminicloudassist_util
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.iam import iam_util
@base.UniverseCompatible
class AddIamPolicyBinding(base.Command):
"""Adds an IAM policy binding for an investigation."""
detailed_help = {
'EXAMPLES': textwrap.dedent("""\
To add an IAM policy binding for the role of 'roles/geminicloudassist.investigationViewer'
for the user 'test-user@gmail.com' on the investigation
'project/my-project/locations/my-location/investigations/my-investigation', run:
$ {command} project/my-project/locations/my-location/investigations/my-investigation --member='user:test-user@gmail.com' --role='roles/geminicloudassist.investigationViewer'
See https://cloud.google.com/iam/docs/managing-policies for details of
policy role and member types.
"""),
}
@staticmethod
def Args(parser):
"""Registers flags for this command.
Args:
parser: The argparse parser.
"""
geminicloudassist_args.AddInvestigationResourceArg(
parser, 'to add IAM policy binding for'
)
iam_util.AddArgsForAddIamPolicyBinding(parser)
def Run(self, args):
"""Adds an IAM policy binding for an investigation.
Args:
args: An argparse namespace. All the arguments that were provided to this
command invocation.
Returns:
The updated IAM policy.
"""
return geminicloudassist_util.AddInvestigationIamPolicyBinding(
args.investigation, args.member, args.role
)

View File

@@ -0,0 +1,100 @@
# -*- coding: utf-8 -*- #
# Copyright 2025 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 create a new investigation."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.gemini_cloud_assist import args as gca_args
from googlecloudsdk.api_lib.gemini_cloud_assist import util as gca_util
from googlecloudsdk.calliope import arg_parsers
from googlecloudsdk.calliope import base
from googlecloudsdk.core.util import times
@base.DefaultUniverseOnly
class Create(base.Command):
"""Create a new investigation.
Shows metadata for the newly created investigation after creation.
This command can fail for the following reasons:
* The chosen investigation ID, if specified, already exists.
* The active account does not have permission to create investigations in the
project.
## EXAMPLES
The following command creates a new investigation with the ID and some basic
information
`example-foo-bar-1`:
$ {command} example-foo-bar-1 --title="Example Investigation" --issue="I
have a problem" --start-time=2025-07-10
"""
@staticmethod
def Args(parser):
gca_args.AddInvestigationResourceArg(
parser, verb="to create", required=False, allow_no_id=True
)
parser.display_info.AddFormat("value(investigation_markdown_detailed())")
parser.add_argument(
"--issue",
required=True,
help=(
"A description of the issue you are investigating, or an error log."
),
)
parser.add_argument(
"--start-time",
required=False,
type=times.ParseDateTime,
help="The estimated start time of the issue you are investigating.",
)
parser.add_argument(
"--end-time",
required=False,
type=times.ParseDateTime,
help="The estimated end time of the issue you are investigating.",
)
parser.add_argument(
"--title",
required=False,
help="The desired title of the resulting investigation.",
)
parser.add_argument(
"--resources",
required=False,
metavar="RESOURCE",
type=arg_parsers.ArgList(),
help="A list of resources relevant to the investigation",
)
def Run(self, args):
investigation_ref = args.CONCEPTS.investigation.Parse()
created_investigation = gca_util.CreateInvestigation(
investigation_ref,
args.title,
args.issue,
args.start_time,
args.end_time,
args.resources,
)
return gca_util.RunInvestigationRevisionBlocking(
created_investigation.revision
)

View File

@@ -0,0 +1,17 @@
release_tracks: [ALPHA]
help_text:
brief: Delete an Investigation.
description: Delete a Gemini Cloud Assist Investigation.
examples: |
The following command deletes an Investigation with ID `foo-bar-1`
$ {command} foo-bar-1
request:
collection: geminicloudassist.projects.locations.investigations
method: delete
arguments:
resource:
help_text: The investigation you want to delete.
spec: !REF googlecloudsdk.command_lib.gemini.cloud_assist.resources:investigation

View File

@@ -0,0 +1,80 @@
# -*- coding: utf-8 -*- #
# Copyright 2025 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 show a specified investigation."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.gemini_cloud_assist import args as gca_args
from googlecloudsdk.api_lib.gemini_cloud_assist import util as gca_util
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.gemini import cloud_assist
@base.DefaultUniverseOnly
class Describe(base.DescribeCommand):
"""Show metadata for an investigation.
Shows metadata for an investigation given a valid investigation ID.
This command can fail for the following reasons:
* The investigation specified does not exist.
* The active account does not have permission to access the given
investigation.
## EXAMPLES
The following command prints metadata for an investigation with the ID
`example-foo-bar-1`:
$ {command} example-foo-bar-1
"""
@staticmethod
def Args(parser):
gca_args.AddInvestigationResourceArg(parser, verb="to describe")
parser.add_argument(
"--detail",
required=False,
action="store_true",
help="Include extra information in the default output.",
)
parser.add_argument(
"--raw",
required=False,
action="store_true",
help=(
"Return the full, unaltered API response instead of the version"
" formatted for human consumption."
),
)
def Run(self, args):
# Only handle --detail flag if no format or --raw were specified.
if not args.IsSpecified("format") and not args.raw:
if args.detail:
args.format = "value(investigation_markdown_detailed())"
else:
args.format = "value(investigation_markdown_short())"
investigation_ref = args.CONCEPTS.investigation.Parse()
if args.raw:
return gca_util.GetInvestigation(investigation_ref.RelativeName())
return cloud_assist.ReformatInvestigation(
gca_util.GetInvestigation(investigation_ref.RelativeName())
)

View File

@@ -0,0 +1,60 @@
# -*- coding: utf-8 -*- #
# Copyright 2025 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 Get IAM policy for an investigation."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.gemini_cloud_assist import args as geminicloudassist_args
from googlecloudsdk.api_lib.gemini_cloud_assist import util as geminicloudassist_util
from googlecloudsdk.calliope import base
@base.UniverseCompatible
class GetIamPolicy(base.Command):
"""Get IAM policy for an investigation."""
detailed_help = {
'EXAMPLES': """\
To get the IAM policy a the investigation 'project/my-project/locations/my-location/investigations/my-investigation', run:
$ {command} project/my-project/locations/my-location/investigations/my-investigation
""",
}
@staticmethod
def Args(parser):
"""Registers flags for this command.
Args:
parser: The argparse parser.
"""
geminicloudassist_args.AddInvestigationResourceArg(
parser, 'to get IAM policy for'
)
def Run(self, args):
""" Get IAM policy for an investigation.
Args:
args: An argparse namespace. All the arguments that were provided to this
command invocation.
Returns:
The IAM policy for the given investigation.
"""
return geminicloudassist_util.GetInvestigationIamPolicy(args.investigation)

View File

@@ -0,0 +1,23 @@
release_tracks: [ALPHA]
help_text:
brief: List Gemini Cloud Assist Investigations.
description: List Gemini Cloud Assist Investigations.
examples: |
To list Gemini Cloud Assist Investigations, run:
$ {command}
request:
collection: geminicloudassist.projects.locations.investigations
method: list
arguments:
resource:
help_text: Location to list investigations for.
spec: !REF googlecloudsdk.command_lib.gemini.cloud_assist.resources:location
output:
format: |
table(name,
title,
executionState)

View File

@@ -0,0 +1,69 @@
# -*- coding: utf-8 -*- #
# Copyright 2025 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 remove an IAM policy binding from an investigation."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.gemini_cloud_assist import args as geminicloudassist_args
from googlecloudsdk.api_lib.gemini_cloud_assist import util as geminicloudassist_util
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.iam import iam_util
@base.UniverseCompatible
class RemoveIamPolicyBinding(base.Command):
"""Removes an IAM policy binding from an investigation."""
detailed_help = {
'EXAMPLES': """\
To remove an IAM policy binding for the role of 'roles/geminicloudassist.investigationUser'
for the user 'test-user@gmail.com' from the investigation
'project/my-project/locations/my-location/investigations/my-investigation', run:
$ {command} project/my-project/locations/my-location/investigations/my-investigation --member='user:test-user@gmail.com' --role='roles/geminicloudassist.investigations.user'
See https://cloud.google.com/iam/docs/managing-policies for details of
policy role and member types.
""",
}
@staticmethod
def Args(parser):
"""Registers flags for this command.
Args:
parser: The argparse parser.
"""
geminicloudassist_args.AddInvestigationResourceArg(
parser, 'to remove IAM policy binding from'
)
iam_util.AddArgsForAddIamPolicyBinding(parser)
def Run(self, args):
"""Removes an IAM policy binding from an investigation.
Args:
args: An argparse namespace. All the arguments that were provided to this
command invocation.
Returns:
The updated IAM policy.
"""
return geminicloudassist_util.RemoveInvestigationIamPolicyBinding(
args.investigation, args.member, args.role
)

View File

@@ -0,0 +1,55 @@
# -*- coding: utf-8 -*- #
# Copyright 2025 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 set IAM policy for an investigation."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.gemini_cloud_assist import args as geminicloudassist_args
from googlecloudsdk.api_lib.gemini_cloud_assist import util as geminicloudassist_util
from googlecloudsdk.calliope import base
@base.UniverseCompatible
class RemoveIamPolicyBinding(base.Command):
"""Sets IAM policy for an investigation."""
detailed_help = {
'EXAMPLES': """\
To set IAM policy for theinvestigation
project/my-project/locations/my-location/investigations/my-investigation defined in `POLICY-FILE-1`', run:
$ {command} project/my-project/locations/my-location/investigations/my-investigation POLICY-FILE-1
""",
}
@staticmethod
def Args(parser):
"""Registers flags for this command.
Args:
parser: The argparse parser.
"""
geminicloudassist_args.AddInvestigationResourceArg(
parser, 'to remove IAM policy binding from'
)
geminicloudassist_args.AddIAMPolicyFileArg(parser)
def Run(self, args):
return geminicloudassist_util.SetInvestigationIamPolicy(
args.investigation, args.policy_file
)

View File

@@ -0,0 +1,133 @@
# -*- coding: utf-8 -*- #
# Copyright 2025 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 create a new investigation."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
import datetime
from googlecloudsdk.api_lib.gemini_cloud_assist import args as gca_args
from googlecloudsdk.api_lib.gemini_cloud_assist import util as gca_util
from googlecloudsdk.calliope import arg_parsers
from googlecloudsdk.calliope import base
from googlecloudsdk.core.util import times
@base.DefaultUniverseOnly
class Create(base.Command):
r"""Update an existing investigation.
Shows metadata for the investigation after updating.
This command can fail for the following reasons:
* The investigation ID doesn't exist.
* The active account does not have permission to update the investigation.
* The investigation is currently running.
## EXAMPLES
The following command updates title, text description, resources, and start
time of the existing investigation with the name`example-foo-bar-1`:
$ {command} example-foo-bar-1 --title="Example Investigation" \
--issue="I have a problem" --start-time=2025-07-10
"""
@staticmethod
def Args(parser):
gca_args.AddInvestigationResourceArg(
parser, verb="to update", required=True, allow_no_id=False
)
parser.display_info.AddFormat("value(investigation_markdown_detailed())")
parser.add_argument(
"--issue",
required=False,
help=(
"A description of the issue you are investigating, or an error log."
),
)
start_time_group = parser.add_mutually_exclusive_group(sort_args=False)
start_time_group.add_argument(
"--start-time",
required=False,
type=times.ParseDateTime,
help="The estimated start time of the issue you are investigating.",
)
start_time_group.add_argument(
"--clear-start-time",
required=False,
action="store_true",
help="Clear the start time of the investigation.",
)
end_time_group = parser.add_mutually_exclusive_group(sort_args=False)
end_time_group.add_argument(
"--end-time",
required=False,
type=times.ParseDateTime,
help="The estimated end time of the issue you are investigating.",
)
end_time_group.add_argument(
"--clear-end-time",
required=False,
action="store_true",
help="Clear the end time of the investigation.",
)
title_group = parser.add_mutually_exclusive_group(sort_args=False)
title_group.add_argument(
"--title",
required=False,
help="The desired title of the resulting investigation.",
)
title_group.add_argument(
"--clear-title",
required=False,
action="store_true",
help="Clear the title of the investigation.",
)
resources_group = parser.add_mutually_exclusive_group(sort_args=False)
resources_group.add_argument(
"--resources",
required=False,
metavar="RESOURCE",
type=arg_parsers.ArgList(),
help="A list of resources relevant to the investigation",
)
resources_group.add_argument(
"--clear-resources",
required=False,
action="store_true",
help="Clear the resources of the investigation.",
)
def Run(self, args):
investigation_ref = args.CONCEPTS.investigation.Parse()
updated_investigation = gca_util.UpdateInvestigation(
investigation_ref,
"" if args.clear_title else args.title,
args.issue,
datetime.datetime.min if args.clear_start_time else args.start_time,
datetime.datetime.max if args.clear_end_time else args.end_time,
[] if args.clear_resources else args.resources,
)
return gca_util.RunInvestigationRevisionBlocking(
updated_investigation.revision
)