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,20 @@
# -*- coding: utf-8 -*- #
# Copyright 2024 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.
"""Libraries to support the gemini command surface."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals

View File

@@ -0,0 +1,352 @@
# -*- 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.
"""Common logic for gemini cloud assist commands."""
import textwrap
from googlecloudsdk.core import resource
def InputMarkdownShort(observation):
"""Returns a short human-readable string representation of an input observation.
There is no gaurentee of output stability over time.
Args:
observation: A dict representing an observation.
Returns:
A string representing the observation.
"""
ret = textwrap.dedent("""\
### {}
{}
""").format(
observation["id"],
observation["text"],
)
return ret
def ObservationMarkdownShort(observation):
"""Returns a short human-readable string representation of an observation.
There is no gaurentee of output stability over time.
Args:
observation: A dict representing an observation.
Returns:
A string representing the observation.
"""
ret = textwrap.dedent("""\
### {}""").format(
observation["title"] if "title" in observation else "No Title",
)
return ret
def HypothesisMarkdownShort(observation):
"""Returns a short human-readable string representation of a hypothesis observation.
There is no gaurentee of output stability over time.
Args:
observation: A dict representing an observation.
Returns:
A string representing the observation.
"""
short_text = ""
if "text" in observation:
split_text = observation["text"].split("\n")
if len(split_text) > 2:
short_text = "\n".join(
[s for s in split_text[:2] if not s.startswith("#")]
)
else:
short_text = observation["text"]
ret = textwrap.dedent("""\
### {}
{}
""").format(
observation["title"] if "title" in observation else "No Title",
short_text,
)
return ret
def InvestigationMarkdownShort(investigation):
"""Returns a short human-readable string representation of an investigation.
There is no gaurentee of output stability over time.
Args:
investigation: A dict representing an investigation.
Returns:
A string representing the investigation.
"""
long_format = textwrap.dedent("""\
# {}
Name: {}
Status: {}
## Inputs
{}
## Observations
{}
## Hypotheses
{}
""").format(
investigation["title"] if "title" in investigation else "No Title",
investigation["name"],
investigation["executionState"],
"\n".join(map(InputMarkdownShort, investigation["inputs"])),
"\n".join(map(ObservationMarkdownShort, investigation["observations"])),
"\n".join(map(HypothesisMarkdownShort, investigation["hypotheses"])),
)
return long_format
def GetTimestamp(observation):
"""Extracts the start and end times from an observation.
Args:
observation: A dict representing an observation.
Returns:
A tuple of two strings: start_time and end_time.
"""
start_time = "None"
end_time = "None"
if "timeIntervals" in observation:
if "startTime" in observation["timeIntervals"][0]:
start_time = observation["timeIntervals"][0]["startTime"]
if "endTime" in observation["timeIntervals"][0]:
end_time = observation["timeIntervals"][0]["endTime"]
return start_time, end_time
def InputMarkdownDetailed(observation):
"""Returns a detailed human-readable string representation of an input observation.
There is no gaurentee of output stability over time.
Args:
observation: A dict representing an observation.
Returns:
A string representing the observation.
"""
start_time, end_time = GetTimestamp(observation)
relevant_resources = (
"".join([f"- {r}\n" for r in observation["relevantResources"]])
if "relevantResources" in observation
else ""
)
ret = textwrap.dedent("""\
### {}
Start Time: {}
End Time: {}
{}
#### Relevant Resources
{}
""").format(
observation["id"],
start_time,
end_time,
observation["text"],
relevant_resources,
)
return ret
def ObservationMarkdownDetailed(observation):
"""Returns a detailed human-readable string representation of an observation.
There is no gaurentee of output stability over time.
Args:
observation: A dict representing an observation.
Returns:
A string representing the observation.
"""
start_time, end_time = GetTimestamp(observation)
relevant_resources = (
"".join([f"- {r}\n" for r in observation["relevantResources"]])
if "relevantResources" in observation
else ""
)
ret = textwrap.dedent("""\
### {}
Type: {}
Start Time: {}
End Time: {}
{}
#### Relevant Resources
{}
""").format(
observation["title"] if "title" in observation else "No Title",
observation["observationType"],
start_time,
end_time,
observation["text"],
relevant_resources,
)
return ret
def HypothesisMarkdownDetailed(observation):
"""Returns a detailed human-readable string representation of a hypothesis observation.
There is no gaurentee of output stability over time.
Args:
observation: A dict representing an observation.
Returns:
A string representing the observation.
"""
# Hypotheses use level-3 headings, we want them to become level-4 headings
lines = observation["text"].split("\n")
for i in range(len(lines)):
if lines[i].startswith("#"):
lines[i] = "#" + lines[i]
edited_text = "\n".join(lines)
ret = textwrap.dedent("""\
### {}
{}
""").format(
observation["title"] if "title" in observation else "No Title",
edited_text,
)
return ret
def InvestigationMarkdownDetailed(investigation):
"""Returns a detailed human-readable string representation of an investigation.
There is no gaurentee of output stability over time.
Args:
investigation: A dict representing an investigation.
Returns:
A string representing the investigation.
"""
long_format = textwrap.dedent("""\
# {}
Name: {}
Status: {}
## Inputs
{}
## Observations
{}
## Hypotheses
{}
""").format(
investigation["title"] if "title" in investigation else "No Title",
investigation["name"],
investigation["executionState"],
"\n".join(map(InputMarkdownDetailed, investigation["inputs"])),
"\n".join(
map(ObservationMarkdownDetailed, investigation["observations"])
),
"\n".join(map(HypothesisMarkdownDetailed, investigation["hypotheses"])),
)
return long_format
def ReformatInvestigation(investigation):
"""Transforms an investigation into an alternate format of the investigation.
This format will have observations grouped by type, with some filtered out for
improved human readability.
Args:
investigation: A dict representing an investigation.
Returns:
A dict representing the investigation.
"""
investigation = resource.resource_projector.MakeSerializable(investigation)
inputs, observations, hypotheses = ExtractObservations(investigation)
return {
"name": investigation["name"],
"title": investigation.get("title", "No Title"),
"executionState": investigation["executionState"],
"inputs": inputs,
"observations": observations,
"hypotheses": hypotheses,
}
_IGNORED_OBSERVATION_TYPES = [
"OBSERVATION_TYPE_STRUCTURED_INPUT",
"OBSERVATION_TYPE_RELATED_RESOURCES",
"OBSERVATION_TYPE_KNOWLEDGE",
]
def ExtractObservations(investigation):
"""Extracts observations from an investigation.
Attempts to mimic UI behavior as much as possible.
Any observations missing observationType, observerType, text, or title will be
ignored.
The observations are returned as inputs, observations, and hypotheses.
Args:
investigation: A dict representing an investigation.
Returns:
A tuple of three lists: inputs, observations, and hypotheses.
"""
inputs = []
observations = []
hypotheses = []
if "observations" not in investigation:
return inputs, observations, hypotheses
for observation in investigation["observations"].values():
if (
"observationType" not in observation
or "observerType" not in observation
or "text" not in observation
):
# This observation doesn't meet the minimum qualifications to be shown.
continue
if observation["observationType"] in _IGNORED_OBSERVATION_TYPES:
continue
if observation["observerType"] == "OBSERVER_TYPE_USER":
inputs.append(observation)
continue
if observation["observationType"] == "OBSERVATION_TYPE_HYPOTHESIS":
hypotheses.append(observation)
continue
observations.append(observation)
return inputs, observations, hypotheses

View File

@@ -0,0 +1,36 @@
project:
name: project
collection: geminicloudassist.projects
attributes:
- &project
parameter_name: projectsId
attribute_name: project
help: |
The project name.
property: core/project
location:
name: location
collection: geminicloudassist.projects.locations
attributes:
- *project
- &location
parameter_name: locationsId
attribute_name: location
help: |
ID of the location of the Gemini Cloud Assist resource.
fallthroughs:
- value: 'global'
investigation:
name: investigation
collection: geminicloudassist.projects.locations.investigations
attributes:
- *project
- *location
- &investigation
parameter_name: investigationsId
attribute_name: investigation
help: |
ID of the Gemini Cloud Assist investigation resource.

View File

@@ -0,0 +1,44 @@
# -*- 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.
#
# NOTE: This file is autogenerated and should not be edited by hand.
# AUTOGEN_CLI_VERSION: HEAD
projects_locations:
name: location
plural_name: locations
collection: cloudaicompanion.projects.locations
attributes:
- &project
parameter_name: projectsId
attribute_name: project
help: The project id of the {resource} resource.
property: core/project
- &location
parameter_name: locationsId
attribute_name: location
help: The location id of the {resource} resource.
disable_auto_completers: true
projects_locations_operations:
name: operation
plural_name: operations
collection: cloudaicompanion.projects.locations.operations
attributes:
- *project
- *location
- &operation
parameter_name: operationsId
attribute_name: operation
help: The operation id of the {resource} resource.
disable_auto_completers: false

View File

@@ -0,0 +1,48 @@
project:
name: project
collection: cloudaicompanion.projects
attributes:
- &project
parameter_name: projectsId
attribute_name: project
help: Cloud Project ID
disable_auto_completers: false
location:
name: location
collection: cloudaicompanion.projects.locations
disable_auto_completers: false
attributes:
- *project
- &location
parameter_name: locationsId
attribute_name: location
help: |
Location of the Gemini resource.
code_repository_index:
name: code_repository_index
collection: cloudaicompanion.projects.locations.codeRepositoryIndexes
disable_auto_completers: false
attributes:
- *project
- *location
- &code_repository_index
parameter_name: codeRepositoryIndexesId
attribute_name: code-repository-index
help: |
ID of the code repository index resource.
repository_group:
name: repository_group
collection: cloudaicompanion.projects.locations.codeRepositoryIndexes.repositoryGroups
attributes:
- *project
- *location
- *code_repository_index
- &repository_group
parameter_name: repositoryGroupsId
attribute_name: repository_group
help: |
ID of the repository group resource.
disable_auto_completers: false

View File

@@ -0,0 +1,279 @@
# -*- 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.
#
# NOTE: This file is autogenerated and should not be edited by hand.
# AUTOGEN_CLI_VERSION: HEAD
projects_locations:
name: location
plural_name: locations
collection: cloudaicompanion.projects.locations
attributes:
- &project
parameter_name: projectsId
attribute_name: project
help: The project id of the {resource} resource.
property: core/project
- &location
parameter_name: locationsId
attribute_name: location
help: The location id of the {resource} resource.
disable_auto_completers: true
projects_locations_code_repository_indexes:
name: codeRepositoryIndex
plural_name: codeRepositoryIndexes
collection: cloudaicompanion.projects.locations.codeRepositoryIndexes
attributes:
- *project
- *location
- &codeRepositoryIndex
parameter_name: codeRepositoryIndexesId
attribute_name: code_repository_index
help: The codeRepositoryIndex id of the {resource} resource.
disable_auto_completers: true
projects_locations_code_tools_settings:
name: codeToolsSetting
plural_name: codeToolsSettings
collection: cloudaicompanion.projects.locations.codeToolsSettings
attributes:
- *project
- *location
- &codeToolsSetting
parameter_name: codeToolsSettingsId
attribute_name: code_tools_setting
help: The codeToolsSetting id of the {resource} resource.
disable_auto_completers: true
projects_locations_data_sharing_with_google_settings:
name: dataSharingWithGoogleSetting
plural_name: dataSharingWithGoogleSettings
collection: cloudaicompanion.projects.locations.dataSharingWithGoogleSettings
attributes:
- *project
- *location
- &dataSharingWithGoogleSetting
parameter_name: dataSharingWithGoogleSettingsId
attribute_name: data_sharing_with_google_setting
help: The dataSharingWithGoogleSetting id of the {resource} resource.
disable_auto_completers: true
projects_locations_gemini_gcp_enablement_settings:
name: geminiGcpEnablementSetting
plural_name: geminiGcpEnablementSettings
collection: cloudaicompanion.projects.locations.geminiGcpEnablementSettings
attributes:
- *project
- *location
- &geminiGcpEnablementSetting
parameter_name: geminiGcpEnablementSettingsId
attribute_name: gemini_gcp_enablement_setting
help: The geminiGcpEnablementSetting id of the {resource} resource.
disable_auto_completers: true
projects_locations_logging_settings:
name: loggingSetting
plural_name: loggingSettings
collection: cloudaicompanion.projects.locations.loggingSettings
attributes:
- *project
- *location
- &loggingSetting
parameter_name: loggingSettingsId
attribute_name: logging_setting
help: The loggingSetting id of the {resource} resource.
disable_auto_completers: true
projects_locations_release_channel_settings:
name: releaseChannelSetting
plural_name: releaseChannelSettings
collection: cloudaicompanion.projects.locations.releaseChannelSettings
attributes:
- *project
- *location
- &releaseChannelSetting
parameter_name: releaseChannelSettingsId
attribute_name: release_channel_setting
help: The releaseChannelSetting id of the {resource} resource.
disable_auto_completers: true
? projects_locations_behavior_settings_or_chat_history_settings_or_code_tools_settings_or_data_control_settings_or_data_sharing_with_google_settings_or_gemini_code_assist_settings_or_gemini_gcp_enablement_settings_or_logging_settings_or_release_channel_settings_or_security_settings_setting_bindings
: name: settingBinding
plural_name: settingBindings
resources:
- name: settingBinding
plural_name: settingBindings
collection: cloudaicompanion.projects.locations.behaviorSettings.settingBindings
attributes:
- *project
- *location
- &behaviorSetting
parameter_name: behaviorSettingsId
attribute_name: behavior_setting
help: The behaviorSetting id of the {resource} resource.
- &settingBinding
parameter_name: settingBindingsId
attribute_name: setting_binding
help: The settingBinding id of the {resource} resource.
disable_auto_completers: true
- name: settingBinding
plural_name: settingBindings
collection: cloudaicompanion.projects.locations.chatHistorySettings.settingBindings
attributes:
- *project
- *location
- &chatHistorySetting
parameter_name: chatHistorySettingsId
attribute_name: chat_history_setting
help: The chatHistorySetting id of the {resource} resource.
- *settingBinding
disable_auto_completers: true
- name: settingBinding
plural_name: settingBindings
collection: cloudaicompanion.projects.locations.codeToolsSettings.settingBindings
attributes:
- *project
- *location
- *codeToolsSetting
- *settingBinding
disable_auto_completers: true
- name: settingBinding
plural_name: settingBindings
collection: cloudaicompanion.projects.locations.dataControlSettings.settingBindings
attributes:
- *project
- *location
- &dataControlSetting
parameter_name: dataControlSettingsId
attribute_name: data_control_setting
help: The dataControlSetting id of the {resource} resource.
- *settingBinding
disable_auto_completers: true
- name: settingBinding
plural_name: settingBindings
collection: cloudaicompanion.projects.locations.dataSharingWithGoogleSettings.settingBindings
attributes:
- *project
- *location
- *dataSharingWithGoogleSetting
- *settingBinding
disable_auto_completers: true
- name: settingBinding
plural_name: settingBindings
collection: cloudaicompanion.projects.locations.geminiCodeAssistSettings.settingBindings
attributes:
- *project
- *location
- &geminiCodeAssistSetting
parameter_name: geminiCodeAssistSettingsId
attribute_name: gemini_code_assist_setting
help: The geminiCodeAssistSetting id of the {resource} resource.
- *settingBinding
disable_auto_completers: true
- name: settingBinding
plural_name: settingBindings
collection: cloudaicompanion.projects.locations.geminiGcpEnablementSettings.settingBindings
attributes:
- *project
- *location
- *geminiGcpEnablementSetting
- *settingBinding
disable_auto_completers: true
- name: settingBinding
plural_name: settingBindings
collection: cloudaicompanion.projects.locations.loggingSettings.settingBindings
attributes:
- *project
- *location
- *loggingSetting
- *settingBinding
disable_auto_completers: true
- name: settingBinding
plural_name: settingBindings
collection: cloudaicompanion.projects.locations.releaseChannelSettings.settingBindings
attributes:
- *project
- *location
- *releaseChannelSetting
- *settingBinding
disable_auto_completers: true
- name: settingBinding
plural_name: settingBindings
collection: cloudaicompanion.projects.locations.securitySettings.settingBindings
attributes:
- *project
- *location
- &securitySetting
parameter_name: securitySettingsId
attribute_name: security_setting
help: The securitySetting id of the {resource} resource.
- *settingBinding
disable_auto_completers: true
projects_locations_code_repository_indexes_repository_groups:
name: repositoryGroup
plural_name: repositoryGroups
collection: cloudaicompanion.projects.locations.codeRepositoryIndexes.repositoryGroups
attributes:
- *project
- *location
- *codeRepositoryIndex
- &repositoryGroup
parameter_name: repositoryGroupsId
attribute_name: repository_group
help: The repositoryGroup id of the {resource} resource.
disable_auto_completers: false
projects_locations_code_tools_settings_setting_bindings:
name: settingBinding
plural_name: settingBindings
collection: cloudaicompanion.projects.locations.codeToolsSettings.settingBindings
attributes:
- *project
- *location
- *codeToolsSetting
- *settingBinding
disable_auto_completers: false
projects_locations_data_sharing_with_google_settings_setting_bindings:
name: settingBinding
plural_name: settingBindings
collection: cloudaicompanion.projects.locations.dataSharingWithGoogleSettings.settingBindings
attributes:
- *project
- *location
- *dataSharingWithGoogleSetting
- *settingBinding
disable_auto_completers: false
projects_locations_gemini_gcp_enablement_settings_setting_bindings:
name: settingBinding
plural_name: settingBindings
collection: cloudaicompanion.projects.locations.geminiGcpEnablementSettings.settingBindings
attributes:
- *project
- *location
- *geminiGcpEnablementSetting
- *settingBinding
disable_auto_completers: false
projects_locations_logging_settings_setting_bindings:
name: settingBinding
plural_name: settingBindings
collection: cloudaicompanion.projects.locations.loggingSettings.settingBindings
attributes:
- *project
- *location
- *loggingSetting
- *settingBinding
disable_auto_completers: false
projects_locations_release_channel_settings_setting_bindings:
name: settingBinding
plural_name: settingBindings
collection: cloudaicompanion.projects.locations.releaseChannelSettings.settingBindings
attributes:
- *project
- *location
- *releaseChannelSetting
- *settingBinding
disable_auto_completers: false

View File

@@ -0,0 +1,57 @@
# -*- 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.
#
# NOTE: This file is autogenerated and should not be edited by hand.
# AUTOGEN_CLI_VERSION: HEAD
projects_locations:
name: location
plural_name: locations
collection: cloudaicompanion.projects.locations
attributes:
- &project
parameter_name: projectsId
attribute_name: project
help: The project id of the {resource} resource.
property: core/project
- &location
parameter_name: locationsId
attribute_name: location
help: The location id of the {resource} resource.
disable_auto_completers: true
projects_locations_code_repository_indexes:
name: codeRepositoryIndex
plural_name: codeRepositoryIndexes
collection: cloudaicompanion.projects.locations.codeRepositoryIndexes
attributes:
- *project
- *location
- &codeRepositoryIndex
parameter_name: codeRepositoryIndexesId
attribute_name: code_repository_index
help: The codeRepositoryIndex id of the {resource} resource.
disable_auto_completers: true
projects_locations_code_repository_indexes_repository_groups:
name: repositoryGroup
plural_name: repositoryGroups
collection: cloudaicompanion.projects.locations.codeRepositoryIndexes.repositoryGroups
attributes:
- *project
- *location
- *codeRepositoryIndex
- &repositoryGroup
parameter_name: repositoryGroupsId
attribute_name: repository_group
help: The repositoryGroup id of the {resource} resource.
disable_auto_completers: false