google-cloud-dialogflow 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 (45) hide show
  1. checksums.yaml +7 -0
  2. data/.yardopts +8 -0
  3. data/LICENSE +201 -0
  4. data/README.md +32 -0
  5. data/lib/google/cloud/dialogflow.rb +452 -0
  6. data/lib/google/cloud/dialogflow/credentials.rb +30 -0
  7. data/lib/google/cloud/dialogflow/v2.rb +454 -0
  8. data/lib/google/cloud/dialogflow/v2/agent_pb.rb +87 -0
  9. data/lib/google/cloud/dialogflow/v2/agent_services_pb.rb +104 -0
  10. data/lib/google/cloud/dialogflow/v2/agents_client.rb +639 -0
  11. data/lib/google/cloud/dialogflow/v2/agents_client_config.json +56 -0
  12. data/lib/google/cloud/dialogflow/v2/context_pb.rb +59 -0
  13. data/lib/google/cloud/dialogflow/v2/context_services_pb.rb +71 -0
  14. data/lib/google/cloud/dialogflow/v2/contexts_client.rb +445 -0
  15. data/lib/google/cloud/dialogflow/v2/contexts_client_config.json +56 -0
  16. data/lib/google/cloud/dialogflow/v2/doc/google/cloud/dialogflow/v2/agent.rb +223 -0
  17. data/lib/google/cloud/dialogflow/v2/doc/google/cloud/dialogflow/v2/context.rb +115 -0
  18. data/lib/google/cloud/dialogflow/v2/doc/google/cloud/dialogflow/v2/entity_type.rb +290 -0
  19. data/lib/google/cloud/dialogflow/v2/doc/google/cloud/dialogflow/v2/intent.rb +714 -0
  20. data/lib/google/cloud/dialogflow/v2/doc/google/cloud/dialogflow/v2/session.rb +451 -0
  21. data/lib/google/cloud/dialogflow/v2/doc/google/cloud/dialogflow/v2/session_entity_type.rb +134 -0
  22. data/lib/google/cloud/dialogflow/v2/doc/google/protobuf/any.rb +124 -0
  23. data/lib/google/cloud/dialogflow/v2/doc/google/protobuf/field_mask.rb +223 -0
  24. data/lib/google/cloud/dialogflow/v2/doc/google/protobuf/struct.rb +73 -0
  25. data/lib/google/cloud/dialogflow/v2/doc/google/rpc/status.rb +83 -0
  26. data/lib/google/cloud/dialogflow/v2/doc/google/type/latlng.rb +64 -0
  27. data/lib/google/cloud/dialogflow/v2/doc/overview.rb +55 -0
  28. data/lib/google/cloud/dialogflow/v2/entity_type_pb.rb +120 -0
  29. data/lib/google/cloud/dialogflow/v2/entity_type_services_pb.rb +105 -0
  30. data/lib/google/cloud/dialogflow/v2/entity_types_client.rb +900 -0
  31. data/lib/google/cloud/dialogflow/v2/entity_types_client_config.json +76 -0
  32. data/lib/google/cloud/dialogflow/v2/intent_pb.rb +274 -0
  33. data/lib/google/cloud/dialogflow/v2/intent_services_pb.rb +91 -0
  34. data/lib/google/cloud/dialogflow/v2/intents_client.rb +684 -0
  35. data/lib/google/cloud/dialogflow/v2/intents_client_config.json +61 -0
  36. data/lib/google/cloud/dialogflow/v2/session_entity_type_pb.rb +61 -0
  37. data/lib/google/cloud/dialogflow/v2/session_entity_type_services_pb.rb +64 -0
  38. data/lib/google/cloud/dialogflow/v2/session_entity_types_client.rb +413 -0
  39. data/lib/google/cloud/dialogflow/v2/session_entity_types_client_config.json +51 -0
  40. data/lib/google/cloud/dialogflow/v2/session_pb.rb +127 -0
  41. data/lib/google/cloud/dialogflow/v2/session_services_pb.rb +55 -0
  42. data/lib/google/cloud/dialogflow/v2/sessions_client.rb +286 -0
  43. data/lib/google/cloud/dialogflow/v2/sessions_client_config.json +36 -0
  44. data/lib/google/cloud/dialogflow/v2/webhook_pb.rb +42 -0
  45. metadata +142 -0
@@ -0,0 +1,64 @@
1
+ # Copyright 2018 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
+ module Google
16
+ module Type
17
+ # An object representing a latitude/longitude pair. This is expressed as a pair
18
+ # of doubles representing degrees latitude and degrees longitude. Unless
19
+ # specified otherwise, this must conform to the
20
+ # <a href="http://www.unoosa.org/pdf/icg/2012/template/WGS_84.pdf">WGS84
21
+ # standard</a>. Values must be within normalized ranges.
22
+ #
23
+ # Example of normalization code in Python:
24
+ #
25
+ # def NormalizeLongitude(longitude):
26
+ # """Wraps decimal degrees longitude to [-180.0, 180.0]."""
27
+ # q, r = divmod(longitude, 360.0)
28
+ # if r > 180.0 or (r == 180.0 and q <= -1.0):
29
+ # return r - 360.0
30
+ # return r
31
+ #
32
+ # def NormalizeLatLng(latitude, longitude):
33
+ # """Wraps decimal degrees latitude and longitude to
34
+ # [-90.0, 90.0] and [-180.0, 180.0], respectively."""
35
+ # r = latitude % 360.0
36
+ # if r <= 90.0:
37
+ # return r, NormalizeLongitude(longitude)
38
+ # elif r >= 270.0:
39
+ # return r - 360, NormalizeLongitude(longitude)
40
+ # else:
41
+ # return 180 - r, NormalizeLongitude(longitude + 180.0)
42
+ #
43
+ # assert 180.0 == NormalizeLongitude(180.0)
44
+ # assert -180.0 == NormalizeLongitude(-180.0)
45
+ # assert -179.0 == NormalizeLongitude(181.0)
46
+ # assert (0.0, 0.0) == NormalizeLatLng(360.0, 0.0)
47
+ # assert (0.0, 0.0) == NormalizeLatLng(-360.0, 0.0)
48
+ # assert (85.0, 180.0) == NormalizeLatLng(95.0, 0.0)
49
+ # assert (-85.0, -170.0) == NormalizeLatLng(-95.0, 10.0)
50
+ # assert (90.0, 10.0) == NormalizeLatLng(90.0, 10.0)
51
+ # assert (-90.0, -10.0) == NormalizeLatLng(-90.0, -10.0)
52
+ # assert (0.0, -170.0) == NormalizeLatLng(-180.0, 10.0)
53
+ # assert (0.0, -170.0) == NormalizeLatLng(180.0, 10.0)
54
+ # assert (-90.0, 10.0) == NormalizeLatLng(270.0, 10.0)
55
+ # assert (90.0, 10.0) == NormalizeLatLng(-270.0, 10.0)
56
+ # @!attribute [rw] latitude
57
+ # @return [Float]
58
+ # The latitude in degrees. It must be in the range [-90.0, +90.0].
59
+ # @!attribute [rw] longitude
60
+ # @return [Float]
61
+ # The longitude in degrees. It must be in the range [-180.0, +180.0].
62
+ class LatLng; end
63
+ end
64
+ end
@@ -0,0 +1,55 @@
1
+ # Copyright 2018 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
+ module Google
16
+ module Cloud
17
+ # rubocop:disable LineLength
18
+
19
+ ##
20
+ # # Ruby Client for Dialogflow API ([Alpha](https://github.com/GoogleCloudPlatform/google-cloud-ruby#versioning))
21
+ #
22
+ # [Dialogflow API][Product Documentation]:
23
+ # An end-to-end development suite for conversational interfaces (e.g.,
24
+ # chatbots, voice-powered apps and devices).
25
+ # - [Product Documentation][]
26
+ #
27
+ # ## Quick Start
28
+ # In order to use this library, you first need to go through the following
29
+ # steps:
30
+ #
31
+ # 1. [Select or create a Cloud Platform project.](https://console.cloud.google.com/project)
32
+ # 2. [Enable billing for your project.](https://cloud.google.com/billing/docs/how-to/modify-project#enable_billing_for_a_project)
33
+ # 3. [Enable the Dialogflow API.](https://console.cloud.google.com/apis/api/dialogflow)
34
+ # 4. [Setup Authentication.](https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/google-cloud/master/guides/authentication)
35
+ #
36
+ # ### Installation
37
+ # ```
38
+ # $ gem install google-cloud-dialogflow
39
+ # ```
40
+ #
41
+ # ### Next Steps
42
+ # - Read the [Dialogflow API Product documentation][Product Documentation]
43
+ # to learn more about the product and see How-to Guides.
44
+ # - View this [repository's main README](https://github.com/GoogleCloudPlatform/google-cloud-ruby/blob/master/README.md)
45
+ # to see the full list of Cloud APIs that we cover.
46
+ #
47
+ # [Product Documentation]: https://cloud.google.com/dialogflow
48
+ #
49
+ #
50
+ module Dialogflow
51
+ module V2
52
+ end
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,120 @@
1
+ # Generated by the protocol buffer compiler. DO NOT EDIT!
2
+ # source: google/cloud/dialogflow/v2/entity_type.proto
3
+
4
+ require 'google/protobuf'
5
+
6
+ require 'google/api/annotations_pb'
7
+ require 'google/longrunning/operations_pb'
8
+ require 'google/protobuf/empty_pb'
9
+ require 'google/protobuf/field_mask_pb'
10
+ require 'google/protobuf/struct_pb'
11
+ Google::Protobuf::DescriptorPool.generated_pool.build do
12
+ add_message "google.cloud.dialogflow.v2.EntityType" do
13
+ optional :name, :string, 1
14
+ optional :display_name, :string, 2
15
+ optional :kind, :enum, 3, "google.cloud.dialogflow.v2.EntityType.Kind"
16
+ optional :auto_expansion_mode, :enum, 4, "google.cloud.dialogflow.v2.EntityType.AutoExpansionMode"
17
+ repeated :entities, :message, 6, "google.cloud.dialogflow.v2.EntityType.Entity"
18
+ end
19
+ add_message "google.cloud.dialogflow.v2.EntityType.Entity" do
20
+ optional :value, :string, 1
21
+ repeated :synonyms, :string, 2
22
+ end
23
+ add_enum "google.cloud.dialogflow.v2.EntityType.Kind" do
24
+ value :KIND_UNSPECIFIED, 0
25
+ value :KIND_MAP, 1
26
+ value :KIND_LIST, 2
27
+ end
28
+ add_enum "google.cloud.dialogflow.v2.EntityType.AutoExpansionMode" do
29
+ value :AUTO_EXPANSION_MODE_UNSPECIFIED, 0
30
+ value :AUTO_EXPANSION_MODE_DEFAULT, 1
31
+ end
32
+ add_message "google.cloud.dialogflow.v2.ListEntityTypesRequest" do
33
+ optional :parent, :string, 1
34
+ optional :language_code, :string, 2
35
+ optional :page_size, :int32, 3
36
+ optional :page_token, :string, 4
37
+ end
38
+ add_message "google.cloud.dialogflow.v2.ListEntityTypesResponse" do
39
+ repeated :entity_types, :message, 1, "google.cloud.dialogflow.v2.EntityType"
40
+ optional :next_page_token, :string, 2
41
+ end
42
+ add_message "google.cloud.dialogflow.v2.GetEntityTypeRequest" do
43
+ optional :name, :string, 1
44
+ optional :language_code, :string, 2
45
+ end
46
+ add_message "google.cloud.dialogflow.v2.CreateEntityTypeRequest" do
47
+ optional :parent, :string, 1
48
+ optional :entity_type, :message, 2, "google.cloud.dialogflow.v2.EntityType"
49
+ optional :language_code, :string, 3
50
+ end
51
+ add_message "google.cloud.dialogflow.v2.UpdateEntityTypeRequest" do
52
+ optional :entity_type, :message, 1, "google.cloud.dialogflow.v2.EntityType"
53
+ optional :language_code, :string, 2
54
+ optional :update_mask, :message, 3, "google.protobuf.FieldMask"
55
+ end
56
+ add_message "google.cloud.dialogflow.v2.DeleteEntityTypeRequest" do
57
+ optional :name, :string, 1
58
+ end
59
+ add_message "google.cloud.dialogflow.v2.BatchUpdateEntityTypesRequest" do
60
+ optional :parent, :string, 1
61
+ optional :language_code, :string, 4
62
+ optional :update_mask, :message, 5, "google.protobuf.FieldMask"
63
+ oneof :entity_type_batch do
64
+ optional :entity_type_batch_uri, :string, 2
65
+ optional :entity_type_batch_inline, :message, 3, "google.cloud.dialogflow.v2.EntityTypeBatch"
66
+ end
67
+ end
68
+ add_message "google.cloud.dialogflow.v2.BatchUpdateEntityTypesResponse" do
69
+ repeated :entity_types, :message, 1, "google.cloud.dialogflow.v2.EntityType"
70
+ end
71
+ add_message "google.cloud.dialogflow.v2.BatchDeleteEntityTypesRequest" do
72
+ optional :parent, :string, 1
73
+ repeated :entity_type_names, :string, 2
74
+ end
75
+ add_message "google.cloud.dialogflow.v2.BatchCreateEntitiesRequest" do
76
+ optional :parent, :string, 1
77
+ repeated :entities, :message, 2, "google.cloud.dialogflow.v2.EntityType.Entity"
78
+ optional :language_code, :string, 3
79
+ end
80
+ add_message "google.cloud.dialogflow.v2.BatchUpdateEntitiesRequest" do
81
+ optional :parent, :string, 1
82
+ repeated :entities, :message, 2, "google.cloud.dialogflow.v2.EntityType.Entity"
83
+ optional :language_code, :string, 3
84
+ optional :update_mask, :message, 4, "google.protobuf.FieldMask"
85
+ end
86
+ add_message "google.cloud.dialogflow.v2.BatchDeleteEntitiesRequest" do
87
+ optional :parent, :string, 1
88
+ repeated :entity_values, :string, 2
89
+ optional :language_code, :string, 3
90
+ end
91
+ add_message "google.cloud.dialogflow.v2.EntityTypeBatch" do
92
+ repeated :entity_types, :message, 1, "google.cloud.dialogflow.v2.EntityType"
93
+ end
94
+ end
95
+
96
+ module Google
97
+ module Cloud
98
+ module Dialogflow
99
+ module V2
100
+ EntityType = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.EntityType").msgclass
101
+ EntityType::Entity = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.EntityType.Entity").msgclass
102
+ EntityType::Kind = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.EntityType.Kind").enummodule
103
+ EntityType::AutoExpansionMode = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.EntityType.AutoExpansionMode").enummodule
104
+ ListEntityTypesRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.ListEntityTypesRequest").msgclass
105
+ ListEntityTypesResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.ListEntityTypesResponse").msgclass
106
+ GetEntityTypeRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.GetEntityTypeRequest").msgclass
107
+ CreateEntityTypeRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.CreateEntityTypeRequest").msgclass
108
+ UpdateEntityTypeRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.UpdateEntityTypeRequest").msgclass
109
+ DeleteEntityTypeRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.DeleteEntityTypeRequest").msgclass
110
+ BatchUpdateEntityTypesRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.BatchUpdateEntityTypesRequest").msgclass
111
+ BatchUpdateEntityTypesResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.BatchUpdateEntityTypesResponse").msgclass
112
+ BatchDeleteEntityTypesRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.BatchDeleteEntityTypesRequest").msgclass
113
+ BatchCreateEntitiesRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.BatchCreateEntitiesRequest").msgclass
114
+ BatchUpdateEntitiesRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.BatchUpdateEntitiesRequest").msgclass
115
+ BatchDeleteEntitiesRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.BatchDeleteEntitiesRequest").msgclass
116
+ EntityTypeBatch = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.EntityTypeBatch").msgclass
117
+ end
118
+ end
119
+ end
120
+ end
@@ -0,0 +1,105 @@
1
+ # Generated by the protocol buffer compiler. DO NOT EDIT!
2
+ # Source: google/cloud/dialogflow/v2/entity_type.proto for package 'google.cloud.dialogflow.v2'
3
+ # Original file comments:
4
+ # Copyright 2018 Google Inc.
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/entity_type_pb'
21
+
22
+ module Google
23
+ module Cloud
24
+ module Dialogflow
25
+ module V2
26
+ module EntityTypes
27
+ # Entities are extracted from user input and represent parameters that are
28
+ # meaningful to your application. For example, a date range, a proper name
29
+ # such as a geographic location or landmark, and so on. Entities represent
30
+ # actionable data for your application.
31
+ #
32
+ # When you define an entity, you can also include synonyms that all map to
33
+ # that entity. For example, "soft drink", "soda", "pop", and so on.
34
+ #
35
+ # There are three types of entities:
36
+ #
37
+ # * **System** - entities that are defined by the Dialogflow API for common
38
+ # data types such as date, time, currency, and so on. A system entity is
39
+ # represented by the `EntityType` type.
40
+ #
41
+ # * **Developer** - entities that are defined by you that represent
42
+ # actionable data that is meaningful to your application. For example,
43
+ # you could define a `pizza.sauce` entity for red or white pizza sauce,
44
+ # a `pizza.cheese` entity for the different types of cheese on a pizza,
45
+ # a `pizza.topping` entity for different toppings, and so on. A developer
46
+ # entity is represented by the `EntityType` type.
47
+ #
48
+ # * **User** - entities that are built for an individual user such as
49
+ # favorites, preferences, playlists, and so on. A user entity is
50
+ # represented by the [SessionEntityType][google.cloud.dialogflow.v2.SessionEntityType] type.
51
+ #
52
+ # For more information about entity types, see the
53
+ # [Dialogflow documentation](https://dialogflow.com/docs/entities).
54
+ class Service
55
+
56
+ include GRPC::GenericService
57
+
58
+ self.marshal_class_method = :encode
59
+ self.unmarshal_class_method = :decode
60
+ self.service_name = 'google.cloud.dialogflow.v2.EntityTypes'
61
+
62
+ # Returns the list of all entity types in the specified agent.
63
+ rpc :ListEntityTypes, ListEntityTypesRequest, ListEntityTypesResponse
64
+ # Retrieves the specified entity type.
65
+ rpc :GetEntityType, GetEntityTypeRequest, EntityType
66
+ # Creates an entity type in the specified agent.
67
+ rpc :CreateEntityType, CreateEntityTypeRequest, EntityType
68
+ # Updates the specified entity type.
69
+ rpc :UpdateEntityType, UpdateEntityTypeRequest, EntityType
70
+ # Deletes the specified entity type.
71
+ rpc :DeleteEntityType, DeleteEntityTypeRequest, Google::Protobuf::Empty
72
+ # Updates/Creates multiple entity types in the specified agent.
73
+ #
74
+ # Operation <response: [BatchUpdateEntityTypesResponse][google.cloud.dialogflow.v2.BatchUpdateEntityTypesResponse],
75
+ # metadata: [google.protobuf.Struct][google.protobuf.Struct]>
76
+ rpc :BatchUpdateEntityTypes, BatchUpdateEntityTypesRequest, Google::Longrunning::Operation
77
+ # Deletes entity types in the specified agent.
78
+ #
79
+ # Operation <response: [google.protobuf.Empty][google.protobuf.Empty],
80
+ # metadata: [google.protobuf.Struct][google.protobuf.Struct]>
81
+ rpc :BatchDeleteEntityTypes, BatchDeleteEntityTypesRequest, Google::Longrunning::Operation
82
+ # Creates multiple new entities in the specified entity type (extends the
83
+ # existing collection of entries).
84
+ #
85
+ # Operation <response: [google.protobuf.Empty][google.protobuf.Empty]>
86
+ rpc :BatchCreateEntities, BatchCreateEntitiesRequest, Google::Longrunning::Operation
87
+ # Updates entities in the specified entity type (replaces the existing
88
+ # collection of entries).
89
+ #
90
+ # Operation <response: [google.protobuf.Empty][google.protobuf.Empty],
91
+ # metadata: [google.protobuf.Struct][google.protobuf.Struct]>
92
+ rpc :BatchUpdateEntities, BatchUpdateEntitiesRequest, Google::Longrunning::Operation
93
+ # Deletes entities in the specified entity type.
94
+ #
95
+ # Operation <response: [google.protobuf.Empty][google.protobuf.Empty],
96
+ # metadata: [google.protobuf.Struct][google.protobuf.Struct]>
97
+ rpc :BatchDeleteEntities, BatchDeleteEntitiesRequest, Google::Longrunning::Operation
98
+ end
99
+
100
+ Stub = Service.rpc_stub_class
101
+ end
102
+ end
103
+ end
104
+ end
105
+ end
@@ -0,0 +1,900 @@
1
+ # Copyright 2018 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/entity_type.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
+ require "json"
23
+ require "pathname"
24
+
25
+ require "google/gax"
26
+ require "google/gax/operation"
27
+ require "google/longrunning/operations_client"
28
+
29
+ require "google/cloud/dialogflow/v2/entity_type_pb"
30
+ require "google/cloud/dialogflow/credentials"
31
+
32
+ module Google
33
+ module Cloud
34
+ module Dialogflow
35
+ module V2
36
+ # Entities are extracted from user input and represent parameters that are
37
+ # meaningful to your application. For example, a date range, a proper name
38
+ # such as a geographic location or landmark, and so on. Entities represent
39
+ # actionable data for your application.
40
+ #
41
+ # When you define an entity, you can also include synonyms that all map to
42
+ # that entity. For example, "soft drink", "soda", "pop", and so on.
43
+ #
44
+ # There are three types of entities:
45
+ #
46
+ # * **System** - entities that are defined by the Dialogflow API for common
47
+ # data types such as date, time, currency, and so on. A system entity is
48
+ # represented by the +EntityType+ type.
49
+ #
50
+ # * **Developer** - entities that are defined by you that represent
51
+ # actionable data that is meaningful to your application. For example,
52
+ # you could define a +pizza.sauce+ entity for red or white pizza sauce,
53
+ # a +pizza.cheese+ entity for the different types of cheese on a pizza,
54
+ # a +pizza.topping+ entity for different toppings, and so on. A developer
55
+ # entity is represented by the +EntityType+ type.
56
+ #
57
+ # * **User** - entities that are built for an individual user such as
58
+ # favorites, preferences, playlists, and so on. A user entity is
59
+ # represented by the {Google::Cloud::Dialogflow::V2::SessionEntityType SessionEntityType} type.
60
+ #
61
+ # For more information about entity types, see the
62
+ # [Dialogflow documentation](https://dialogflow.com/docs/entities).
63
+ #
64
+ # @!attribute [r] entity_types_stub
65
+ # @return [Google::Cloud::Dialogflow::V2::EntityTypes::Stub]
66
+ class EntityTypesClient
67
+ attr_reader :entity_types_stub
68
+
69
+ # The default address of the service.
70
+ SERVICE_ADDRESS = "dialogflow.googleapis.com".freeze
71
+
72
+ # The default port of the service.
73
+ DEFAULT_SERVICE_PORT = 443
74
+
75
+ DEFAULT_TIMEOUT = 30
76
+
77
+ PAGE_DESCRIPTORS = {
78
+ "list_entity_types" => Google::Gax::PageDescriptor.new(
79
+ "page_token",
80
+ "next_page_token",
81
+ "entity_types")
82
+ }.freeze
83
+
84
+ private_constant :PAGE_DESCRIPTORS
85
+
86
+ # The scopes needed to make gRPC calls to all of the methods defined in
87
+ # this service.
88
+ ALL_SCOPES = [
89
+ "https://www.googleapis.com/auth/cloud-platform"
90
+ ].freeze
91
+
92
+ class OperationsClient < Google::Longrunning::OperationsClient
93
+ self::SERVICE_ADDRESS = EntityTypesClient::SERVICE_ADDRESS
94
+ end
95
+
96
+ PROJECT_AGENT_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
97
+ "projects/{project}/agent"
98
+ )
99
+
100
+ private_constant :PROJECT_AGENT_PATH_TEMPLATE
101
+
102
+ ENTITY_TYPE_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
103
+ "projects/{project}/agent/entityTypes/{entity_type}"
104
+ )
105
+
106
+ private_constant :ENTITY_TYPE_PATH_TEMPLATE
107
+
108
+ # Returns a fully-qualified project_agent resource name string.
109
+ # @param project [String]
110
+ # @return [String]
111
+ def self.project_agent_path project
112
+ PROJECT_AGENT_PATH_TEMPLATE.render(
113
+ :"project" => project
114
+ )
115
+ end
116
+
117
+ # Returns a fully-qualified entity_type resource name string.
118
+ # @param project [String]
119
+ # @param entity_type [String]
120
+ # @return [String]
121
+ def self.entity_type_path project, entity_type
122
+ ENTITY_TYPE_PATH_TEMPLATE.render(
123
+ :"project" => project,
124
+ :"entity_type" => entity_type
125
+ )
126
+ end
127
+
128
+ # @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc]
129
+ # Provides the means for authenticating requests made by the client. This parameter can
130
+ # be many types.
131
+ # A `Google::Auth::Credentials` uses a the properties of its represented keyfile for
132
+ # authenticating requests made by this client.
133
+ # A `String` will be treated as the path to the keyfile to be used for the construction of
134
+ # credentials for this client.
135
+ # A `Hash` will be treated as the contents of a keyfile to be used for the construction of
136
+ # credentials for this client.
137
+ # A `GRPC::Core::Channel` will be used to make calls through.
138
+ # A `GRPC::Core::ChannelCredentials` for the setting up the RPC client. The channel credentials
139
+ # should already be composed with a `GRPC::Core::CallCredentials` object.
140
+ # A `Proc` will be used as an updater_proc for the Grpc channel. The proc transforms the
141
+ # metadata for requests, generally, to give OAuth credentials.
142
+ # @param scopes [Array<String>]
143
+ # The OAuth scopes for this service. This parameter is ignored if
144
+ # an updater_proc is supplied.
145
+ # @param client_config [Hash]
146
+ # A Hash for call options for each method. See
147
+ # Google::Gax#construct_settings for the structure of
148
+ # this data. Falls back to the default config if not specified
149
+ # or the specified config is missing data points.
150
+ # @param timeout [Numeric]
151
+ # The default timeout, in seconds, for calls made through this client.
152
+ def initialize \
153
+ credentials: nil,
154
+ scopes: ALL_SCOPES,
155
+ client_config: {},
156
+ timeout: DEFAULT_TIMEOUT,
157
+ lib_name: nil,
158
+ lib_version: ""
159
+ # These require statements are intentionally placed here to initialize
160
+ # the gRPC module only when it's required.
161
+ # See https://github.com/googleapis/toolkit/issues/446
162
+ require "google/gax/grpc"
163
+ require "google/cloud/dialogflow/v2/entity_type_services_pb"
164
+
165
+ credentials ||= Google::Cloud::Dialogflow::Credentials.default
166
+
167
+ @operations_client = OperationsClient.new(
168
+ credentials: credentials,
169
+ scopes: scopes,
170
+ client_config: client_config,
171
+ timeout: timeout,
172
+ lib_name: lib_name,
173
+ lib_version: lib_version,
174
+ )
175
+
176
+ if credentials.is_a?(String) || credentials.is_a?(Hash)
177
+ updater_proc = Google::Cloud::Dialogflow::Credentials.new(credentials).updater_proc
178
+ end
179
+ if credentials.is_a?(GRPC::Core::Channel)
180
+ channel = credentials
181
+ end
182
+ if credentials.is_a?(GRPC::Core::ChannelCredentials)
183
+ chan_creds = credentials
184
+ end
185
+ if credentials.is_a?(Proc)
186
+ updater_proc = credentials
187
+ end
188
+ if credentials.is_a?(Google::Auth::Credentials)
189
+ updater_proc = credentials.updater_proc
190
+ end
191
+
192
+ package_version = Gem.loaded_specs['google-cloud-dialogflow'].version.version
193
+
194
+ google_api_client = "gl-ruby/#{RUBY_VERSION}"
195
+ google_api_client << " #{lib_name}/#{lib_version}" if lib_name
196
+ google_api_client << " gapic/#{package_version} gax/#{Google::Gax::VERSION}"
197
+ google_api_client << " grpc/#{GRPC::VERSION}"
198
+ google_api_client.freeze
199
+
200
+ headers = { :"x-goog-api-client" => google_api_client }
201
+ client_config_file = Pathname.new(__dir__).join(
202
+ "entity_types_client_config.json"
203
+ )
204
+ defaults = client_config_file.open do |f|
205
+ Google::Gax.construct_settings(
206
+ "google.cloud.dialogflow.v2.EntityTypes",
207
+ JSON.parse(f.read),
208
+ client_config,
209
+ Google::Gax::Grpc::STATUS_CODE_NAMES,
210
+ timeout,
211
+ page_descriptors: PAGE_DESCRIPTORS,
212
+ errors: Google::Gax::Grpc::API_ERRORS,
213
+ kwargs: headers
214
+ )
215
+ end
216
+
217
+ # Allow overriding the service path/port in subclasses.
218
+ service_path = self.class::SERVICE_ADDRESS
219
+ port = self.class::DEFAULT_SERVICE_PORT
220
+ @entity_types_stub = Google::Gax::Grpc.create_stub(
221
+ service_path,
222
+ port,
223
+ chan_creds: chan_creds,
224
+ channel: channel,
225
+ updater_proc: updater_proc,
226
+ scopes: scopes,
227
+ &Google::Cloud::Dialogflow::V2::EntityTypes::Stub.method(:new)
228
+ )
229
+
230
+ @list_entity_types = Google::Gax.create_api_call(
231
+ @entity_types_stub.method(:list_entity_types),
232
+ defaults["list_entity_types"]
233
+ )
234
+ @get_entity_type = Google::Gax.create_api_call(
235
+ @entity_types_stub.method(:get_entity_type),
236
+ defaults["get_entity_type"]
237
+ )
238
+ @create_entity_type = Google::Gax.create_api_call(
239
+ @entity_types_stub.method(:create_entity_type),
240
+ defaults["create_entity_type"]
241
+ )
242
+ @update_entity_type = Google::Gax.create_api_call(
243
+ @entity_types_stub.method(:update_entity_type),
244
+ defaults["update_entity_type"]
245
+ )
246
+ @delete_entity_type = Google::Gax.create_api_call(
247
+ @entity_types_stub.method(:delete_entity_type),
248
+ defaults["delete_entity_type"]
249
+ )
250
+ @batch_update_entity_types = Google::Gax.create_api_call(
251
+ @entity_types_stub.method(:batch_update_entity_types),
252
+ defaults["batch_update_entity_types"]
253
+ )
254
+ @batch_delete_entity_types = Google::Gax.create_api_call(
255
+ @entity_types_stub.method(:batch_delete_entity_types),
256
+ defaults["batch_delete_entity_types"]
257
+ )
258
+ @batch_create_entities = Google::Gax.create_api_call(
259
+ @entity_types_stub.method(:batch_create_entities),
260
+ defaults["batch_create_entities"]
261
+ )
262
+ @batch_update_entities = Google::Gax.create_api_call(
263
+ @entity_types_stub.method(:batch_update_entities),
264
+ defaults["batch_update_entities"]
265
+ )
266
+ @batch_delete_entities = Google::Gax.create_api_call(
267
+ @entity_types_stub.method(:batch_delete_entities),
268
+ defaults["batch_delete_entities"]
269
+ )
270
+ end
271
+
272
+ # Service calls
273
+
274
+ # Returns the list of all entity types in the specified agent.
275
+ #
276
+ # @param parent [String]
277
+ # Required. The agent to list all entity types from.
278
+ # Format: +projects/<Project ID>/agent+.
279
+ # @param language_code [String]
280
+ # Optional. The language to list entity synonyms for. If not specified,
281
+ # the agent's default language is used.
282
+ # [More than a dozen
283
+ # languages](https://dialogflow.com/docs/reference/language) are supported.
284
+ # Note: languages must be enabled in the agent, before they can be used.
285
+ # @param page_size [Integer]
286
+ # The maximum number of resources contained in the underlying API
287
+ # response. If page streaming is performed per-resource, this
288
+ # parameter does not affect the return value. If page streaming is
289
+ # performed per-page, this determines the maximum number of
290
+ # resources in a page.
291
+ # @param options [Google::Gax::CallOptions]
292
+ # Overrides the default settings for this call, e.g, timeout,
293
+ # retries, etc.
294
+ # @return [Google::Gax::PagedEnumerable<Google::Cloud::Dialogflow::V2::EntityType>]
295
+ # An enumerable of Google::Cloud::Dialogflow::V2::EntityType instances.
296
+ # See Google::Gax::PagedEnumerable documentation for other
297
+ # operations such as per-page iteration or access to the response
298
+ # object.
299
+ # @raise [Google::Gax::GaxError] if the RPC is aborted.
300
+ # @example
301
+ # require "google/cloud/dialogflow/v2"
302
+ #
303
+ # entity_types_client = Google::Cloud::Dialogflow::V2::EntityTypes.new
304
+ # formatted_parent = Google::Cloud::Dialogflow::V2::EntityTypesClient.project_agent_path("[PROJECT]")
305
+ #
306
+ # # Iterate over all results.
307
+ # entity_types_client.list_entity_types(formatted_parent).each do |element|
308
+ # # Process element.
309
+ # end
310
+ #
311
+ # # Or iterate over results one page at a time.
312
+ # entity_types_client.list_entity_types(formatted_parent).each_page do |page|
313
+ # # Process each page at a time.
314
+ # page.each do |element|
315
+ # # Process element.
316
+ # end
317
+ # end
318
+
319
+ def list_entity_types \
320
+ parent,
321
+ language_code: nil,
322
+ page_size: nil,
323
+ options: nil
324
+ req = {
325
+ parent: parent,
326
+ language_code: language_code,
327
+ page_size: page_size
328
+ }.delete_if { |_, v| v.nil? }
329
+ req = Google::Gax::to_proto(req, Google::Cloud::Dialogflow::V2::ListEntityTypesRequest)
330
+ @list_entity_types.call(req, options)
331
+ end
332
+
333
+ # Retrieves the specified entity type.
334
+ #
335
+ # @param name [String]
336
+ # Required. The name of the entity type.
337
+ # Format: +projects/<Project ID>/agent/entityTypes/<EntityType ID>+.
338
+ # @param language_code [String]
339
+ # Optional. The language to retrieve entity synonyms for. If not specified,
340
+ # the agent's default language is used.
341
+ # [More than a dozen
342
+ # languages](https://dialogflow.com/docs/reference/language) are supported.
343
+ # Note: languages must be enabled in the agent, before they can be used.
344
+ # @param options [Google::Gax::CallOptions]
345
+ # Overrides the default settings for this call, e.g, timeout,
346
+ # retries, etc.
347
+ # @return [Google::Cloud::Dialogflow::V2::EntityType]
348
+ # @raise [Google::Gax::GaxError] if the RPC is aborted.
349
+ # @example
350
+ # require "google/cloud/dialogflow/v2"
351
+ #
352
+ # entity_types_client = Google::Cloud::Dialogflow::V2::EntityTypes.new
353
+ # formatted_name = Google::Cloud::Dialogflow::V2::EntityTypesClient.entity_type_path("[PROJECT]", "[ENTITY_TYPE]")
354
+ # response = entity_types_client.get_entity_type(formatted_name)
355
+
356
+ def get_entity_type \
357
+ name,
358
+ language_code: nil,
359
+ options: nil
360
+ req = {
361
+ name: name,
362
+ language_code: language_code
363
+ }.delete_if { |_, v| v.nil? }
364
+ req = Google::Gax::to_proto(req, Google::Cloud::Dialogflow::V2::GetEntityTypeRequest)
365
+ @get_entity_type.call(req, options)
366
+ end
367
+
368
+ # Creates an entity type in the specified agent.
369
+ #
370
+ # @param parent [String]
371
+ # Required. The agent to create a entity type for.
372
+ # Format: +projects/<Project ID>/agent+.
373
+ # @param entity_type [Google::Cloud::Dialogflow::V2::EntityType | Hash]
374
+ # Required. The entity type to create.
375
+ # A hash of the same form as `Google::Cloud::Dialogflow::V2::EntityType`
376
+ # can also be provided.
377
+ # @param language_code [String]
378
+ # Optional. The language of entity synonyms defined in +entity_type+. If not
379
+ # specified, the agent's default language is used.
380
+ # [More than a dozen
381
+ # languages](https://dialogflow.com/docs/reference/language) are supported.
382
+ # Note: languages must be enabled in the agent, before they can be used.
383
+ # @param options [Google::Gax::CallOptions]
384
+ # Overrides the default settings for this call, e.g, timeout,
385
+ # retries, etc.
386
+ # @return [Google::Cloud::Dialogflow::V2::EntityType]
387
+ # @raise [Google::Gax::GaxError] if the RPC is aborted.
388
+ # @example
389
+ # require "google/cloud/dialogflow/v2"
390
+ #
391
+ # entity_types_client = Google::Cloud::Dialogflow::V2::EntityTypes.new
392
+ # formatted_parent = Google::Cloud::Dialogflow::V2::EntityTypesClient.project_agent_path("[PROJECT]")
393
+ #
394
+ # # TODO: Initialize +entity_type+:
395
+ # entity_type = {}
396
+ # response = entity_types_client.create_entity_type(formatted_parent, entity_type)
397
+
398
+ def create_entity_type \
399
+ parent,
400
+ entity_type,
401
+ language_code: nil,
402
+ options: nil
403
+ req = {
404
+ parent: parent,
405
+ entity_type: entity_type,
406
+ language_code: language_code
407
+ }.delete_if { |_, v| v.nil? }
408
+ req = Google::Gax::to_proto(req, Google::Cloud::Dialogflow::V2::CreateEntityTypeRequest)
409
+ @create_entity_type.call(req, options)
410
+ end
411
+
412
+ # Updates the specified entity type.
413
+ #
414
+ # @param entity_type [Google::Cloud::Dialogflow::V2::EntityType | Hash]
415
+ # Required. The entity type to update.
416
+ # Format: +projects/<Project ID>/agent/entityTypes/<EntityType ID>+.
417
+ # A hash of the same form as `Google::Cloud::Dialogflow::V2::EntityType`
418
+ # can also be provided.
419
+ # @param language_code [String]
420
+ # Optional. The language of entity synonyms defined in +entity_type+. If not
421
+ # specified, the agent's default language is used.
422
+ # [More than a dozen
423
+ # languages](https://dialogflow.com/docs/reference/language) are supported.
424
+ # Note: languages must be enabled in the agent, before they can be used.
425
+ # @param update_mask [Google::Protobuf::FieldMask | Hash]
426
+ # Optional. The mask to control which fields get updated.
427
+ # A hash of the same form as `Google::Protobuf::FieldMask`
428
+ # can also be provided.
429
+ # @param options [Google::Gax::CallOptions]
430
+ # Overrides the default settings for this call, e.g, timeout,
431
+ # retries, etc.
432
+ # @return [Google::Cloud::Dialogflow::V2::EntityType]
433
+ # @raise [Google::Gax::GaxError] if the RPC is aborted.
434
+ # @example
435
+ # require "google/cloud/dialogflow/v2"
436
+ #
437
+ # entity_types_client = Google::Cloud::Dialogflow::V2::EntityTypes.new
438
+ #
439
+ # # TODO: Initialize +entity_type+:
440
+ # entity_type = {}
441
+ # response = entity_types_client.update_entity_type(entity_type)
442
+
443
+ def update_entity_type \
444
+ entity_type,
445
+ language_code: nil,
446
+ update_mask: nil,
447
+ options: nil
448
+ req = {
449
+ entity_type: entity_type,
450
+ language_code: language_code,
451
+ update_mask: update_mask
452
+ }.delete_if { |_, v| v.nil? }
453
+ req = Google::Gax::to_proto(req, Google::Cloud::Dialogflow::V2::UpdateEntityTypeRequest)
454
+ @update_entity_type.call(req, options)
455
+ end
456
+
457
+ # Deletes the specified entity type.
458
+ #
459
+ # @param name [String]
460
+ # Required. The name of the entity type to delete.
461
+ # Format: +projects/<Project ID>/agent/entityTypes/<EntityType ID>+.
462
+ # @param options [Google::Gax::CallOptions]
463
+ # Overrides the default settings for this call, e.g, timeout,
464
+ # retries, etc.
465
+ # @raise [Google::Gax::GaxError] if the RPC is aborted.
466
+ # @example
467
+ # require "google/cloud/dialogflow/v2"
468
+ #
469
+ # entity_types_client = Google::Cloud::Dialogflow::V2::EntityTypes.new
470
+ # formatted_name = Google::Cloud::Dialogflow::V2::EntityTypesClient.entity_type_path("[PROJECT]", "[ENTITY_TYPE]")
471
+ # entity_types_client.delete_entity_type(formatted_name)
472
+
473
+ def delete_entity_type \
474
+ name,
475
+ options: nil
476
+ req = {
477
+ name: name
478
+ }.delete_if { |_, v| v.nil? }
479
+ req = Google::Gax::to_proto(req, Google::Cloud::Dialogflow::V2::DeleteEntityTypeRequest)
480
+ @delete_entity_type.call(req, options)
481
+ nil
482
+ end
483
+
484
+ # Updates/Creates multiple entity types in the specified agent.
485
+ #
486
+ # Operation <response: {Google::Cloud::Dialogflow::V2::BatchUpdateEntityTypesResponse BatchUpdateEntityTypesResponse},
487
+ # metadata: {Google::Protobuf::Struct}>
488
+ #
489
+ # @param parent [String]
490
+ # Required. The name of the agent to update or create entity types in.
491
+ # Format: +projects/<Project ID>/agent+.
492
+ # @param entity_type_batch_uri [String]
493
+ # The URI to a Google Cloud Storage file containing entity types to update
494
+ # or create. The file format can either be a serialized proto (of
495
+ # EntityBatch type) or a JSON object. Note: The URI must start with
496
+ # "gs://".
497
+ # @param entity_type_batch_inline [Google::Cloud::Dialogflow::V2::EntityTypeBatch | Hash]
498
+ # The collection of entity type to update or create.
499
+ # A hash of the same form as `Google::Cloud::Dialogflow::V2::EntityTypeBatch`
500
+ # can also be provided.
501
+ # @param language_code [String]
502
+ # Optional. The language of entity synonyms defined in +entity_types+. If not
503
+ # specified, the agent's default language is used.
504
+ # [More than a dozen
505
+ # languages](https://dialogflow.com/docs/reference/language) are supported.
506
+ # Note: languages must be enabled in the agent, before they can be used.
507
+ # @param update_mask [Google::Protobuf::FieldMask | Hash]
508
+ # Optional. The mask to control which fields get updated.
509
+ # A hash of the same form as `Google::Protobuf::FieldMask`
510
+ # can also be provided.
511
+ # @param options [Google::Gax::CallOptions]
512
+ # Overrides the default settings for this call, e.g, timeout,
513
+ # retries, etc.
514
+ # @return [Google::Gax::Operation]
515
+ # @raise [Google::Gax::GaxError] if the RPC is aborted.
516
+ # @example
517
+ # require "google/cloud/dialogflow/v2"
518
+ #
519
+ # entity_types_client = Google::Cloud::Dialogflow::V2::EntityTypes.new
520
+ # formatted_parent = Google::Cloud::Dialogflow::V2::EntityTypesClient.project_agent_path("[PROJECT]")
521
+ #
522
+ # # Register a callback during the method call.
523
+ # operation = entity_types_client.batch_update_entity_types(formatted_parent) do |op|
524
+ # raise op.results.message if op.error?
525
+ # op_results = op.results
526
+ # # Process the results.
527
+ #
528
+ # metadata = op.metadata
529
+ # # Process the metadata.
530
+ # end
531
+ #
532
+ # # Or use the return value to register a callback.
533
+ # operation.on_done do |op|
534
+ # raise op.results.message if op.error?
535
+ # op_results = op.results
536
+ # # Process the results.
537
+ #
538
+ # metadata = op.metadata
539
+ # # Process the metadata.
540
+ # end
541
+ #
542
+ # # Manually reload the operation.
543
+ # operation.reload!
544
+ #
545
+ # # Or block until the operation completes, triggering callbacks on
546
+ # # completion.
547
+ # operation.wait_until_done!
548
+
549
+ def batch_update_entity_types \
550
+ parent,
551
+ entity_type_batch_uri: nil,
552
+ entity_type_batch_inline: nil,
553
+ language_code: nil,
554
+ update_mask: nil,
555
+ options: nil
556
+ req = {
557
+ parent: parent,
558
+ entity_type_batch_uri: entity_type_batch_uri,
559
+ entity_type_batch_inline: entity_type_batch_inline,
560
+ language_code: language_code,
561
+ update_mask: update_mask
562
+ }.delete_if { |_, v| v.nil? }
563
+ req = Google::Gax::to_proto(req, Google::Cloud::Dialogflow::V2::BatchUpdateEntityTypesRequest)
564
+ operation = Google::Gax::Operation.new(
565
+ @batch_update_entity_types.call(req, options),
566
+ @operations_client,
567
+ Google::Cloud::Dialogflow::V2::BatchUpdateEntityTypesResponse,
568
+ Google::Protobuf::Struct,
569
+ call_options: options
570
+ )
571
+ operation.on_done { |operation| yield(operation) } if block_given?
572
+ operation
573
+ end
574
+
575
+ # Deletes entity types in the specified agent.
576
+ #
577
+ # Operation <response: {Google::Protobuf::Empty},
578
+ # metadata: {Google::Protobuf::Struct}>
579
+ #
580
+ # @param parent [String]
581
+ # Required. The name of the agent to delete all entities types for. Format:
582
+ # +projects/<Project ID>/agent+.
583
+ # @param entity_type_names [Array<String>]
584
+ # Required. The names entity types to delete. All names must point to the
585
+ # same agent as +parent+.
586
+ # @param options [Google::Gax::CallOptions]
587
+ # Overrides the default settings for this call, e.g, timeout,
588
+ # retries, etc.
589
+ # @return [Google::Gax::Operation]
590
+ # @raise [Google::Gax::GaxError] if the RPC is aborted.
591
+ # @example
592
+ # require "google/cloud/dialogflow/v2"
593
+ #
594
+ # entity_types_client = Google::Cloud::Dialogflow::V2::EntityTypes.new
595
+ # formatted_parent = Google::Cloud::Dialogflow::V2::EntityTypesClient.project_agent_path("[PROJECT]")
596
+ #
597
+ # # TODO: Initialize +entity_type_names+:
598
+ # entity_type_names = []
599
+ #
600
+ # # Register a callback during the method call.
601
+ # operation = entity_types_client.batch_delete_entity_types(formatted_parent, entity_type_names) do |op|
602
+ # raise op.results.message if op.error?
603
+ # op_results = op.results
604
+ # # Process the results.
605
+ #
606
+ # metadata = op.metadata
607
+ # # Process the metadata.
608
+ # end
609
+ #
610
+ # # Or use the return value to register a callback.
611
+ # operation.on_done do |op|
612
+ # raise op.results.message if op.error?
613
+ # op_results = op.results
614
+ # # Process the results.
615
+ #
616
+ # metadata = op.metadata
617
+ # # Process the metadata.
618
+ # end
619
+ #
620
+ # # Manually reload the operation.
621
+ # operation.reload!
622
+ #
623
+ # # Or block until the operation completes, triggering callbacks on
624
+ # # completion.
625
+ # operation.wait_until_done!
626
+
627
+ def batch_delete_entity_types \
628
+ parent,
629
+ entity_type_names,
630
+ options: nil
631
+ req = {
632
+ parent: parent,
633
+ entity_type_names: entity_type_names
634
+ }.delete_if { |_, v| v.nil? }
635
+ req = Google::Gax::to_proto(req, Google::Cloud::Dialogflow::V2::BatchDeleteEntityTypesRequest)
636
+ operation = Google::Gax::Operation.new(
637
+ @batch_delete_entity_types.call(req, options),
638
+ @operations_client,
639
+ Google::Protobuf::Empty,
640
+ Google::Protobuf::Struct,
641
+ call_options: options
642
+ )
643
+ operation.on_done { |operation| yield(operation) } if block_given?
644
+ operation
645
+ end
646
+
647
+ # Creates multiple new entities in the specified entity type (extends the
648
+ # existing collection of entries).
649
+ #
650
+ # Operation <response: {Google::Protobuf::Empty}>
651
+ #
652
+ # @param parent [String]
653
+ # Required. The name of the entity type to create entities in. Format:
654
+ # +projects/<Project ID>/agent/entityTypes/<Entity Type ID>+.
655
+ # @param entities [Array<Google::Cloud::Dialogflow::V2::EntityType::Entity | Hash>]
656
+ # Required. The collection of entities to create.
657
+ # A hash of the same form as `Google::Cloud::Dialogflow::V2::EntityType::Entity`
658
+ # can also be provided.
659
+ # @param language_code [String]
660
+ # Optional. The language of entity synonyms defined in +entities+. If not
661
+ # specified, the agent's default language is used.
662
+ # [More than a dozen
663
+ # languages](https://dialogflow.com/docs/reference/language) are supported.
664
+ # Note: languages must be enabled in the agent, before they can be used.
665
+ # @param options [Google::Gax::CallOptions]
666
+ # Overrides the default settings for this call, e.g, timeout,
667
+ # retries, etc.
668
+ # @return [Google::Gax::Operation]
669
+ # @raise [Google::Gax::GaxError] if the RPC is aborted.
670
+ # @example
671
+ # require "google/cloud/dialogflow/v2"
672
+ #
673
+ # entity_types_client = Google::Cloud::Dialogflow::V2::EntityTypes.new
674
+ # formatted_parent = Google::Cloud::Dialogflow::V2::EntityTypesClient.entity_type_path("[PROJECT]", "[ENTITY_TYPE]")
675
+ #
676
+ # # TODO: Initialize +entities+:
677
+ # entities = []
678
+ #
679
+ # # Register a callback during the method call.
680
+ # operation = entity_types_client.batch_create_entities(formatted_parent, entities) do |op|
681
+ # raise op.results.message if op.error?
682
+ # op_results = op.results
683
+ # # Process the results.
684
+ #
685
+ # metadata = op.metadata
686
+ # # Process the metadata.
687
+ # end
688
+ #
689
+ # # Or use the return value to register a callback.
690
+ # operation.on_done do |op|
691
+ # raise op.results.message if op.error?
692
+ # op_results = op.results
693
+ # # Process the results.
694
+ #
695
+ # metadata = op.metadata
696
+ # # Process the metadata.
697
+ # end
698
+ #
699
+ # # Manually reload the operation.
700
+ # operation.reload!
701
+ #
702
+ # # Or block until the operation completes, triggering callbacks on
703
+ # # completion.
704
+ # operation.wait_until_done!
705
+
706
+ def batch_create_entities \
707
+ parent,
708
+ entities,
709
+ language_code: nil,
710
+ options: nil
711
+ req = {
712
+ parent: parent,
713
+ entities: entities,
714
+ language_code: language_code
715
+ }.delete_if { |_, v| v.nil? }
716
+ req = Google::Gax::to_proto(req, Google::Cloud::Dialogflow::V2::BatchCreateEntitiesRequest)
717
+ operation = Google::Gax::Operation.new(
718
+ @batch_create_entities.call(req, options),
719
+ @operations_client,
720
+ Google::Protobuf::Empty,
721
+ Google::Protobuf::Struct,
722
+ call_options: options
723
+ )
724
+ operation.on_done { |operation| yield(operation) } if block_given?
725
+ operation
726
+ end
727
+
728
+ # Updates entities in the specified entity type (replaces the existing
729
+ # collection of entries).
730
+ #
731
+ # Operation <response: {Google::Protobuf::Empty},
732
+ # metadata: {Google::Protobuf::Struct}>
733
+ #
734
+ # @param parent [String]
735
+ # Required. The name of the entity type to update the entities in. Format:
736
+ # +projects/<Project ID>/agent/entityTypes/<Entity Type ID>+.
737
+ # @param entities [Array<Google::Cloud::Dialogflow::V2::EntityType::Entity | Hash>]
738
+ # Required. The collection of new entities to replace the existing entities.
739
+ # A hash of the same form as `Google::Cloud::Dialogflow::V2::EntityType::Entity`
740
+ # can also be provided.
741
+ # @param language_code [String]
742
+ # Optional. The language of entity synonyms defined in +entities+. If not
743
+ # specified, the agent's default language is used.
744
+ # [More than a dozen
745
+ # languages](https://dialogflow.com/docs/reference/language) are supported.
746
+ # Note: languages must be enabled in the agent, before they can be used.
747
+ # @param update_mask [Google::Protobuf::FieldMask | Hash]
748
+ # Optional. The mask to control which fields get updated.
749
+ # A hash of the same form as `Google::Protobuf::FieldMask`
750
+ # can also be provided.
751
+ # @param options [Google::Gax::CallOptions]
752
+ # Overrides the default settings for this call, e.g, timeout,
753
+ # retries, etc.
754
+ # @return [Google::Gax::Operation]
755
+ # @raise [Google::Gax::GaxError] if the RPC is aborted.
756
+ # @example
757
+ # require "google/cloud/dialogflow/v2"
758
+ #
759
+ # entity_types_client = Google::Cloud::Dialogflow::V2::EntityTypes.new
760
+ # formatted_parent = Google::Cloud::Dialogflow::V2::EntityTypesClient.entity_type_path("[PROJECT]", "[ENTITY_TYPE]")
761
+ #
762
+ # # TODO: Initialize +entities+:
763
+ # entities = []
764
+ #
765
+ # # Register a callback during the method call.
766
+ # operation = entity_types_client.batch_update_entities(formatted_parent, entities) do |op|
767
+ # raise op.results.message if op.error?
768
+ # op_results = op.results
769
+ # # Process the results.
770
+ #
771
+ # metadata = op.metadata
772
+ # # Process the metadata.
773
+ # end
774
+ #
775
+ # # Or use the return value to register a callback.
776
+ # operation.on_done do |op|
777
+ # raise op.results.message if op.error?
778
+ # op_results = op.results
779
+ # # Process the results.
780
+ #
781
+ # metadata = op.metadata
782
+ # # Process the metadata.
783
+ # end
784
+ #
785
+ # # Manually reload the operation.
786
+ # operation.reload!
787
+ #
788
+ # # Or block until the operation completes, triggering callbacks on
789
+ # # completion.
790
+ # operation.wait_until_done!
791
+
792
+ def batch_update_entities \
793
+ parent,
794
+ entities,
795
+ language_code: nil,
796
+ update_mask: nil,
797
+ options: nil
798
+ req = {
799
+ parent: parent,
800
+ entities: entities,
801
+ language_code: language_code,
802
+ update_mask: update_mask
803
+ }.delete_if { |_, v| v.nil? }
804
+ req = Google::Gax::to_proto(req, Google::Cloud::Dialogflow::V2::BatchUpdateEntitiesRequest)
805
+ operation = Google::Gax::Operation.new(
806
+ @batch_update_entities.call(req, options),
807
+ @operations_client,
808
+ Google::Protobuf::Empty,
809
+ Google::Protobuf::Struct,
810
+ call_options: options
811
+ )
812
+ operation.on_done { |operation| yield(operation) } if block_given?
813
+ operation
814
+ end
815
+
816
+ # Deletes entities in the specified entity type.
817
+ #
818
+ # Operation <response: {Google::Protobuf::Empty},
819
+ # metadata: {Google::Protobuf::Struct}>
820
+ #
821
+ # @param parent [String]
822
+ # Required. The name of the entity type to delete entries for. Format:
823
+ # +projects/<Project ID>/agent/entityTypes/<Entity Type ID>+.
824
+ # @param entity_values [Array<String>]
825
+ # Required. The canonical +values+ of the entities to delete. Note that
826
+ # these are not fully-qualified names, i.e. they don't start with
827
+ # +projects/<Project ID>+.
828
+ # @param language_code [String]
829
+ # Optional. The language of entity synonyms defined in +entities+. If not
830
+ # specified, the agent's default language is used.
831
+ # [More than a dozen
832
+ # languages](https://dialogflow.com/docs/reference/language) are supported.
833
+ # Note: languages must be enabled in the agent, before they can be used.
834
+ # @param options [Google::Gax::CallOptions]
835
+ # Overrides the default settings for this call, e.g, timeout,
836
+ # retries, etc.
837
+ # @return [Google::Gax::Operation]
838
+ # @raise [Google::Gax::GaxError] if the RPC is aborted.
839
+ # @example
840
+ # require "google/cloud/dialogflow/v2"
841
+ #
842
+ # entity_types_client = Google::Cloud::Dialogflow::V2::EntityTypes.new
843
+ # formatted_parent = Google::Cloud::Dialogflow::V2::EntityTypesClient.entity_type_path("[PROJECT]", "[ENTITY_TYPE]")
844
+ #
845
+ # # TODO: Initialize +entity_values+:
846
+ # entity_values = []
847
+ #
848
+ # # Register a callback during the method call.
849
+ # operation = entity_types_client.batch_delete_entities(formatted_parent, entity_values) do |op|
850
+ # raise op.results.message if op.error?
851
+ # op_results = op.results
852
+ # # Process the results.
853
+ #
854
+ # metadata = op.metadata
855
+ # # Process the metadata.
856
+ # end
857
+ #
858
+ # # Or use the return value to register a callback.
859
+ # operation.on_done do |op|
860
+ # raise op.results.message if op.error?
861
+ # op_results = op.results
862
+ # # Process the results.
863
+ #
864
+ # metadata = op.metadata
865
+ # # Process the metadata.
866
+ # end
867
+ #
868
+ # # Manually reload the operation.
869
+ # operation.reload!
870
+ #
871
+ # # Or block until the operation completes, triggering callbacks on
872
+ # # completion.
873
+ # operation.wait_until_done!
874
+
875
+ def batch_delete_entities \
876
+ parent,
877
+ entity_values,
878
+ language_code: nil,
879
+ options: nil
880
+ req = {
881
+ parent: parent,
882
+ entity_values: entity_values,
883
+ language_code: language_code
884
+ }.delete_if { |_, v| v.nil? }
885
+ req = Google::Gax::to_proto(req, Google::Cloud::Dialogflow::V2::BatchDeleteEntitiesRequest)
886
+ operation = Google::Gax::Operation.new(
887
+ @batch_delete_entities.call(req, options),
888
+ @operations_client,
889
+ Google::Protobuf::Empty,
890
+ Google::Protobuf::Struct,
891
+ call_options: options
892
+ )
893
+ operation.on_done { |operation| yield(operation) } if block_given?
894
+ operation
895
+ end
896
+ end
897
+ end
898
+ end
899
+ end
900
+ end