google-cloud-dialogflow-v2 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. checksums.yaml +7 -0
  2. data/.yardopts +12 -0
  3. data/AUTHENTICATION.md +169 -0
  4. data/LICENSE.md +201 -0
  5. data/README.md +24 -0
  6. data/lib/google-cloud-dialogflow-v2.rb +1 -0
  7. data/lib/google/cloud/common_resources_pb.rb +15 -0
  8. data/lib/google/cloud/dialogflow/v2.rb +24 -0
  9. data/lib/google/cloud/dialogflow/v2/agent_pb.rb +122 -0
  10. data/lib/google/cloud/dialogflow/v2/agent_services_pb.rb +110 -0
  11. data/lib/google/cloud/dialogflow/v2/agents.rb +21 -0
  12. data/lib/google/cloud/dialogflow/v2/agents/client.rb +1047 -0
  13. data/lib/google/cloud/dialogflow/v2/agents/credentials.rb +53 -0
  14. data/lib/google/cloud/dialogflow/v2/agents/operations.rb +559 -0
  15. data/lib/google/cloud/dialogflow/v2/agents/paths.rb +59 -0
  16. data/lib/google/cloud/dialogflow/v2/audio_config_pb.rb +97 -0
  17. data/lib/google/cloud/dialogflow/v2/context_pb.rb +64 -0
  18. data/lib/google/cloud/dialogflow/v2/context_services_pb.rb +74 -0
  19. data/lib/google/cloud/dialogflow/v2/contexts.rb +20 -0
  20. data/lib/google/cloud/dialogflow/v2/contexts/client.rb +756 -0
  21. data/lib/google/cloud/dialogflow/v2/contexts/credentials.rb +53 -0
  22. data/lib/google/cloud/dialogflow/v2/contexts/paths.rb +50 -0
  23. data/lib/google/cloud/dialogflow/v2/entity_type_pb.rb +126 -0
  24. data/lib/google/cloud/dialogflow/v2/entity_type_services_pb.rb +104 -0
  25. data/lib/google/cloud/dialogflow/v2/entity_types.rb +21 -0
  26. data/lib/google/cloud/dialogflow/v2/entity_types/client.rb +1150 -0
  27. data/lib/google/cloud/dialogflow/v2/entity_types/credentials.rb +53 -0
  28. data/lib/google/cloud/dialogflow/v2/entity_types/operations.rb +559 -0
  29. data/lib/google/cloud/dialogflow/v2/entity_types/paths.rb +62 -0
  30. data/lib/google/cloud/dialogflow/v2/intent_pb.rb +368 -0
  31. data/lib/google/cloud/dialogflow/v2/intent_services_pb.rb +92 -0
  32. data/lib/google/cloud/dialogflow/v2/intents.rb +21 -0
  33. data/lib/google/cloud/dialogflow/v2/intents/client.rb +893 -0
  34. data/lib/google/cloud/dialogflow/v2/intents/credentials.rb +53 -0
  35. data/lib/google/cloud/dialogflow/v2/intents/operations.rb +559 -0
  36. data/lib/google/cloud/dialogflow/v2/intents/paths.rb +81 -0
  37. data/lib/google/cloud/dialogflow/v2/session_entity_type_pb.rb +66 -0
  38. data/lib/google/cloud/dialogflow/v2/session_entity_type_services_pb.rb +92 -0
  39. data/lib/google/cloud/dialogflow/v2/session_entity_types.rb +20 -0
  40. data/lib/google/cloud/dialogflow/v2/session_entity_types/client.rb +727 -0
  41. data/lib/google/cloud/dialogflow/v2/session_entity_types/credentials.rb +53 -0
  42. data/lib/google/cloud/dialogflow/v2/session_entity_types/paths.rb +69 -0
  43. data/lib/google/cloud/dialogflow/v2/session_pb.rb +142 -0
  44. data/lib/google/cloud/dialogflow/v2/session_services_pb.rb +55 -0
  45. data/lib/google/cloud/dialogflow/v2/sessions.rb +20 -0
  46. data/lib/google/cloud/dialogflow/v2/sessions/client.rb +472 -0
  47. data/lib/google/cloud/dialogflow/v2/sessions/credentials.rb +53 -0
  48. data/lib/google/cloud/dialogflow/v2/sessions/paths.rb +110 -0
  49. data/lib/google/cloud/dialogflow/v2/validation_result_pb.rb +37 -0
  50. data/lib/google/cloud/dialogflow/v2/version.rb +28 -0
  51. data/lib/google/cloud/dialogflow/v2/webhook_pb.rb +47 -0
  52. data/proto_docs/README.md +4 -0
  53. data/proto_docs/google/api/field_behavior.rb +59 -0
  54. data/proto_docs/google/api/resource.rb +247 -0
  55. data/proto_docs/google/cloud/dialogflow/v2/agent.rb +287 -0
  56. data/proto_docs/google/cloud/dialogflow/v2/audio_config.rb +363 -0
  57. data/proto_docs/google/cloud/dialogflow/v2/context.rb +144 -0
  58. data/proto_docs/google/cloud/dialogflow/v2/entity_type.rb +354 -0
  59. data/proto_docs/google/cloud/dialogflow/v2/intent.rb +1070 -0
  60. data/proto_docs/google/cloud/dialogflow/v2/session.rb +541 -0
  61. data/proto_docs/google/cloud/dialogflow/v2/session_entity_type.rb +155 -0
  62. data/proto_docs/google/cloud/dialogflow/v2/validation_result.rb +81 -0
  63. data/proto_docs/google/cloud/dialogflow/v2/webhook.rb +153 -0
  64. data/proto_docs/google/longrunning/operations.rb +150 -0
  65. data/proto_docs/google/protobuf/any.rb +137 -0
  66. data/proto_docs/google/protobuf/duration.rb +98 -0
  67. data/proto_docs/google/protobuf/empty.rb +36 -0
  68. data/proto_docs/google/protobuf/field_mask.rb +237 -0
  69. data/proto_docs/google/protobuf/struct.rb +96 -0
  70. data/proto_docs/google/rpc/status.rb +46 -0
  71. data/proto_docs/google/type/latlng.rb +38 -0
  72. metadata +225 -0
@@ -0,0 +1,122 @@
1
+ # Generated by the protocol buffer compiler. DO NOT EDIT!
2
+ # source: google/cloud/dialogflow/v2/agent.proto
3
+
4
+ require 'google/protobuf'
5
+
6
+ require 'google/api/annotations_pb'
7
+ require 'google/api/client_pb'
8
+ require 'google/api/field_behavior_pb'
9
+ require 'google/api/resource_pb'
10
+ require 'google/cloud/dialogflow/v2/validation_result_pb'
11
+ require 'google/longrunning/operations_pb'
12
+ require 'google/protobuf/empty_pb'
13
+ require 'google/protobuf/field_mask_pb'
14
+ Google::Protobuf::DescriptorPool.generated_pool.build do
15
+ add_file("google/cloud/dialogflow/v2/agent.proto", :syntax => :proto3) do
16
+ add_message "google.cloud.dialogflow.v2.Agent" do
17
+ optional :parent, :string, 1
18
+ optional :display_name, :string, 2
19
+ optional :default_language_code, :string, 3
20
+ repeated :supported_language_codes, :string, 4
21
+ optional :time_zone, :string, 5
22
+ optional :description, :string, 6
23
+ optional :avatar_uri, :string, 7
24
+ optional :enable_logging, :bool, 8
25
+ optional :match_mode, :enum, 9, "google.cloud.dialogflow.v2.Agent.MatchMode"
26
+ optional :classification_threshold, :float, 10
27
+ optional :api_version, :enum, 14, "google.cloud.dialogflow.v2.Agent.ApiVersion"
28
+ optional :tier, :enum, 15, "google.cloud.dialogflow.v2.Agent.Tier"
29
+ end
30
+ add_enum "google.cloud.dialogflow.v2.Agent.MatchMode" do
31
+ value :MATCH_MODE_UNSPECIFIED, 0
32
+ value :MATCH_MODE_HYBRID, 1
33
+ value :MATCH_MODE_ML_ONLY, 2
34
+ end
35
+ add_enum "google.cloud.dialogflow.v2.Agent.ApiVersion" do
36
+ value :API_VERSION_UNSPECIFIED, 0
37
+ value :API_VERSION_V1, 1
38
+ value :API_VERSION_V2, 2
39
+ value :API_VERSION_V2_BETA_1, 3
40
+ end
41
+ add_enum "google.cloud.dialogflow.v2.Agent.Tier" do
42
+ value :TIER_UNSPECIFIED, 0
43
+ value :TIER_STANDARD, 1
44
+ value :TIER_ENTERPRISE, 2
45
+ value :TIER_ENTERPRISE_PLUS, 3
46
+ end
47
+ add_message "google.cloud.dialogflow.v2.GetAgentRequest" do
48
+ optional :parent, :string, 1
49
+ end
50
+ add_message "google.cloud.dialogflow.v2.SetAgentRequest" do
51
+ optional :agent, :message, 1, "google.cloud.dialogflow.v2.Agent"
52
+ optional :update_mask, :message, 2, "google.protobuf.FieldMask"
53
+ end
54
+ add_message "google.cloud.dialogflow.v2.DeleteAgentRequest" do
55
+ optional :parent, :string, 1
56
+ end
57
+ add_message "google.cloud.dialogflow.v2.SearchAgentsRequest" do
58
+ optional :parent, :string, 1
59
+ optional :page_size, :int32, 2
60
+ optional :page_token, :string, 3
61
+ end
62
+ add_message "google.cloud.dialogflow.v2.SearchAgentsResponse" do
63
+ repeated :agents, :message, 1, "google.cloud.dialogflow.v2.Agent"
64
+ optional :next_page_token, :string, 2
65
+ end
66
+ add_message "google.cloud.dialogflow.v2.TrainAgentRequest" do
67
+ optional :parent, :string, 1
68
+ end
69
+ add_message "google.cloud.dialogflow.v2.ExportAgentRequest" do
70
+ optional :parent, :string, 1
71
+ optional :agent_uri, :string, 2
72
+ end
73
+ add_message "google.cloud.dialogflow.v2.ExportAgentResponse" do
74
+ oneof :agent do
75
+ optional :agent_uri, :string, 1
76
+ optional :agent_content, :bytes, 2
77
+ end
78
+ end
79
+ add_message "google.cloud.dialogflow.v2.ImportAgentRequest" do
80
+ optional :parent, :string, 1
81
+ oneof :agent do
82
+ optional :agent_uri, :string, 2
83
+ optional :agent_content, :bytes, 3
84
+ end
85
+ end
86
+ add_message "google.cloud.dialogflow.v2.RestoreAgentRequest" do
87
+ optional :parent, :string, 1
88
+ oneof :agent do
89
+ optional :agent_uri, :string, 2
90
+ optional :agent_content, :bytes, 3
91
+ end
92
+ end
93
+ add_message "google.cloud.dialogflow.v2.GetValidationResultRequest" do
94
+ optional :parent, :string, 1
95
+ optional :language_code, :string, 3
96
+ end
97
+ end
98
+ end
99
+
100
+ module Google
101
+ module Cloud
102
+ module Dialogflow
103
+ module V2
104
+ Agent = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.Agent").msgclass
105
+ Agent::MatchMode = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.Agent.MatchMode").enummodule
106
+ Agent::ApiVersion = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.Agent.ApiVersion").enummodule
107
+ Agent::Tier = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.Agent.Tier").enummodule
108
+ GetAgentRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.GetAgentRequest").msgclass
109
+ SetAgentRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.SetAgentRequest").msgclass
110
+ DeleteAgentRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.DeleteAgentRequest").msgclass
111
+ SearchAgentsRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.SearchAgentsRequest").msgclass
112
+ SearchAgentsResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.SearchAgentsResponse").msgclass
113
+ TrainAgentRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.TrainAgentRequest").msgclass
114
+ ExportAgentRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.ExportAgentRequest").msgclass
115
+ ExportAgentResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.ExportAgentResponse").msgclass
116
+ ImportAgentRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.ImportAgentRequest").msgclass
117
+ RestoreAgentRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.RestoreAgentRequest").msgclass
118
+ GetValidationResultRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.GetValidationResultRequest").msgclass
119
+ end
120
+ end
121
+ end
122
+ end
@@ -0,0 +1,110 @@
1
+ # Generated by the protocol buffer compiler. DO NOT EDIT!
2
+ # Source: google/cloud/dialogflow/v2/agent.proto for package 'google.cloud.dialogflow.v2'
3
+ # Original file comments:
4
+ # Copyright 2020 Google LLC
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ require 'grpc'
20
+ require 'google/cloud/dialogflow/v2/agent_pb'
21
+
22
+ module Google
23
+ module Cloud
24
+ module Dialogflow
25
+ module V2
26
+ module Agents
27
+ # Agents are best described as Natural Language Understanding (NLU) modules
28
+ # that transform user requests into actionable data. You can include agents
29
+ # in your app, product, or service to determine user intent and respond to the
30
+ # user in a natural way.
31
+ #
32
+ # After you create an agent, you can add [Intents][google.cloud.dialogflow.v2.Intents], [Contexts][google.cloud.dialogflow.v2.Contexts],
33
+ # [Entity Types][google.cloud.dialogflow.v2.EntityTypes], [Webhooks][google.cloud.dialogflow.v2.WebhookRequest], and so on to
34
+ # manage the flow of a conversation and match user input to predefined intents
35
+ # and actions.
36
+ #
37
+ # You can create an agent using both Dialogflow Standard Edition and
38
+ # Dialogflow Enterprise Edition. For details, see
39
+ # [Dialogflow
40
+ # Editions](https://cloud.google.com/dialogflow/docs/editions).
41
+ #
42
+ # You can save your agent for backup or versioning by exporting the agent by
43
+ # using the [ExportAgent][google.cloud.dialogflow.v2.Agents.ExportAgent] method. You can import a saved
44
+ # agent by using the [ImportAgent][google.cloud.dialogflow.v2.Agents.ImportAgent] method.
45
+ #
46
+ # Dialogflow provides several
47
+ # [prebuilt
48
+ # agents](https://cloud.google.com/dialogflow/docs/agents-prebuilt)
49
+ # for common conversation scenarios such as determining a date and time,
50
+ # converting currency, and so on.
51
+ #
52
+ # For more information about agents, see the
53
+ # [Dialogflow
54
+ # documentation](https://cloud.google.com/dialogflow/docs/agents-overview).
55
+ class Service
56
+
57
+ include GRPC::GenericService
58
+
59
+ self.marshal_class_method = :encode
60
+ self.unmarshal_class_method = :decode
61
+ self.service_name = 'google.cloud.dialogflow.v2.Agents'
62
+
63
+ # Retrieves the specified agent.
64
+ rpc :GetAgent, GetAgentRequest, Agent
65
+ # Creates/updates the specified agent.
66
+ rpc :SetAgent, SetAgentRequest, Agent
67
+ # Deletes the specified agent.
68
+ rpc :DeleteAgent, DeleteAgentRequest, Google::Protobuf::Empty
69
+ # Returns the list of agents.
70
+ #
71
+ # Since there is at most one conversational agent per project, this method is
72
+ # useful primarily for listing all agents across projects the caller has
73
+ # access to. One can achieve that with a wildcard project collection id "-".
74
+ # Refer to [List
75
+ # Sub-Collections](https://cloud.google.com/apis/design/design_patterns#list_sub-collections).
76
+ rpc :SearchAgents, SearchAgentsRequest, SearchAgentsResponse
77
+ # Trains the specified agent.
78
+ #
79
+ # Operation <response: [google.protobuf.Empty][google.protobuf.Empty]>
80
+ rpc :TrainAgent, TrainAgentRequest, Google::Longrunning::Operation
81
+ # Exports the specified agent to a ZIP file.
82
+ #
83
+ # Operation <response: [ExportAgentResponse][google.cloud.dialogflow.v2.ExportAgentResponse]>
84
+ rpc :ExportAgent, ExportAgentRequest, Google::Longrunning::Operation
85
+ # Imports the specified agent from a ZIP file.
86
+ #
87
+ # Uploads new intents and entity types without deleting the existing ones.
88
+ # Intents and entity types with the same name are replaced with the new
89
+ # versions from ImportAgentRequest.
90
+ #
91
+ # Operation <response: [google.protobuf.Empty][google.protobuf.Empty]>
92
+ rpc :ImportAgent, ImportAgentRequest, Google::Longrunning::Operation
93
+ # Restores the specified agent from a ZIP file.
94
+ #
95
+ # Replaces the current agent version with a new one. All the intents and
96
+ # entity types in the older version are deleted.
97
+ #
98
+ # Operation <response: [google.protobuf.Empty][google.protobuf.Empty]>
99
+ rpc :RestoreAgent, RestoreAgentRequest, Google::Longrunning::Operation
100
+ # Gets agent validation result. Agent validation is performed during
101
+ # training time and is updated automatically when training is completed.
102
+ rpc :GetValidationResult, GetValidationResultRequest, ValidationResult
103
+ end
104
+
105
+ Stub = Service.rpc_stub_class
106
+ end
107
+ end
108
+ end
109
+ end
110
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2020 Google LLC
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # https://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ # Auto-generated by gapic-generator-ruby. DO NOT EDIT!
18
+
19
+ require "google/cloud/dialogflow/v2/agents/client"
20
+ require "google/cloud/dialogflow/v2/agents/operations"
21
+ require "google/cloud/dialogflow/v2/agents/credentials"
@@ -0,0 +1,1047 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2020 Google LLC
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # https://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ # Auto-generated by gapic-generator-ruby. DO NOT EDIT!
18
+
19
+ require "gapic/common"
20
+ require "gapic/config"
21
+ require "gapic/config/method"
22
+
23
+ require "google/cloud/errors"
24
+ require "google/cloud/dialogflow/v2/version"
25
+ require "google/cloud/dialogflow/v2/agent_pb"
26
+ require "google/cloud/dialogflow/v2/agents/credentials"
27
+ require "google/cloud/dialogflow/v2/agents/paths"
28
+ require "google/cloud/dialogflow/v2/agents/operations"
29
+
30
+
31
+ module Google
32
+ module Cloud
33
+ module Dialogflow
34
+ module V2
35
+ module Agents
36
+ # Service that implements Agents API.
37
+ class Client
38
+ include Paths
39
+
40
+ # @private
41
+ attr_reader :agents_stub
42
+
43
+ ##
44
+ # Configure the Agents Client class.
45
+ #
46
+ # See {Google::Cloud::Dialogflow::V2::Agents::Client::Configuration}
47
+ # for a description of the configuration fields.
48
+ #
49
+ # ## Example
50
+ #
51
+ # To modify the configuration for all Agents clients:
52
+ #
53
+ # Google::Cloud::Dialogflow::V2::Agents::Client.configure do |config|
54
+ # config.timeout = 10_000
55
+ # end
56
+ #
57
+ # @yield [config] Configure the Client client.
58
+ # @yieldparam config [Client::Configuration]
59
+ #
60
+ # @return [Client::Configuration]
61
+ #
62
+ def self.configure
63
+ @configure ||= begin
64
+ namespace = ["Google", "Cloud", "Dialogflow", "V2"]
65
+ parent_config = while namespace.any?
66
+ parent_name = namespace.join "::"
67
+ parent_const = const_get parent_name
68
+ break parent_const.configure if parent_const&.respond_to? :configure
69
+ namespace.pop
70
+ end
71
+ default_config = Client::Configuration.new parent_config
72
+
73
+ default_config.rpcs.get_agent.timeout = 60.0
74
+ default_config.rpcs.get_agent.retry_policy = {
75
+ initial_delay: 0.1,
76
+ max_delay: 60.0,
77
+ multiplier: 1.3,
78
+ retry_codes: ["UNAVAILABLE", "DEADLINE_EXCEEDED"]
79
+ }
80
+
81
+ default_config.rpcs.set_agent.timeout = 60.0
82
+ default_config.rpcs.set_agent.retry_policy = {
83
+ initial_delay: 0.1,
84
+ max_delay: 60.0,
85
+ multiplier: 1.3,
86
+ retry_codes: ["UNAVAILABLE", "DEADLINE_EXCEEDED"]
87
+ }
88
+
89
+ default_config.rpcs.delete_agent.timeout = 60.0
90
+ default_config.rpcs.delete_agent.retry_policy = {
91
+ initial_delay: 0.1,
92
+ max_delay: 60.0,
93
+ multiplier: 1.3,
94
+ retry_codes: ["UNAVAILABLE", "DEADLINE_EXCEEDED"]
95
+ }
96
+
97
+ default_config.rpcs.search_agents.timeout = 60.0
98
+ default_config.rpcs.search_agents.retry_policy = {
99
+ initial_delay: 0.1,
100
+ max_delay: 60.0,
101
+ multiplier: 1.3,
102
+ retry_codes: ["UNAVAILABLE", "DEADLINE_EXCEEDED"]
103
+ }
104
+
105
+ default_config.rpcs.train_agent.timeout = 60.0
106
+ default_config.rpcs.train_agent.retry_policy = {
107
+ initial_delay: 0.1,
108
+ max_delay: 60.0,
109
+ multiplier: 1.3,
110
+ retry_codes: ["UNAVAILABLE", "DEADLINE_EXCEEDED"]
111
+ }
112
+
113
+ default_config.rpcs.export_agent.timeout = 60.0
114
+ default_config.rpcs.export_agent.retry_policy = {
115
+ initial_delay: 0.1,
116
+ max_delay: 60.0,
117
+ multiplier: 1.3,
118
+ retry_codes: ["UNAVAILABLE", "DEADLINE_EXCEEDED"]
119
+ }
120
+
121
+ default_config.rpcs.import_agent.timeout = 60.0
122
+
123
+ default_config.rpcs.restore_agent.timeout = 60.0
124
+ default_config.rpcs.restore_agent.retry_policy = {
125
+ initial_delay: 0.1,
126
+ max_delay: 60.0,
127
+ multiplier: 1.3,
128
+ retry_codes: ["UNAVAILABLE", "DEADLINE_EXCEEDED"]
129
+ }
130
+
131
+ default_config
132
+ end
133
+ yield @configure if block_given?
134
+ @configure
135
+ end
136
+
137
+ ##
138
+ # Configure the Agents Client instance.
139
+ #
140
+ # The configuration is set to the derived mode, meaning that values can be changed,
141
+ # but structural changes (adding new fields, etc.) are not allowed. Structural changes
142
+ # should be made on {Client.configure}.
143
+ #
144
+ # See {Google::Cloud::Dialogflow::V2::Agents::Client::Configuration}
145
+ # for a description of the configuration fields.
146
+ #
147
+ # @yield [config] Configure the Client client.
148
+ # @yieldparam config [Client::Configuration]
149
+ #
150
+ # @return [Client::Configuration]
151
+ #
152
+ def configure
153
+ yield @config if block_given?
154
+ @config
155
+ end
156
+
157
+ ##
158
+ # Create a new Agents client object.
159
+ #
160
+ # ## Examples
161
+ #
162
+ # To create a new Agents client with the default
163
+ # configuration:
164
+ #
165
+ # client = Google::Cloud::Dialogflow::V2::Agents::Client.new
166
+ #
167
+ # To create a new Agents client with a custom
168
+ # configuration:
169
+ #
170
+ # client = Google::Cloud::Dialogflow::V2::Agents::Client.new do |config|
171
+ # config.timeout = 10_000
172
+ # end
173
+ #
174
+ # @yield [config] Configure the Agents client.
175
+ # @yieldparam config [Client::Configuration]
176
+ #
177
+ def initialize
178
+ # These require statements are intentionally placed here to initialize
179
+ # the gRPC module only when it's required.
180
+ # See https://github.com/googleapis/toolkit/issues/446
181
+ require "gapic/grpc"
182
+ require "google/cloud/dialogflow/v2/agent_services_pb"
183
+
184
+ # Create the configuration object
185
+ @config = Configuration.new Client.configure
186
+
187
+ # Yield the configuration if needed
188
+ yield @config if block_given?
189
+
190
+ # Create credentials
191
+ credentials = @config.credentials
192
+ credentials ||= Credentials.default scope: @config.scope
193
+ if credentials.is_a?(String) || credentials.is_a?(Hash)
194
+ credentials = Credentials.new credentials, scope: @config.scope
195
+ end
196
+ @quota_project_id = credentials.respond_to?(:quota_project_id) ? credentials.quota_project_id : nil
197
+
198
+ @operations_client = Operations.new do |config|
199
+ config.credentials = credentials
200
+ end
201
+
202
+ @agents_stub = Gapic::ServiceStub.new(
203
+ Google::Cloud::Dialogflow::V2::Agents::Stub,
204
+ credentials: credentials,
205
+ endpoint: @config.endpoint,
206
+ channel_args: @config.channel_args,
207
+ interceptors: @config.interceptors
208
+ )
209
+ end
210
+
211
+ # Service calls
212
+
213
+ ##
214
+ # Retrieves the specified agent.
215
+ #
216
+ # @overload get_agent(request, options = nil)
217
+ # @param request [Google::Cloud::Dialogflow::V2::GetAgentRequest | Hash]
218
+ # Retrieves the specified agent.
219
+ # @param options [Gapic::CallOptions, Hash]
220
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
221
+ #
222
+ # @overload get_agent(parent: nil)
223
+ # @param parent [String]
224
+ # Required. The project that the agent to fetch is associated with.
225
+ # Format: `projects/<Project ID>`.
226
+ #
227
+ #
228
+ # @yield [response, operation] Access the result along with the RPC operation
229
+ # @yieldparam response [Google::Cloud::Dialogflow::V2::Agent]
230
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
231
+ #
232
+ # @return [Google::Cloud::Dialogflow::V2::Agent]
233
+ #
234
+ # @raise [Google::Cloud::Error] if the RPC is aborted.
235
+ #
236
+ def get_agent request, options = nil
237
+ raise ArgumentError, "request must be provided" if request.nil?
238
+
239
+ request = Gapic::Protobuf.coerce request, to: Google::Cloud::Dialogflow::V2::GetAgentRequest
240
+
241
+ # Converts hash and nil to an options object
242
+ options = Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
243
+
244
+ # Customize the options with defaults
245
+ metadata = @config.rpcs.get_agent.metadata.to_h
246
+
247
+ # Set x-goog-api-client and x-goog-user-project headers
248
+ metadata[:"x-goog-api-client"] ||= Gapic::Headers.x_goog_api_client \
249
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
250
+ gapic_version: ::Google::Cloud::Dialogflow::V2::VERSION
251
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
252
+
253
+ header_params = {
254
+ "parent" => request.parent
255
+ }
256
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
257
+ metadata[:"x-goog-request-params"] ||= request_params_header
258
+
259
+ options.apply_defaults timeout: @config.rpcs.get_agent.timeout,
260
+ metadata: metadata,
261
+ retry_policy: @config.rpcs.get_agent.retry_policy
262
+ options.apply_defaults metadata: @config.metadata,
263
+ retry_policy: @config.retry_policy
264
+
265
+ @agents_stub.call_rpc :get_agent, request, options: options do |response, operation|
266
+ yield response, operation if block_given?
267
+ return response
268
+ end
269
+ rescue GRPC::BadStatus => e
270
+ raise Google::Cloud::Error.from_error(e)
271
+ end
272
+
273
+ ##
274
+ # Creates/updates the specified agent.
275
+ #
276
+ # @overload set_agent(request, options = nil)
277
+ # @param request [Google::Cloud::Dialogflow::V2::SetAgentRequest | Hash]
278
+ # Creates/updates the specified agent.
279
+ # @param options [Gapic::CallOptions, Hash]
280
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
281
+ #
282
+ # @overload set_agent(agent: nil, update_mask: nil)
283
+ # @param agent [Google::Cloud::Dialogflow::V2::Agent | Hash]
284
+ # Required. The agent to update.
285
+ # @param update_mask [Google::Protobuf::FieldMask | Hash]
286
+ # Optional. The mask to control which fields get updated.
287
+ #
288
+ #
289
+ # @yield [response, operation] Access the result along with the RPC operation
290
+ # @yieldparam response [Google::Cloud::Dialogflow::V2::Agent]
291
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
292
+ #
293
+ # @return [Google::Cloud::Dialogflow::V2::Agent]
294
+ #
295
+ # @raise [Google::Cloud::Error] if the RPC is aborted.
296
+ #
297
+ def set_agent request, options = nil
298
+ raise ArgumentError, "request must be provided" if request.nil?
299
+
300
+ request = Gapic::Protobuf.coerce request, to: Google::Cloud::Dialogflow::V2::SetAgentRequest
301
+
302
+ # Converts hash and nil to an options object
303
+ options = Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
304
+
305
+ # Customize the options with defaults
306
+ metadata = @config.rpcs.set_agent.metadata.to_h
307
+
308
+ # Set x-goog-api-client and x-goog-user-project headers
309
+ metadata[:"x-goog-api-client"] ||= Gapic::Headers.x_goog_api_client \
310
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
311
+ gapic_version: ::Google::Cloud::Dialogflow::V2::VERSION
312
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
313
+
314
+ header_params = {
315
+ "agent.parent" => request.agent.parent
316
+ }
317
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
318
+ metadata[:"x-goog-request-params"] ||= request_params_header
319
+
320
+ options.apply_defaults timeout: @config.rpcs.set_agent.timeout,
321
+ metadata: metadata,
322
+ retry_policy: @config.rpcs.set_agent.retry_policy
323
+ options.apply_defaults metadata: @config.metadata,
324
+ retry_policy: @config.retry_policy
325
+
326
+ @agents_stub.call_rpc :set_agent, request, options: options do |response, operation|
327
+ yield response, operation if block_given?
328
+ return response
329
+ end
330
+ rescue GRPC::BadStatus => e
331
+ raise Google::Cloud::Error.from_error(e)
332
+ end
333
+
334
+ ##
335
+ # Deletes the specified agent.
336
+ #
337
+ # @overload delete_agent(request, options = nil)
338
+ # @param request [Google::Cloud::Dialogflow::V2::DeleteAgentRequest | Hash]
339
+ # Deletes the specified agent.
340
+ # @param options [Gapic::CallOptions, Hash]
341
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
342
+ #
343
+ # @overload delete_agent(parent: nil)
344
+ # @param parent [String]
345
+ # Required. The project that the agent to delete is associated with.
346
+ # Format: `projects/<Project ID>`.
347
+ #
348
+ #
349
+ # @yield [response, operation] Access the result along with the RPC operation
350
+ # @yieldparam response [Google::Protobuf::Empty]
351
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
352
+ #
353
+ # @return [Google::Protobuf::Empty]
354
+ #
355
+ # @raise [Google::Cloud::Error] if the RPC is aborted.
356
+ #
357
+ def delete_agent request, options = nil
358
+ raise ArgumentError, "request must be provided" if request.nil?
359
+
360
+ request = Gapic::Protobuf.coerce request, to: Google::Cloud::Dialogflow::V2::DeleteAgentRequest
361
+
362
+ # Converts hash and nil to an options object
363
+ options = Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
364
+
365
+ # Customize the options with defaults
366
+ metadata = @config.rpcs.delete_agent.metadata.to_h
367
+
368
+ # Set x-goog-api-client and x-goog-user-project headers
369
+ metadata[:"x-goog-api-client"] ||= Gapic::Headers.x_goog_api_client \
370
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
371
+ gapic_version: ::Google::Cloud::Dialogflow::V2::VERSION
372
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
373
+
374
+ header_params = {
375
+ "parent" => request.parent
376
+ }
377
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
378
+ metadata[:"x-goog-request-params"] ||= request_params_header
379
+
380
+ options.apply_defaults timeout: @config.rpcs.delete_agent.timeout,
381
+ metadata: metadata,
382
+ retry_policy: @config.rpcs.delete_agent.retry_policy
383
+ options.apply_defaults metadata: @config.metadata,
384
+ retry_policy: @config.retry_policy
385
+
386
+ @agents_stub.call_rpc :delete_agent, request, options: options do |response, operation|
387
+ yield response, operation if block_given?
388
+ return response
389
+ end
390
+ rescue GRPC::BadStatus => e
391
+ raise Google::Cloud::Error.from_error(e)
392
+ end
393
+
394
+ ##
395
+ # Returns the list of agents.
396
+ #
397
+ # Since there is at most one conversational agent per project, this method is
398
+ # useful primarily for listing all agents across projects the caller has
399
+ # access to. One can achieve that with a wildcard project collection id "-".
400
+ # Refer to [List
401
+ # Sub-Collections](https://cloud.google.com/apis/design/design_patterns#list_sub-collections).
402
+ #
403
+ # @overload search_agents(request, options = nil)
404
+ # @param request [Google::Cloud::Dialogflow::V2::SearchAgentsRequest | Hash]
405
+ # Returns the list of agents.
406
+ #
407
+ # Since there is at most one conversational agent per project, this method is
408
+ # useful primarily for listing all agents across projects the caller has
409
+ # access to. One can achieve that with a wildcard project collection id "-".
410
+ # Refer to [List
411
+ # Sub-Collections](https://cloud.google.com/apis/design/design_patterns#list_sub-collections).
412
+ # @param options [Gapic::CallOptions, Hash]
413
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
414
+ #
415
+ # @overload search_agents(parent: nil, page_size: nil, page_token: nil)
416
+ # @param parent [String]
417
+ # Required. The project to list agents from.
418
+ # Format: `projects/<Project ID or '-'>`.
419
+ # @param page_size [Integer]
420
+ # Optional. The maximum number of items to return in a single page. By
421
+ # default 100 and at most 1000.
422
+ # @param page_token [String]
423
+ # The next_page_token value returned from a previous list request.
424
+ #
425
+ #
426
+ # @yield [response, operation] Access the result along with the RPC operation
427
+ # @yieldparam response [Gapic::PagedEnumerable<Google::Cloud::Dialogflow::V2::Agent>]
428
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
429
+ #
430
+ # @return [Gapic::PagedEnumerable<Google::Cloud::Dialogflow::V2::Agent>]
431
+ #
432
+ # @raise [Google::Cloud::Error] if the RPC is aborted.
433
+ #
434
+ def search_agents request, options = nil
435
+ raise ArgumentError, "request must be provided" if request.nil?
436
+
437
+ request = Gapic::Protobuf.coerce request, to: Google::Cloud::Dialogflow::V2::SearchAgentsRequest
438
+
439
+ # Converts hash and nil to an options object
440
+ options = Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
441
+
442
+ # Customize the options with defaults
443
+ metadata = @config.rpcs.search_agents.metadata.to_h
444
+
445
+ # Set x-goog-api-client and x-goog-user-project headers
446
+ metadata[:"x-goog-api-client"] ||= Gapic::Headers.x_goog_api_client \
447
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
448
+ gapic_version: ::Google::Cloud::Dialogflow::V2::VERSION
449
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
450
+
451
+ header_params = {
452
+ "parent" => request.parent
453
+ }
454
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
455
+ metadata[:"x-goog-request-params"] ||= request_params_header
456
+
457
+ options.apply_defaults timeout: @config.rpcs.search_agents.timeout,
458
+ metadata: metadata,
459
+ retry_policy: @config.rpcs.search_agents.retry_policy
460
+ options.apply_defaults metadata: @config.metadata,
461
+ retry_policy: @config.retry_policy
462
+
463
+ @agents_stub.call_rpc :search_agents, request, options: options do |response, operation|
464
+ response = Gapic::PagedEnumerable.new @agents_stub, :search_agents, request, response, operation, options
465
+ yield response, operation if block_given?
466
+ return response
467
+ end
468
+ rescue GRPC::BadStatus => e
469
+ raise Google::Cloud::Error.from_error(e)
470
+ end
471
+
472
+ ##
473
+ # Trains the specified agent.
474
+ #
475
+ # Operation <response: {Google::Protobuf::Empty google.protobuf.Empty}>
476
+ #
477
+ # @overload train_agent(request, options = nil)
478
+ # @param request [Google::Cloud::Dialogflow::V2::TrainAgentRequest | Hash]
479
+ # Trains the specified agent.
480
+ #
481
+ # Operation <response: {Google::Protobuf::Empty google.protobuf.Empty}>
482
+ # @param options [Gapic::CallOptions, Hash]
483
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
484
+ #
485
+ # @overload train_agent(parent: nil)
486
+ # @param parent [String]
487
+ # Required. The project that the agent to train is associated with.
488
+ # Format: `projects/<Project ID>`.
489
+ #
490
+ #
491
+ # @yield [response, operation] Access the result along with the RPC operation
492
+ # @yieldparam response [Gapic::Operation]
493
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
494
+ #
495
+ # @return [Gapic::Operation]
496
+ #
497
+ # @raise [Google::Cloud::Error] if the RPC is aborted.
498
+ #
499
+ def train_agent request, options = nil
500
+ raise ArgumentError, "request must be provided" if request.nil?
501
+
502
+ request = Gapic::Protobuf.coerce request, to: Google::Cloud::Dialogflow::V2::TrainAgentRequest
503
+
504
+ # Converts hash and nil to an options object
505
+ options = Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
506
+
507
+ # Customize the options with defaults
508
+ metadata = @config.rpcs.train_agent.metadata.to_h
509
+
510
+ # Set x-goog-api-client and x-goog-user-project headers
511
+ metadata[:"x-goog-api-client"] ||= Gapic::Headers.x_goog_api_client \
512
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
513
+ gapic_version: ::Google::Cloud::Dialogflow::V2::VERSION
514
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
515
+
516
+ header_params = {
517
+ "parent" => request.parent
518
+ }
519
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
520
+ metadata[:"x-goog-request-params"] ||= request_params_header
521
+
522
+ options.apply_defaults timeout: @config.rpcs.train_agent.timeout,
523
+ metadata: metadata,
524
+ retry_policy: @config.rpcs.train_agent.retry_policy
525
+ options.apply_defaults metadata: @config.metadata,
526
+ retry_policy: @config.retry_policy
527
+
528
+ @agents_stub.call_rpc :train_agent, request, options: options do |response, operation|
529
+ response = Gapic::Operation.new response, @operations_client, options: options
530
+ yield response, operation if block_given?
531
+ return response
532
+ end
533
+ rescue GRPC::BadStatus => e
534
+ raise Google::Cloud::Error.from_error(e)
535
+ end
536
+
537
+ ##
538
+ # Exports the specified agent to a ZIP file.
539
+ #
540
+ # Operation <response: {Google::Cloud::Dialogflow::V2::ExportAgentResponse ExportAgentResponse}>
541
+ #
542
+ # @overload export_agent(request, options = nil)
543
+ # @param request [Google::Cloud::Dialogflow::V2::ExportAgentRequest | Hash]
544
+ # Exports the specified agent to a ZIP file.
545
+ #
546
+ # Operation <response: {Google::Cloud::Dialogflow::V2::ExportAgentResponse ExportAgentResponse}>
547
+ # @param options [Gapic::CallOptions, Hash]
548
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
549
+ #
550
+ # @overload export_agent(parent: nil, agent_uri: nil)
551
+ # @param parent [String]
552
+ # Required. The project that the agent to export is associated with.
553
+ # Format: `projects/<Project ID>`.
554
+ # @param agent_uri [String]
555
+ # Required. The [Google Cloud Storage](https://cloud.google.com/storage/docs/)
556
+ # URI to export the agent to.
557
+ # The format of this URI must be `gs://<bucket-name>/<object-name>`.
558
+ # If left unspecified, the serialized agent is returned inline.
559
+ #
560
+ #
561
+ # @yield [response, operation] Access the result along with the RPC operation
562
+ # @yieldparam response [Gapic::Operation]
563
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
564
+ #
565
+ # @return [Gapic::Operation]
566
+ #
567
+ # @raise [Google::Cloud::Error] if the RPC is aborted.
568
+ #
569
+ def export_agent request, options = nil
570
+ raise ArgumentError, "request must be provided" if request.nil?
571
+
572
+ request = Gapic::Protobuf.coerce request, to: Google::Cloud::Dialogflow::V2::ExportAgentRequest
573
+
574
+ # Converts hash and nil to an options object
575
+ options = Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
576
+
577
+ # Customize the options with defaults
578
+ metadata = @config.rpcs.export_agent.metadata.to_h
579
+
580
+ # Set x-goog-api-client and x-goog-user-project headers
581
+ metadata[:"x-goog-api-client"] ||= Gapic::Headers.x_goog_api_client \
582
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
583
+ gapic_version: ::Google::Cloud::Dialogflow::V2::VERSION
584
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
585
+
586
+ header_params = {
587
+ "parent" => request.parent
588
+ }
589
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
590
+ metadata[:"x-goog-request-params"] ||= request_params_header
591
+
592
+ options.apply_defaults timeout: @config.rpcs.export_agent.timeout,
593
+ metadata: metadata,
594
+ retry_policy: @config.rpcs.export_agent.retry_policy
595
+ options.apply_defaults metadata: @config.metadata,
596
+ retry_policy: @config.retry_policy
597
+
598
+ @agents_stub.call_rpc :export_agent, request, options: options do |response, operation|
599
+ response = Gapic::Operation.new response, @operations_client, options: options
600
+ yield response, operation if block_given?
601
+ return response
602
+ end
603
+ rescue GRPC::BadStatus => e
604
+ raise Google::Cloud::Error.from_error(e)
605
+ end
606
+
607
+ ##
608
+ # Imports the specified agent from a ZIP file.
609
+ #
610
+ # Uploads new intents and entity types without deleting the existing ones.
611
+ # Intents and entity types with the same name are replaced with the new
612
+ # versions from ImportAgentRequest.
613
+ #
614
+ # Operation <response: {Google::Protobuf::Empty google.protobuf.Empty}>
615
+ #
616
+ # @overload import_agent(request, options = nil)
617
+ # @param request [Google::Cloud::Dialogflow::V2::ImportAgentRequest | Hash]
618
+ # Imports the specified agent from a ZIP file.
619
+ #
620
+ # Uploads new intents and entity types without deleting the existing ones.
621
+ # Intents and entity types with the same name are replaced with the new
622
+ # versions from ImportAgentRequest.
623
+ #
624
+ # Operation <response: {Google::Protobuf::Empty google.protobuf.Empty}>
625
+ # @param options [Gapic::CallOptions, Hash]
626
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
627
+ #
628
+ # @overload import_agent(parent: nil, agent_uri: nil, agent_content: nil)
629
+ # @param parent [String]
630
+ # Required. The project that the agent to import is associated with.
631
+ # Format: `projects/<Project ID>`.
632
+ # @param agent_uri [String]
633
+ # The URI to a Google Cloud Storage file containing the agent to import.
634
+ # Note: The URI must start with "gs://".
635
+ # @param agent_content [String]
636
+ # Zip compressed raw byte content for agent.
637
+ #
638
+ #
639
+ # @yield [response, operation] Access the result along with the RPC operation
640
+ # @yieldparam response [Gapic::Operation]
641
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
642
+ #
643
+ # @return [Gapic::Operation]
644
+ #
645
+ # @raise [Google::Cloud::Error] if the RPC is aborted.
646
+ #
647
+ def import_agent request, options = nil
648
+ raise ArgumentError, "request must be provided" if request.nil?
649
+
650
+ request = Gapic::Protobuf.coerce request, to: Google::Cloud::Dialogflow::V2::ImportAgentRequest
651
+
652
+ # Converts hash and nil to an options object
653
+ options = Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
654
+
655
+ # Customize the options with defaults
656
+ metadata = @config.rpcs.import_agent.metadata.to_h
657
+
658
+ # Set x-goog-api-client and x-goog-user-project headers
659
+ metadata[:"x-goog-api-client"] ||= Gapic::Headers.x_goog_api_client \
660
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
661
+ gapic_version: ::Google::Cloud::Dialogflow::V2::VERSION
662
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
663
+
664
+ header_params = {
665
+ "parent" => request.parent
666
+ }
667
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
668
+ metadata[:"x-goog-request-params"] ||= request_params_header
669
+
670
+ options.apply_defaults timeout: @config.rpcs.import_agent.timeout,
671
+ metadata: metadata,
672
+ retry_policy: @config.rpcs.import_agent.retry_policy
673
+ options.apply_defaults metadata: @config.metadata,
674
+ retry_policy: @config.retry_policy
675
+
676
+ @agents_stub.call_rpc :import_agent, request, options: options do |response, operation|
677
+ response = Gapic::Operation.new response, @operations_client, options: options
678
+ yield response, operation if block_given?
679
+ return response
680
+ end
681
+ rescue GRPC::BadStatus => e
682
+ raise Google::Cloud::Error.from_error(e)
683
+ end
684
+
685
+ ##
686
+ # Restores the specified agent from a ZIP file.
687
+ #
688
+ # Replaces the current agent version with a new one. All the intents and
689
+ # entity types in the older version are deleted.
690
+ #
691
+ # Operation <response: {Google::Protobuf::Empty google.protobuf.Empty}>
692
+ #
693
+ # @overload restore_agent(request, options = nil)
694
+ # @param request [Google::Cloud::Dialogflow::V2::RestoreAgentRequest | Hash]
695
+ # Restores the specified agent from a ZIP file.
696
+ #
697
+ # Replaces the current agent version with a new one. All the intents and
698
+ # entity types in the older version are deleted.
699
+ #
700
+ # Operation <response: {Google::Protobuf::Empty google.protobuf.Empty}>
701
+ # @param options [Gapic::CallOptions, Hash]
702
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
703
+ #
704
+ # @overload restore_agent(parent: nil, agent_uri: nil, agent_content: nil)
705
+ # @param parent [String]
706
+ # Required. The project that the agent to restore is associated with.
707
+ # Format: `projects/<Project ID>`.
708
+ # @param agent_uri [String]
709
+ # The URI to a Google Cloud Storage file containing the agent to restore.
710
+ # Note: The URI must start with "gs://".
711
+ # @param agent_content [String]
712
+ # Zip compressed raw byte content for agent.
713
+ #
714
+ #
715
+ # @yield [response, operation] Access the result along with the RPC operation
716
+ # @yieldparam response [Gapic::Operation]
717
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
718
+ #
719
+ # @return [Gapic::Operation]
720
+ #
721
+ # @raise [Google::Cloud::Error] if the RPC is aborted.
722
+ #
723
+ def restore_agent request, options = nil
724
+ raise ArgumentError, "request must be provided" if request.nil?
725
+
726
+ request = Gapic::Protobuf.coerce request, to: Google::Cloud::Dialogflow::V2::RestoreAgentRequest
727
+
728
+ # Converts hash and nil to an options object
729
+ options = Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
730
+
731
+ # Customize the options with defaults
732
+ metadata = @config.rpcs.restore_agent.metadata.to_h
733
+
734
+ # Set x-goog-api-client and x-goog-user-project headers
735
+ metadata[:"x-goog-api-client"] ||= Gapic::Headers.x_goog_api_client \
736
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
737
+ gapic_version: ::Google::Cloud::Dialogflow::V2::VERSION
738
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
739
+
740
+ header_params = {
741
+ "parent" => request.parent
742
+ }
743
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
744
+ metadata[:"x-goog-request-params"] ||= request_params_header
745
+
746
+ options.apply_defaults timeout: @config.rpcs.restore_agent.timeout,
747
+ metadata: metadata,
748
+ retry_policy: @config.rpcs.restore_agent.retry_policy
749
+ options.apply_defaults metadata: @config.metadata,
750
+ retry_policy: @config.retry_policy
751
+
752
+ @agents_stub.call_rpc :restore_agent, request, options: options do |response, operation|
753
+ response = Gapic::Operation.new response, @operations_client, options: options
754
+ yield response, operation if block_given?
755
+ return response
756
+ end
757
+ rescue GRPC::BadStatus => e
758
+ raise Google::Cloud::Error.from_error(e)
759
+ end
760
+
761
+ ##
762
+ # Gets agent validation result. Agent validation is performed during
763
+ # training time and is updated automatically when training is completed.
764
+ #
765
+ # @overload get_validation_result(request, options = nil)
766
+ # @param request [Google::Cloud::Dialogflow::V2::GetValidationResultRequest | Hash]
767
+ # Gets agent validation result. Agent validation is performed during
768
+ # training time and is updated automatically when training is completed.
769
+ # @param options [Gapic::CallOptions, Hash]
770
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
771
+ #
772
+ # @overload get_validation_result(parent: nil, language_code: nil)
773
+ # @param parent [String]
774
+ # Required. The project that the agent is associated with.
775
+ # Format: `projects/<Project ID>`.
776
+ # @param language_code [String]
777
+ # Optional. The language for which you want a validation result. If not
778
+ # specified, the agent's default language is used. [Many
779
+ # languages](https://cloud.google.com/dialogflow/docs/reference/language)
780
+ # are supported. Note: languages must be enabled in the agent before they can
781
+ # be used.
782
+ #
783
+ #
784
+ # @yield [response, operation] Access the result along with the RPC operation
785
+ # @yieldparam response [Google::Cloud::Dialogflow::V2::ValidationResult]
786
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
787
+ #
788
+ # @return [Google::Cloud::Dialogflow::V2::ValidationResult]
789
+ #
790
+ # @raise [Google::Cloud::Error] if the RPC is aborted.
791
+ #
792
+ def get_validation_result request, options = nil
793
+ raise ArgumentError, "request must be provided" if request.nil?
794
+
795
+ request = Gapic::Protobuf.coerce request, to: Google::Cloud::Dialogflow::V2::GetValidationResultRequest
796
+
797
+ # Converts hash and nil to an options object
798
+ options = Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
799
+
800
+ # Customize the options with defaults
801
+ metadata = @config.rpcs.get_validation_result.metadata.to_h
802
+
803
+ # Set x-goog-api-client and x-goog-user-project headers
804
+ metadata[:"x-goog-api-client"] ||= Gapic::Headers.x_goog_api_client \
805
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
806
+ gapic_version: ::Google::Cloud::Dialogflow::V2::VERSION
807
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
808
+
809
+ header_params = {
810
+ "parent" => request.parent
811
+ }
812
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
813
+ metadata[:"x-goog-request-params"] ||= request_params_header
814
+
815
+ options.apply_defaults timeout: @config.rpcs.get_validation_result.timeout,
816
+ metadata: metadata,
817
+ retry_policy: @config.rpcs.get_validation_result.retry_policy
818
+ options.apply_defaults metadata: @config.metadata,
819
+ retry_policy: @config.retry_policy
820
+
821
+ @agents_stub.call_rpc :get_validation_result, request, options: options do |response, operation|
822
+ yield response, operation if block_given?
823
+ return response
824
+ end
825
+ rescue GRPC::BadStatus => e
826
+ raise Google::Cloud::Error.from_error(e)
827
+ end
828
+
829
+ ##
830
+ # Configuration class for the Agents API.
831
+ #
832
+ # This class represents the configuration for Agents,
833
+ # providing control over timeouts, retry behavior, logging, transport
834
+ # parameters, and other low-level controls. Certain parameters can also be
835
+ # applied individually to specific RPCs. See
836
+ # {Google::Cloud::Dialogflow::V2::Agents::Client::Configuration::Rpcs}
837
+ # for a list of RPCs that can be configured independently.
838
+ #
839
+ # Configuration can be applied globally to all clients, or to a single client
840
+ # on construction.
841
+ #
842
+ # # Examples
843
+ #
844
+ # To modify the global config, setting the timeout for get_agent
845
+ # to 20 seconds, and all remaining timeouts to 10 seconds:
846
+ #
847
+ # Google::Cloud::Dialogflow::V2::Agents::Client.configure do |config|
848
+ # config.timeout = 10_000
849
+ # config.rpcs.get_agent.timeout = 20_000
850
+ # end
851
+ #
852
+ # To apply the above configuration only to a new client:
853
+ #
854
+ # client = Google::Cloud::Dialogflow::V2::Agents::Client.new do |config|
855
+ # config.timeout = 10_000
856
+ # config.rpcs.get_agent.timeout = 20_000
857
+ # end
858
+ #
859
+ # @!attribute [rw] endpoint
860
+ # The hostname or hostname:port of the service endpoint.
861
+ # Defaults to `"dialogflow.googleapis.com"`.
862
+ # @return [String]
863
+ # @!attribute [rw] credentials
864
+ # Credentials to send with calls. You may provide any of the following types:
865
+ # * (`String`) The path to a service account key file in JSON format
866
+ # * (`Hash`) A service account key as a Hash
867
+ # * (`Google::Auth::Credentials`) A googleauth credentials object
868
+ # (see the [googleauth docs](https://googleapis.dev/ruby/googleauth/latest/index.html))
869
+ # * (`Signet::OAuth2::Client`) A signet oauth2 client object
870
+ # (see the [signet docs](https://googleapis.dev/ruby/signet/latest/Signet/OAuth2/Client.html))
871
+ # * (`GRPC::Core::Channel`) a gRPC channel with included credentials
872
+ # * (`GRPC::Core::ChannelCredentials`) a gRPC credentails object
873
+ # * (`nil`) indicating no credentials
874
+ # @return [Object]
875
+ # @!attribute [rw] scope
876
+ # The OAuth scopes
877
+ # @return [Array<String>]
878
+ # @!attribute [rw] lib_name
879
+ # The library name as recorded in instrumentation and logging
880
+ # @return [String]
881
+ # @!attribute [rw] lib_version
882
+ # The library version as recorded in instrumentation and logging
883
+ # @return [String]
884
+ # @!attribute [rw] channel_args
885
+ # Extra parameters passed to the gRPC channel. Note: this is ignored if a
886
+ # `GRPC::Core::Channel` object is provided as the credential.
887
+ # @return [Hash]
888
+ # @!attribute [rw] interceptors
889
+ # An array of interceptors that are run before calls are executed.
890
+ # @return [Array<GRPC::ClientInterceptor>]
891
+ # @!attribute [rw] timeout
892
+ # The call timeout in milliseconds.
893
+ # @return [Numeric]
894
+ # @!attribute [rw] metadata
895
+ # Additional gRPC headers to be sent with the call.
896
+ # @return [Hash{Symbol=>String}]
897
+ # @!attribute [rw] retry_policy
898
+ # The retry policy. The value is a hash with the following keys:
899
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
900
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
901
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
902
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
903
+ # trigger a retry.
904
+ # @return [Hash]
905
+ #
906
+ class Configuration
907
+ extend Gapic::Config
908
+
909
+ config_attr :endpoint, "dialogflow.googleapis.com", String
910
+ config_attr :credentials, nil do |value|
911
+ allowed = [::String, ::Hash, ::Proc, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
912
+ allowed += [::GRPC::Core::Channel, ::GRPC::Core::ChannelCredentials] if defined? ::GRPC
913
+ allowed.any? { |klass| klass === value }
914
+ end
915
+ config_attr :scope, nil, String, Array, nil
916
+ config_attr :lib_name, nil, String, nil
917
+ config_attr :lib_version, nil, String, nil
918
+ config_attr(:channel_args, { "grpc.service_config_disable_resolution"=>1 }, Hash, nil)
919
+ config_attr :interceptors, nil, Array, nil
920
+ config_attr :timeout, nil, Numeric, nil
921
+ config_attr :metadata, nil, Hash, nil
922
+ config_attr :retry_policy, nil, Hash, Proc, nil
923
+
924
+ # @private
925
+ def initialize parent_config = nil
926
+ @parent_config = parent_config unless parent_config.nil?
927
+
928
+ yield self if block_given?
929
+ end
930
+
931
+ ##
932
+ # Configurations for individual RPCs
933
+ # @return [Rpcs]
934
+ #
935
+ def rpcs
936
+ @rpcs ||= begin
937
+ parent_rpcs = nil
938
+ parent_rpcs = @parent_config.rpcs if @parent_config&.respond_to? :rpcs
939
+ Rpcs.new parent_rpcs
940
+ end
941
+ end
942
+
943
+ ##
944
+ # Configuration RPC class for the Agents API.
945
+ #
946
+ # Includes fields providing the configuration for each RPC in this service.
947
+ # Each configuration object is of type `Gapic::Config::Method` and includes
948
+ # the following configuration fields:
949
+ #
950
+ # * `timeout` (*type:* `Numeric`) - The call timeout in milliseconds
951
+ # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional gRPC headers
952
+ # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
953
+ # include the following keys:
954
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
955
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
956
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
957
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
958
+ # trigger a retry.
959
+ #
960
+ class Rpcs
961
+ ##
962
+ # RPC-specific configuration for `get_agent`
963
+ # @return [Gapic::Config::Method]
964
+ #
965
+ attr_reader :get_agent
966
+ ##
967
+ # RPC-specific configuration for `set_agent`
968
+ # @return [Gapic::Config::Method]
969
+ #
970
+ attr_reader :set_agent
971
+ ##
972
+ # RPC-specific configuration for `delete_agent`
973
+ # @return [Gapic::Config::Method]
974
+ #
975
+ attr_reader :delete_agent
976
+ ##
977
+ # RPC-specific configuration for `search_agents`
978
+ # @return [Gapic::Config::Method]
979
+ #
980
+ attr_reader :search_agents
981
+ ##
982
+ # RPC-specific configuration for `train_agent`
983
+ # @return [Gapic::Config::Method]
984
+ #
985
+ attr_reader :train_agent
986
+ ##
987
+ # RPC-specific configuration for `export_agent`
988
+ # @return [Gapic::Config::Method]
989
+ #
990
+ attr_reader :export_agent
991
+ ##
992
+ # RPC-specific configuration for `import_agent`
993
+ # @return [Gapic::Config::Method]
994
+ #
995
+ attr_reader :import_agent
996
+ ##
997
+ # RPC-specific configuration for `restore_agent`
998
+ # @return [Gapic::Config::Method]
999
+ #
1000
+ attr_reader :restore_agent
1001
+ ##
1002
+ # RPC-specific configuration for `get_validation_result`
1003
+ # @return [Gapic::Config::Method]
1004
+ #
1005
+ attr_reader :get_validation_result
1006
+
1007
+ # @private
1008
+ def initialize parent_rpcs = nil
1009
+ get_agent_config = parent_rpcs&.get_agent if parent_rpcs&.respond_to? :get_agent
1010
+ @get_agent = Gapic::Config::Method.new get_agent_config
1011
+ set_agent_config = parent_rpcs&.set_agent if parent_rpcs&.respond_to? :set_agent
1012
+ @set_agent = Gapic::Config::Method.new set_agent_config
1013
+ delete_agent_config = parent_rpcs&.delete_agent if parent_rpcs&.respond_to? :delete_agent
1014
+ @delete_agent = Gapic::Config::Method.new delete_agent_config
1015
+ search_agents_config = parent_rpcs&.search_agents if parent_rpcs&.respond_to? :search_agents
1016
+ @search_agents = Gapic::Config::Method.new search_agents_config
1017
+ train_agent_config = parent_rpcs&.train_agent if parent_rpcs&.respond_to? :train_agent
1018
+ @train_agent = Gapic::Config::Method.new train_agent_config
1019
+ export_agent_config = parent_rpcs&.export_agent if parent_rpcs&.respond_to? :export_agent
1020
+ @export_agent = Gapic::Config::Method.new export_agent_config
1021
+ import_agent_config = parent_rpcs&.import_agent if parent_rpcs&.respond_to? :import_agent
1022
+ @import_agent = Gapic::Config::Method.new import_agent_config
1023
+ restore_agent_config = parent_rpcs&.restore_agent if parent_rpcs&.respond_to? :restore_agent
1024
+ @restore_agent = Gapic::Config::Method.new restore_agent_config
1025
+ get_validation_result_config = parent_rpcs&.get_validation_result if parent_rpcs&.respond_to? :get_validation_result
1026
+ @get_validation_result = Gapic::Config::Method.new get_validation_result_config
1027
+
1028
+ yield self if block_given?
1029
+ end
1030
+ end
1031
+ end
1032
+ end
1033
+ end
1034
+ end
1035
+ end
1036
+ end
1037
+ end
1038
+
1039
+ # rubocop:disable Lint/HandleExceptions
1040
+
1041
+ # Once client is loaded, load helpers.rb if it exists.
1042
+ begin
1043
+ require "google/cloud/dialogflow/v2/agents/helpers"
1044
+ rescue LoadError
1045
+ end
1046
+
1047
+ # rubocop:enable Lint/HandleExceptions