google-cloud-dialogflow-v2 0.6.2 → 0.8.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (119) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE.md +188 -190
  3. data/README.md +70 -2
  4. data/lib/google/cloud/dialogflow/v2.rb +13 -2
  5. data/lib/google/cloud/dialogflow/v2/agent_services_pb.rb +25 -40
  6. data/lib/google/cloud/dialogflow/v2/agents.rb +1 -28
  7. data/lib/google/cloud/dialogflow/v2/agents/client.rb +41 -100
  8. data/lib/google/cloud/dialogflow/v2/agents/operations.rb +96 -11
  9. data/lib/google/cloud/dialogflow/v2/agents/paths.rb +42 -3
  10. data/lib/google/cloud/dialogflow/v2/answer_record_pb.rb +100 -0
  11. data/lib/google/cloud/dialogflow/v2/answer_record_services_pb.rb +48 -0
  12. data/lib/google/cloud/dialogflow/v2/answer_records.rb +49 -0
  13. data/lib/google/cloud/dialogflow/v2/answer_records/client.rb +478 -0
  14. data/lib/google/cloud/dialogflow/v2/answer_records/credentials.rb +52 -0
  15. data/lib/google/cloud/dialogflow/v2/answer_records/paths.rb +105 -0
  16. data/lib/google/cloud/dialogflow/v2/audio_config_pb.rb +7 -0
  17. data/lib/google/cloud/dialogflow/v2/context_services_pb.rb +8 -25
  18. data/lib/google/cloud/dialogflow/v2/contexts.rb +1 -18
  19. data/lib/google/cloud/dialogflow/v2/contexts/client.rb +24 -63
  20. data/lib/google/cloud/dialogflow/v2/contexts/paths.rb +74 -2
  21. data/lib/google/cloud/dialogflow/v2/conversation_event_pb.rb +39 -0
  22. data/lib/google/cloud/dialogflow/v2/conversation_pb.rb +89 -0
  23. data/lib/google/cloud/dialogflow/v2/conversation_profile_pb.rb +182 -0
  24. data/lib/google/cloud/dialogflow/v2/conversation_profile_services_pb.rb +61 -0
  25. data/lib/google/cloud/dialogflow/v2/conversation_profiles.rb +49 -0
  26. data/lib/google/cloud/dialogflow/v2/conversation_profiles/client.rb +699 -0
  27. data/lib/google/cloud/dialogflow/v2/conversation_profiles/credentials.rb +52 -0
  28. data/lib/google/cloud/dialogflow/v2/conversation_profiles/paths.rb +246 -0
  29. data/lib/google/cloud/dialogflow/v2/conversation_services_pb.rb +75 -0
  30. data/lib/google/cloud/dialogflow/v2/conversations.rb +49 -0
  31. data/lib/google/cloud/dialogflow/v2/conversations/client.rb +757 -0
  32. data/lib/google/cloud/dialogflow/v2/conversations/credentials.rb +52 -0
  33. data/lib/google/cloud/dialogflow/v2/conversations/paths.rb +146 -0
  34. data/lib/google/cloud/dialogflow/v2/document_pb.rb +99 -0
  35. data/lib/google/cloud/dialogflow/v2/document_services_pb.rb +73 -0
  36. data/lib/google/cloud/dialogflow/v2/documents.rb +50 -0
  37. data/lib/google/cloud/dialogflow/v2/documents/client.rb +810 -0
  38. data/lib/google/cloud/dialogflow/v2/documents/credentials.rb +52 -0
  39. data/lib/google/cloud/dialogflow/v2/documents/operations.rb +655 -0
  40. data/lib/google/cloud/dialogflow/v2/documents/paths.rb +119 -0
  41. data/lib/google/cloud/dialogflow/v2/entity_type_services_pb.rb +12 -39
  42. data/lib/google/cloud/dialogflow/v2/entity_types.rb +1 -28
  43. data/lib/google/cloud/dialogflow/v2/entity_types/client.rb +28 -91
  44. data/lib/google/cloud/dialogflow/v2/entity_types/operations.rb +96 -11
  45. data/lib/google/cloud/dialogflow/v2/entity_types/paths.rb +58 -12
  46. data/lib/google/cloud/dialogflow/v2/environment_pb.rb +50 -1
  47. data/lib/google/cloud/dialogflow/v2/environment_services_pb.rb +24 -3
  48. data/lib/google/cloud/dialogflow/v2/environments.rb +1 -1
  49. data/lib/google/cloud/dialogflow/v2/environments/client.rb +430 -14
  50. data/lib/google/cloud/dialogflow/v2/environments/paths.rb +104 -5
  51. data/lib/google/cloud/dialogflow/v2/fulfillment_pb.rb +59 -0
  52. data/lib/google/cloud/dialogflow/v2/fulfillment_services_pb.rb +47 -0
  53. data/lib/google/cloud/dialogflow/v2/fulfillments.rb +49 -0
  54. data/lib/google/cloud/dialogflow/v2/fulfillments/client.rb +460 -0
  55. data/lib/google/cloud/dialogflow/v2/fulfillments/credentials.rb +52 -0
  56. data/lib/google/cloud/dialogflow/v2/fulfillments/paths.rb +69 -0
  57. data/lib/google/cloud/dialogflow/v2/gcs_pb.rb +20 -0
  58. data/lib/google/cloud/dialogflow/v2/human_agent_assistant_event_pb.rb +26 -0
  59. data/lib/google/cloud/dialogflow/v2/intent_pb.rb +2 -0
  60. data/lib/google/cloud/dialogflow/v2/intent_services_pb.rb +9 -40
  61. data/lib/google/cloud/dialogflow/v2/intents.rb +1 -32
  62. data/lib/google/cloud/dialogflow/v2/intents/client.rb +34 -81
  63. data/lib/google/cloud/dialogflow/v2/intents/operations.rb +96 -11
  64. data/lib/google/cloud/dialogflow/v2/intents/paths.rb +97 -13
  65. data/lib/google/cloud/dialogflow/v2/knowledge_base_pb.rb +60 -0
  66. data/lib/google/cloud/dialogflow/v2/knowledge_base_services_pb.rb +53 -0
  67. data/lib/google/cloud/dialogflow/v2/knowledge_bases.rb +49 -0
  68. data/lib/google/cloud/dialogflow/v2/knowledge_bases/client.rb +696 -0
  69. data/lib/google/cloud/dialogflow/v2/knowledge_bases/credentials.rb +52 -0
  70. data/lib/google/cloud/dialogflow/v2/knowledge_bases/paths.rb +105 -0
  71. data/lib/google/cloud/dialogflow/v2/participant_pb.rb +172 -0
  72. data/lib/google/cloud/dialogflow/v2/participant_services_pb.rb +64 -0
  73. data/lib/google/cloud/dialogflow/v2/participants.rb +49 -0
  74. data/lib/google/cloud/dialogflow/v2/participants/client.rb +894 -0
  75. data/lib/google/cloud/dialogflow/v2/participants/credentials.rb +52 -0
  76. data/lib/google/cloud/dialogflow/v2/participants/paths.rb +334 -0
  77. data/lib/google/cloud/dialogflow/v2/session_entity_type_services_pb.rb +7 -23
  78. data/lib/google/cloud/dialogflow/v2/session_entity_types.rb +1 -17
  79. data/lib/google/cloud/dialogflow/v2/session_entity_types/client.rb +23 -53
  80. data/lib/google/cloud/dialogflow/v2/session_entity_types/paths.rb +74 -2
  81. data/lib/google/cloud/dialogflow/v2/session_pb.rb +1 -0
  82. data/lib/google/cloud/dialogflow/v2/session_services_pb.rb +15 -7
  83. data/lib/google/cloud/dialogflow/v2/sessions.rb +4 -4
  84. data/lib/google/cloud/dialogflow/v2/sessions/client.rb +51 -15
  85. data/lib/google/cloud/dialogflow/v2/sessions/paths.rb +113 -3
  86. data/lib/google/cloud/dialogflow/v2/version.rb +1 -1
  87. data/lib/google/cloud/dialogflow/v2/version_pb.rb +69 -0
  88. data/lib/google/cloud/dialogflow/v2/version_services_pb.rb +59 -0
  89. data/lib/google/cloud/dialogflow/v2/versions.rb +49 -0
  90. data/lib/google/cloud/dialogflow/v2/versions/client.rb +709 -0
  91. data/lib/google/cloud/dialogflow/v2/versions/credentials.rb +52 -0
  92. data/lib/google/cloud/dialogflow/v2/versions/paths.rb +110 -0
  93. data/proto_docs/google/api/field_behavior.rb +6 -0
  94. data/proto_docs/google/api/resource.rb +50 -14
  95. data/proto_docs/google/cloud/dialogflow/v2/agent.rb +9 -1
  96. data/proto_docs/google/cloud/dialogflow/v2/answer_record.rb +252 -0
  97. data/proto_docs/google/cloud/dialogflow/v2/audio_config.rb +25 -0
  98. data/proto_docs/google/cloud/dialogflow/v2/context.rb +17 -2
  99. data/proto_docs/google/cloud/dialogflow/v2/conversation.rb +253 -0
  100. data/proto_docs/google/cloud/dialogflow/v2/conversation_event.rb +83 -0
  101. data/proto_docs/google/cloud/dialogflow/v2/conversation_profile.rb +522 -0
  102. data/proto_docs/google/cloud/dialogflow/v2/document.rb +267 -0
  103. data/proto_docs/google/cloud/dialogflow/v2/entity_type.rb +12 -3
  104. data/proto_docs/google/cloud/dialogflow/v2/environment.rb +187 -5
  105. data/proto_docs/google/cloud/dialogflow/v2/fulfillment.rb +144 -0
  106. data/proto_docs/google/cloud/dialogflow/v2/human_agent_assistant_event.rb +45 -0
  107. data/proto_docs/google/cloud/dialogflow/v2/intent.rb +29 -4
  108. data/proto_docs/google/cloud/dialogflow/v2/knowledge_base.rb +139 -0
  109. data/proto_docs/google/cloud/dialogflow/v2/participant.rb +503 -0
  110. data/proto_docs/google/cloud/dialogflow/v2/session.rb +52 -7
  111. data/proto_docs/google/cloud/dialogflow/v2/session_entity_type.rb +7 -6
  112. data/proto_docs/google/cloud/dialogflow/v2/validation_result.rb +1 -1
  113. data/proto_docs/google/cloud/dialogflow/v2/version.rb +176 -0
  114. data/proto_docs/google/cloud/dialogflow/v2/webhook.rb +2 -2
  115. data/proto_docs/google/longrunning/operations.rb +17 -3
  116. data/proto_docs/google/protobuf/any.rb +5 -2
  117. data/proto_docs/google/protobuf/timestamp.rb +10 -1
  118. data/proto_docs/google/type/latlng.rb +2 -2
  119. metadata +73 -9
@@ -0,0 +1,52 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2021 Google LLC
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # https://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ # Auto-generated by gapic-generator-ruby. DO NOT EDIT!
18
+
19
+ require "googleauth"
20
+
21
+ module Google
22
+ module Cloud
23
+ module Dialogflow
24
+ module V2
25
+ module Conversations
26
+ # Credentials for the Conversations API.
27
+ class Credentials < ::Google::Auth::Credentials
28
+ self.scope = [
29
+ "https://www.googleapis.com/auth/cloud-platform",
30
+ "https://www.googleapis.com/auth/dialogflow"
31
+ ]
32
+ self.env_vars = [
33
+ "DIALOGFLOW_CREDENTIALS",
34
+ "DIALOGFLOW_KEYFILE",
35
+ "GOOGLE_CLOUD_CREDENTIALS",
36
+ "GOOGLE_CLOUD_KEYFILE",
37
+ "GCLOUD_KEYFILE",
38
+ "DIALOGFLOW_CREDENTIALS_JSON",
39
+ "DIALOGFLOW_KEYFILE_JSON",
40
+ "GOOGLE_CLOUD_CREDENTIALS_JSON",
41
+ "GOOGLE_CLOUD_KEYFILE_JSON",
42
+ "GCLOUD_KEYFILE_JSON"
43
+ ]
44
+ self.paths = [
45
+ "~/.config/google_cloud/application_default_credentials.json"
46
+ ]
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,146 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2021 Google LLC
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # https://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ # Auto-generated by gapic-generator-ruby. DO NOT EDIT!
18
+
19
+
20
+ module Google
21
+ module Cloud
22
+ module Dialogflow
23
+ module V2
24
+ module Conversations
25
+ # Path helper methods for the Conversations API.
26
+ module Paths
27
+ ##
28
+ # Create a fully-qualified Conversation resource string.
29
+ #
30
+ # @overload conversation_path(project:, conversation:)
31
+ # The resource will be in the following format:
32
+ #
33
+ # `projects/{project}/conversations/{conversation}`
34
+ #
35
+ # @param project [String]
36
+ # @param conversation [String]
37
+ #
38
+ # @overload conversation_path(project:, location:, conversation:)
39
+ # The resource will be in the following format:
40
+ #
41
+ # `projects/{project}/locations/{location}/conversations/{conversation}`
42
+ #
43
+ # @param project [String]
44
+ # @param location [String]
45
+ # @param conversation [String]
46
+ #
47
+ # @return [::String]
48
+ def conversation_path **args
49
+ resources = {
50
+ "conversation:project" => (proc do |project:, conversation:|
51
+ raise ::ArgumentError, "project cannot contain /" if project.to_s.include? "/"
52
+
53
+ "projects/#{project}/conversations/#{conversation}"
54
+ end),
55
+ "conversation:location:project" => (proc do |project:, location:, conversation:|
56
+ raise ::ArgumentError, "project cannot contain /" if project.to_s.include? "/"
57
+ raise ::ArgumentError, "location cannot contain /" if location.to_s.include? "/"
58
+
59
+ "projects/#{project}/locations/#{location}/conversations/#{conversation}"
60
+ end)
61
+ }
62
+
63
+ resource = resources[args.keys.sort.join(":")]
64
+ raise ::ArgumentError, "no resource found for values #{args.keys}" if resource.nil?
65
+ resource.call(**args)
66
+ end
67
+
68
+ ##
69
+ # Create a fully-qualified ConversationProfile resource string.
70
+ #
71
+ # @overload conversation_profile_path(project:, conversation_profile:)
72
+ # The resource will be in the following format:
73
+ #
74
+ # `projects/{project}/conversationProfiles/{conversation_profile}`
75
+ #
76
+ # @param project [String]
77
+ # @param conversation_profile [String]
78
+ #
79
+ # @overload conversation_profile_path(project:, location:, conversation_profile:)
80
+ # The resource will be in the following format:
81
+ #
82
+ # `projects/{project}/locations/{location}/conversationProfiles/{conversation_profile}`
83
+ #
84
+ # @param project [String]
85
+ # @param location [String]
86
+ # @param conversation_profile [String]
87
+ #
88
+ # @return [::String]
89
+ def conversation_profile_path **args
90
+ resources = {
91
+ "conversation_profile:project" => (proc do |project:, conversation_profile:|
92
+ raise ::ArgumentError, "project cannot contain /" if project.to_s.include? "/"
93
+
94
+ "projects/#{project}/conversationProfiles/#{conversation_profile}"
95
+ end),
96
+ "conversation_profile:location:project" => (proc do |project:, location:, conversation_profile:|
97
+ raise ::ArgumentError, "project cannot contain /" if project.to_s.include? "/"
98
+ raise ::ArgumentError, "location cannot contain /" if location.to_s.include? "/"
99
+
100
+ "projects/#{project}/locations/#{location}/conversationProfiles/#{conversation_profile}"
101
+ end)
102
+ }
103
+
104
+ resource = resources[args.keys.sort.join(":")]
105
+ raise ::ArgumentError, "no resource found for values #{args.keys}" if resource.nil?
106
+ resource.call(**args)
107
+ end
108
+
109
+ ##
110
+ # Create a fully-qualified Location resource string.
111
+ #
112
+ # The resource will be in the following format:
113
+ #
114
+ # `projects/{project}/locations/{location}`
115
+ #
116
+ # @param project [String]
117
+ # @param location [String]
118
+ #
119
+ # @return [::String]
120
+ def location_path project:, location:
121
+ raise ::ArgumentError, "project cannot contain /" if project.to_s.include? "/"
122
+
123
+ "projects/#{project}/locations/#{location}"
124
+ end
125
+
126
+ ##
127
+ # Create a fully-qualified Project resource string.
128
+ #
129
+ # The resource will be in the following format:
130
+ #
131
+ # `projects/{project}`
132
+ #
133
+ # @param project [String]
134
+ #
135
+ # @return [::String]
136
+ def project_path project:
137
+ "projects/#{project}"
138
+ end
139
+
140
+ extend self
141
+ end
142
+ end
143
+ end
144
+ end
145
+ end
146
+ end
@@ -0,0 +1,99 @@
1
+ # Generated by the protocol buffer compiler. DO NOT EDIT!
2
+ # source: google/cloud/dialogflow/v2/document.proto
3
+
4
+ require 'google/protobuf'
5
+
6
+ require 'google/api/annotations_pb'
7
+ require 'google/api/client_pb'
8
+ require 'google/api/field_behavior_pb'
9
+ require 'google/api/resource_pb'
10
+ require 'google/longrunning/operations_pb'
11
+ require 'google/protobuf/field_mask_pb'
12
+ require 'google/protobuf/timestamp_pb'
13
+ require 'google/rpc/status_pb'
14
+ Google::Protobuf::DescriptorPool.generated_pool.build do
15
+ add_file("google/cloud/dialogflow/v2/document.proto", :syntax => :proto3) do
16
+ add_message "google.cloud.dialogflow.v2.Document" do
17
+ optional :name, :string, 1
18
+ optional :display_name, :string, 2
19
+ optional :mime_type, :string, 3
20
+ repeated :knowledge_types, :enum, 4, "google.cloud.dialogflow.v2.Document.KnowledgeType"
21
+ optional :enable_auto_reload, :bool, 11
22
+ optional :latest_reload_status, :message, 12, "google.cloud.dialogflow.v2.Document.ReloadStatus"
23
+ map :metadata, :string, :string, 7
24
+ oneof :source do
25
+ optional :content_uri, :string, 5
26
+ optional :raw_content, :bytes, 9
27
+ end
28
+ end
29
+ add_message "google.cloud.dialogflow.v2.Document.ReloadStatus" do
30
+ optional :time, :message, 1, "google.protobuf.Timestamp"
31
+ optional :status, :message, 2, "google.rpc.Status"
32
+ end
33
+ add_enum "google.cloud.dialogflow.v2.Document.KnowledgeType" do
34
+ value :KNOWLEDGE_TYPE_UNSPECIFIED, 0
35
+ value :FAQ, 1
36
+ value :EXTRACTIVE_QA, 2
37
+ value :ARTICLE_SUGGESTION, 3
38
+ end
39
+ add_message "google.cloud.dialogflow.v2.GetDocumentRequest" do
40
+ optional :name, :string, 1
41
+ end
42
+ add_message "google.cloud.dialogflow.v2.ListDocumentsRequest" do
43
+ optional :parent, :string, 1
44
+ optional :page_size, :int32, 2
45
+ optional :page_token, :string, 3
46
+ end
47
+ add_message "google.cloud.dialogflow.v2.ListDocumentsResponse" do
48
+ repeated :documents, :message, 1, "google.cloud.dialogflow.v2.Document"
49
+ optional :next_page_token, :string, 2
50
+ end
51
+ add_message "google.cloud.dialogflow.v2.CreateDocumentRequest" do
52
+ optional :parent, :string, 1
53
+ optional :document, :message, 2, "google.cloud.dialogflow.v2.Document"
54
+ end
55
+ add_message "google.cloud.dialogflow.v2.DeleteDocumentRequest" do
56
+ optional :name, :string, 1
57
+ end
58
+ add_message "google.cloud.dialogflow.v2.UpdateDocumentRequest" do
59
+ optional :document, :message, 1, "google.cloud.dialogflow.v2.Document"
60
+ optional :update_mask, :message, 2, "google.protobuf.FieldMask"
61
+ end
62
+ add_message "google.cloud.dialogflow.v2.ReloadDocumentRequest" do
63
+ optional :name, :string, 1
64
+ oneof :source do
65
+ optional :content_uri, :string, 3
66
+ end
67
+ end
68
+ add_message "google.cloud.dialogflow.v2.KnowledgeOperationMetadata" do
69
+ optional :state, :enum, 1, "google.cloud.dialogflow.v2.KnowledgeOperationMetadata.State"
70
+ end
71
+ add_enum "google.cloud.dialogflow.v2.KnowledgeOperationMetadata.State" do
72
+ value :STATE_UNSPECIFIED, 0
73
+ value :PENDING, 1
74
+ value :RUNNING, 2
75
+ value :DONE, 3
76
+ end
77
+ end
78
+ end
79
+
80
+ module Google
81
+ module Cloud
82
+ module Dialogflow
83
+ module V2
84
+ Document = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.Document").msgclass
85
+ Document::ReloadStatus = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.Document.ReloadStatus").msgclass
86
+ Document::KnowledgeType = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.Document.KnowledgeType").enummodule
87
+ GetDocumentRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.GetDocumentRequest").msgclass
88
+ ListDocumentsRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.ListDocumentsRequest").msgclass
89
+ ListDocumentsResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.ListDocumentsResponse").msgclass
90
+ CreateDocumentRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.CreateDocumentRequest").msgclass
91
+ DeleteDocumentRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.DeleteDocumentRequest").msgclass
92
+ UpdateDocumentRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.UpdateDocumentRequest").msgclass
93
+ ReloadDocumentRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.ReloadDocumentRequest").msgclass
94
+ KnowledgeOperationMetadata = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.KnowledgeOperationMetadata").msgclass
95
+ KnowledgeOperationMetadata::State = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.KnowledgeOperationMetadata.State").enummodule
96
+ end
97
+ end
98
+ end
99
+ end
@@ -0,0 +1,73 @@
1
+ # Generated by the protocol buffer compiler. DO NOT EDIT!
2
+ # Source: google/cloud/dialogflow/v2/document.proto for package 'google.cloud.dialogflow.v2'
3
+ # Original file comments:
4
+ # Copyright 2021 Google LLC
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ require 'grpc'
20
+ require 'google/cloud/dialogflow/v2/document_pb'
21
+
22
+ module Google
23
+ module Cloud
24
+ module Dialogflow
25
+ module V2
26
+ module Documents
27
+ # Service for managing knowledge [Documents][google.cloud.dialogflow.v2.Document].
28
+ class Service
29
+
30
+ include ::GRPC::GenericService
31
+
32
+ self.marshal_class_method = :encode
33
+ self.unmarshal_class_method = :decode
34
+ self.service_name = 'google.cloud.dialogflow.v2.Documents'
35
+
36
+ # Returns the list of all documents of the knowledge base.
37
+ rpc :ListDocuments, ::Google::Cloud::Dialogflow::V2::ListDocumentsRequest, ::Google::Cloud::Dialogflow::V2::ListDocumentsResponse
38
+ # Retrieves the specified document.
39
+ rpc :GetDocument, ::Google::Cloud::Dialogflow::V2::GetDocumentRequest, ::Google::Cloud::Dialogflow::V2::Document
40
+ # Creates a new document.
41
+ #
42
+ # Operation <response: [Document][google.cloud.dialogflow.v2.Document],
43
+ # metadata: [KnowledgeOperationMetadata][google.cloud.dialogflow.v2.KnowledgeOperationMetadata]>
44
+ rpc :CreateDocument, ::Google::Cloud::Dialogflow::V2::CreateDocumentRequest, ::Google::Longrunning::Operation
45
+ # Deletes the specified document.
46
+ #
47
+ # Operation <response: [google.protobuf.Empty][google.protobuf.Empty],
48
+ # metadata: [KnowledgeOperationMetadata][google.cloud.dialogflow.v2.KnowledgeOperationMetadata]>
49
+ rpc :DeleteDocument, ::Google::Cloud::Dialogflow::V2::DeleteDocumentRequest, ::Google::Longrunning::Operation
50
+ # Updates the specified document.
51
+ #
52
+ # Operation <response: [Document][google.cloud.dialogflow.v2.Document],
53
+ # metadata: [KnowledgeOperationMetadata][google.cloud.dialogflow.v2.KnowledgeOperationMetadata]>
54
+ rpc :UpdateDocument, ::Google::Cloud::Dialogflow::V2::UpdateDocumentRequest, ::Google::Longrunning::Operation
55
+ # Reloads the specified document from its specified source, content_uri or
56
+ # content. The previously loaded content of the document will be deleted.
57
+ # Note: Even when the content of the document has not changed, there still
58
+ # may be side effects because of internal implementation changes.
59
+ #
60
+ # Note: The `projects.agent.knowledgeBases.documents` resource is deprecated;
61
+ # only use `projects.knowledgeBases.documents`.
62
+ #
63
+ # Operation <response: [Document][google.cloud.dialogflow.v2.Document],
64
+ # metadata: [KnowledgeOperationMetadata][google.cloud.dialogflow.v2.KnowledgeOperationMetadata]>
65
+ rpc :ReloadDocument, ::Google::Cloud::Dialogflow::V2::ReloadDocumentRequest, ::Google::Longrunning::Operation
66
+ end
67
+
68
+ Stub = Service.rpc_stub_class
69
+ end
70
+ end
71
+ end
72
+ end
73
+ end
@@ -0,0 +1,50 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2021 Google LLC
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # https://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ # Auto-generated by gapic-generator-ruby. DO NOT EDIT!
18
+
19
+ require "gapic/common"
20
+ require "gapic/config"
21
+ require "gapic/config/method"
22
+
23
+ require "google/cloud/dialogflow/v2/version"
24
+
25
+ require "google/cloud/dialogflow/v2/documents/credentials"
26
+ require "google/cloud/dialogflow/v2/documents/paths"
27
+ require "google/cloud/dialogflow/v2/documents/operations"
28
+ require "google/cloud/dialogflow/v2/documents/client"
29
+
30
+ module Google
31
+ module Cloud
32
+ module Dialogflow
33
+ module V2
34
+ ##
35
+ # Service for managing knowledge {::Google::Cloud::Dialogflow::V2::Document Documents}.
36
+ #
37
+ # To load this service and instantiate a client:
38
+ #
39
+ # require "google/cloud/dialogflow/v2/documents"
40
+ # client = ::Google::Cloud::Dialogflow::V2::Documents::Client.new
41
+ #
42
+ module Documents
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
48
+
49
+ helper_path = ::File.join __dir__, "documents", "helpers.rb"
50
+ require "google/cloud/dialogflow/v2/documents/helpers" if ::File.file? helper_path
@@ -0,0 +1,810 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2021 Google LLC
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # https://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ # Auto-generated by gapic-generator-ruby. DO NOT EDIT!
18
+
19
+ require "google/cloud/errors"
20
+ require "google/cloud/dialogflow/v2/document_pb"
21
+
22
+ module Google
23
+ module Cloud
24
+ module Dialogflow
25
+ module V2
26
+ module Documents
27
+ ##
28
+ # Client for the Documents service.
29
+ #
30
+ # Service for managing knowledge {::Google::Cloud::Dialogflow::V2::Document Documents}.
31
+ #
32
+ class Client
33
+ include Paths
34
+
35
+ # @private
36
+ attr_reader :documents_stub
37
+
38
+ ##
39
+ # Configure the Documents Client class.
40
+ #
41
+ # See {::Google::Cloud::Dialogflow::V2::Documents::Client::Configuration}
42
+ # for a description of the configuration fields.
43
+ #
44
+ # ## Example
45
+ #
46
+ # To modify the configuration for all Documents clients:
47
+ #
48
+ # ::Google::Cloud::Dialogflow::V2::Documents::Client.configure do |config|
49
+ # config.timeout = 10.0
50
+ # end
51
+ #
52
+ # @yield [config] Configure the Client client.
53
+ # @yieldparam config [Client::Configuration]
54
+ #
55
+ # @return [Client::Configuration]
56
+ #
57
+ def self.configure
58
+ @configure ||= begin
59
+ namespace = ["Google", "Cloud", "Dialogflow", "V2"]
60
+ parent_config = while namespace.any?
61
+ parent_name = namespace.join "::"
62
+ parent_const = const_get parent_name
63
+ break parent_const.configure if parent_const.respond_to? :configure
64
+ namespace.pop
65
+ end
66
+ default_config = Client::Configuration.new parent_config
67
+
68
+ default_config.timeout = 60.0
69
+ default_config.retry_policy = {
70
+ initial_delay: 0.1,
71
+ max_delay: 60.0,
72
+ multiplier: 1.3,
73
+ retry_codes: [14]
74
+ }
75
+
76
+ default_config
77
+ end
78
+ yield @configure if block_given?
79
+ @configure
80
+ end
81
+
82
+ ##
83
+ # Configure the Documents Client instance.
84
+ #
85
+ # The configuration is set to the derived mode, meaning that values can be changed,
86
+ # but structural changes (adding new fields, etc.) are not allowed. Structural changes
87
+ # should be made on {Client.configure}.
88
+ #
89
+ # See {::Google::Cloud::Dialogflow::V2::Documents::Client::Configuration}
90
+ # for a description of the configuration fields.
91
+ #
92
+ # @yield [config] Configure the Client client.
93
+ # @yieldparam config [Client::Configuration]
94
+ #
95
+ # @return [Client::Configuration]
96
+ #
97
+ def configure
98
+ yield @config if block_given?
99
+ @config
100
+ end
101
+
102
+ ##
103
+ # Create a new Documents client object.
104
+ #
105
+ # ## Examples
106
+ #
107
+ # To create a new Documents client with the default
108
+ # configuration:
109
+ #
110
+ # client = ::Google::Cloud::Dialogflow::V2::Documents::Client.new
111
+ #
112
+ # To create a new Documents client with a custom
113
+ # configuration:
114
+ #
115
+ # client = ::Google::Cloud::Dialogflow::V2::Documents::Client.new do |config|
116
+ # config.timeout = 10.0
117
+ # end
118
+ #
119
+ # @yield [config] Configure the Documents client.
120
+ # @yieldparam config [Client::Configuration]
121
+ #
122
+ def initialize
123
+ # These require statements are intentionally placed here to initialize
124
+ # the gRPC module only when it's required.
125
+ # See https://github.com/googleapis/toolkit/issues/446
126
+ require "gapic/grpc"
127
+ require "google/cloud/dialogflow/v2/document_services_pb"
128
+
129
+ # Create the configuration object
130
+ @config = Configuration.new Client.configure
131
+
132
+ # Yield the configuration if needed
133
+ yield @config if block_given?
134
+
135
+ # Create credentials
136
+ credentials = @config.credentials
137
+ # Use self-signed JWT if the scope and endpoint are unchanged from default,
138
+ # but only if the default endpoint does not have a region prefix.
139
+ enable_self_signed_jwt = @config.scope == Client.configure.scope &&
140
+ @config.endpoint == Client.configure.endpoint &&
141
+ !@config.endpoint.split(".").first.include?("-")
142
+ credentials ||= Credentials.default scope: @config.scope,
143
+ enable_self_signed_jwt: enable_self_signed_jwt
144
+ if credentials.is_a?(String) || credentials.is_a?(Hash)
145
+ credentials = Credentials.new credentials, scope: @config.scope
146
+ end
147
+ @quota_project_id = @config.quota_project
148
+ @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id
149
+
150
+ @operations_client = Operations.new do |config|
151
+ config.credentials = credentials
152
+ config.endpoint = @config.endpoint
153
+ end
154
+
155
+ @documents_stub = ::Gapic::ServiceStub.new(
156
+ ::Google::Cloud::Dialogflow::V2::Documents::Stub,
157
+ credentials: credentials,
158
+ endpoint: @config.endpoint,
159
+ channel_args: @config.channel_args,
160
+ interceptors: @config.interceptors
161
+ )
162
+ end
163
+
164
+ ##
165
+ # Get the associated client for long-running operations.
166
+ #
167
+ # @return [::Google::Cloud::Dialogflow::V2::Documents::Operations]
168
+ #
169
+ attr_reader :operations_client
170
+
171
+ # Service calls
172
+
173
+ ##
174
+ # Returns the list of all documents of the knowledge base.
175
+ #
176
+ # @overload list_documents(request, options = nil)
177
+ # Pass arguments to `list_documents` via a request object, either of type
178
+ # {::Google::Cloud::Dialogflow::V2::ListDocumentsRequest} or an equivalent Hash.
179
+ #
180
+ # @param request [::Google::Cloud::Dialogflow::V2::ListDocumentsRequest, ::Hash]
181
+ # A request object representing the call parameters. Required. To specify no
182
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
183
+ # @param options [::Gapic::CallOptions, ::Hash]
184
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
185
+ #
186
+ # @overload list_documents(parent: nil, page_size: nil, page_token: nil)
187
+ # Pass arguments to `list_documents` via keyword arguments. Note that at
188
+ # least one keyword argument is required. To specify no parameters, or to keep all
189
+ # the default parameter values, pass an empty Hash as a request object (see above).
190
+ #
191
+ # @param parent [::String]
192
+ # Required. The knowledge base to list all documents for.
193
+ # Format: `projects/<Project ID>/locations/<Location
194
+ # ID>/knowledgeBases/<Knowledge Base ID>`.
195
+ # @param page_size [::Integer]
196
+ # The maximum number of items to return in a single page. By
197
+ # default 10 and at most 100.
198
+ # @param page_token [::String]
199
+ # The next_page_token value returned from a previous list request.
200
+ #
201
+ # @yield [response, operation] Access the result along with the RPC operation
202
+ # @yieldparam response [::Gapic::PagedEnumerable<::Google::Cloud::Dialogflow::V2::Document>]
203
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
204
+ #
205
+ # @return [::Gapic::PagedEnumerable<::Google::Cloud::Dialogflow::V2::Document>]
206
+ #
207
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
208
+ #
209
+ def list_documents request, options = nil
210
+ raise ::ArgumentError, "request must be provided" if request.nil?
211
+
212
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Dialogflow::V2::ListDocumentsRequest
213
+
214
+ # Converts hash and nil to an options object
215
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
216
+
217
+ # Customize the options with defaults
218
+ metadata = @config.rpcs.list_documents.metadata.to_h
219
+
220
+ # Set x-goog-api-client and x-goog-user-project headers
221
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
222
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
223
+ gapic_version: ::Google::Cloud::Dialogflow::V2::VERSION
224
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
225
+
226
+ header_params = {
227
+ "parent" => request.parent
228
+ }
229
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
230
+ metadata[:"x-goog-request-params"] ||= request_params_header
231
+
232
+ options.apply_defaults timeout: @config.rpcs.list_documents.timeout,
233
+ metadata: metadata,
234
+ retry_policy: @config.rpcs.list_documents.retry_policy
235
+ options.apply_defaults metadata: @config.metadata,
236
+ retry_policy: @config.retry_policy
237
+
238
+ @documents_stub.call_rpc :list_documents, request, options: options do |response, operation|
239
+ response = ::Gapic::PagedEnumerable.new @documents_stub, :list_documents, request, response, operation, options
240
+ yield response, operation if block_given?
241
+ return response
242
+ end
243
+ rescue ::GRPC::BadStatus => e
244
+ raise ::Google::Cloud::Error.from_error(e)
245
+ end
246
+
247
+ ##
248
+ # Retrieves the specified document.
249
+ #
250
+ # @overload get_document(request, options = nil)
251
+ # Pass arguments to `get_document` via a request object, either of type
252
+ # {::Google::Cloud::Dialogflow::V2::GetDocumentRequest} or an equivalent Hash.
253
+ #
254
+ # @param request [::Google::Cloud::Dialogflow::V2::GetDocumentRequest, ::Hash]
255
+ # A request object representing the call parameters. Required. To specify no
256
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
257
+ # @param options [::Gapic::CallOptions, ::Hash]
258
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
259
+ #
260
+ # @overload get_document(name: nil)
261
+ # Pass arguments to `get_document` via keyword arguments. Note that at
262
+ # least one keyword argument is required. To specify no parameters, or to keep all
263
+ # the default parameter values, pass an empty Hash as a request object (see above).
264
+ #
265
+ # @param name [::String]
266
+ # Required. The name of the document to retrieve.
267
+ # Format `projects/<Project ID>/locations/<Location
268
+ # ID>/knowledgeBases/<Knowledge Base ID>/documents/<Document ID>`.
269
+ #
270
+ # @yield [response, operation] Access the result along with the RPC operation
271
+ # @yieldparam response [::Google::Cloud::Dialogflow::V2::Document]
272
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
273
+ #
274
+ # @return [::Google::Cloud::Dialogflow::V2::Document]
275
+ #
276
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
277
+ #
278
+ def get_document request, options = nil
279
+ raise ::ArgumentError, "request must be provided" if request.nil?
280
+
281
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Dialogflow::V2::GetDocumentRequest
282
+
283
+ # Converts hash and nil to an options object
284
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
285
+
286
+ # Customize the options with defaults
287
+ metadata = @config.rpcs.get_document.metadata.to_h
288
+
289
+ # Set x-goog-api-client and x-goog-user-project headers
290
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
291
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
292
+ gapic_version: ::Google::Cloud::Dialogflow::V2::VERSION
293
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
294
+
295
+ header_params = {
296
+ "name" => request.name
297
+ }
298
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
299
+ metadata[:"x-goog-request-params"] ||= request_params_header
300
+
301
+ options.apply_defaults timeout: @config.rpcs.get_document.timeout,
302
+ metadata: metadata,
303
+ retry_policy: @config.rpcs.get_document.retry_policy
304
+ options.apply_defaults metadata: @config.metadata,
305
+ retry_policy: @config.retry_policy
306
+
307
+ @documents_stub.call_rpc :get_document, request, options: options do |response, operation|
308
+ yield response, operation if block_given?
309
+ return response
310
+ end
311
+ rescue ::GRPC::BadStatus => e
312
+ raise ::Google::Cloud::Error.from_error(e)
313
+ end
314
+
315
+ ##
316
+ # Creates a new document.
317
+ #
318
+ # Operation <response: {::Google::Cloud::Dialogflow::V2::Document Document},
319
+ # metadata: {::Google::Cloud::Dialogflow::V2::KnowledgeOperationMetadata KnowledgeOperationMetadata}>
320
+ #
321
+ # @overload create_document(request, options = nil)
322
+ # Pass arguments to `create_document` via a request object, either of type
323
+ # {::Google::Cloud::Dialogflow::V2::CreateDocumentRequest} or an equivalent Hash.
324
+ #
325
+ # @param request [::Google::Cloud::Dialogflow::V2::CreateDocumentRequest, ::Hash]
326
+ # A request object representing the call parameters. Required. To specify no
327
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
328
+ # @param options [::Gapic::CallOptions, ::Hash]
329
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
330
+ #
331
+ # @overload create_document(parent: nil, document: nil)
332
+ # Pass arguments to `create_document` via keyword arguments. Note that at
333
+ # least one keyword argument is required. To specify no parameters, or to keep all
334
+ # the default parameter values, pass an empty Hash as a request object (see above).
335
+ #
336
+ # @param parent [::String]
337
+ # Required. The knowledge base to create a document for.
338
+ # Format: `projects/<Project ID>/locations/<Location
339
+ # ID>/knowledgeBases/<Knowledge Base ID>`.
340
+ # @param document [::Google::Cloud::Dialogflow::V2::Document, ::Hash]
341
+ # Required. The document to create.
342
+ #
343
+ # @yield [response, operation] Access the result along with the RPC operation
344
+ # @yieldparam response [::Gapic::Operation]
345
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
346
+ #
347
+ # @return [::Gapic::Operation]
348
+ #
349
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
350
+ #
351
+ def create_document request, options = nil
352
+ raise ::ArgumentError, "request must be provided" if request.nil?
353
+
354
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Dialogflow::V2::CreateDocumentRequest
355
+
356
+ # Converts hash and nil to an options object
357
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
358
+
359
+ # Customize the options with defaults
360
+ metadata = @config.rpcs.create_document.metadata.to_h
361
+
362
+ # Set x-goog-api-client and x-goog-user-project headers
363
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
364
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
365
+ gapic_version: ::Google::Cloud::Dialogflow::V2::VERSION
366
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
367
+
368
+ header_params = {
369
+ "parent" => request.parent
370
+ }
371
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
372
+ metadata[:"x-goog-request-params"] ||= request_params_header
373
+
374
+ options.apply_defaults timeout: @config.rpcs.create_document.timeout,
375
+ metadata: metadata,
376
+ retry_policy: @config.rpcs.create_document.retry_policy
377
+ options.apply_defaults metadata: @config.metadata,
378
+ retry_policy: @config.retry_policy
379
+
380
+ @documents_stub.call_rpc :create_document, request, options: options do |response, operation|
381
+ response = ::Gapic::Operation.new response, @operations_client, options: options
382
+ yield response, operation if block_given?
383
+ return response
384
+ end
385
+ rescue ::GRPC::BadStatus => e
386
+ raise ::Google::Cloud::Error.from_error(e)
387
+ end
388
+
389
+ ##
390
+ # Deletes the specified document.
391
+ #
392
+ # Operation <response: {::Google::Protobuf::Empty google.protobuf.Empty},
393
+ # metadata: {::Google::Cloud::Dialogflow::V2::KnowledgeOperationMetadata KnowledgeOperationMetadata}>
394
+ #
395
+ # @overload delete_document(request, options = nil)
396
+ # Pass arguments to `delete_document` via a request object, either of type
397
+ # {::Google::Cloud::Dialogflow::V2::DeleteDocumentRequest} or an equivalent Hash.
398
+ #
399
+ # @param request [::Google::Cloud::Dialogflow::V2::DeleteDocumentRequest, ::Hash]
400
+ # A request object representing the call parameters. Required. To specify no
401
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
402
+ # @param options [::Gapic::CallOptions, ::Hash]
403
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
404
+ #
405
+ # @overload delete_document(name: nil)
406
+ # Pass arguments to `delete_document` via keyword arguments. Note that at
407
+ # least one keyword argument is required. To specify no parameters, or to keep all
408
+ # the default parameter values, pass an empty Hash as a request object (see above).
409
+ #
410
+ # @param name [::String]
411
+ # Required. The name of the document to delete.
412
+ # Format: `projects/<Project ID>/locations/<Location
413
+ # ID>/knowledgeBases/<Knowledge Base ID>/documents/<Document ID>`.
414
+ #
415
+ # @yield [response, operation] Access the result along with the RPC operation
416
+ # @yieldparam response [::Gapic::Operation]
417
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
418
+ #
419
+ # @return [::Gapic::Operation]
420
+ #
421
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
422
+ #
423
+ def delete_document request, options = nil
424
+ raise ::ArgumentError, "request must be provided" if request.nil?
425
+
426
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Dialogflow::V2::DeleteDocumentRequest
427
+
428
+ # Converts hash and nil to an options object
429
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
430
+
431
+ # Customize the options with defaults
432
+ metadata = @config.rpcs.delete_document.metadata.to_h
433
+
434
+ # Set x-goog-api-client and x-goog-user-project headers
435
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
436
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
437
+ gapic_version: ::Google::Cloud::Dialogflow::V2::VERSION
438
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
439
+
440
+ header_params = {
441
+ "name" => request.name
442
+ }
443
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
444
+ metadata[:"x-goog-request-params"] ||= request_params_header
445
+
446
+ options.apply_defaults timeout: @config.rpcs.delete_document.timeout,
447
+ metadata: metadata,
448
+ retry_policy: @config.rpcs.delete_document.retry_policy
449
+ options.apply_defaults metadata: @config.metadata,
450
+ retry_policy: @config.retry_policy
451
+
452
+ @documents_stub.call_rpc :delete_document, request, options: options do |response, operation|
453
+ response = ::Gapic::Operation.new response, @operations_client, options: options
454
+ yield response, operation if block_given?
455
+ return response
456
+ end
457
+ rescue ::GRPC::BadStatus => e
458
+ raise ::Google::Cloud::Error.from_error(e)
459
+ end
460
+
461
+ ##
462
+ # Updates the specified document.
463
+ #
464
+ # Operation <response: {::Google::Cloud::Dialogflow::V2::Document Document},
465
+ # metadata: {::Google::Cloud::Dialogflow::V2::KnowledgeOperationMetadata KnowledgeOperationMetadata}>
466
+ #
467
+ # @overload update_document(request, options = nil)
468
+ # Pass arguments to `update_document` via a request object, either of type
469
+ # {::Google::Cloud::Dialogflow::V2::UpdateDocumentRequest} or an equivalent Hash.
470
+ #
471
+ # @param request [::Google::Cloud::Dialogflow::V2::UpdateDocumentRequest, ::Hash]
472
+ # A request object representing the call parameters. Required. To specify no
473
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
474
+ # @param options [::Gapic::CallOptions, ::Hash]
475
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
476
+ #
477
+ # @overload update_document(document: nil, update_mask: nil)
478
+ # Pass arguments to `update_document` via keyword arguments. Note that at
479
+ # least one keyword argument is required. To specify no parameters, or to keep all
480
+ # the default parameter values, pass an empty Hash as a request object (see above).
481
+ #
482
+ # @param document [::Google::Cloud::Dialogflow::V2::Document, ::Hash]
483
+ # Required. The document to update.
484
+ # @param update_mask [::Google::Protobuf::FieldMask, ::Hash]
485
+ # Optional. Not specified means `update all`.
486
+ # Currently, only `display_name` can be updated, an InvalidArgument will be
487
+ # returned for attempting to update other fields.
488
+ #
489
+ # @yield [response, operation] Access the result along with the RPC operation
490
+ # @yieldparam response [::Gapic::Operation]
491
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
492
+ #
493
+ # @return [::Gapic::Operation]
494
+ #
495
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
496
+ #
497
+ def update_document request, options = nil
498
+ raise ::ArgumentError, "request must be provided" if request.nil?
499
+
500
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Dialogflow::V2::UpdateDocumentRequest
501
+
502
+ # Converts hash and nil to an options object
503
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
504
+
505
+ # Customize the options with defaults
506
+ metadata = @config.rpcs.update_document.metadata.to_h
507
+
508
+ # Set x-goog-api-client and x-goog-user-project headers
509
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
510
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
511
+ gapic_version: ::Google::Cloud::Dialogflow::V2::VERSION
512
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
513
+
514
+ header_params = {
515
+ "document.name" => request.document.name
516
+ }
517
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
518
+ metadata[:"x-goog-request-params"] ||= request_params_header
519
+
520
+ options.apply_defaults timeout: @config.rpcs.update_document.timeout,
521
+ metadata: metadata,
522
+ retry_policy: @config.rpcs.update_document.retry_policy
523
+ options.apply_defaults metadata: @config.metadata,
524
+ retry_policy: @config.retry_policy
525
+
526
+ @documents_stub.call_rpc :update_document, request, options: options do |response, operation|
527
+ response = ::Gapic::Operation.new response, @operations_client, options: options
528
+ yield response, operation if block_given?
529
+ return response
530
+ end
531
+ rescue ::GRPC::BadStatus => e
532
+ raise ::Google::Cloud::Error.from_error(e)
533
+ end
534
+
535
+ ##
536
+ # Reloads the specified document from its specified source, content_uri or
537
+ # content. The previously loaded content of the document will be deleted.
538
+ # Note: Even when the content of the document has not changed, there still
539
+ # may be side effects because of internal implementation changes.
540
+ #
541
+ # Note: The `projects.agent.knowledgeBases.documents` resource is deprecated;
542
+ # only use `projects.knowledgeBases.documents`.
543
+ #
544
+ # Operation <response: {::Google::Cloud::Dialogflow::V2::Document Document},
545
+ # metadata: {::Google::Cloud::Dialogflow::V2::KnowledgeOperationMetadata KnowledgeOperationMetadata}>
546
+ #
547
+ # @overload reload_document(request, options = nil)
548
+ # Pass arguments to `reload_document` via a request object, either of type
549
+ # {::Google::Cloud::Dialogflow::V2::ReloadDocumentRequest} or an equivalent Hash.
550
+ #
551
+ # @param request [::Google::Cloud::Dialogflow::V2::ReloadDocumentRequest, ::Hash]
552
+ # A request object representing the call parameters. Required. To specify no
553
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
554
+ # @param options [::Gapic::CallOptions, ::Hash]
555
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
556
+ #
557
+ # @overload reload_document(name: nil, content_uri: nil)
558
+ # Pass arguments to `reload_document` via keyword arguments. Note that at
559
+ # least one keyword argument is required. To specify no parameters, or to keep all
560
+ # the default parameter values, pass an empty Hash as a request object (see above).
561
+ #
562
+ # @param name [::String]
563
+ # Required. The name of the document to reload.
564
+ # Format: `projects/<Project ID>/locations/<Location
565
+ # ID>/knowledgeBases/<Knowledge Base ID>/documents/<Document ID>`
566
+ # @param content_uri [::String]
567
+ # Optional. The path of gcs source file for reloading document content. For now,
568
+ # only gcs uri is supported.
569
+ #
570
+ # For documents stored in Google Cloud Storage, these URIs must have
571
+ # the form `gs://<bucket-name>/<object-name>`.
572
+ #
573
+ # @yield [response, operation] Access the result along with the RPC operation
574
+ # @yieldparam response [::Gapic::Operation]
575
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
576
+ #
577
+ # @return [::Gapic::Operation]
578
+ #
579
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
580
+ #
581
+ def reload_document request, options = nil
582
+ raise ::ArgumentError, "request must be provided" if request.nil?
583
+
584
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Dialogflow::V2::ReloadDocumentRequest
585
+
586
+ # Converts hash and nil to an options object
587
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
588
+
589
+ # Customize the options with defaults
590
+ metadata = @config.rpcs.reload_document.metadata.to_h
591
+
592
+ # Set x-goog-api-client and x-goog-user-project headers
593
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
594
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
595
+ gapic_version: ::Google::Cloud::Dialogflow::V2::VERSION
596
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
597
+
598
+ header_params = {
599
+ "name" => request.name
600
+ }
601
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
602
+ metadata[:"x-goog-request-params"] ||= request_params_header
603
+
604
+ options.apply_defaults timeout: @config.rpcs.reload_document.timeout,
605
+ metadata: metadata,
606
+ retry_policy: @config.rpcs.reload_document.retry_policy
607
+ options.apply_defaults metadata: @config.metadata,
608
+ retry_policy: @config.retry_policy
609
+
610
+ @documents_stub.call_rpc :reload_document, request, options: options do |response, operation|
611
+ response = ::Gapic::Operation.new response, @operations_client, options: options
612
+ yield response, operation if block_given?
613
+ return response
614
+ end
615
+ rescue ::GRPC::BadStatus => e
616
+ raise ::Google::Cloud::Error.from_error(e)
617
+ end
618
+
619
+ ##
620
+ # Configuration class for the Documents API.
621
+ #
622
+ # This class represents the configuration for Documents,
623
+ # providing control over timeouts, retry behavior, logging, transport
624
+ # parameters, and other low-level controls. Certain parameters can also be
625
+ # applied individually to specific RPCs. See
626
+ # {::Google::Cloud::Dialogflow::V2::Documents::Client::Configuration::Rpcs}
627
+ # for a list of RPCs that can be configured independently.
628
+ #
629
+ # Configuration can be applied globally to all clients, or to a single client
630
+ # on construction.
631
+ #
632
+ # # Examples
633
+ #
634
+ # To modify the global config, setting the timeout for list_documents
635
+ # to 20 seconds, and all remaining timeouts to 10 seconds:
636
+ #
637
+ # ::Google::Cloud::Dialogflow::V2::Documents::Client.configure do |config|
638
+ # config.timeout = 10.0
639
+ # config.rpcs.list_documents.timeout = 20.0
640
+ # end
641
+ #
642
+ # To apply the above configuration only to a new client:
643
+ #
644
+ # client = ::Google::Cloud::Dialogflow::V2::Documents::Client.new do |config|
645
+ # config.timeout = 10.0
646
+ # config.rpcs.list_documents.timeout = 20.0
647
+ # end
648
+ #
649
+ # @!attribute [rw] endpoint
650
+ # The hostname or hostname:port of the service endpoint.
651
+ # Defaults to `"dialogflow.googleapis.com"`.
652
+ # @return [::String]
653
+ # @!attribute [rw] credentials
654
+ # Credentials to send with calls. You may provide any of the following types:
655
+ # * (`String`) The path to a service account key file in JSON format
656
+ # * (`Hash`) A service account key as a Hash
657
+ # * (`Google::Auth::Credentials`) A googleauth credentials object
658
+ # (see the [googleauth docs](https://googleapis.dev/ruby/googleauth/latest/index.html))
659
+ # * (`Signet::OAuth2::Client`) A signet oauth2 client object
660
+ # (see the [signet docs](https://googleapis.dev/ruby/signet/latest/Signet/OAuth2/Client.html))
661
+ # * (`GRPC::Core::Channel`) a gRPC channel with included credentials
662
+ # * (`GRPC::Core::ChannelCredentials`) a gRPC credentails object
663
+ # * (`nil`) indicating no credentials
664
+ # @return [::Object]
665
+ # @!attribute [rw] scope
666
+ # The OAuth scopes
667
+ # @return [::Array<::String>]
668
+ # @!attribute [rw] lib_name
669
+ # The library name as recorded in instrumentation and logging
670
+ # @return [::String]
671
+ # @!attribute [rw] lib_version
672
+ # The library version as recorded in instrumentation and logging
673
+ # @return [::String]
674
+ # @!attribute [rw] channel_args
675
+ # Extra parameters passed to the gRPC channel. Note: this is ignored if a
676
+ # `GRPC::Core::Channel` object is provided as the credential.
677
+ # @return [::Hash]
678
+ # @!attribute [rw] interceptors
679
+ # An array of interceptors that are run before calls are executed.
680
+ # @return [::Array<::GRPC::ClientInterceptor>]
681
+ # @!attribute [rw] timeout
682
+ # The call timeout in seconds.
683
+ # @return [::Numeric]
684
+ # @!attribute [rw] metadata
685
+ # Additional gRPC headers to be sent with the call.
686
+ # @return [::Hash{::Symbol=>::String}]
687
+ # @!attribute [rw] retry_policy
688
+ # The retry policy. The value is a hash with the following keys:
689
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
690
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
691
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
692
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
693
+ # trigger a retry.
694
+ # @return [::Hash]
695
+ # @!attribute [rw] quota_project
696
+ # A separate project against which to charge quota.
697
+ # @return [::String]
698
+ #
699
+ class Configuration
700
+ extend ::Gapic::Config
701
+
702
+ config_attr :endpoint, "dialogflow.googleapis.com", ::String
703
+ config_attr :credentials, nil do |value|
704
+ allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
705
+ allowed += [::GRPC::Core::Channel, ::GRPC::Core::ChannelCredentials] if defined? ::GRPC
706
+ allowed.any? { |klass| klass === value }
707
+ end
708
+ config_attr :scope, nil, ::String, ::Array, nil
709
+ config_attr :lib_name, nil, ::String, nil
710
+ config_attr :lib_version, nil, ::String, nil
711
+ config_attr(:channel_args, { "grpc.service_config_disable_resolution" => 1 }, ::Hash, nil)
712
+ config_attr :interceptors, nil, ::Array, nil
713
+ config_attr :timeout, nil, ::Numeric, nil
714
+ config_attr :metadata, nil, ::Hash, nil
715
+ config_attr :retry_policy, nil, ::Hash, ::Proc, nil
716
+ config_attr :quota_project, nil, ::String, nil
717
+
718
+ # @private
719
+ def initialize parent_config = nil
720
+ @parent_config = parent_config unless parent_config.nil?
721
+
722
+ yield self if block_given?
723
+ end
724
+
725
+ ##
726
+ # Configurations for individual RPCs
727
+ # @return [Rpcs]
728
+ #
729
+ def rpcs
730
+ @rpcs ||= begin
731
+ parent_rpcs = nil
732
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
733
+ Rpcs.new parent_rpcs
734
+ end
735
+ end
736
+
737
+ ##
738
+ # Configuration RPC class for the Documents API.
739
+ #
740
+ # Includes fields providing the configuration for each RPC in this service.
741
+ # Each configuration object is of type `Gapic::Config::Method` and includes
742
+ # the following configuration fields:
743
+ #
744
+ # * `timeout` (*type:* `Numeric`) - The call timeout in seconds
745
+ # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional gRPC headers
746
+ # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
747
+ # include the following keys:
748
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
749
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
750
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
751
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
752
+ # trigger a retry.
753
+ #
754
+ class Rpcs
755
+ ##
756
+ # RPC-specific configuration for `list_documents`
757
+ # @return [::Gapic::Config::Method]
758
+ #
759
+ attr_reader :list_documents
760
+ ##
761
+ # RPC-specific configuration for `get_document`
762
+ # @return [::Gapic::Config::Method]
763
+ #
764
+ attr_reader :get_document
765
+ ##
766
+ # RPC-specific configuration for `create_document`
767
+ # @return [::Gapic::Config::Method]
768
+ #
769
+ attr_reader :create_document
770
+ ##
771
+ # RPC-specific configuration for `delete_document`
772
+ # @return [::Gapic::Config::Method]
773
+ #
774
+ attr_reader :delete_document
775
+ ##
776
+ # RPC-specific configuration for `update_document`
777
+ # @return [::Gapic::Config::Method]
778
+ #
779
+ attr_reader :update_document
780
+ ##
781
+ # RPC-specific configuration for `reload_document`
782
+ # @return [::Gapic::Config::Method]
783
+ #
784
+ attr_reader :reload_document
785
+
786
+ # @private
787
+ def initialize parent_rpcs = nil
788
+ list_documents_config = parent_rpcs.list_documents if parent_rpcs.respond_to? :list_documents
789
+ @list_documents = ::Gapic::Config::Method.new list_documents_config
790
+ get_document_config = parent_rpcs.get_document if parent_rpcs.respond_to? :get_document
791
+ @get_document = ::Gapic::Config::Method.new get_document_config
792
+ create_document_config = parent_rpcs.create_document if parent_rpcs.respond_to? :create_document
793
+ @create_document = ::Gapic::Config::Method.new create_document_config
794
+ delete_document_config = parent_rpcs.delete_document if parent_rpcs.respond_to? :delete_document
795
+ @delete_document = ::Gapic::Config::Method.new delete_document_config
796
+ update_document_config = parent_rpcs.update_document if parent_rpcs.respond_to? :update_document
797
+ @update_document = ::Gapic::Config::Method.new update_document_config
798
+ reload_document_config = parent_rpcs.reload_document if parent_rpcs.respond_to? :reload_document
799
+ @reload_document = ::Gapic::Config::Method.new reload_document_config
800
+
801
+ yield self if block_given?
802
+ end
803
+ end
804
+ end
805
+ end
806
+ end
807
+ end
808
+ end
809
+ end
810
+ end