google-cloud-dialogflow 0.13.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +2 -1
  3. data/AUTHENTICATION.md +51 -59
  4. data/LICENSE.md +203 -0
  5. data/MIGRATING.md +445 -0
  6. data/README.md +35 -25
  7. data/lib/{google/cloud/dialogflow/v2/doc/google/protobuf/empty.rb → google-cloud-dialogflow.rb} +4 -14
  8. data/lib/google/cloud/dialogflow.rb +374 -506
  9. data/lib/google/cloud/dialogflow/version.rb +1 -1
  10. metadata +62 -83
  11. data/LICENSE +0 -201
  12. data/lib/google/cloud/dialogflow/v2.rb +0 -598
  13. data/lib/google/cloud/dialogflow/v2/agent_pb.rb +0 -115
  14. data/lib/google/cloud/dialogflow/v2/agent_services_pb.rb +0 -109
  15. data/lib/google/cloud/dialogflow/v2/agents_client.rb +0 -760
  16. data/lib/google/cloud/dialogflow/v2/agents_client_config.json +0 -66
  17. data/lib/google/cloud/dialogflow/v2/audio_config_pb.rb +0 -96
  18. data/lib/google/cloud/dialogflow/v2/context_pb.rb +0 -63
  19. data/lib/google/cloud/dialogflow/v2/context_services_pb.rb +0 -76
  20. data/lib/google/cloud/dialogflow/v2/contexts_client.rb +0 -519
  21. data/lib/google/cloud/dialogflow/v2/contexts_client_config.json +0 -56
  22. data/lib/google/cloud/dialogflow/v2/credentials.rb +0 -42
  23. data/lib/google/cloud/dialogflow/v2/doc/google/cloud/dialogflow/v2/agent.rb +0 -233
  24. data/lib/google/cloud/dialogflow/v2/doc/google/cloud/dialogflow/v2/audio_config.rb +0 -341
  25. data/lib/google/cloud/dialogflow/v2/doc/google/cloud/dialogflow/v2/context.rb +0 -116
  26. data/lib/google/cloud/dialogflow/v2/doc/google/cloud/dialogflow/v2/entity_type.rb +0 -305
  27. data/lib/google/cloud/dialogflow/v2/doc/google/cloud/dialogflow/v2/intent.rb +0 -937
  28. data/lib/google/cloud/dialogflow/v2/doc/google/cloud/dialogflow/v2/session.rb +0 -482
  29. data/lib/google/cloud/dialogflow/v2/doc/google/cloud/dialogflow/v2/session_entity_type.rb +0 -130
  30. data/lib/google/cloud/dialogflow/v2/doc/google/longrunning/operations.rb +0 -51
  31. data/lib/google/cloud/dialogflow/v2/doc/google/protobuf/any.rb +0 -131
  32. data/lib/google/cloud/dialogflow/v2/doc/google/protobuf/duration.rb +0 -91
  33. data/lib/google/cloud/dialogflow/v2/doc/google/protobuf/field_mask.rb +0 -222
  34. data/lib/google/cloud/dialogflow/v2/doc/google/protobuf/struct.rb +0 -74
  35. data/lib/google/cloud/dialogflow/v2/doc/google/rpc/status.rb +0 -39
  36. data/lib/google/cloud/dialogflow/v2/doc/google/type/latlng.rb +0 -31
  37. data/lib/google/cloud/dialogflow/v2/entity_type_pb.rb +0 -125
  38. data/lib/google/cloud/dialogflow/v2/entity_type_services_pb.rb +0 -106
  39. data/lib/google/cloud/dialogflow/v2/entity_types_client.rb +0 -994
  40. data/lib/google/cloud/dialogflow/v2/entity_types_client_config.json +0 -76
  41. data/lib/google/cloud/dialogflow/v2/intent_pb.rb +0 -367
  42. data/lib/google/cloud/dialogflow/v2/intent_services_pb.rb +0 -94
  43. data/lib/google/cloud/dialogflow/v2/intents_client.rb +0 -760
  44. data/lib/google/cloud/dialogflow/v2/intents_client_config.json +0 -61
  45. data/lib/google/cloud/dialogflow/v2/session_entity_type_pb.rb +0 -65
  46. data/lib/google/cloud/dialogflow/v2/session_entity_type_services_pb.rb +0 -94
  47. data/lib/google/cloud/dialogflow/v2/session_entity_types_client.rb +0 -504
  48. data/lib/google/cloud/dialogflow/v2/session_entity_types_client_config.json +0 -51
  49. data/lib/google/cloud/dialogflow/v2/session_pb.rb +0 -138
  50. data/lib/google/cloud/dialogflow/v2/session_services_pb.rb +0 -57
  51. data/lib/google/cloud/dialogflow/v2/sessions_client.rb +0 -326
  52. data/lib/google/cloud/dialogflow/v2/sessions_client_config.json +0 -36
  53. data/lib/google/cloud/dialogflow/v2/webhook_pb.rb +0 -46
@@ -1,115 +0,0 @@
1
- # Generated by the protocol buffer compiler. DO NOT EDIT!
2
- # source: google/cloud/dialogflow/v2/agent.proto
3
-
4
-
5
- require 'google/protobuf'
6
-
7
- require 'google/api/annotations_pb'
8
- require 'google/api/client_pb'
9
- require 'google/api/field_behavior_pb'
10
- require 'google/api/resource_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_message "google.cloud.dialogflow.v2.Agent" do
16
- optional :parent, :string, 1
17
- optional :display_name, :string, 2
18
- optional :default_language_code, :string, 3
19
- repeated :supported_language_codes, :string, 4
20
- optional :time_zone, :string, 5
21
- optional :description, :string, 6
22
- optional :avatar_uri, :string, 7
23
- optional :enable_logging, :bool, 8
24
- optional :match_mode, :enum, 9, "google.cloud.dialogflow.v2.Agent.MatchMode"
25
- optional :classification_threshold, :float, 10
26
- optional :api_version, :enum, 14, "google.cloud.dialogflow.v2.Agent.ApiVersion"
27
- optional :tier, :enum, 15, "google.cloud.dialogflow.v2.Agent.Tier"
28
- end
29
- add_enum "google.cloud.dialogflow.v2.Agent.MatchMode" do
30
- value :MATCH_MODE_UNSPECIFIED, 0
31
- value :MATCH_MODE_HYBRID, 1
32
- value :MATCH_MODE_ML_ONLY, 2
33
- end
34
- add_enum "google.cloud.dialogflow.v2.Agent.ApiVersion" do
35
- value :API_VERSION_UNSPECIFIED, 0
36
- value :API_VERSION_V1, 1
37
- value :API_VERSION_V2, 2
38
- value :API_VERSION_V2_BETA_1, 3
39
- end
40
- add_enum "google.cloud.dialogflow.v2.Agent.Tier" do
41
- value :TIER_UNSPECIFIED, 0
42
- value :TIER_STANDARD, 1
43
- value :TIER_ENTERPRISE, 2
44
- value :TIER_ENTERPRISE_PLUS, 3
45
- end
46
- add_message "google.cloud.dialogflow.v2.GetAgentRequest" do
47
- optional :parent, :string, 1
48
- end
49
- add_message "google.cloud.dialogflow.v2.SetAgentRequest" do
50
- optional :agent, :message, 1, "google.cloud.dialogflow.v2.Agent"
51
- optional :update_mask, :message, 2, "google.protobuf.FieldMask"
52
- end
53
- add_message "google.cloud.dialogflow.v2.DeleteAgentRequest" do
54
- optional :parent, :string, 1
55
- end
56
- add_message "google.cloud.dialogflow.v2.SearchAgentsRequest" do
57
- optional :parent, :string, 1
58
- optional :page_size, :int32, 2
59
- optional :page_token, :string, 3
60
- end
61
- add_message "google.cloud.dialogflow.v2.SearchAgentsResponse" do
62
- repeated :agents, :message, 1, "google.cloud.dialogflow.v2.Agent"
63
- optional :next_page_token, :string, 2
64
- end
65
- add_message "google.cloud.dialogflow.v2.TrainAgentRequest" do
66
- optional :parent, :string, 1
67
- end
68
- add_message "google.cloud.dialogflow.v2.ExportAgentRequest" do
69
- optional :parent, :string, 1
70
- optional :agent_uri, :string, 2
71
- end
72
- add_message "google.cloud.dialogflow.v2.ExportAgentResponse" do
73
- oneof :agent do
74
- optional :agent_uri, :string, 1
75
- optional :agent_content, :bytes, 2
76
- end
77
- end
78
- add_message "google.cloud.dialogflow.v2.ImportAgentRequest" do
79
- optional :parent, :string, 1
80
- oneof :agent do
81
- optional :agent_uri, :string, 2
82
- optional :agent_content, :bytes, 3
83
- end
84
- end
85
- add_message "google.cloud.dialogflow.v2.RestoreAgentRequest" do
86
- optional :parent, :string, 1
87
- oneof :agent do
88
- optional :agent_uri, :string, 2
89
- optional :agent_content, :bytes, 3
90
- end
91
- end
92
- end
93
-
94
- module Google
95
- module Cloud
96
- module Dialogflow
97
- module V2
98
- Agent = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.Agent").msgclass
99
- Agent::MatchMode = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.Agent.MatchMode").enummodule
100
- Agent::ApiVersion = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.Agent.ApiVersion").enummodule
101
- Agent::Tier = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.Agent.Tier").enummodule
102
- GetAgentRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.GetAgentRequest").msgclass
103
- SetAgentRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.SetAgentRequest").msgclass
104
- DeleteAgentRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.DeleteAgentRequest").msgclass
105
- SearchAgentsRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.SearchAgentsRequest").msgclass
106
- SearchAgentsResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.SearchAgentsResponse").msgclass
107
- TrainAgentRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.TrainAgentRequest").msgclass
108
- ExportAgentRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.ExportAgentRequest").msgclass
109
- ExportAgentResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.ExportAgentResponse").msgclass
110
- ImportAgentRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.ImportAgentRequest").msgclass
111
- RestoreAgentRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.RestoreAgentRequest").msgclass
112
- end
113
- end
114
- end
115
- end
@@ -1,109 +0,0 @@
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 2019 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
-
20
-
21
- require 'grpc'
22
- require 'google/cloud/dialogflow/v2/agent_pb'
23
-
24
- module Google
25
- module Cloud
26
- module Dialogflow
27
- module V2
28
- module Agents
29
- # Agents are best described as Natural Language Understanding (NLU) modules
30
- # that transform user requests into actionable data. You can include agents
31
- # in your app, product, or service to determine user intent and respond to the
32
- # user in a natural way.
33
- #
34
- # After you create an agent, you can add [Intents][google.cloud.dialogflow.v2.Intents], [Contexts][google.cloud.dialogflow.v2.Contexts],
35
- # [Entity Types][google.cloud.dialogflow.v2.EntityTypes], [Webhooks][google.cloud.dialogflow.v2.WebhookRequest], and so on to
36
- # manage the flow of a conversation and match user input to predefined intents
37
- # and actions.
38
- #
39
- # You can create an agent using both Dialogflow Standard Edition and
40
- # Dialogflow Enterprise Edition. For details, see
41
- # [Dialogflow
42
- # Editions](https://cloud.google.com/dialogflow/docs/editions).
43
- #
44
- # You can save your agent for backup or versioning by exporting the agent by
45
- # using the [ExportAgent][google.cloud.dialogflow.v2.Agents.ExportAgent] method. You can import a saved
46
- # agent by using the [ImportAgent][google.cloud.dialogflow.v2.Agents.ImportAgent] method.
47
- #
48
- # Dialogflow provides several
49
- # [prebuilt
50
- # agents](https://cloud.google.com/dialogflow/docs/agents-prebuilt)
51
- # for common conversation scenarios such as determining a date and time,
52
- # converting currency, and so on.
53
- #
54
- # For more information about agents, see the
55
- # [Dialogflow
56
- # documentation](https://cloud.google.com/dialogflow/docs/agents-overview).
57
- class Service
58
-
59
- include GRPC::GenericService
60
-
61
- self.marshal_class_method = :encode
62
- self.unmarshal_class_method = :decode
63
- self.service_name = 'google.cloud.dialogflow.v2.Agents'
64
-
65
- # Retrieves the specified agent.
66
- rpc :GetAgent, GetAgentRequest, Agent
67
- # Creates/updates the specified agent.
68
- rpc :SetAgent, SetAgentRequest, Agent
69
- # Deletes the specified agent.
70
- rpc :DeleteAgent, DeleteAgentRequest, Google::Protobuf::Empty
71
- # Returns the list of agents.
72
- #
73
- # Since there is at most one conversational agent per project, this method is
74
- # useful primarily for listing all agents across projects the caller has
75
- # access to. One can achieve that with a wildcard project collection id "-".
76
- # Refer to [List
77
- # Sub-Collections](https://cloud.google.com/apis/design/design_patterns#list_sub-collections).
78
- rpc :SearchAgents, SearchAgentsRequest, SearchAgentsResponse
79
- # Trains the specified agent.
80
- #
81
- # Operation <response: [google.protobuf.Empty][google.protobuf.Empty]>
82
- rpc :TrainAgent, TrainAgentRequest, Google::Longrunning::Operation
83
- # Exports the specified agent to a ZIP file.
84
- #
85
- # Operation <response: [ExportAgentResponse][google.cloud.dialogflow.v2.ExportAgentResponse]>
86
- rpc :ExportAgent, ExportAgentRequest, Google::Longrunning::Operation
87
- # Imports the specified agent from a ZIP file.
88
- #
89
- # Uploads new intents and entity types without deleting the existing ones.
90
- # Intents and entity types with the same name are replaced with the new
91
- # versions from ImportAgentRequest.
92
- #
93
- # Operation <response: [google.protobuf.Empty][google.protobuf.Empty]>
94
- rpc :ImportAgent, ImportAgentRequest, Google::Longrunning::Operation
95
- # Restores the specified agent from a ZIP file.
96
- #
97
- # Replaces the current agent version with a new one. All the intents and
98
- # entity types in the older version are deleted.
99
- #
100
- # Operation <response: [google.protobuf.Empty][google.protobuf.Empty]>
101
- rpc :RestoreAgent, RestoreAgentRequest, Google::Longrunning::Operation
102
- end
103
-
104
- Stub = Service.rpc_stub_class
105
- end
106
- end
107
- end
108
- end
109
- end
@@ -1,760 +0,0 @@
1
- # Copyright 2020 Google LLC
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # https://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
- #
15
- # EDITING INSTRUCTIONS
16
- # This file was generated from the file
17
- # https://github.com/googleapis/googleapis/blob/master/google/cloud/dialogflow/v2/agent.proto,
18
- # and updates to that file get reflected here through a refresh process.
19
- # For the short term, the refresh process will only be runnable by Google
20
- # engineers.
21
-
22
-
23
- require "json"
24
- require "pathname"
25
-
26
- require "google/gax"
27
- require "google/gax/operation"
28
- require "google/longrunning/operations_client"
29
-
30
- require "google/cloud/dialogflow/v2/agent_pb"
31
- require "google/cloud/dialogflow/v2/credentials"
32
- require "google/cloud/dialogflow/version"
33
-
34
- module Google
35
- module Cloud
36
- module Dialogflow
37
- module V2
38
- # Agents are best described as Natural Language Understanding (NLU) modules
39
- # that transform user requests into actionable data. You can include agents
40
- # in your app, product, or service to determine user intent and respond to the
41
- # user in a natural way.
42
- #
43
- # After you create an agent, you can add {Google::Cloud::Dialogflow::V2::Intents Intents}, {Google::Cloud::Dialogflow::V2::Contexts Contexts},
44
- # {Google::Cloud::Dialogflow::V2::EntityTypes Entity Types}, {Google::Cloud::Dialogflow::V2::WebhookRequest Webhooks}, and so on to
45
- # manage the flow of a conversation and match user input to predefined intents
46
- # and actions.
47
- #
48
- # You can create an agent using both Dialogflow Standard Edition and
49
- # Dialogflow Enterprise Edition. For details, see
50
- # [Dialogflow
51
- # Editions](https://cloud.google.com/dialogflow/docs/editions).
52
- #
53
- # You can save your agent for backup or versioning by exporting the agent by
54
- # using the {Google::Cloud::Dialogflow::V2::Agents::ExportAgent ExportAgent} method. You can import a saved
55
- # agent by using the {Google::Cloud::Dialogflow::V2::Agents::ImportAgent ImportAgent} method.
56
- #
57
- # Dialogflow provides several
58
- # [prebuilt
59
- # agents](https://cloud.google.com/dialogflow/docs/agents-prebuilt)
60
- # for common conversation scenarios such as determining a date and time,
61
- # converting currency, and so on.
62
- #
63
- # For more information about agents, see the
64
- # [Dialogflow
65
- # documentation](https://cloud.google.com/dialogflow/docs/agents-overview).
66
- #
67
- # @!attribute [r] agents_stub
68
- # @return [Google::Cloud::Dialogflow::V2::Agents::Stub]
69
- class AgentsClient
70
- # @private
71
- attr_reader :agents_stub
72
-
73
- # The default address of the service.
74
- SERVICE_ADDRESS = "dialogflow.googleapis.com".freeze
75
-
76
- # The default port of the service.
77
- DEFAULT_SERVICE_PORT = 443
78
-
79
- # The default set of gRPC interceptors.
80
- GRPC_INTERCEPTORS = []
81
-
82
- DEFAULT_TIMEOUT = 30
83
-
84
- PAGE_DESCRIPTORS = {
85
- "search_agents" => Google::Gax::PageDescriptor.new(
86
- "page_token",
87
- "next_page_token",
88
- "agents")
89
- }.freeze
90
-
91
- private_constant :PAGE_DESCRIPTORS
92
-
93
- # The scopes needed to make gRPC calls to all of the methods defined in
94
- # this service.
95
- ALL_SCOPES = [
96
- "https://www.googleapis.com/auth/cloud-platform",
97
- "https://www.googleapis.com/auth/dialogflow"
98
- ].freeze
99
-
100
- # @private
101
- class OperationsClient < Google::Longrunning::OperationsClient
102
- self::SERVICE_ADDRESS = AgentsClient::SERVICE_ADDRESS
103
- self::GRPC_INTERCEPTORS = AgentsClient::GRPC_INTERCEPTORS
104
- end
105
-
106
- PROJECT_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
107
- "projects/{project}"
108
- )
109
-
110
- private_constant :PROJECT_PATH_TEMPLATE
111
-
112
- # Returns a fully-qualified project resource name string.
113
- # @param project [String]
114
- # @return [String]
115
- def self.project_path project
116
- PROJECT_PATH_TEMPLATE.render(
117
- :"project" => project
118
- )
119
- end
120
-
121
- # @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc]
122
- # Provides the means for authenticating requests made by the client. This parameter can
123
- # be many types.
124
- # A `Google::Auth::Credentials` uses a the properties of its represented keyfile for
125
- # authenticating requests made by this client.
126
- # A `String` will be treated as the path to the keyfile to be used for the construction of
127
- # credentials for this client.
128
- # A `Hash` will be treated as the contents of a keyfile to be used for the construction of
129
- # credentials for this client.
130
- # A `GRPC::Core::Channel` will be used to make calls through.
131
- # A `GRPC::Core::ChannelCredentials` for the setting up the RPC client. The channel credentials
132
- # should already be composed with a `GRPC::Core::CallCredentials` object.
133
- # A `Proc` will be used as an updater_proc for the Grpc channel. The proc transforms the
134
- # metadata for requests, generally, to give OAuth credentials.
135
- # @param scopes [Array<String>]
136
- # The OAuth scopes for this service. This parameter is ignored if
137
- # an updater_proc is supplied.
138
- # @param client_config [Hash]
139
- # A Hash for call options for each method. See
140
- # Google::Gax#construct_settings for the structure of
141
- # this data. Falls back to the default config if not specified
142
- # or the specified config is missing data points.
143
- # @param timeout [Numeric]
144
- # The default timeout, in seconds, for calls made through this client.
145
- # @param metadata [Hash]
146
- # Default metadata to be sent with each request. This can be overridden on a per call basis.
147
- # @param service_address [String]
148
- # Override for the service hostname, or `nil` to leave as the default.
149
- # @param service_port [Integer]
150
- # Override for the service port, or `nil` to leave as the default.
151
- # @param exception_transformer [Proc]
152
- # An optional proc that intercepts any exceptions raised during an API call to inject
153
- # custom error handling.
154
- def initialize \
155
- credentials: nil,
156
- scopes: ALL_SCOPES,
157
- client_config: {},
158
- timeout: DEFAULT_TIMEOUT,
159
- metadata: nil,
160
- service_address: nil,
161
- service_port: nil,
162
- exception_transformer: nil,
163
- lib_name: nil,
164
- lib_version: ""
165
- # These require statements are intentionally placed here to initialize
166
- # the gRPC module only when it's required.
167
- # See https://github.com/googleapis/toolkit/issues/446
168
- require "google/gax/grpc"
169
- require "google/cloud/dialogflow/v2/agent_services_pb"
170
-
171
- credentials ||= Google::Cloud::Dialogflow::V2::Credentials.default
172
-
173
- @operations_client = OperationsClient.new(
174
- credentials: credentials,
175
- scopes: scopes,
176
- client_config: client_config,
177
- timeout: timeout,
178
- lib_name: lib_name,
179
- service_address: service_address,
180
- service_port: service_port,
181
- lib_version: lib_version,
182
- metadata: metadata,
183
- )
184
-
185
- if credentials.is_a?(String) || credentials.is_a?(Hash)
186
- updater_proc = Google::Cloud::Dialogflow::V2::Credentials.new(credentials).updater_proc
187
- end
188
- if credentials.is_a?(GRPC::Core::Channel)
189
- channel = credentials
190
- end
191
- if credentials.is_a?(GRPC::Core::ChannelCredentials)
192
- chan_creds = credentials
193
- end
194
- if credentials.is_a?(Proc)
195
- updater_proc = credentials
196
- end
197
- if credentials.is_a?(Google::Auth::Credentials)
198
- updater_proc = credentials.updater_proc
199
- end
200
-
201
- package_version = Google::Cloud::Dialogflow::VERSION
202
-
203
- google_api_client = "gl-ruby/#{RUBY_VERSION}"
204
- google_api_client << " #{lib_name}/#{lib_version}" if lib_name
205
- google_api_client << " gapic/#{package_version} gax/#{Google::Gax::VERSION}"
206
- google_api_client << " grpc/#{GRPC::VERSION}"
207
- google_api_client.freeze
208
-
209
- headers = { :"x-goog-api-client" => google_api_client }
210
- headers.merge!(metadata) unless metadata.nil?
211
- client_config_file = Pathname.new(__dir__).join(
212
- "agents_client_config.json"
213
- )
214
- defaults = client_config_file.open do |f|
215
- Google::Gax.construct_settings(
216
- "google.cloud.dialogflow.v2.Agents",
217
- JSON.parse(f.read),
218
- client_config,
219
- Google::Gax::Grpc::STATUS_CODE_NAMES,
220
- timeout,
221
- page_descriptors: PAGE_DESCRIPTORS,
222
- errors: Google::Gax::Grpc::API_ERRORS,
223
- metadata: headers
224
- )
225
- end
226
-
227
- # Allow overriding the service path/port in subclasses.
228
- service_path = service_address || self.class::SERVICE_ADDRESS
229
- port = service_port || self.class::DEFAULT_SERVICE_PORT
230
- interceptors = self.class::GRPC_INTERCEPTORS
231
- @agents_stub = Google::Gax::Grpc.create_stub(
232
- service_path,
233
- port,
234
- chan_creds: chan_creds,
235
- channel: channel,
236
- updater_proc: updater_proc,
237
- scopes: scopes,
238
- interceptors: interceptors,
239
- &Google::Cloud::Dialogflow::V2::Agents::Stub.method(:new)
240
- )
241
-
242
- @set_agent = Google::Gax.create_api_call(
243
- @agents_stub.method(:set_agent),
244
- defaults["set_agent"],
245
- exception_transformer: exception_transformer,
246
- params_extractor: proc do |request|
247
- {'agent.parent' => request.agent.parent}
248
- end
249
- )
250
- @delete_agent = Google::Gax.create_api_call(
251
- @agents_stub.method(:delete_agent),
252
- defaults["delete_agent"],
253
- exception_transformer: exception_transformer,
254
- params_extractor: proc do |request|
255
- {'parent' => request.parent}
256
- end
257
- )
258
- @get_agent = Google::Gax.create_api_call(
259
- @agents_stub.method(:get_agent),
260
- defaults["get_agent"],
261
- exception_transformer: exception_transformer,
262
- params_extractor: proc do |request|
263
- {'parent' => request.parent}
264
- end
265
- )
266
- @search_agents = Google::Gax.create_api_call(
267
- @agents_stub.method(:search_agents),
268
- defaults["search_agents"],
269
- exception_transformer: exception_transformer,
270
- params_extractor: proc do |request|
271
- {'parent' => request.parent}
272
- end
273
- )
274
- @train_agent = Google::Gax.create_api_call(
275
- @agents_stub.method(:train_agent),
276
- defaults["train_agent"],
277
- exception_transformer: exception_transformer,
278
- params_extractor: proc do |request|
279
- {'parent' => request.parent}
280
- end
281
- )
282
- @export_agent = Google::Gax.create_api_call(
283
- @agents_stub.method(:export_agent),
284
- defaults["export_agent"],
285
- exception_transformer: exception_transformer,
286
- params_extractor: proc do |request|
287
- {'parent' => request.parent}
288
- end
289
- )
290
- @import_agent = Google::Gax.create_api_call(
291
- @agents_stub.method(:import_agent),
292
- defaults["import_agent"],
293
- exception_transformer: exception_transformer,
294
- params_extractor: proc do |request|
295
- {'parent' => request.parent}
296
- end
297
- )
298
- @restore_agent = Google::Gax.create_api_call(
299
- @agents_stub.method(:restore_agent),
300
- defaults["restore_agent"],
301
- exception_transformer: exception_transformer,
302
- params_extractor: proc do |request|
303
- {'parent' => request.parent}
304
- end
305
- )
306
- end
307
-
308
- # Service calls
309
-
310
- # Creates/updates the specified agent.
311
- #
312
- # @param agent [Google::Cloud::Dialogflow::V2::Agent | Hash]
313
- # Required. The agent to update.
314
- # A hash of the same form as `Google::Cloud::Dialogflow::V2::Agent`
315
- # can also be provided.
316
- # @param update_mask [Google::Protobuf::FieldMask | Hash]
317
- # Optional. The mask to control which fields get updated.
318
- # A hash of the same form as `Google::Protobuf::FieldMask`
319
- # can also be provided.
320
- # @param options [Google::Gax::CallOptions]
321
- # Overrides the default settings for this call, e.g, timeout,
322
- # retries, etc.
323
- # @yield [result, operation] Access the result along with the RPC operation
324
- # @yieldparam result [Google::Cloud::Dialogflow::V2::Agent]
325
- # @yieldparam operation [GRPC::ActiveCall::Operation]
326
- # @return [Google::Cloud::Dialogflow::V2::Agent]
327
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
328
- # @example
329
- # require "google/cloud/dialogflow"
330
- #
331
- # agents_client = Google::Cloud::Dialogflow::Agents.new(version: :v2)
332
- #
333
- # # TODO: Initialize `agent`:
334
- # agent = {}
335
- # response = agents_client.set_agent(agent)
336
-
337
- def set_agent \
338
- agent,
339
- update_mask: nil,
340
- options: nil,
341
- &block
342
- req = {
343
- agent: agent,
344
- update_mask: update_mask
345
- }.delete_if { |_, v| v.nil? }
346
- req = Google::Gax::to_proto(req, Google::Cloud::Dialogflow::V2::SetAgentRequest)
347
- @set_agent.call(req, options, &block)
348
- end
349
-
350
- # Deletes the specified agent.
351
- #
352
- # @param parent [String]
353
- # Required. The project that the agent to delete is associated with.
354
- # Format: `projects/<Project ID>`.
355
- # @param options [Google::Gax::CallOptions]
356
- # Overrides the default settings for this call, e.g, timeout,
357
- # retries, etc.
358
- # @yield [result, operation] Access the result along with the RPC operation
359
- # @yieldparam result []
360
- # @yieldparam operation [GRPC::ActiveCall::Operation]
361
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
362
- # @example
363
- # require "google/cloud/dialogflow"
364
- #
365
- # agents_client = Google::Cloud::Dialogflow::Agents.new(version: :v2)
366
- # formatted_parent = Google::Cloud::Dialogflow::V2::AgentsClient.project_path("[PROJECT]")
367
- # agents_client.delete_agent(formatted_parent)
368
-
369
- def delete_agent \
370
- parent,
371
- options: nil,
372
- &block
373
- req = {
374
- parent: parent
375
- }.delete_if { |_, v| v.nil? }
376
- req = Google::Gax::to_proto(req, Google::Cloud::Dialogflow::V2::DeleteAgentRequest)
377
- @delete_agent.call(req, options, &block)
378
- nil
379
- end
380
-
381
- # Retrieves the specified agent.
382
- #
383
- # @param parent [String]
384
- # Required. The project that the agent to fetch is associated with.
385
- # Format: `projects/<Project ID>`.
386
- # @param options [Google::Gax::CallOptions]
387
- # Overrides the default settings for this call, e.g, timeout,
388
- # retries, etc.
389
- # @yield [result, operation] Access the result along with the RPC operation
390
- # @yieldparam result [Google::Cloud::Dialogflow::V2::Agent]
391
- # @yieldparam operation [GRPC::ActiveCall::Operation]
392
- # @return [Google::Cloud::Dialogflow::V2::Agent]
393
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
394
- # @example
395
- # require "google/cloud/dialogflow"
396
- #
397
- # agents_client = Google::Cloud::Dialogflow::Agents.new(version: :v2)
398
- # formatted_parent = Google::Cloud::Dialogflow::V2::AgentsClient.project_path("[PROJECT]")
399
- # response = agents_client.get_agent(formatted_parent)
400
-
401
- def get_agent \
402
- parent,
403
- options: nil,
404
- &block
405
- req = {
406
- parent: parent
407
- }.delete_if { |_, v| v.nil? }
408
- req = Google::Gax::to_proto(req, Google::Cloud::Dialogflow::V2::GetAgentRequest)
409
- @get_agent.call(req, options, &block)
410
- end
411
-
412
- # Returns the list of agents.
413
- #
414
- # Since there is at most one conversational agent per project, this method is
415
- # useful primarily for listing all agents across projects the caller has
416
- # access to. One can achieve that with a wildcard project collection id "-".
417
- # Refer to [List
418
- # Sub-Collections](https://cloud.google.com/apis/design/design_patterns#list_sub-collections).
419
- #
420
- # @param parent [String]
421
- # Required. The project to list agents from.
422
- # Format: `projects/<Project ID or '-'>`.
423
- # @param page_size [Integer]
424
- # The maximum number of resources contained in the underlying API
425
- # response. If page streaming is performed per-resource, this
426
- # parameter does not affect the return value. If page streaming is
427
- # performed per-page, this determines the maximum number of
428
- # resources in a page.
429
- # @param options [Google::Gax::CallOptions]
430
- # Overrides the default settings for this call, e.g, timeout,
431
- # retries, etc.
432
- # @yield [result, operation] Access the result along with the RPC operation
433
- # @yieldparam result [Google::Gax::PagedEnumerable<Google::Cloud::Dialogflow::V2::Agent>]
434
- # @yieldparam operation [GRPC::ActiveCall::Operation]
435
- # @return [Google::Gax::PagedEnumerable<Google::Cloud::Dialogflow::V2::Agent>]
436
- # An enumerable of Google::Cloud::Dialogflow::V2::Agent instances.
437
- # See Google::Gax::PagedEnumerable documentation for other
438
- # operations such as per-page iteration or access to the response
439
- # object.
440
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
441
- # @example
442
- # require "google/cloud/dialogflow"
443
- #
444
- # agents_client = Google::Cloud::Dialogflow::Agents.new(version: :v2)
445
- # formatted_parent = Google::Cloud::Dialogflow::V2::AgentsClient.project_path("[PROJECT]")
446
- #
447
- # # Iterate over all results.
448
- # agents_client.search_agents(formatted_parent).each do |element|
449
- # # Process element.
450
- # end
451
- #
452
- # # Or iterate over results one page at a time.
453
- # agents_client.search_agents(formatted_parent).each_page do |page|
454
- # # Process each page at a time.
455
- # page.each do |element|
456
- # # Process element.
457
- # end
458
- # end
459
-
460
- def search_agents \
461
- parent,
462
- page_size: nil,
463
- options: nil,
464
- &block
465
- req = {
466
- parent: parent,
467
- page_size: page_size
468
- }.delete_if { |_, v| v.nil? }
469
- req = Google::Gax::to_proto(req, Google::Cloud::Dialogflow::V2::SearchAgentsRequest)
470
- @search_agents.call(req, options, &block)
471
- end
472
-
473
- # Trains the specified agent.
474
- #
475
- # Operation <response: {Google::Protobuf::Empty}>
476
- #
477
- # @param parent [String]
478
- # Required. The project that the agent to train is associated with.
479
- # Format: `projects/<Project ID>`.
480
- # @param options [Google::Gax::CallOptions]
481
- # Overrides the default settings for this call, e.g, timeout,
482
- # retries, etc.
483
- # @return [Google::Gax::Operation]
484
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
485
- # @example
486
- # require "google/cloud/dialogflow"
487
- #
488
- # agents_client = Google::Cloud::Dialogflow::Agents.new(version: :v2)
489
- # formatted_parent = Google::Cloud::Dialogflow::V2::AgentsClient.project_path("[PROJECT]")
490
- #
491
- # # Register a callback during the method call.
492
- # operation = agents_client.train_agent(formatted_parent) do |op|
493
- # raise op.results.message if op.error?
494
- # op_results = op.results
495
- # # Process the results.
496
- #
497
- # metadata = op.metadata
498
- # # Process the metadata.
499
- # end
500
- #
501
- # # Or use the return value to register a callback.
502
- # operation.on_done do |op|
503
- # raise op.results.message if op.error?
504
- # op_results = op.results
505
- # # Process the results.
506
- #
507
- # metadata = op.metadata
508
- # # Process the metadata.
509
- # end
510
- #
511
- # # Manually reload the operation.
512
- # operation.reload!
513
- #
514
- # # Or block until the operation completes, triggering callbacks on
515
- # # completion.
516
- # operation.wait_until_done!
517
-
518
- def train_agent \
519
- parent,
520
- options: nil
521
- req = {
522
- parent: parent
523
- }.delete_if { |_, v| v.nil? }
524
- req = Google::Gax::to_proto(req, Google::Cloud::Dialogflow::V2::TrainAgentRequest)
525
- operation = Google::Gax::Operation.new(
526
- @train_agent.call(req, options),
527
- @operations_client,
528
- Google::Protobuf::Empty,
529
- Google::Protobuf::Struct,
530
- call_options: options
531
- )
532
- operation.on_done { |operation| yield(operation) } if block_given?
533
- operation
534
- end
535
-
536
- # Exports the specified agent to a ZIP file.
537
- #
538
- # Operation <response: {Google::Cloud::Dialogflow::V2::ExportAgentResponse ExportAgentResponse}>
539
- #
540
- # @param parent [String]
541
- # Required. The project that the agent to export is associated with.
542
- # Format: `projects/<Project ID>`.
543
- # @param agent_uri [String]
544
- # Required. The [Google Cloud Storage](https://cloud.google.com/storage/docs/)
545
- # URI to export the agent to.
546
- # The format of this URI must be `gs://<bucket-name>/<object-name>`.
547
- # If left unspecified, the serialized agent is returned inline.
548
- # @param options [Google::Gax::CallOptions]
549
- # Overrides the default settings for this call, e.g, timeout,
550
- # retries, etc.
551
- # @return [Google::Gax::Operation]
552
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
553
- # @example
554
- # require "google/cloud/dialogflow"
555
- #
556
- # agents_client = Google::Cloud::Dialogflow::Agents.new(version: :v2)
557
- # formatted_parent = Google::Cloud::Dialogflow::V2::AgentsClient.project_path("[PROJECT]")
558
- #
559
- # # Register a callback during the method call.
560
- # operation = agents_client.export_agent(formatted_parent) do |op|
561
- # raise op.results.message if op.error?
562
- # op_results = op.results
563
- # # Process the results.
564
- #
565
- # metadata = op.metadata
566
- # # Process the metadata.
567
- # end
568
- #
569
- # # Or use the return value to register a callback.
570
- # operation.on_done do |op|
571
- # raise op.results.message if op.error?
572
- # op_results = op.results
573
- # # Process the results.
574
- #
575
- # metadata = op.metadata
576
- # # Process the metadata.
577
- # end
578
- #
579
- # # Manually reload the operation.
580
- # operation.reload!
581
- #
582
- # # Or block until the operation completes, triggering callbacks on
583
- # # completion.
584
- # operation.wait_until_done!
585
-
586
- def export_agent \
587
- parent,
588
- agent_uri: nil,
589
- options: nil
590
- req = {
591
- parent: parent,
592
- agent_uri: agent_uri
593
- }.delete_if { |_, v| v.nil? }
594
- req = Google::Gax::to_proto(req, Google::Cloud::Dialogflow::V2::ExportAgentRequest)
595
- operation = Google::Gax::Operation.new(
596
- @export_agent.call(req, options),
597
- @operations_client,
598
- Google::Cloud::Dialogflow::V2::ExportAgentResponse,
599
- Google::Protobuf::Struct,
600
- call_options: options
601
- )
602
- operation.on_done { |operation| yield(operation) } if block_given?
603
- operation
604
- end
605
-
606
- # Imports the specified agent from a ZIP file.
607
- #
608
- # Uploads new intents and entity types without deleting the existing ones.
609
- # Intents and entity types with the same name are replaced with the new
610
- # versions from ImportAgentRequest.
611
- #
612
- # Operation <response: {Google::Protobuf::Empty}>
613
- #
614
- # @param parent [String]
615
- # Required. The project that the agent to import is associated with.
616
- # Format: `projects/<Project ID>`.
617
- # @param agent_uri [String]
618
- # The URI to a Google Cloud Storage file containing the agent to import.
619
- # Note: The URI must start with "gs://".
620
- # @param agent_content [String]
621
- # Zip compressed raw byte content for agent.
622
- # @param options [Google::Gax::CallOptions]
623
- # Overrides the default settings for this call, e.g, timeout,
624
- # retries, etc.
625
- # @return [Google::Gax::Operation]
626
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
627
- # @example
628
- # require "google/cloud/dialogflow"
629
- #
630
- # agents_client = Google::Cloud::Dialogflow::Agents.new(version: :v2)
631
- # formatted_parent = Google::Cloud::Dialogflow::V2::AgentsClient.project_path("[PROJECT]")
632
- #
633
- # # Register a callback during the method call.
634
- # operation = agents_client.import_agent(formatted_parent) do |op|
635
- # raise op.results.message if op.error?
636
- # op_results = op.results
637
- # # Process the results.
638
- #
639
- # metadata = op.metadata
640
- # # Process the metadata.
641
- # end
642
- #
643
- # # Or use the return value to register a callback.
644
- # operation.on_done do |op|
645
- # raise op.results.message if op.error?
646
- # op_results = op.results
647
- # # Process the results.
648
- #
649
- # metadata = op.metadata
650
- # # Process the metadata.
651
- # end
652
- #
653
- # # Manually reload the operation.
654
- # operation.reload!
655
- #
656
- # # Or block until the operation completes, triggering callbacks on
657
- # # completion.
658
- # operation.wait_until_done!
659
-
660
- def import_agent \
661
- parent,
662
- agent_uri: nil,
663
- agent_content: nil,
664
- options: nil
665
- req = {
666
- parent: parent,
667
- agent_uri: agent_uri,
668
- agent_content: agent_content
669
- }.delete_if { |_, v| v.nil? }
670
- req = Google::Gax::to_proto(req, Google::Cloud::Dialogflow::V2::ImportAgentRequest)
671
- operation = Google::Gax::Operation.new(
672
- @import_agent.call(req, options),
673
- @operations_client,
674
- Google::Protobuf::Empty,
675
- Google::Protobuf::Struct,
676
- call_options: options
677
- )
678
- operation.on_done { |operation| yield(operation) } if block_given?
679
- operation
680
- end
681
-
682
- # Restores the specified agent from a ZIP file.
683
- #
684
- # Replaces the current agent version with a new one. All the intents and
685
- # entity types in the older version are deleted.
686
- #
687
- # Operation <response: {Google::Protobuf::Empty}>
688
- #
689
- # @param parent [String]
690
- # Required. The project that the agent to restore is associated with.
691
- # Format: `projects/<Project ID>`.
692
- # @param agent_uri [String]
693
- # The URI to a Google Cloud Storage file containing the agent to restore.
694
- # Note: The URI must start with "gs://".
695
- # @param agent_content [String]
696
- # Zip compressed raw byte content for agent.
697
- # @param options [Google::Gax::CallOptions]
698
- # Overrides the default settings for this call, e.g, timeout,
699
- # retries, etc.
700
- # @return [Google::Gax::Operation]
701
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
702
- # @example
703
- # require "google/cloud/dialogflow"
704
- #
705
- # agents_client = Google::Cloud::Dialogflow::Agents.new(version: :v2)
706
- # formatted_parent = Google::Cloud::Dialogflow::V2::AgentsClient.project_path("[PROJECT]")
707
- #
708
- # # Register a callback during the method call.
709
- # operation = agents_client.restore_agent(formatted_parent) do |op|
710
- # raise op.results.message if op.error?
711
- # op_results = op.results
712
- # # Process the results.
713
- #
714
- # metadata = op.metadata
715
- # # Process the metadata.
716
- # end
717
- #
718
- # # Or use the return value to register a callback.
719
- # operation.on_done do |op|
720
- # raise op.results.message if op.error?
721
- # op_results = op.results
722
- # # Process the results.
723
- #
724
- # metadata = op.metadata
725
- # # Process the metadata.
726
- # end
727
- #
728
- # # Manually reload the operation.
729
- # operation.reload!
730
- #
731
- # # Or block until the operation completes, triggering callbacks on
732
- # # completion.
733
- # operation.wait_until_done!
734
-
735
- def restore_agent \
736
- parent,
737
- agent_uri: nil,
738
- agent_content: nil,
739
- options: nil
740
- req = {
741
- parent: parent,
742
- agent_uri: agent_uri,
743
- agent_content: agent_content
744
- }.delete_if { |_, v| v.nil? }
745
- req = Google::Gax::to_proto(req, Google::Cloud::Dialogflow::V2::RestoreAgentRequest)
746
- operation = Google::Gax::Operation.new(
747
- @restore_agent.call(req, options),
748
- @operations_client,
749
- Google::Protobuf::Empty,
750
- Google::Protobuf::Struct,
751
- call_options: options
752
- )
753
- operation.on_done { |operation| yield(operation) } if block_given?
754
- operation
755
- end
756
- end
757
- end
758
- end
759
- end
760
- end