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
@@ -103,8 +103,13 @@ module Google
103
103
  # Lists operations that match the specified filter in the request. If the
104
104
  # server doesn't support this method, it returns `UNIMPLEMENTED`.
105
105
  #
106
- # NOTE: the `name` binding below allows API services to override the binding
107
- # to use different resource name schemes, such as `users/*/operations`.
106
+ # NOTE: the `name` binding allows API services to override the binding
107
+ # to use different resource name schemes, such as `users/*/operations`. To
108
+ # override the binding, API services can add a binding such as
109
+ # `"/v1/{name=users/*}/operations"` to their service configuration.
110
+ # For backwards compatibility, the default name includes the operations
111
+ # collection id, however overriding users must ensure the name binding
112
+ # is the parent resource, without the operations collection id.
108
113
  #
109
114
  # @overload list_operations(request, options = nil)
110
115
  # Pass arguments to `list_operations` via a request object, either of type
@@ -122,7 +127,7 @@ module Google
122
127
  # the default parameter values, pass an empty Hash as a request object (see above).
123
128
  #
124
129
  # @param name [::String]
125
- # The name of the operation collection.
130
+ # The name of the operation's parent resource.
126
131
  # @param filter [::String]
127
132
  # The standard list filter.
128
133
  # @param page_size [::Integer]
@@ -390,6 +395,79 @@ module Google
390
395
  raise ::Google::Cloud::Error.from_error(e)
391
396
  end
392
397
 
398
+ ##
399
+ # Waits for the specified long-running operation until it is done or reaches
400
+ # at most a specified timeout, returning the latest state. If the operation
401
+ # is already done, the latest state is immediately returned. If the timeout
402
+ # specified is greater than the default HTTP/RPC timeout, the HTTP/RPC
403
+ # timeout is used. If the server does not support this method, it returns
404
+ # `google.rpc.Code.UNIMPLEMENTED`.
405
+ # Note that this method is on a best-effort basis. It may return the latest
406
+ # state before the specified timeout (including immediately), meaning even an
407
+ # immediate response is no guarantee that the operation is done.
408
+ #
409
+ # @overload wait_operation(request, options = nil)
410
+ # Pass arguments to `wait_operation` via a request object, either of type
411
+ # {::Google::Longrunning::WaitOperationRequest} or an equivalent Hash.
412
+ #
413
+ # @param request [::Google::Longrunning::WaitOperationRequest, ::Hash]
414
+ # A request object representing the call parameters. Required. To specify no
415
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
416
+ # @param options [::Gapic::CallOptions, ::Hash]
417
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
418
+ #
419
+ # @overload wait_operation(name: nil, timeout: nil)
420
+ # Pass arguments to `wait_operation` via keyword arguments. Note that at
421
+ # least one keyword argument is required. To specify no parameters, or to keep all
422
+ # the default parameter values, pass an empty Hash as a request object (see above).
423
+ #
424
+ # @param name [::String]
425
+ # The name of the operation resource to wait on.
426
+ # @param timeout [::Google::Protobuf::Duration, ::Hash]
427
+ # The maximum duration to wait before timing out. If left blank, the wait
428
+ # will be at most the time permitted by the underlying HTTP/RPC protocol.
429
+ # If RPC context deadline is also specified, the shorter one will be used.
430
+ #
431
+ # @yield [response, operation] Access the result along with the RPC operation
432
+ # @yieldparam response [::Gapic::Operation]
433
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
434
+ #
435
+ # @return [::Gapic::Operation]
436
+ #
437
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
438
+ #
439
+ def wait_operation request, options = nil
440
+ raise ::ArgumentError, "request must be provided" if request.nil?
441
+
442
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Longrunning::WaitOperationRequest
443
+
444
+ # Converts hash and nil to an options object
445
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
446
+
447
+ # Customize the options with defaults
448
+ metadata = @config.rpcs.wait_operation.metadata.to_h
449
+
450
+ # Set x-goog-api-client and x-goog-user-project headers
451
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
452
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
453
+ gapic_version: ::Google::Cloud::Dialogflow::V2::VERSION
454
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
455
+
456
+ options.apply_defaults timeout: @config.rpcs.wait_operation.timeout,
457
+ metadata: metadata,
458
+ retry_policy: @config.rpcs.wait_operation.retry_policy
459
+ options.apply_defaults metadata: @config.metadata,
460
+ retry_policy: @config.retry_policy
461
+
462
+ @operations_stub.call_rpc :wait_operation, request, options: options do |response, operation|
463
+ response = ::Gapic::Operation.new response, @operations_client, options: options
464
+ yield response, operation if block_given?
465
+ return response
466
+ end
467
+ rescue ::GRPC::BadStatus => e
468
+ raise ::Google::Cloud::Error.from_error(e)
469
+ end
470
+
393
471
  ##
394
472
  # Configuration class for the Operations API.
395
473
  #
@@ -475,14 +553,14 @@ module Google
475
553
 
476
554
  config_attr :endpoint, "dialogflow.googleapis.com", ::String
477
555
  config_attr :credentials, nil do |value|
478
- allowed = [::String, ::Hash, ::Proc, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
556
+ allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
479
557
  allowed += [::GRPC::Core::Channel, ::GRPC::Core::ChannelCredentials] if defined? ::GRPC
480
558
  allowed.any? { |klass| klass === value }
481
559
  end
482
560
  config_attr :scope, nil, ::String, ::Array, nil
483
561
  config_attr :lib_name, nil, ::String, nil
484
562
  config_attr :lib_version, nil, ::String, nil
485
- config_attr(:channel_args, { "grpc.service_config_disable_resolution"=>1 }, ::Hash, nil)
563
+ config_attr(:channel_args, { "grpc.service_config_disable_resolution" => 1 }, ::Hash, nil)
486
564
  config_attr :interceptors, nil, ::Array, nil
487
565
  config_attr :timeout, nil, ::Numeric, nil
488
566
  config_attr :metadata, nil, ::Hash, nil
@@ -503,7 +581,7 @@ module Google
503
581
  def rpcs
504
582
  @rpcs ||= begin
505
583
  parent_rpcs = nil
506
- parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config&.respond_to?(:rpcs)
584
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
507
585
  Rpcs.new parent_rpcs
508
586
  end
509
587
  end
@@ -515,7 +593,7 @@ module Google
515
593
  # Each configuration object is of type `Gapic::Config::Method` and includes
516
594
  # the following configuration fields:
517
595
  #
518
- # * `timeout` (*type:* `Numeric`) - The call timeout in milliseconds
596
+ # * `timeout` (*type:* `Numeric`) - The call timeout in seconds
519
597
  # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional gRPC headers
520
598
  # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
521
599
  # include the following keys:
@@ -546,17 +624,24 @@ module Google
546
624
  # @return [::Gapic::Config::Method]
547
625
  #
548
626
  attr_reader :cancel_operation
627
+ ##
628
+ # RPC-specific configuration for `wait_operation`
629
+ # @return [::Gapic::Config::Method]
630
+ #
631
+ attr_reader :wait_operation
549
632
 
550
633
  # @private
551
634
  def initialize parent_rpcs = nil
552
- list_operations_config = parent_rpcs&.list_operations if parent_rpcs&.respond_to? :list_operations
635
+ list_operations_config = parent_rpcs.list_operations if parent_rpcs.respond_to? :list_operations
553
636
  @list_operations = ::Gapic::Config::Method.new list_operations_config
554
- get_operation_config = parent_rpcs&.get_operation if parent_rpcs&.respond_to? :get_operation
637
+ get_operation_config = parent_rpcs.get_operation if parent_rpcs.respond_to? :get_operation
555
638
  @get_operation = ::Gapic::Config::Method.new get_operation_config
556
- delete_operation_config = parent_rpcs&.delete_operation if parent_rpcs&.respond_to? :delete_operation
639
+ delete_operation_config = parent_rpcs.delete_operation if parent_rpcs.respond_to? :delete_operation
557
640
  @delete_operation = ::Gapic::Config::Method.new delete_operation_config
558
- cancel_operation_config = parent_rpcs&.cancel_operation if parent_rpcs&.respond_to? :cancel_operation
641
+ cancel_operation_config = parent_rpcs.cancel_operation if parent_rpcs.respond_to? :cancel_operation
559
642
  @cancel_operation = ::Gapic::Config::Method.new cancel_operation_config
643
+ wait_operation_config = parent_rpcs.wait_operation if parent_rpcs.respond_to? :wait_operation
644
+ @wait_operation = ::Gapic::Config::Method.new wait_operation_config
560
645
 
561
646
  yield self if block_given?
562
647
  end
@@ -27,15 +27,37 @@ module Google
27
27
  ##
28
28
  # Create a fully-qualified Agent resource string.
29
29
  #
30
- # The resource will be in the following format:
30
+ # @overload agent_path(project:)
31
+ # The resource will be in the following format:
32
+ #
33
+ # `projects/{project}/agent`
34
+ #
35
+ # @param project [String]
31
36
  #
32
- # `projects/{project}/agent`
37
+ # @overload agent_path(project:, location:)
38
+ # The resource will be in the following format:
39
+ #
40
+ # `projects/{project}/locations/{location}/agent`
33
41
  #
34
- # @param project [String]
42
+ # @param project [String]
43
+ # @param location [String]
35
44
  #
36
45
  # @return [::String]
37
- def agent_path project:
38
- "projects/#{project}/agent"
46
+ def agent_path **args
47
+ resources = {
48
+ "project" => (proc do |project:|
49
+ "projects/#{project}/agent"
50
+ end),
51
+ "location:project" => (proc do |project:, location:|
52
+ raise ::ArgumentError, "project cannot contain /" if project.to_s.include? "/"
53
+
54
+ "projects/#{project}/locations/#{location}/agent"
55
+ end)
56
+ }
57
+
58
+ resource = resources[args.keys.sort.join(":")]
59
+ raise ::ArgumentError, "no resource found for values #{args.keys}" if resource.nil?
60
+ resource.call(**args)
39
61
  end
40
62
 
41
63
  ##
@@ -61,10 +83,32 @@ module Google
61
83
  # @param session [String]
62
84
  # @param context [String]
63
85
  #
86
+ # @overload context_path(project:, location:, session:, context:)
87
+ # The resource will be in the following format:
88
+ #
89
+ # `projects/{project}/locations/{location}/agent/sessions/{session}/contexts/{context}`
90
+ #
91
+ # @param project [String]
92
+ # @param location [String]
93
+ # @param session [String]
94
+ # @param context [String]
95
+ #
96
+ # @overload context_path(project:, location:, environment:, user:, session:, context:)
97
+ # The resource will be in the following format:
98
+ #
99
+ # `projects/{project}/locations/{location}/agent/environments/{environment}/users/{user}/sessions/{session}/contexts/{context}`
100
+ #
101
+ # @param project [String]
102
+ # @param location [String]
103
+ # @param environment [String]
104
+ # @param user [String]
105
+ # @param session [String]
106
+ # @param context [String]
107
+ #
64
108
  # @return [::String]
65
109
  def context_path **args
66
110
  resources = {
67
- "context:project:session" => (proc do |project:, session:, context:|
111
+ "context:project:session" => (proc do |project:, session:, context:|
68
112
  raise ::ArgumentError, "project cannot contain /" if project.to_s.include? "/"
69
113
  raise ::ArgumentError, "session cannot contain /" if session.to_s.include? "/"
70
114
 
@@ -77,6 +121,22 @@ module Google
77
121
  raise ::ArgumentError, "session cannot contain /" if session.to_s.include? "/"
78
122
 
79
123
  "projects/#{project}/agent/environments/#{environment}/users/#{user}/sessions/#{session}/contexts/#{context}"
124
+ end),
125
+ "context:location:project:session" => (proc do |project:, location:, session:, context:|
126
+ raise ::ArgumentError, "project cannot contain /" if project.to_s.include? "/"
127
+ raise ::ArgumentError, "location cannot contain /" if location.to_s.include? "/"
128
+ raise ::ArgumentError, "session cannot contain /" if session.to_s.include? "/"
129
+
130
+ "projects/#{project}/locations/#{location}/agent/sessions/#{session}/contexts/#{context}"
131
+ end),
132
+ "context:environment:location:project:session:user" => (proc do |project:, location:, environment:, user:, session:, context:|
133
+ raise ::ArgumentError, "project cannot contain /" if project.to_s.include? "/"
134
+ raise ::ArgumentError, "location cannot contain /" if location.to_s.include? "/"
135
+ raise ::ArgumentError, "environment cannot contain /" if environment.to_s.include? "/"
136
+ raise ::ArgumentError, "user cannot contain /" if user.to_s.include? "/"
137
+ raise ::ArgumentError, "session cannot contain /" if session.to_s.include? "/"
138
+
139
+ "projects/#{project}/locations/#{location}/agent/environments/#{environment}/users/#{user}/sessions/#{session}/contexts/#{context}"
80
140
  end)
81
141
  }
82
142
 
@@ -88,18 +148,42 @@ module Google
88
148
  ##
89
149
  # Create a fully-qualified Intent resource string.
90
150
  #
91
- # The resource will be in the following format:
151
+ # @overload intent_path(project:, intent:)
152
+ # The resource will be in the following format:
153
+ #
154
+ # `projects/{project}/agent/intents/{intent}`
155
+ #
156
+ # @param project [String]
157
+ # @param intent [String]
158
+ #
159
+ # @overload intent_path(project:, location:, intent:)
160
+ # The resource will be in the following format:
92
161
  #
93
- # `projects/{project}/agent/intents/{intent}`
162
+ # `projects/{project}/locations/{location}/agent/intents/{intent}`
94
163
  #
95
- # @param project [String]
96
- # @param intent [String]
164
+ # @param project [String]
165
+ # @param location [String]
166
+ # @param intent [String]
97
167
  #
98
168
  # @return [::String]
99
- def intent_path project:, intent:
100
- raise ::ArgumentError, "project cannot contain /" if project.to_s.include? "/"
169
+ def intent_path **args
170
+ resources = {
171
+ "intent:project" => (proc do |project:, intent:|
172
+ raise ::ArgumentError, "project cannot contain /" if project.to_s.include? "/"
101
173
 
102
- "projects/#{project}/agent/intents/#{intent}"
174
+ "projects/#{project}/agent/intents/#{intent}"
175
+ end),
176
+ "intent:location:project" => (proc do |project:, location:, intent:|
177
+ raise ::ArgumentError, "project cannot contain /" if project.to_s.include? "/"
178
+ raise ::ArgumentError, "location cannot contain /" if location.to_s.include? "/"
179
+
180
+ "projects/#{project}/locations/#{location}/agent/intents/#{intent}"
181
+ end)
182
+ }
183
+
184
+ resource = resources[args.keys.sort.join(":")]
185
+ raise ::ArgumentError, "no resource found for values #{args.keys}" if resource.nil?
186
+ resource.call(**args)
103
187
  end
104
188
 
105
189
  extend self
@@ -0,0 +1,60 @@
1
+ # Generated by the protocol buffer compiler. DO NOT EDIT!
2
+ # source: google/cloud/dialogflow/v2/knowledge_base.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/protobuf/empty_pb'
11
+ require 'google/protobuf/field_mask_pb'
12
+ Google::Protobuf::DescriptorPool.generated_pool.build do
13
+ add_file("google/cloud/dialogflow/v2/knowledge_base.proto", :syntax => :proto3) do
14
+ add_message "google.cloud.dialogflow.v2.KnowledgeBase" do
15
+ optional :name, :string, 1
16
+ optional :display_name, :string, 2
17
+ optional :language_code, :string, 4
18
+ end
19
+ add_message "google.cloud.dialogflow.v2.ListKnowledgeBasesRequest" do
20
+ optional :parent, :string, 1
21
+ optional :page_size, :int32, 2
22
+ optional :page_token, :string, 3
23
+ end
24
+ add_message "google.cloud.dialogflow.v2.ListKnowledgeBasesResponse" do
25
+ repeated :knowledge_bases, :message, 1, "google.cloud.dialogflow.v2.KnowledgeBase"
26
+ optional :next_page_token, :string, 2
27
+ end
28
+ add_message "google.cloud.dialogflow.v2.GetKnowledgeBaseRequest" do
29
+ optional :name, :string, 1
30
+ end
31
+ add_message "google.cloud.dialogflow.v2.CreateKnowledgeBaseRequest" do
32
+ optional :parent, :string, 1
33
+ optional :knowledge_base, :message, 2, "google.cloud.dialogflow.v2.KnowledgeBase"
34
+ end
35
+ add_message "google.cloud.dialogflow.v2.DeleteKnowledgeBaseRequest" do
36
+ optional :name, :string, 1
37
+ optional :force, :bool, 2
38
+ end
39
+ add_message "google.cloud.dialogflow.v2.UpdateKnowledgeBaseRequest" do
40
+ optional :knowledge_base, :message, 1, "google.cloud.dialogflow.v2.KnowledgeBase"
41
+ optional :update_mask, :message, 2, "google.protobuf.FieldMask"
42
+ end
43
+ end
44
+ end
45
+
46
+ module Google
47
+ module Cloud
48
+ module Dialogflow
49
+ module V2
50
+ KnowledgeBase = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.KnowledgeBase").msgclass
51
+ ListKnowledgeBasesRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.ListKnowledgeBasesRequest").msgclass
52
+ ListKnowledgeBasesResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.ListKnowledgeBasesResponse").msgclass
53
+ GetKnowledgeBaseRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.GetKnowledgeBaseRequest").msgclass
54
+ CreateKnowledgeBaseRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.CreateKnowledgeBaseRequest").msgclass
55
+ DeleteKnowledgeBaseRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.DeleteKnowledgeBaseRequest").msgclass
56
+ UpdateKnowledgeBaseRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.UpdateKnowledgeBaseRequest").msgclass
57
+ end
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,53 @@
1
+ # Generated by the protocol buffer compiler. DO NOT EDIT!
2
+ # Source: google/cloud/dialogflow/v2/knowledge_base.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/knowledge_base_pb'
21
+
22
+ module Google
23
+ module Cloud
24
+ module Dialogflow
25
+ module V2
26
+ module KnowledgeBases
27
+ # Service for managing [KnowledgeBases][google.cloud.dialogflow.v2.KnowledgeBase].
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.KnowledgeBases'
35
+
36
+ # Returns the list of all knowledge bases of the specified agent.
37
+ rpc :ListKnowledgeBases, ::Google::Cloud::Dialogflow::V2::ListKnowledgeBasesRequest, ::Google::Cloud::Dialogflow::V2::ListKnowledgeBasesResponse
38
+ # Retrieves the specified knowledge base.
39
+ rpc :GetKnowledgeBase, ::Google::Cloud::Dialogflow::V2::GetKnowledgeBaseRequest, ::Google::Cloud::Dialogflow::V2::KnowledgeBase
40
+ # Creates a knowledge base.
41
+ rpc :CreateKnowledgeBase, ::Google::Cloud::Dialogflow::V2::CreateKnowledgeBaseRequest, ::Google::Cloud::Dialogflow::V2::KnowledgeBase
42
+ # Deletes the specified knowledge base.
43
+ rpc :DeleteKnowledgeBase, ::Google::Cloud::Dialogflow::V2::DeleteKnowledgeBaseRequest, ::Google::Protobuf::Empty
44
+ # Updates the specified knowledge base.
45
+ rpc :UpdateKnowledgeBase, ::Google::Cloud::Dialogflow::V2::UpdateKnowledgeBaseRequest, ::Google::Cloud::Dialogflow::V2::KnowledgeBase
46
+ end
47
+
48
+ Stub = Service.rpc_stub_class
49
+ end
50
+ end
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,49 @@
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/knowledge_bases/credentials"
26
+ require "google/cloud/dialogflow/v2/knowledge_bases/paths"
27
+ require "google/cloud/dialogflow/v2/knowledge_bases/client"
28
+
29
+ module Google
30
+ module Cloud
31
+ module Dialogflow
32
+ module V2
33
+ ##
34
+ # Service for managing {::Google::Cloud::Dialogflow::V2::KnowledgeBase KnowledgeBases}.
35
+ #
36
+ # To load this service and instantiate a client:
37
+ #
38
+ # require "google/cloud/dialogflow/v2/knowledge_bases"
39
+ # client = ::Google::Cloud::Dialogflow::V2::KnowledgeBases::Client.new
40
+ #
41
+ module KnowledgeBases
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
47
+
48
+ helper_path = ::File.join __dir__, "knowledge_bases", "helpers.rb"
49
+ require "google/cloud/dialogflow/v2/knowledge_bases/helpers" if ::File.file? helper_path