google-cloud-dialogflow-cx-v3 0.22.0 → 0.24.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (89) hide show
  1. checksums.yaml +4 -4
  2. data/AUTHENTICATION.md +72 -101
  3. data/lib/google/cloud/dialogflow/cx/v3/agent_pb.rb +2 -1
  4. data/lib/google/cloud/dialogflow/cx/v3/agents/client.rb +33 -8
  5. data/lib/google/cloud/dialogflow/cx/v3/agents/operations.rb +28 -6
  6. data/lib/google/cloud/dialogflow/cx/v3/agents/rest/client.rb +35 -7
  7. data/lib/google/cloud/dialogflow/cx/v3/agents/rest/operations.rb +33 -8
  8. data/lib/google/cloud/dialogflow/cx/v3/agents/rest/service_stub.rb +14 -2
  9. data/lib/google/cloud/dialogflow/cx/v3/audio_config_pb.rb +2 -1
  10. data/lib/google/cloud/dialogflow/cx/v3/changelogs/client.rb +32 -8
  11. data/lib/google/cloud/dialogflow/cx/v3/changelogs/rest/client.rb +34 -7
  12. data/lib/google/cloud/dialogflow/cx/v3/changelogs/rest/service_stub.rb +14 -2
  13. data/lib/google/cloud/dialogflow/cx/v3/deployments/client.rb +32 -8
  14. data/lib/google/cloud/dialogflow/cx/v3/deployments/rest/client.rb +34 -7
  15. data/lib/google/cloud/dialogflow/cx/v3/deployments/rest/service_stub.rb +14 -2
  16. data/lib/google/cloud/dialogflow/cx/v3/entity_type_pb.rb +1 -1
  17. data/lib/google/cloud/dialogflow/cx/v3/entity_type_services_pb.rb +2 -2
  18. data/lib/google/cloud/dialogflow/cx/v3/entity_types/client.rb +151 -127
  19. data/lib/google/cloud/dialogflow/cx/v3/entity_types/rest/client.rb +146 -119
  20. data/lib/google/cloud/dialogflow/cx/v3/entity_types/rest/service_stub.rb +62 -50
  21. data/lib/google/cloud/dialogflow/cx/v3/environments/client.rb +33 -8
  22. data/lib/google/cloud/dialogflow/cx/v3/environments/operations.rb +28 -6
  23. data/lib/google/cloud/dialogflow/cx/v3/environments/rest/client.rb +35 -7
  24. data/lib/google/cloud/dialogflow/cx/v3/environments/rest/operations.rb +33 -8
  25. data/lib/google/cloud/dialogflow/cx/v3/environments/rest/service_stub.rb +14 -2
  26. data/lib/google/cloud/dialogflow/cx/v3/experiments/client.rb +32 -8
  27. data/lib/google/cloud/dialogflow/cx/v3/experiments/rest/client.rb +34 -7
  28. data/lib/google/cloud/dialogflow/cx/v3/experiments/rest/service_stub.rb +14 -2
  29. data/lib/google/cloud/dialogflow/cx/v3/flows/client.rb +33 -8
  30. data/lib/google/cloud/dialogflow/cx/v3/flows/operations.rb +28 -6
  31. data/lib/google/cloud/dialogflow/cx/v3/flows/rest/client.rb +35 -7
  32. data/lib/google/cloud/dialogflow/cx/v3/flows/rest/operations.rb +33 -8
  33. data/lib/google/cloud/dialogflow/cx/v3/flows/rest/service_stub.rb +14 -2
  34. data/lib/google/cloud/dialogflow/cx/v3/generator_pb.rb +60 -0
  35. data/lib/google/cloud/dialogflow/cx/v3/generator_services_pb.rb +55 -0
  36. data/lib/google/cloud/dialogflow/cx/v3/generators/client.rb +851 -0
  37. data/lib/google/cloud/dialogflow/cx/v3/generators/credentials.rb +54 -0
  38. data/lib/google/cloud/dialogflow/cx/v3/generators/paths.rb +75 -0
  39. data/lib/google/cloud/dialogflow/cx/v3/generators/rest/client.rb +798 -0
  40. data/lib/google/cloud/dialogflow/cx/v3/generators/rest/service_stub.rb +359 -0
  41. data/lib/google/cloud/dialogflow/cx/v3/generators/rest.rb +55 -0
  42. data/lib/google/cloud/dialogflow/cx/v3/generators.rb +57 -0
  43. data/lib/google/cloud/dialogflow/cx/v3/intents/client.rb +33 -8
  44. data/lib/google/cloud/dialogflow/cx/v3/intents/operations.rb +28 -6
  45. data/lib/google/cloud/dialogflow/cx/v3/intents/rest/client.rb +35 -7
  46. data/lib/google/cloud/dialogflow/cx/v3/intents/rest/operations.rb +33 -8
  47. data/lib/google/cloud/dialogflow/cx/v3/intents/rest/service_stub.rb +14 -2
  48. data/lib/google/cloud/dialogflow/cx/v3/pages/client.rb +32 -8
  49. data/lib/google/cloud/dialogflow/cx/v3/pages/rest/client.rb +34 -7
  50. data/lib/google/cloud/dialogflow/cx/v3/pages/rest/service_stub.rb +14 -2
  51. data/lib/google/cloud/dialogflow/cx/v3/rest.rb +1 -0
  52. data/lib/google/cloud/dialogflow/cx/v3/security_settings_service/client.rb +32 -8
  53. data/lib/google/cloud/dialogflow/cx/v3/security_settings_service/rest/client.rb +34 -7
  54. data/lib/google/cloud/dialogflow/cx/v3/security_settings_service/rest/service_stub.rb +14 -2
  55. data/lib/google/cloud/dialogflow/cx/v3/session_entity_types/client.rb +32 -8
  56. data/lib/google/cloud/dialogflow/cx/v3/session_entity_types/rest/client.rb +34 -7
  57. data/lib/google/cloud/dialogflow/cx/v3/session_entity_types/rest/service_stub.rb +14 -2
  58. data/lib/google/cloud/dialogflow/cx/v3/session_pb.rb +12 -1
  59. data/lib/google/cloud/dialogflow/cx/v3/session_services_pb.rb +3 -0
  60. data/lib/google/cloud/dialogflow/cx/v3/sessions/client.rb +133 -8
  61. data/lib/google/cloud/dialogflow/cx/v3/sessions/paths.rb +45 -0
  62. data/lib/google/cloud/dialogflow/cx/v3/sessions/rest/client.rb +128 -7
  63. data/lib/google/cloud/dialogflow/cx/v3/sessions/rest/service_stub.rb +74 -2
  64. data/lib/google/cloud/dialogflow/cx/v3/test_cases/client.rb +33 -8
  65. data/lib/google/cloud/dialogflow/cx/v3/test_cases/operations.rb +28 -6
  66. data/lib/google/cloud/dialogflow/cx/v3/test_cases/rest/client.rb +35 -7
  67. data/lib/google/cloud/dialogflow/cx/v3/test_cases/rest/operations.rb +33 -8
  68. data/lib/google/cloud/dialogflow/cx/v3/test_cases/rest/service_stub.rb +14 -2
  69. data/lib/google/cloud/dialogflow/cx/v3/transition_route_groups/client.rb +32 -8
  70. data/lib/google/cloud/dialogflow/cx/v3/transition_route_groups/rest/client.rb +34 -7
  71. data/lib/google/cloud/dialogflow/cx/v3/transition_route_groups/rest/service_stub.rb +14 -2
  72. data/lib/google/cloud/dialogflow/cx/v3/version.rb +1 -1
  73. data/lib/google/cloud/dialogflow/cx/v3/versions/client.rb +33 -8
  74. data/lib/google/cloud/dialogflow/cx/v3/versions/operations.rb +28 -6
  75. data/lib/google/cloud/dialogflow/cx/v3/versions/rest/client.rb +35 -7
  76. data/lib/google/cloud/dialogflow/cx/v3/versions/rest/operations.rb +33 -8
  77. data/lib/google/cloud/dialogflow/cx/v3/versions/rest/service_stub.rb +14 -2
  78. data/lib/google/cloud/dialogflow/cx/v3/webhooks/client.rb +32 -8
  79. data/lib/google/cloud/dialogflow/cx/v3/webhooks/rest/client.rb +34 -7
  80. data/lib/google/cloud/dialogflow/cx/v3/webhooks/rest/service_stub.rb +14 -2
  81. data/lib/google/cloud/dialogflow/cx/v3.rb +1 -0
  82. data/proto_docs/google/api/client.rb +14 -0
  83. data/proto_docs/google/cloud/dialogflow/cx/v3/agent.rb +16 -0
  84. data/proto_docs/google/cloud/dialogflow/cx/v3/audio_config.rb +47 -3
  85. data/proto_docs/google/cloud/dialogflow/cx/v3/generator.rb +187 -0
  86. data/proto_docs/google/cloud/dialogflow/cx/v3/session.rb +187 -0
  87. data/proto_docs/google/cloud/dialogflow/cx/v3/validation_message.rb +1 -0
  88. data/proto_docs/google/cloud/dialogflow/cx/v3/webhook.rb +2 -0
  89. metadata +17 -7
@@ -35,6 +35,9 @@ module Google
35
35
  # determine user intent and respond.
36
36
  #
37
37
  class Client
38
+ # @private
39
+ DEFAULT_ENDPOINT_TEMPLATE = "dialogflow.$UNIVERSE_DOMAIN$"
40
+
38
41
  include Paths
39
42
 
40
43
  # @private
@@ -107,6 +110,15 @@ module Google
107
110
  @config
108
111
  end
109
112
 
113
+ ##
114
+ # The effective universe domain
115
+ #
116
+ # @return [String]
117
+ #
118
+ def universe_domain
119
+ @sessions_stub.universe_domain
120
+ end
121
+
110
122
  ##
111
123
  # Create a new Sessions client object.
112
124
  #
@@ -140,8 +152,9 @@ module Google
140
152
  credentials = @config.credentials
141
153
  # Use self-signed JWT if the endpoint is unchanged from default,
142
154
  # but only if the default endpoint does not have a region prefix.
143
- enable_self_signed_jwt = @config.endpoint == Configuration::DEFAULT_ENDPOINT &&
144
- !@config.endpoint.split(".").first.include?("-")
155
+ enable_self_signed_jwt = @config.endpoint.nil? ||
156
+ (@config.endpoint == Configuration::DEFAULT_ENDPOINT &&
157
+ !@config.endpoint.split(".").first.include?("-"))
145
158
  credentials ||= Credentials.default scope: @config.scope,
146
159
  enable_self_signed_jwt: enable_self_signed_jwt
147
160
  if credentials.is_a?(::String) || credentials.is_a?(::Hash)
@@ -154,12 +167,15 @@ module Google
154
167
  config.credentials = credentials
155
168
  config.quota_project = @quota_project_id
156
169
  config.endpoint = @config.endpoint
170
+ config.universe_domain = @config.universe_domain
157
171
  end
158
172
 
159
173
  @sessions_stub = ::Gapic::ServiceStub.new(
160
174
  ::Google::Cloud::Dialogflow::CX::V3::Sessions::Stub,
161
- credentials: credentials,
162
- endpoint: @config.endpoint,
175
+ credentials: credentials,
176
+ endpoint: @config.endpoint,
177
+ endpoint_template: DEFAULT_ENDPOINT_TEMPLATE,
178
+ universe_domain: @config.universe_domain,
163
179
  channel_args: @config.channel_args,
164
180
  interceptors: @config.interceptors,
165
181
  channel_pool_config: @config.channel_pool
@@ -571,6 +587,100 @@ module Google
571
587
  raise ::Google::Cloud::Error.from_error(e)
572
588
  end
573
589
 
590
+ ##
591
+ # Updates the feedback received from the user for a single turn of the bot
592
+ # response.
593
+ #
594
+ # @overload submit_answer_feedback(request, options = nil)
595
+ # Pass arguments to `submit_answer_feedback` via a request object, either of type
596
+ # {::Google::Cloud::Dialogflow::CX::V3::SubmitAnswerFeedbackRequest} or an equivalent Hash.
597
+ #
598
+ # @param request [::Google::Cloud::Dialogflow::CX::V3::SubmitAnswerFeedbackRequest, ::Hash]
599
+ # A request object representing the call parameters. Required. To specify no
600
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
601
+ # @param options [::Gapic::CallOptions, ::Hash]
602
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
603
+ #
604
+ # @overload submit_answer_feedback(session: nil, response_id: nil, answer_feedback: nil, update_mask: nil)
605
+ # Pass arguments to `submit_answer_feedback` via keyword arguments. Note that at
606
+ # least one keyword argument is required. To specify no parameters, or to keep all
607
+ # the default parameter values, pass an empty Hash as a request object (see above).
608
+ #
609
+ # @param session [::String]
610
+ # Required. The name of the session the feedback was sent to.
611
+ # @param response_id [::String]
612
+ # Required. ID of the response to update its feedback. This is the same as
613
+ # DetectIntentResponse.response_id.
614
+ # @param answer_feedback [::Google::Cloud::Dialogflow::CX::V3::AnswerFeedback, ::Hash]
615
+ # Required. Feedback provided for a bot answer.
616
+ # @param update_mask [::Google::Protobuf::FieldMask, ::Hash]
617
+ # Optional. The mask to control which fields to update. If the mask is not
618
+ # present, all fields will be updated.
619
+ #
620
+ # @yield [response, operation] Access the result along with the RPC operation
621
+ # @yieldparam response [::Google::Cloud::Dialogflow::CX::V3::AnswerFeedback]
622
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
623
+ #
624
+ # @return [::Google::Cloud::Dialogflow::CX::V3::AnswerFeedback]
625
+ #
626
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
627
+ #
628
+ # @example Basic example
629
+ # require "google/cloud/dialogflow/cx/v3"
630
+ #
631
+ # # Create a client object. The client can be reused for multiple calls.
632
+ # client = Google::Cloud::Dialogflow::CX::V3::Sessions::Client.new
633
+ #
634
+ # # Create a request. To set request fields, pass in keyword arguments.
635
+ # request = Google::Cloud::Dialogflow::CX::V3::SubmitAnswerFeedbackRequest.new
636
+ #
637
+ # # Call the submit_answer_feedback method.
638
+ # result = client.submit_answer_feedback request
639
+ #
640
+ # # The returned object is of type Google::Cloud::Dialogflow::CX::V3::AnswerFeedback.
641
+ # p result
642
+ #
643
+ def submit_answer_feedback request, options = nil
644
+ raise ::ArgumentError, "request must be provided" if request.nil?
645
+
646
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Dialogflow::CX::V3::SubmitAnswerFeedbackRequest
647
+
648
+ # Converts hash and nil to an options object
649
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
650
+
651
+ # Customize the options with defaults
652
+ metadata = @config.rpcs.submit_answer_feedback.metadata.to_h
653
+
654
+ # Set x-goog-api-client and x-goog-user-project headers
655
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
656
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
657
+ gapic_version: ::Google::Cloud::Dialogflow::CX::V3::VERSION
658
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
659
+
660
+ header_params = {}
661
+ if request.session
662
+ header_params["session"] = request.session
663
+ end
664
+
665
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
666
+ metadata[:"x-goog-request-params"] ||= request_params_header
667
+
668
+ options.apply_defaults timeout: @config.rpcs.submit_answer_feedback.timeout,
669
+ metadata: metadata,
670
+ retry_policy: @config.rpcs.submit_answer_feedback.retry_policy
671
+
672
+ options.apply_defaults timeout: @config.timeout,
673
+ metadata: @config.metadata,
674
+ retry_policy: @config.retry_policy
675
+
676
+ @sessions_stub.call_rpc :submit_answer_feedback, request, options: options do |response, operation|
677
+ yield response, operation if block_given?
678
+ return response
679
+ end
680
+ rescue ::GRPC::BadStatus => e
681
+ raise ::Google::Cloud::Error.from_error(e)
682
+ end
683
+
574
684
  ##
575
685
  # Configuration class for the Sessions API.
576
686
  #
@@ -601,9 +711,9 @@ module Google
601
711
  # end
602
712
  #
603
713
  # @!attribute [rw] endpoint
604
- # The hostname or hostname:port of the service endpoint.
605
- # Defaults to `"dialogflow.googleapis.com"`.
606
- # @return [::String]
714
+ # A custom service endpoint, as a hostname or hostname:port. The default is
715
+ # nil, indicating to use the default endpoint in the current universe domain.
716
+ # @return [::String,nil]
607
717
  # @!attribute [rw] credentials
608
718
  # Credentials to send with calls. You may provide any of the following types:
609
719
  # * (`String`) The path to a service account key file in JSON format
@@ -649,13 +759,20 @@ module Google
649
759
  # @!attribute [rw] quota_project
650
760
  # A separate project against which to charge quota.
651
761
  # @return [::String]
762
+ # @!attribute [rw] universe_domain
763
+ # The universe domain within which to make requests. This determines the
764
+ # default endpoint URL. The default value of nil uses the environment
765
+ # universe (usually the default "googleapis.com" universe).
766
+ # @return [::String,nil]
652
767
  #
653
768
  class Configuration
654
769
  extend ::Gapic::Config
655
770
 
771
+ # @private
772
+ # The endpoint specific to the default "googleapis.com" universe. Deprecated.
656
773
  DEFAULT_ENDPOINT = "dialogflow.googleapis.com"
657
774
 
658
- config_attr :endpoint, DEFAULT_ENDPOINT, ::String
775
+ config_attr :endpoint, nil, ::String, nil
659
776
  config_attr :credentials, nil do |value|
660
777
  allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
661
778
  allowed += [::GRPC::Core::Channel, ::GRPC::Core::ChannelCredentials] if defined? ::GRPC
@@ -670,6 +787,7 @@ module Google
670
787
  config_attr :metadata, nil, ::Hash, nil
671
788
  config_attr :retry_policy, nil, ::Hash, ::Proc, nil
672
789
  config_attr :quota_project, nil, ::String, nil
790
+ config_attr :universe_domain, nil, ::String, nil
673
791
 
674
792
  # @private
675
793
  def initialize parent_config = nil
@@ -736,6 +854,11 @@ module Google
736
854
  # @return [::Gapic::Config::Method]
737
855
  #
738
856
  attr_reader :fulfill_intent
857
+ ##
858
+ # RPC-specific configuration for `submit_answer_feedback`
859
+ # @return [::Gapic::Config::Method]
860
+ #
861
+ attr_reader :submit_answer_feedback
739
862
 
740
863
  # @private
741
864
  def initialize parent_rpcs = nil
@@ -747,6 +870,8 @@ module Google
747
870
  @match_intent = ::Gapic::Config::Method.new match_intent_config
748
871
  fulfill_intent_config = parent_rpcs.fulfill_intent if parent_rpcs.respond_to? :fulfill_intent
749
872
  @fulfill_intent = ::Gapic::Config::Method.new fulfill_intent_config
873
+ submit_answer_feedback_config = parent_rpcs.submit_answer_feedback if parent_rpcs.respond_to? :submit_answer_feedback
874
+ @submit_answer_feedback = ::Gapic::Config::Method.new submit_answer_feedback_config
750
875
 
751
876
  yield self if block_given?
752
877
  end
@@ -25,6 +25,51 @@ module Google
25
25
  module Sessions
26
26
  # Path helper methods for the Sessions API.
27
27
  module Paths
28
+ ##
29
+ # Create a fully-qualified DataStore resource string.
30
+ #
31
+ # @overload data_store_path(project:, location:, data_store:)
32
+ # The resource will be in the following format:
33
+ #
34
+ # `projects/{project}/locations/{location}/dataStores/{data_store}`
35
+ #
36
+ # @param project [String]
37
+ # @param location [String]
38
+ # @param data_store [String]
39
+ #
40
+ # @overload data_store_path(project:, location:, collection:, data_store:)
41
+ # The resource will be in the following format:
42
+ #
43
+ # `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}`
44
+ #
45
+ # @param project [String]
46
+ # @param location [String]
47
+ # @param collection [String]
48
+ # @param data_store [String]
49
+ #
50
+ # @return [::String]
51
+ def data_store_path **args
52
+ resources = {
53
+ "data_store:location:project" => (proc do |project:, location:, data_store:|
54
+ raise ::ArgumentError, "project cannot contain /" if project.to_s.include? "/"
55
+ raise ::ArgumentError, "location cannot contain /" if location.to_s.include? "/"
56
+
57
+ "projects/#{project}/locations/#{location}/dataStores/#{data_store}"
58
+ end),
59
+ "collection:data_store:location:project" => (proc do |project:, location:, collection:, data_store:|
60
+ raise ::ArgumentError, "project cannot contain /" if project.to_s.include? "/"
61
+ raise ::ArgumentError, "location cannot contain /" if location.to_s.include? "/"
62
+ raise ::ArgumentError, "collection cannot contain /" if collection.to_s.include? "/"
63
+
64
+ "projects/#{project}/locations/#{location}/collections/#{collection}/dataStores/#{data_store}"
65
+ end)
66
+ }
67
+
68
+ resource = resources[args.keys.sort.join(":")]
69
+ raise ::ArgumentError, "no resource found for values #{args.keys}" if resource.nil?
70
+ resource.call(**args)
71
+ end
72
+
28
73
  ##
29
74
  # Create a fully-qualified EntityType resource string.
30
75
  #
@@ -37,6 +37,9 @@ module Google
37
37
  # determine user intent and respond.
38
38
  #
39
39
  class Client
40
+ # @private
41
+ DEFAULT_ENDPOINT_TEMPLATE = "dialogflow.$UNIVERSE_DOMAIN$"
42
+
40
43
  include Paths
41
44
 
42
45
  # @private
@@ -107,6 +110,15 @@ module Google
107
110
  @config
108
111
  end
109
112
 
113
+ ##
114
+ # The effective universe domain
115
+ #
116
+ # @return [String]
117
+ #
118
+ def universe_domain
119
+ @sessions_stub.universe_domain
120
+ end
121
+
110
122
  ##
111
123
  # Create a new Sessions REST client object.
112
124
  #
@@ -134,8 +146,9 @@ module Google
134
146
  credentials = @config.credentials
135
147
  # Use self-signed JWT if the endpoint is unchanged from default,
136
148
  # but only if the default endpoint does not have a region prefix.
137
- enable_self_signed_jwt = @config.endpoint == Configuration::DEFAULT_ENDPOINT &&
138
- !@config.endpoint.split(".").first.include?("-")
149
+ enable_self_signed_jwt = @config.endpoint.nil? ||
150
+ (@config.endpoint == Configuration::DEFAULT_ENDPOINT &&
151
+ !@config.endpoint.split(".").first.include?("-"))
139
152
  credentials ||= Credentials.default scope: @config.scope,
140
153
  enable_self_signed_jwt: enable_self_signed_jwt
141
154
  if credentials.is_a?(::String) || credentials.is_a?(::Hash)
@@ -149,10 +162,16 @@ module Google
149
162
  config.credentials = credentials
150
163
  config.quota_project = @quota_project_id
151
164
  config.endpoint = @config.endpoint
165
+ config.universe_domain = @config.universe_domain
152
166
  config.bindings_override = @config.bindings_override
153
167
  end
154
168
 
155
- @sessions_stub = ::Google::Cloud::Dialogflow::CX::V3::Sessions::Rest::ServiceStub.new endpoint: @config.endpoint, credentials: credentials
169
+ @sessions_stub = ::Google::Cloud::Dialogflow::CX::V3::Sessions::Rest::ServiceStub.new(
170
+ endpoint: @config.endpoint,
171
+ endpoint_template: DEFAULT_ENDPOINT_TEMPLATE,
172
+ universe_domain: @config.universe_domain,
173
+ credentials: credentials
174
+ )
156
175
  end
157
176
 
158
177
  ##
@@ -455,6 +474,93 @@ module Google
455
474
  raise ::Google::Cloud::Error.from_error(e)
456
475
  end
457
476
 
477
+ ##
478
+ # Updates the feedback received from the user for a single turn of the bot
479
+ # response.
480
+ #
481
+ # @overload submit_answer_feedback(request, options = nil)
482
+ # Pass arguments to `submit_answer_feedback` via a request object, either of type
483
+ # {::Google::Cloud::Dialogflow::CX::V3::SubmitAnswerFeedbackRequest} or an equivalent Hash.
484
+ #
485
+ # @param request [::Google::Cloud::Dialogflow::CX::V3::SubmitAnswerFeedbackRequest, ::Hash]
486
+ # A request object representing the call parameters. Required. To specify no
487
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
488
+ # @param options [::Gapic::CallOptions, ::Hash]
489
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
490
+ #
491
+ # @overload submit_answer_feedback(session: nil, response_id: nil, answer_feedback: nil, update_mask: nil)
492
+ # Pass arguments to `submit_answer_feedback` via keyword arguments. Note that at
493
+ # least one keyword argument is required. To specify no parameters, or to keep all
494
+ # the default parameter values, pass an empty Hash as a request object (see above).
495
+ #
496
+ # @param session [::String]
497
+ # Required. The name of the session the feedback was sent to.
498
+ # @param response_id [::String]
499
+ # Required. ID of the response to update its feedback. This is the same as
500
+ # DetectIntentResponse.response_id.
501
+ # @param answer_feedback [::Google::Cloud::Dialogflow::CX::V3::AnswerFeedback, ::Hash]
502
+ # Required. Feedback provided for a bot answer.
503
+ # @param update_mask [::Google::Protobuf::FieldMask, ::Hash]
504
+ # Optional. The mask to control which fields to update. If the mask is not
505
+ # present, all fields will be updated.
506
+ # @yield [result, operation] Access the result along with the TransportOperation object
507
+ # @yieldparam result [::Google::Cloud::Dialogflow::CX::V3::AnswerFeedback]
508
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
509
+ #
510
+ # @return [::Google::Cloud::Dialogflow::CX::V3::AnswerFeedback]
511
+ #
512
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
513
+ #
514
+ # @example Basic example
515
+ # require "google/cloud/dialogflow/cx/v3"
516
+ #
517
+ # # Create a client object. The client can be reused for multiple calls.
518
+ # client = Google::Cloud::Dialogflow::CX::V3::Sessions::Rest::Client.new
519
+ #
520
+ # # Create a request. To set request fields, pass in keyword arguments.
521
+ # request = Google::Cloud::Dialogflow::CX::V3::SubmitAnswerFeedbackRequest.new
522
+ #
523
+ # # Call the submit_answer_feedback method.
524
+ # result = client.submit_answer_feedback request
525
+ #
526
+ # # The returned object is of type Google::Cloud::Dialogflow::CX::V3::AnswerFeedback.
527
+ # p result
528
+ #
529
+ def submit_answer_feedback request, options = nil
530
+ raise ::ArgumentError, "request must be provided" if request.nil?
531
+
532
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Dialogflow::CX::V3::SubmitAnswerFeedbackRequest
533
+
534
+ # Converts hash and nil to an options object
535
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
536
+
537
+ # Customize the options with defaults
538
+ call_metadata = @config.rpcs.submit_answer_feedback.metadata.to_h
539
+
540
+ # Set x-goog-api-client and x-goog-user-project headers
541
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
542
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
543
+ gapic_version: ::Google::Cloud::Dialogflow::CX::V3::VERSION,
544
+ transports_version_send: [:rest]
545
+
546
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
547
+
548
+ options.apply_defaults timeout: @config.rpcs.submit_answer_feedback.timeout,
549
+ metadata: call_metadata,
550
+ retry_policy: @config.rpcs.submit_answer_feedback.retry_policy
551
+
552
+ options.apply_defaults timeout: @config.timeout,
553
+ metadata: @config.metadata,
554
+ retry_policy: @config.retry_policy
555
+
556
+ @sessions_stub.submit_answer_feedback request, options do |result, operation|
557
+ yield result, operation if block_given?
558
+ return result
559
+ end
560
+ rescue ::Gapic::Rest::Error => e
561
+ raise ::Google::Cloud::Error.from_error(e)
562
+ end
563
+
458
564
  ##
459
565
  # Configuration class for the Sessions REST API.
460
566
  #
@@ -485,9 +591,9 @@ module Google
485
591
  # end
486
592
  #
487
593
  # @!attribute [rw] endpoint
488
- # The hostname or hostname:port of the service endpoint.
489
- # Defaults to `"dialogflow.googleapis.com"`.
490
- # @return [::String]
594
+ # A custom service endpoint, as a hostname or hostname:port. The default is
595
+ # nil, indicating to use the default endpoint in the current universe domain.
596
+ # @return [::String,nil]
491
597
  # @!attribute [rw] credentials
492
598
  # Credentials to send with calls. You may provide any of the following types:
493
599
  # * (`String`) The path to a service account key file in JSON format
@@ -524,13 +630,20 @@ module Google
524
630
  # @!attribute [rw] quota_project
525
631
  # A separate project against which to charge quota.
526
632
  # @return [::String]
633
+ # @!attribute [rw] universe_domain
634
+ # The universe domain within which to make requests. This determines the
635
+ # default endpoint URL. The default value of nil uses the environment
636
+ # universe (usually the default "googleapis.com" universe).
637
+ # @return [::String,nil]
527
638
  #
528
639
  class Configuration
529
640
  extend ::Gapic::Config
530
641
 
642
+ # @private
643
+ # The endpoint specific to the default "googleapis.com" universe. Deprecated.
531
644
  DEFAULT_ENDPOINT = "dialogflow.googleapis.com"
532
645
 
533
- config_attr :endpoint, DEFAULT_ENDPOINT, ::String
646
+ config_attr :endpoint, nil, ::String, nil
534
647
  config_attr :credentials, nil do |value|
535
648
  allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
536
649
  allowed.any? { |klass| klass === value }
@@ -542,6 +655,7 @@ module Google
542
655
  config_attr :metadata, nil, ::Hash, nil
543
656
  config_attr :retry_policy, nil, ::Hash, ::Proc, nil
544
657
  config_attr :quota_project, nil, ::String, nil
658
+ config_attr :universe_domain, nil, ::String, nil
545
659
 
546
660
  # @private
547
661
  # Overrides for http bindings for the RPCs of this service
@@ -602,6 +716,11 @@ module Google
602
716
  # @return [::Gapic::Config::Method]
603
717
  #
604
718
  attr_reader :fulfill_intent
719
+ ##
720
+ # RPC-specific configuration for `submit_answer_feedback`
721
+ # @return [::Gapic::Config::Method]
722
+ #
723
+ attr_reader :submit_answer_feedback
605
724
 
606
725
  # @private
607
726
  def initialize parent_rpcs = nil
@@ -611,6 +730,8 @@ module Google
611
730
  @match_intent = ::Gapic::Config::Method.new match_intent_config
612
731
  fulfill_intent_config = parent_rpcs.fulfill_intent if parent_rpcs.respond_to? :fulfill_intent
613
732
  @fulfill_intent = ::Gapic::Config::Method.new fulfill_intent_config
733
+ submit_answer_feedback_config = parent_rpcs.submit_answer_feedback if parent_rpcs.respond_to? :submit_answer_feedback
734
+ @submit_answer_feedback = ::Gapic::Config::Method.new submit_answer_feedback_config
614
735
 
615
736
  yield self if block_given?
616
737
  end
@@ -31,16 +31,28 @@ module Google
31
31
  # including transcoding, making the REST call, and deserialing the response.
32
32
  #
33
33
  class ServiceStub
34
- def initialize endpoint:, credentials:
34
+ def initialize endpoint:, endpoint_template:, universe_domain:, credentials:
35
35
  # These require statements are intentionally placed here to initialize
36
36
  # the REST modules only when it's required.
37
37
  require "gapic/rest"
38
38
 
39
- @client_stub = ::Gapic::Rest::ClientStub.new endpoint: endpoint, credentials: credentials,
39
+ @client_stub = ::Gapic::Rest::ClientStub.new endpoint: endpoint,
40
+ endpoint_template: endpoint_template,
41
+ universe_domain: universe_domain,
42
+ credentials: credentials,
40
43
  numeric_enums: true,
41
44
  raise_faraday_errors: false
42
45
  end
43
46
 
47
+ ##
48
+ # The effective universe domain
49
+ #
50
+ # @return [String]
51
+ #
52
+ def universe_domain
53
+ @client_stub.universe_domain
54
+ end
55
+
44
56
  ##
45
57
  # Baseline implementation for the detect_intent REST call
46
58
  #
@@ -155,6 +167,44 @@ module Google
155
167
  result
156
168
  end
157
169
 
170
+ ##
171
+ # Baseline implementation for the submit_answer_feedback REST call
172
+ #
173
+ # @param request_pb [::Google::Cloud::Dialogflow::CX::V3::SubmitAnswerFeedbackRequest]
174
+ # A request object representing the call parameters. Required.
175
+ # @param options [::Gapic::CallOptions]
176
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
177
+ #
178
+ # @yield [result, operation] Access the result along with the TransportOperation object
179
+ # @yieldparam result [::Google::Cloud::Dialogflow::CX::V3::AnswerFeedback]
180
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
181
+ #
182
+ # @return [::Google::Cloud::Dialogflow::CX::V3::AnswerFeedback]
183
+ # A result object deserialized from the server's reply
184
+ def submit_answer_feedback request_pb, options = nil
185
+ raise ::ArgumentError, "request must be provided" if request_pb.nil?
186
+
187
+ verb, uri, query_string_params, body = ServiceStub.transcode_submit_answer_feedback_request request_pb
188
+ query_string_params = if query_string_params.any?
189
+ query_string_params.to_h { |p| p.split "=", 2 }
190
+ else
191
+ {}
192
+ end
193
+
194
+ response = @client_stub.make_http_request(
195
+ verb,
196
+ uri: uri,
197
+ body: body || "",
198
+ params: query_string_params,
199
+ options: options
200
+ )
201
+ operation = ::Gapic::Rest::TransportOperation.new response
202
+ result = ::Google::Cloud::Dialogflow::CX::V3::AnswerFeedback.decode_json response.body, ignore_unknown_fields: true
203
+
204
+ yield result, operation if block_given?
205
+ result
206
+ end
207
+
158
208
  ##
159
209
  # @private
160
210
  #
@@ -244,6 +294,28 @@ module Google
244
294
  )
245
295
  transcoder.transcode request_pb
246
296
  end
297
+
298
+ ##
299
+ # @private
300
+ #
301
+ # GRPC transcoding helper method for the submit_answer_feedback REST call
302
+ #
303
+ # @param request_pb [::Google::Cloud::Dialogflow::CX::V3::SubmitAnswerFeedbackRequest]
304
+ # A request object representing the call parameters. Required.
305
+ # @return [Array(String, [String, nil], Hash{String => String})]
306
+ # Uri, Body, Query string parameters
307
+ def self.transcode_submit_answer_feedback_request request_pb
308
+ transcoder = Gapic::Rest::GrpcTranscoder.new
309
+ .with_bindings(
310
+ uri_method: :post,
311
+ uri_template: "/v3/{session}:submitAnswerFeedback",
312
+ body: "*",
313
+ matches: [
314
+ ["session", %r{^projects/[^/]+/locations/[^/]+/agents/[^/]+/sessions/[^/]+/?$}, false]
315
+ ]
316
+ )
317
+ transcoder.transcode request_pb
318
+ end
247
319
  end
248
320
  end
249
321
  end