google-cloud-dialogflow-v2 0.6.1 → 0.8.0

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 +24 -39
  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 +7 -24
  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 +11 -38
  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 +23 -2
  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 +8 -39
  61. data/lib/google/cloud/dialogflow/v2/intents.rb +1 -32
  62. data/lib/google/cloud/dialogflow/v2/intents/client.rb +25 -80
  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 +6 -22
  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 +14 -6
  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 +20 -3
  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 AnswerRecords
26
+ # Credentials for the AnswerRecords 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,105 @@
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 AnswerRecords
25
+ # Path helper methods for the AnswerRecords API.
26
+ module Paths
27
+ ##
28
+ # Create a fully-qualified AnswerRecord resource string.
29
+ #
30
+ # @overload answer_record_path(project:, answer_record:)
31
+ # The resource will be in the following format:
32
+ #
33
+ # `projects/{project}/answerRecords/{answer_record}`
34
+ #
35
+ # @param project [String]
36
+ # @param answer_record [String]
37
+ #
38
+ # @overload answer_record_path(project:, location:, answer_record:)
39
+ # The resource will be in the following format:
40
+ #
41
+ # `projects/{project}/locations/{location}/answerRecords/{answer_record}`
42
+ #
43
+ # @param project [String]
44
+ # @param location [String]
45
+ # @param answer_record [String]
46
+ #
47
+ # @return [::String]
48
+ def answer_record_path **args
49
+ resources = {
50
+ "answer_record:project" => (proc do |project:, answer_record:|
51
+ raise ::ArgumentError, "project cannot contain /" if project.to_s.include? "/"
52
+
53
+ "projects/#{project}/answerRecords/#{answer_record}"
54
+ end),
55
+ "answer_record:location:project" => (proc do |project:, location:, answer_record:|
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}/answerRecords/#{answer_record}"
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 Location resource string.
70
+ #
71
+ # The resource will be in the following format:
72
+ #
73
+ # `projects/{project}/locations/{location}`
74
+ #
75
+ # @param project [String]
76
+ # @param location [String]
77
+ #
78
+ # @return [::String]
79
+ def location_path project:, location:
80
+ raise ::ArgumentError, "project cannot contain /" if project.to_s.include? "/"
81
+
82
+ "projects/#{project}/locations/#{location}"
83
+ end
84
+
85
+ ##
86
+ # Create a fully-qualified Project resource string.
87
+ #
88
+ # The resource will be in the following format:
89
+ #
90
+ # `projects/{project}`
91
+ #
92
+ # @param project [String]
93
+ #
94
+ # @return [::String]
95
+ def project_path project:
96
+ "projects/#{project}"
97
+ end
98
+
99
+ extend self
100
+ end
101
+ end
102
+ end
103
+ end
104
+ end
105
+ end
@@ -29,6 +29,7 @@ Google::Protobuf::DescriptorPool.generated_pool.build do
29
29
  optional :model, :string, 7
30
30
  optional :model_variant, :enum, 10, "google.cloud.dialogflow.v2.SpeechModelVariant"
31
31
  optional :single_utterance, :bool, 8
32
+ optional :disable_no_speech_recognized_event, :bool, 14
32
33
  end
33
34
  add_message "google.cloud.dialogflow.v2.VoiceSelectionParams" do
34
35
  optional :name, :string, 1
@@ -46,6 +47,9 @@ Google::Protobuf::DescriptorPool.generated_pool.build do
46
47
  optional :sample_rate_hertz, :int32, 2
47
48
  optional :synthesize_speech_config, :message, 3, "google.cloud.dialogflow.v2.SynthesizeSpeechConfig"
48
49
  end
50
+ add_message "google.cloud.dialogflow.v2.SpeechToTextConfig" do
51
+ optional :speech_model_variant, :enum, 1, "google.cloud.dialogflow.v2.SpeechModelVariant"
52
+ end
49
53
  add_enum "google.cloud.dialogflow.v2.AudioEncoding" do
50
54
  value :AUDIO_ENCODING_UNSPECIFIED, 0
51
55
  value :AUDIO_ENCODING_LINEAR_16, 1
@@ -72,7 +76,9 @@ Google::Protobuf::DescriptorPool.generated_pool.build do
72
76
  value :OUTPUT_AUDIO_ENCODING_UNSPECIFIED, 0
73
77
  value :OUTPUT_AUDIO_ENCODING_LINEAR_16, 1
74
78
  value :OUTPUT_AUDIO_ENCODING_MP3, 2
79
+ value :OUTPUT_AUDIO_ENCODING_MP3_64_KBPS, 4
75
80
  value :OUTPUT_AUDIO_ENCODING_OGG_OPUS, 3
81
+ value :OUTPUT_AUDIO_ENCODING_MULAW, 5
76
82
  end
77
83
  end
78
84
  end
@@ -87,6 +93,7 @@ module Google
87
93
  VoiceSelectionParams = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.VoiceSelectionParams").msgclass
88
94
  SynthesizeSpeechConfig = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.SynthesizeSpeechConfig").msgclass
89
95
  OutputAudioConfig = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.OutputAudioConfig").msgclass
96
+ SpeechToTextConfig = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.SpeechToTextConfig").msgclass
90
97
  AudioEncoding = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.AudioEncoding").enummodule
91
98
  SpeechModelVariant = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.SpeechModelVariant").enummodule
92
99
  SsmlVoiceGender = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.SsmlVoiceGender").enummodule
@@ -24,24 +24,7 @@ module Google
24
24
  module Dialogflow
25
25
  module V2
26
26
  module Contexts
27
- # A context represents additional information included with user input or with
28
- # an intent returned by the Dialogflow API. Contexts are helpful for
29
- # differentiating user input which may be vague or have a different meaning
30
- # depending on additional details from your application such as user setting
31
- # and preferences, previous user input, where the user is in your application,
32
- # geographic location, and so on.
33
- #
34
- # You can include contexts as input parameters of a
35
- # [DetectIntent][google.cloud.dialogflow.v2.Sessions.DetectIntent] (or
36
- # [StreamingDetectIntent][google.cloud.dialogflow.v2.Sessions.StreamingDetectIntent]) request,
37
- # or as output contexts included in the returned intent.
38
- # Contexts expire when an intent is matched, after the number of `DetectIntent`
39
- # requests specified by the `lifespan_count` parameter, or after 20 minutes
40
- # if no intents are matched for a `DetectIntent` request.
41
- #
42
- # For more information about contexts, see the
43
- # [Dialogflow
44
- # documentation](https://cloud.google.com/dialogflow/docs/contexts-overview).
27
+ # Service for managing [Contexts][google.cloud.dialogflow.v2.Context].
45
28
  class Service
46
29
 
47
30
  include GRPC::GenericService
@@ -51,19 +34,19 @@ module Google
51
34
  self.service_name = 'google.cloud.dialogflow.v2.Contexts'
52
35
 
53
36
  # Returns the list of all contexts in the specified session.
54
- rpc :ListContexts, ListContextsRequest, ListContextsResponse
37
+ rpc :ListContexts, ::Google::Cloud::Dialogflow::V2::ListContextsRequest, ::Google::Cloud::Dialogflow::V2::ListContextsResponse
55
38
  # Retrieves the specified context.
56
- rpc :GetContext, GetContextRequest, Context
39
+ rpc :GetContext, ::Google::Cloud::Dialogflow::V2::GetContextRequest, ::Google::Cloud::Dialogflow::V2::Context
57
40
  # Creates a context.
58
41
  #
59
42
  # If the specified context already exists, overrides the context.
60
- rpc :CreateContext, CreateContextRequest, Context
43
+ rpc :CreateContext, ::Google::Cloud::Dialogflow::V2::CreateContextRequest, ::Google::Cloud::Dialogflow::V2::Context
61
44
  # Updates the specified context.
62
- rpc :UpdateContext, UpdateContextRequest, Context
45
+ rpc :UpdateContext, ::Google::Cloud::Dialogflow::V2::UpdateContextRequest, ::Google::Cloud::Dialogflow::V2::Context
63
46
  # Deletes the specified context.
64
- rpc :DeleteContext, DeleteContextRequest, Google::Protobuf::Empty
47
+ rpc :DeleteContext, ::Google::Cloud::Dialogflow::V2::DeleteContextRequest, ::Google::Protobuf::Empty
65
48
  # Deletes all active contexts in the specified session.
66
- rpc :DeleteAllContexts, DeleteAllContextsRequest, Google::Protobuf::Empty
49
+ rpc :DeleteAllContexts, ::Google::Cloud::Dialogflow::V2::DeleteAllContextsRequest, ::Google::Protobuf::Empty
67
50
  end
68
51
 
69
52
  Stub = Service.rpc_stub_class
@@ -31,24 +31,7 @@ module Google
31
31
  module Dialogflow
32
32
  module V2
33
33
  ##
34
- # A context represents additional information included with user input or with
35
- # an intent returned by the Dialogflow API. Contexts are helpful for
36
- # differentiating user input which may be vague or have a different meaning
37
- # depending on additional details from your application such as user setting
38
- # and preferences, previous user input, where the user is in your application,
39
- # geographic location, and so on.
40
- #
41
- # You can include contexts as input parameters of a
42
- # {::Google::Cloud::Dialogflow::V2::Sessions::Client#detect_intent DetectIntent} (or
43
- # {::Google::Cloud::Dialogflow::V2::Sessions::Client#streaming_detect_intent StreamingDetectIntent}) request,
44
- # or as output contexts included in the returned intent.
45
- # Contexts expire when an intent is matched, after the number of `DetectIntent`
46
- # requests specified by the `lifespan_count` parameter, or after 20 minutes
47
- # if no intents are matched for a `DetectIntent` request.
48
- #
49
- # For more information about contexts, see the
50
- # [Dialogflow
51
- # documentation](https://cloud.google.com/dialogflow/docs/contexts-overview).
34
+ # Service for managing {::Google::Cloud::Dialogflow::V2::Context Contexts}.
52
35
  #
53
36
  # To load this service and instantiate a client:
54
37
  #
@@ -27,24 +27,7 @@ module Google
27
27
  ##
28
28
  # Client for the Contexts service.
29
29
  #
30
- # A context represents additional information included with user input or with
31
- # an intent returned by the Dialogflow API. Contexts are helpful for
32
- # differentiating user input which may be vague or have a different meaning
33
- # depending on additional details from your application such as user setting
34
- # and preferences, previous user input, where the user is in your application,
35
- # geographic location, and so on.
36
- #
37
- # You can include contexts as input parameters of a
38
- # {::Google::Cloud::Dialogflow::V2::Sessions::Client#detect_intent DetectIntent} (or
39
- # {::Google::Cloud::Dialogflow::V2::Sessions::Client#streaming_detect_intent StreamingDetectIntent}) request,
40
- # or as output contexts included in the returned intent.
41
- # Contexts expire when an intent is matched, after the number of `DetectIntent`
42
- # requests specified by the `lifespan_count` parameter, or after 20 minutes
43
- # if no intents are matched for a `DetectIntent` request.
44
- #
45
- # For more information about contexts, see the
46
- # [Dialogflow
47
- # documentation](https://cloud.google.com/dialogflow/docs/contexts-overview).
30
+ # Service for managing {::Google::Cloud::Dialogflow::V2::Context Contexts}.
48
31
  #
49
32
  class Client
50
33
  include Paths
@@ -77,45 +60,17 @@ module Google
77
60
  parent_config = while namespace.any?
78
61
  parent_name = namespace.join "::"
79
62
  parent_const = const_get parent_name
80
- break parent_const.configure if parent_const&.respond_to? :configure
63
+ break parent_const.configure if parent_const.respond_to? :configure
81
64
  namespace.pop
82
65
  end
83
66
  default_config = Client::Configuration.new parent_config
84
67
 
85
- default_config.rpcs.list_contexts.timeout = 60.0
86
- default_config.rpcs.list_contexts.retry_policy = {
87
- initial_delay: 0.1,
88
- max_delay: 60.0,
89
- multiplier: 1.3,
90
- retry_codes: ["UNAVAILABLE", "DEADLINE_EXCEEDED"]
91
- }
92
-
93
- default_config.rpcs.get_context.timeout = 60.0
94
- default_config.rpcs.get_context.retry_policy = {
95
- initial_delay: 0.1,
96
- max_delay: 60.0,
97
- multiplier: 1.3,
98
- retry_codes: ["UNAVAILABLE", "DEADLINE_EXCEEDED"]
99
- }
100
-
101
- default_config.rpcs.create_context.timeout = 60.0
102
-
103
- default_config.rpcs.update_context.timeout = 60.0
104
-
105
- default_config.rpcs.delete_context.timeout = 60.0
106
- default_config.rpcs.delete_context.retry_policy = {
107
- initial_delay: 0.1,
108
- max_delay: 60.0,
109
- multiplier: 1.3,
110
- retry_codes: ["UNAVAILABLE", "DEADLINE_EXCEEDED"]
111
- }
112
-
113
- default_config.rpcs.delete_all_contexts.timeout = 60.0
114
- default_config.rpcs.delete_all_contexts.retry_policy = {
68
+ default_config.timeout = 60.0
69
+ default_config.retry_policy = {
115
70
  initial_delay: 0.1,
116
- max_delay: 60.0,
117
- multiplier: 1.3,
118
- retry_codes: ["UNAVAILABLE", "DEADLINE_EXCEEDED"]
71
+ max_delay: 60.0,
72
+ multiplier: 1.3,
73
+ retry_codes: [14]
119
74
  }
120
75
 
121
76
  default_config
@@ -179,7 +134,13 @@ module Google
179
134
 
180
135
  # Create credentials
181
136
  credentials = @config.credentials
182
- credentials ||= Credentials.default scope: @config.scope
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
183
144
  if credentials.is_a?(String) || credentials.is_a?(Hash)
184
145
  credentials = Credentials.new credentials, scope: @config.scope
185
146
  end
@@ -715,14 +676,14 @@ module Google
715
676
 
716
677
  config_attr :endpoint, "dialogflow.googleapis.com", ::String
717
678
  config_attr :credentials, nil do |value|
718
- allowed = [::String, ::Hash, ::Proc, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
679
+ allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
719
680
  allowed += [::GRPC::Core::Channel, ::GRPC::Core::ChannelCredentials] if defined? ::GRPC
720
681
  allowed.any? { |klass| klass === value }
721
682
  end
722
683
  config_attr :scope, nil, ::String, ::Array, nil
723
684
  config_attr :lib_name, nil, ::String, nil
724
685
  config_attr :lib_version, nil, ::String, nil
725
- config_attr(:channel_args, { "grpc.service_config_disable_resolution"=>1 }, ::Hash, nil)
686
+ config_attr(:channel_args, { "grpc.service_config_disable_resolution" => 1 }, ::Hash, nil)
726
687
  config_attr :interceptors, nil, ::Array, nil
727
688
  config_attr :timeout, nil, ::Numeric, nil
728
689
  config_attr :metadata, nil, ::Hash, nil
@@ -743,7 +704,7 @@ module Google
743
704
  def rpcs
744
705
  @rpcs ||= begin
745
706
  parent_rpcs = nil
746
- parent_rpcs = @parent_config.rpcs if @parent_config&.respond_to? :rpcs
707
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
747
708
  Rpcs.new parent_rpcs
748
709
  end
749
710
  end
@@ -755,7 +716,7 @@ module Google
755
716
  # Each configuration object is of type `Gapic::Config::Method` and includes
756
717
  # the following configuration fields:
757
718
  #
758
- # * `timeout` (*type:* `Numeric`) - The call timeout in milliseconds
719
+ # * `timeout` (*type:* `Numeric`) - The call timeout in seconds
759
720
  # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional gRPC headers
760
721
  # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
761
722
  # include the following keys:
@@ -799,17 +760,17 @@ module Google
799
760
 
800
761
  # @private
801
762
  def initialize parent_rpcs = nil
802
- list_contexts_config = parent_rpcs&.list_contexts if parent_rpcs&.respond_to? :list_contexts
763
+ list_contexts_config = parent_rpcs.list_contexts if parent_rpcs.respond_to? :list_contexts
803
764
  @list_contexts = ::Gapic::Config::Method.new list_contexts_config
804
- get_context_config = parent_rpcs&.get_context if parent_rpcs&.respond_to? :get_context
765
+ get_context_config = parent_rpcs.get_context if parent_rpcs.respond_to? :get_context
805
766
  @get_context = ::Gapic::Config::Method.new get_context_config
806
- create_context_config = parent_rpcs&.create_context if parent_rpcs&.respond_to? :create_context
767
+ create_context_config = parent_rpcs.create_context if parent_rpcs.respond_to? :create_context
807
768
  @create_context = ::Gapic::Config::Method.new create_context_config
808
- update_context_config = parent_rpcs&.update_context if parent_rpcs&.respond_to? :update_context
769
+ update_context_config = parent_rpcs.update_context if parent_rpcs.respond_to? :update_context
809
770
  @update_context = ::Gapic::Config::Method.new update_context_config
810
- delete_context_config = parent_rpcs&.delete_context if parent_rpcs&.respond_to? :delete_context
771
+ delete_context_config = parent_rpcs.delete_context if parent_rpcs.respond_to? :delete_context
811
772
  @delete_context = ::Gapic::Config::Method.new delete_context_config
812
- delete_all_contexts_config = parent_rpcs&.delete_all_contexts if parent_rpcs&.respond_to? :delete_all_contexts
773
+ delete_all_contexts_config = parent_rpcs.delete_all_contexts if parent_rpcs.respond_to? :delete_all_contexts
813
774
  @delete_all_contexts = ::Gapic::Config::Method.new delete_all_contexts_config
814
775
 
815
776
  yield self if block_given?
@@ -47,10 +47,32 @@ module Google
47
47
  # @param session [String]
48
48
  # @param context [String]
49
49
  #
50
+ # @overload context_path(project:, location:, session:, context:)
51
+ # The resource will be in the following format:
52
+ #
53
+ # `projects/{project}/locations/{location}/agent/sessions/{session}/contexts/{context}`
54
+ #
55
+ # @param project [String]
56
+ # @param location [String]
57
+ # @param session [String]
58
+ # @param context [String]
59
+ #
60
+ # @overload context_path(project:, location:, environment:, user:, session:, context:)
61
+ # The resource will be in the following format:
62
+ #
63
+ # `projects/{project}/locations/{location}/agent/environments/{environment}/users/{user}/sessions/{session}/contexts/{context}`
64
+ #
65
+ # @param project [String]
66
+ # @param location [String]
67
+ # @param environment [String]
68
+ # @param user [String]
69
+ # @param session [String]
70
+ # @param context [String]
71
+ #
50
72
  # @return [::String]
51
73
  def context_path **args
52
74
  resources = {
53
- "context:project:session" => (proc do |project:, session:, context:|
75
+ "context:project:session" => (proc do |project:, session:, context:|
54
76
  raise ::ArgumentError, "project cannot contain /" if project.to_s.include? "/"
55
77
  raise ::ArgumentError, "session cannot contain /" if session.to_s.include? "/"
56
78
 
@@ -63,6 +85,22 @@ module Google
63
85
  raise ::ArgumentError, "session cannot contain /" if session.to_s.include? "/"
64
86
 
65
87
  "projects/#{project}/agent/environments/#{environment}/users/#{user}/sessions/#{session}/contexts/#{context}"
88
+ end),
89
+ "context:location:project:session" => (proc do |project:, location:, session:, context:|
90
+ raise ::ArgumentError, "project cannot contain /" if project.to_s.include? "/"
91
+ raise ::ArgumentError, "location cannot contain /" if location.to_s.include? "/"
92
+ raise ::ArgumentError, "session cannot contain /" if session.to_s.include? "/"
93
+
94
+ "projects/#{project}/locations/#{location}/agent/sessions/#{session}/contexts/#{context}"
95
+ end),
96
+ "context:environment:location:project:session:user" => (proc do |project:, location:, environment:, user:, session:, context:|
97
+ raise ::ArgumentError, "project cannot contain /" if project.to_s.include? "/"
98
+ raise ::ArgumentError, "location cannot contain /" if location.to_s.include? "/"
99
+ raise ::ArgumentError, "environment cannot contain /" if environment.to_s.include? "/"
100
+ raise ::ArgumentError, "user cannot contain /" if user.to_s.include? "/"
101
+ raise ::ArgumentError, "session cannot contain /" if session.to_s.include? "/"
102
+
103
+ "projects/#{project}/locations/#{location}/agent/environments/#{environment}/users/#{user}/sessions/#{session}/contexts/#{context}"
66
104
  end)
67
105
  }
68
106
 
@@ -92,10 +130,30 @@ module Google
92
130
  # @param user [String]
93
131
  # @param session [String]
94
132
  #
133
+ # @overload session_path(project:, location:, session:)
134
+ # The resource will be in the following format:
135
+ #
136
+ # `projects/{project}/locations/{location}/agent/sessions/{session}`
137
+ #
138
+ # @param project [String]
139
+ # @param location [String]
140
+ # @param session [String]
141
+ #
142
+ # @overload session_path(project:, location:, environment:, user:, session:)
143
+ # The resource will be in the following format:
144
+ #
145
+ # `projects/{project}/locations/{location}/agent/environments/{environment}/users/{user}/sessions/{session}`
146
+ #
147
+ # @param project [String]
148
+ # @param location [String]
149
+ # @param environment [String]
150
+ # @param user [String]
151
+ # @param session [String]
152
+ #
95
153
  # @return [::String]
96
154
  def session_path **args
97
155
  resources = {
98
- "project:session" => (proc do |project:, session:|
156
+ "project:session" => (proc do |project:, session:|
99
157
  raise ::ArgumentError, "project cannot contain /" if project.to_s.include? "/"
100
158
 
101
159
  "projects/#{project}/agent/sessions/#{session}"
@@ -106,6 +164,20 @@ module Google
106
164
  raise ::ArgumentError, "user cannot contain /" if user.to_s.include? "/"
107
165
 
108
166
  "projects/#{project}/agent/environments/#{environment}/users/#{user}/sessions/#{session}"
167
+ end),
168
+ "location:project:session" => (proc do |project:, location:, session:|
169
+ raise ::ArgumentError, "project cannot contain /" if project.to_s.include? "/"
170
+ raise ::ArgumentError, "location cannot contain /" if location.to_s.include? "/"
171
+
172
+ "projects/#{project}/locations/#{location}/agent/sessions/#{session}"
173
+ end),
174
+ "environment:location:project:session:user" => (proc do |project:, location:, environment:, user:, session:|
175
+ raise ::ArgumentError, "project cannot contain /" if project.to_s.include? "/"
176
+ raise ::ArgumentError, "location cannot contain /" if location.to_s.include? "/"
177
+ raise ::ArgumentError, "environment cannot contain /" if environment.to_s.include? "/"
178
+ raise ::ArgumentError, "user cannot contain /" if user.to_s.include? "/"
179
+
180
+ "projects/#{project}/locations/#{location}/agent/environments/#{environment}/users/#{user}/sessions/#{session}"
109
181
  end)
110
182
  }
111
183