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,34 @@
# -*- 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.
"""The gcloud dialogflow command group."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class Dialogflow(base.Group):
"""Interact with and manage Dialogflow agents, entities, and intents.
"""
category = base.AI_AND_MACHINE_LEARNING_CATEGORY
def Filter(self, context, args):
# TODO(b/190532304): Determine if command group works with project number
base.RequireProjectID(args)
del context, args

View File

@@ -0,0 +1,28 @@
# -*- 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.
"""The gcloud dialogflow agent command group."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class Agent(base.Group):
"""Manage, train, and query the Dialogflow agent for a project.
"""

View File

@@ -0,0 +1,22 @@
release_tracks: [ALPHA]
help_text:
brief: Describe the Dialogflow agent of the current project.
description: |
Describe the Dialogflow agent of the current project.
examples: |
To describe the agent for the current project:
$ {command}
To describe the agent for a given project:
$ {command} --project="my-project"
arguments:
resource:
help_text: Project to use.
spec: !REF googlecloudsdk.command_lib.dialogflow.resources:project
request:
collection: dialogflow.projects
method: getAgent

View File

@@ -0,0 +1,45 @@
release_tracks: [ALPHA]
command_type: GENERIC
help_text:
brief: Export the Dialogflow agent to a zip file.
description: |
Export the Dialogflow agent of the current project to a zip file. The zip file will contain
data on all intents and entity types of the agent.
examples: |
To export the agent of the current project to local file path/to/agent.zip:
$ {command} --destination="path/to/agent.zip"
To export the agent of the current project to agent.zip in Google Storage Bucket `mybucket`:
$ {command} --destination="gs://mybucket/agent.zip"
arguments:
resource:
help_text: The agent to export.
spec: !REF googlecloudsdk.command_lib.dialogflow.resources:project
is_parent_resource: true
params:
- arg_name: destination
help_text: |
Path to a file or the URI to a Google Cloud Storage to save the agent to. Note: A URI must
start with "gs://".
required: true
request:
collection: dialogflow.projects.agent
method: export
modify_request_hooks:
- googlecloudsdk.command_lib.dialogflow.agent.hooks:SetAgentUri
async:
collection: dialogflow.projects.operations
extract_resource_result: false
response:
modify_response_hooks:
- googlecloudsdk.command_lib.dialogflow.agent.hooks:SaveAgentToFile
result_attribute: response
output:
format: none

View File

@@ -0,0 +1,58 @@
release_tracks: [ALPHA]
command_type: GENERIC
help_text:
brief: Import a Dialogflow agent from a zip file.
description: |
Import a Dialogflow agent from a ZIP file and upload it to the agent of the current project.
By default, uploads new intents and entity types without deleting the existing ones. Intents
and entity types with the same name are replaced with the new versions.
examples: |
To import local file `path/to/agent.zip` to the agent of the current project:
$ {command} --source="path/to/agent.zip"
To import `agent.zip` in Google Storage Bucket `mybucket` to the agent of the current project:
$ {command} --source="gs://mybucket/agent.zip"
To import local file `path/to/agent.zip` to the agent of the current project and replace all
existing resources in the agent:
$ {command} --source="path/to/agent.zip" --replace-all
arguments:
resource:
help_text: The agent to import.
spec: !REF googlecloudsdk.command_lib.dialogflow.resources:project
is_parent_resource: true
params:
- arg_name: source
help_text: |
Path to a file or the URI to a Google Cloud Storage file containing the agent to import.
Note: A URI must start with "gs://".
required: true
- arg_name: replace-all
type: bool
action: store_true
help_text: |
If true, replace the current agent version with a new one. All the intents and entity types
in the older version will be deleted.
request:
collection: dialogflow.projects.agent
method: import
modify_method_hook:
googlecloudsdk.command_lib.dialogflow.agent.hooks:ChooseImportOrRestoreMethod
modify_request_hooks:
- googlecloudsdk.command_lib.dialogflow.agent.hooks:ModifyImportOrRestoreRequest
async:
collection: dialogflow.projects.operations
extract_resource_result: false
response:
modify_response_hooks:
- googlecloudsdk.command_lib.dialogflow.agent.hooks:LogImportSuccess
output:
format: none

View File

@@ -0,0 +1,74 @@
release_tracks: [ALPHA]
help_text:
brief: Send a text or audio conversational query to the agent of the current project.
description: |
Send a text or audio conversational query to the agent of the current project.
examples: |
To query the agent of the current project with text:
$ {command} --query-text="hi"
To query the agent of the current project with text in session `my-session`:
$ {command} --session="my-session" --query-text="hi"
To query the agent of the current project with audio:
$ {command} --query-audio-file="path/to/audio_file.wav" --sample-rate="16000" --audio-encoding="AUDIO_ENCODING_LINEAR_16"
arguments:
params:
- arg_name: session
api_field: session
processor: googlecloudsdk.command_lib.dialogflow.agent.hooks:AddSessionPrefix
default: DEFAULT_SESSION
help_text: |
ID of the session to send the query to. This can be any number or string up to 36 bytes. By
default, a different random ID will be used for every request.
- arg_name: language
default: en
help_text: |
The language code of the query. For information on supported languages, see:
https://dialogflow.com/docs/languages.
- group:
mutex: true
required: true
params:
- arg_name: query-text
api_field: googleCloudDialogflowV2DetectIntentRequest.queryInput.text.text
help_text: Conversational query in the form of text.
- group:
help_text: |
Audio file and config:
params:
- arg_name: query-audio-file
required: true
processor: googlecloudsdk.core.util.files:ReadBinaryFileContents
api_field: googleCloudDialogflowV2DetectIntentRequest.inputAudio
help_text: |
Path to an audio file to use as a conversational query.
- arg_name: sample-rate
required: true
api_field: |-
googleCloudDialogflowV2DetectIntentRequest.queryInput.audioConfig.sampleRateHertz
help_text: |
Sample rate of the audio file in Hertz.
- arg_name: audio-encoding
required: true
api_field: |-
googleCloudDialogflowV2DetectIntentRequest.queryInput.audioConfig.audioEncoding
help_text: |
Encoding of the audio file.
See here for more information:
https://cloud.google.com/dialogflow-enterprise/docs/reference/rest/v2/projects.agent.sessions/detectIntent#AudioEncoding.
request:
collection: dialogflow.projects.agent.sessions
disable_resource_check: true
method: detectIntent
modify_request_hooks:
- googlecloudsdk.command_lib.dialogflow.agent.hooks:SetQueryLanguage
output:
format: value(queryResult.fulfillmentText)

View File

@@ -0,0 +1,30 @@
release_tracks: [ALPHA]
help_text:
brief: Train the Dialogflow agent of the current project.
description: |
Train the Dialogflow agent of the current project with its current intents and entities.
examples: |
To train the agent for the current project:
$ {command}
arguments:
resource:
help_text: The agent to train.
spec: !REF googlecloudsdk.command_lib.dialogflow.resources:project
is_parent_resource: true
request:
collection: dialogflow.projects.agent
method: train
async:
collection: dialogflow.projects.operations
extract_resource_result: false
response:
modify_response_hooks:
- googlecloudsdk.command_lib.dialogflow.agent.hooks:LogTrainSuccess
output:
format: none

View File

@@ -0,0 +1,28 @@
# -*- 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.
"""The gcloud dialogflow entity-types command group."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class EntityTypes(base.Group):
"""Create, list, describe, update, and delete Dialogflow entity types.
"""

View File

@@ -0,0 +1,19 @@
flags:
display_name:
arg_name: display-name
api_field: googleCloudDialogflowV2EntityType.displayName
help_text: A human readable name for the entity type.
auto_expand:
arg_name: auto-expand
api_field: googleCloudDialogflowV2EntityType.autoExpansionMode
action: store_true
type: bool
choices:
- enum_value: AUTO_EXPANSION_MODE_DEFAULT
arg_value: true
- enum_value: AUTO_EXPANSION_MODE_UNSPECIFIED
arg_value: false
help_text: |
Whether or not the entity type can be automatically expanded to
idenitify entities not explicitly included.

View File

@@ -0,0 +1,55 @@
release_tracks: [ALPHA]
help_text:
brief: Create a Dialogflow entity type for the agent of the current project.
description: Create a Dialogflow entity type for the agent of the current project.
examples: |
To create an entity type with a display name and entities:
$ {command} --display-name="color" --entities=red,blue
arguments:
resource:
help_text: The agent to create the entity type under.
spec: !REF googlecloudsdk.command_lib.dialogflow.resources:agent
is_parent_resource: true
params:
- _COMMON_: flags.display_name
required: true
- _COMMON_: flags.auto_expand
- arg_name: entities
api_field: googleCloudDialogflowV2EntityType.entities
repeated: false
type: googlecloudsdk.command_lib.dialogflow.entity_types.hooks:EntitiesType
help_text: |
Comma separated list of entities, or a map of entities to synonyms.
If a list, the entities can contain references to other entity types (with or without
aliases).
To specify a map, set this flag with `--flags-file` as a map, where each key is the
canonical name and each value is a list of synonyms to map to the canonical name. The
canonical name must be explicitly included in the list of synonyms. For more information
on `--flags-file`, see `gcloud topics flags-file`.
For example, use `--flags-file=flags.yaml`, where `flags.yaml` contains:
```
--entities:
red:
- red
- cherry
- rose
blue:
- blue
- azure
- cyan
```
For more information, see
https://cloud.google.com/dialogflow-enterprise/docs/reference/rest/v2/Entity.
request:
collection: dialogflow.projects.agent.entityTypes
display_resource_type: entity type
modify_request_hooks:
- googlecloudsdk.command_lib.dialogflow.entity_types.hooks:AddEntityTypeKind

View File

@@ -0,0 +1,17 @@
release_tracks: [ALPHA]
help_text:
brief: Delete a Dialogflow entity type.
description: Delete a Dialogflow entity type.
examples: |
To delete an entity type:
$ {command} 12345678-1234-1234-1234-1234567890ab
arguments:
resource:
help_text: Entity type to delete.
spec: !REF googlecloudsdk.command_lib.dialogflow.resources:entityType
request:
collection: dialogflow.projects.agent.entityTypes

View File

@@ -0,0 +1,17 @@
release_tracks: [ALPHA]
help_text:
brief: Describe a Dialogflow entity type.
description: Describe a Dialogflow entity type.
examples: |
To delete an entity type:
$ {command} 12345678-1234-1234-1234-1234567890ab
arguments:
resource:
help_text: Entity type to describe.
spec: !REF googlecloudsdk.command_lib.dialogflow.resources:entityType
request:
collection: dialogflow.projects.agent.entityTypes

View File

@@ -0,0 +1,23 @@
release_tracks: [ALPHA]
help_text:
brief: |
List all Dialogflow entity types for the agent of the current project.
description: |
List all Dialogflow entity types for the agent of the current project.
examples: |
To list all intents for the current project:
$ {command}
arguments:
resource:
help_text: Agent to list the entity types under.
spec: !REF googlecloudsdk.command_lib.dialogflow.resources:agent
override_resource_collection: true
request:
collection: dialogflow.projects.agent.entityTypes
response:
id_field: name

View File

@@ -0,0 +1,78 @@
release_tracks: [ALPHA]
help_text:
brief: Update a Dialogflow entity type.
description: Update a Dialogflow entity type.
examples: |
To update the display name of an entity type:
$ {command} --display-name="color"
update:
disable_auto_field_mask: true
read_modify_update: true
arguments:
resource:
help_text: Entity type to update.
spec: !REF googlecloudsdk.command_lib.dialogflow.resources:entityType
params:
- _COMMON_: flags.display_name
- _COMMON_: flags.auto_expand
- group:
help_text: 'Use these flags for adding and removing entities:'
params:
- arg_name: add-entities
repeated: false
type: googlecloudsdk.command_lib.dialogflow.entity_types.hooks:EntitiesType
help_text: |
Comma separated list of entities, or a map of entities to synonyms, to be added to
existing list of entities.
If specified with `--remove-entities` or `--clear-entities`, entities will be removed in
a separate request before entities are added. If an entity with a given value exists,
it will be overwritten.
If a list, the entities can contain references to other entity types (with or without
aliases).
To specify a map, set this flag with `--flags-file` as a map, where each key is the
canonical name and each value is a list of synonyms to map to the canonical name. The
canonical name must be explicitly included in the list of synonyms. For more information on
`--flags-file`, see `gcloud topics flags-file`.
For example, use `--flags-file=flags.yaml`, where `flags.yaml` contains:
```
--entities:
red:
- red
- cherry
- rose
blue:
- blue
- azure
- cyan
```
For more information, see
https://cloud.google.com/dialogflow-enterprise/docs/reference/rest/v2/Entity.
- group:
mutex: true
params:
- arg_name: remove-entities
type: 'googlecloudsdk.calliope.arg_parsers:ArgList:'
help_text: A comma separated list of entities to be removed.
- arg_name: clear-entities
type: bool
help_text: |
If true, remove all existing entities.
Can be used with `--add-entities` to replace existing entities.
request:
collection: dialogflow.projects.agent.entityTypes
method: patch
modify_request_hooks:
- googlecloudsdk.command_lib.dialogflow.entity_types.hooks:PatchEntityType
- googlecloudsdk.command_lib.dialogflow.entity_types.hooks:SetUpdateMask
- googlecloudsdk.command_lib.dialogflow.entity_types.hooks:AddEntityTypeKind

View File

@@ -0,0 +1,31 @@
# -*- 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.
"""The gcloud dialogflow intents command group."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class Intents(base.Group):
"""Create, list, describe, and delete Dialogflow intents.
Intents convert a number of user expressions or patterns into an action. An
action is an extraction of a user command or sentence semantics.
"""

View File

@@ -0,0 +1,56 @@
flags:
priority:
arg_name: priority
api_field: googleCloudDialogflowV2Intent.priority
help_text: |
Priority of the intent.
Higher numbers represent higher priorities. Zero or negative numbers mean that the intent is
disabled. Default priority is 500000.
is_fallback:
arg_name: is-fallback
help_text: If true, set this intent as a fallback intent.
api_field: googleCloudDialogflowV2Intent.isFallback
type: bool
action: store_true
training_phrases:
arg_name: training-phrases
api_field: googleCloudDialogflowV2Intent.trainingPhrases
type: googlecloudsdk.command_lib.dialogflow.intents.hooks:TrainingPhrasesType
help_text: |
List of examples or templates.
Can be provided as comma separated unannotated examples or as a list training phrase objects.
To provide training phrase objects, specify the flag with `--flags-file`.
For example, use `--flags-file=flags.yaml`, where `flags.yaml` contains:
```
--training-phrases:
- type: TEMPLATE
parts:
- text: I love the color
- text: red
entityType: <entity_type_id>
alias: color
```
For more information on training phrases, see:
https://cloud.google.com/dialogflow-enterprise/docs/reference/rest/Shared.Types/Intent#TrainingPhrase
For more information on `--flags-file`, see `gcloud topics flags-file`.
responses:
arg_name: responses
api_field: googleCloudDialogflowV2Intent.messages
type: googlecloudsdk.command_lib.dialogflow.intents.hooks:ResponseToMessage
help_text: |
Comma separated list of simple text responses to send to the user.
ml_enabled:
arg_name: ml-enabled
api_field: googleCloudDialogflowV2Intent.mlDisabled
type: bool
default: true
action: store_true
help_text: |
If true, enable machine learning for the intent.

View File

@@ -0,0 +1,45 @@
release_tracks: [ALPHA]
help_text:
brief: Create a Dialogflow entity type for the agent of the current project.
description: |
Create a Dialogflow intent for the agent of the current project.
examples: |
To create an intent with a training phrase and a response:
$ {command} --display-name="test-intent" --priority=1 --training-phrases="example query"
--responses="example response"
arguments:
resource:
help_text: The agent to create the entity type under.
spec: !REF googlecloudsdk.command_lib.dialogflow.resources:agent
is_parent_resource: true
params:
- arg_name: display-name
api_field: googleCloudDialogflowV2Intent.displayName
required: true
help_text: Human-readable name for the intent.
- _COMMON_: flags.priority
- _COMMON_: flags.is_fallback
- _COMMON_: flags.training_phrases
- _COMMON_: flags.responses
- _COMMON_: flags.ml_enabled
- arg_name: other-properties
type: "googlecloudsdk.calliope.arg_parsers:ArgDict:"
metavar: KEY=VALUE
help_text: |
Map containing other properties to set on the intent.
For more information on available properties, see:
https://cloud.google.com/dialogflow-enterprise/docs/reference/rest/v2/projects.agent.intents
To set complex types, specify this flag with `--flags-file`. For more information, see
`gcloud topics flags-file`.
Other flags take precedence over properties specified here.
request:
collection: dialogflow.projects.agent.intents
display_resource_type: intent
modify_request_hooks:
- googlecloudsdk.command_lib.dialogflow.intents.hooks:AddOtherPropertiesToRequest

View File

@@ -0,0 +1,17 @@
release_tracks: [ALPHA]
help_text:
brief: Delete a Dialogflow intent.
description: Delete a Dialogflow intent.
examples: |
To delete an intent:
$ {command} 12345678-1234-1234-1234-1234567890ab
arguments:
resource:
help_text: Intent to delete.
spec: !REF googlecloudsdk.command_lib.dialogflow.resources:intent
request:
collection: dialogflow.projects.agent.intents

View File

@@ -0,0 +1,17 @@
release_tracks: [ALPHA]
help_text:
brief: Describe a Dialogflow intent.
description: Describe a Dialogflow intent.
examples: |
To describe an intent:
$ {command} 12345678-1234-1234-1234-1234567890ab
arguments:
resource:
help_text: Intent to describe.
spec: !REF googlecloudsdk.command_lib.dialogflow.resources:intent
request:
collection: dialogflow.projects.agent.intents

View File

@@ -0,0 +1,27 @@
release_tracks: [ALPHA]
help_text:
brief: |
List all Dialogflow intents for the agent of the current project.
description: |
List all Dialogflow intents for the agent of the current project.
examples: |
To list all intents for the current project:
$ {command}
arguments:
resource:
help_text: The agent to list the intents under.
spec: !REF googlecloudsdk.command_lib.dialogflow.resources:agent
override_resource_collection: true
request:
collection: dialogflow.projects.agent.intents
response:
id_field: name
output:
format: |
table(name.basename(), displayName, priority)

View File

@@ -0,0 +1,40 @@
release_tracks: [ALPHA]
help_text:
brief: Update a Dialogflow entity type for the agent of the current project.
description: |
Update a Dialogflow intent for the agent of the current project.
examples: |
To update the training phrases of an intent:
$ {command} 12345678-1234-1234-1234-1234567890ab --training-phrases="example query"
arguments:
resource:
help_text: Intent to update.
spec: !REF googlecloudsdk.command_lib.dialogflow.resources:intent
params:
- _COMMON_: flags.priority
- _COMMON_: flags.is_fallback
- _COMMON_: flags.training_phrases
- _COMMON_: flags.responses
- _COMMON_: flags.ml_enabled
- arg_name: other-properties
metavar: KEY=VALUE
type: "googlecloudsdk.calliope.arg_parsers:ArgDict:"
help_text: |
Map containing other properties to set on the intent.
Only the properties specified will be updated.
For more information on available properties, see:
https://cloud.google.com/dialogflow-enterprise/docs/reference/rest/Shared.Types/Intent
To set complex types, specify this flag with `--flags-file`. For more information, see
`gcloud topics flags-file`.
Other flags take precedence over properties specified here.
request:
collection: dialogflow.projects.agent.intents
modify_request_hooks:
- googlecloudsdk.command_lib.dialogflow.intents.hooks:AddOtherPropertiesToRequest