google-cloud-dialogflow 0.14.0 → 1.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +2 -1
  3. data/AUTHENTICATION.md +51 -59
  4. data/LICENSE.md +203 -0
  5. data/MIGRATING.md +445 -0
  6. data/README.md +35 -25
  7. data/lib/{google/cloud/dialogflow/v2/doc/google/protobuf/empty.rb → google-cloud-dialogflow.rb} +4 -14
  8. data/lib/google/cloud/dialogflow.rb +256 -506
  9. data/lib/google/cloud/dialogflow/version.rb +1 -1
  10. metadata +63 -86
  11. data/LICENSE +0 -201
  12. data/lib/google/cloud/dialogflow/v2.rb +0 -598
  13. data/lib/google/cloud/dialogflow/v2/agent_pb.rb +0 -121
  14. data/lib/google/cloud/dialogflow/v2/agent_services_pb.rb +0 -111
  15. data/lib/google/cloud/dialogflow/v2/agents_client.rb +0 -807
  16. data/lib/google/cloud/dialogflow/v2/agents_client_config.json +0 -71
  17. data/lib/google/cloud/dialogflow/v2/audio_config_pb.rb +0 -96
  18. data/lib/google/cloud/dialogflow/v2/context_pb.rb +0 -63
  19. data/lib/google/cloud/dialogflow/v2/context_services_pb.rb +0 -75
  20. data/lib/google/cloud/dialogflow/v2/contexts_client.rb +0 -519
  21. data/lib/google/cloud/dialogflow/v2/contexts_client_config.json +0 -56
  22. data/lib/google/cloud/dialogflow/v2/credentials.rb +0 -42
  23. data/lib/google/cloud/dialogflow/v2/doc/google/cloud/dialogflow/v2/agent.rb +0 -247
  24. data/lib/google/cloud/dialogflow/v2/doc/google/cloud/dialogflow/v2/audio_config.rb +0 -341
  25. data/lib/google/cloud/dialogflow/v2/doc/google/cloud/dialogflow/v2/context.rb +0 -116
  26. data/lib/google/cloud/dialogflow/v2/doc/google/cloud/dialogflow/v2/entity_type.rb +0 -305
  27. data/lib/google/cloud/dialogflow/v2/doc/google/cloud/dialogflow/v2/intent.rb +0 -937
  28. data/lib/google/cloud/dialogflow/v2/doc/google/cloud/dialogflow/v2/session.rb +0 -498
  29. data/lib/google/cloud/dialogflow/v2/doc/google/cloud/dialogflow/v2/session_entity_type.rb +0 -130
  30. data/lib/google/cloud/dialogflow/v2/doc/google/cloud/dialogflow/v2/validation_result.rb +0 -71
  31. data/lib/google/cloud/dialogflow/v2/doc/google/longrunning/operations.rb +0 -51
  32. data/lib/google/cloud/dialogflow/v2/doc/google/protobuf/any.rb +0 -131
  33. data/lib/google/cloud/dialogflow/v2/doc/google/protobuf/duration.rb +0 -91
  34. data/lib/google/cloud/dialogflow/v2/doc/google/protobuf/field_mask.rb +0 -222
  35. data/lib/google/cloud/dialogflow/v2/doc/google/protobuf/struct.rb +0 -74
  36. data/lib/google/cloud/dialogflow/v2/doc/google/rpc/status.rb +0 -39
  37. data/lib/google/cloud/dialogflow/v2/doc/google/type/latlng.rb +0 -31
  38. data/lib/google/cloud/dialogflow/v2/entity_type_pb.rb +0 -125
  39. data/lib/google/cloud/dialogflow/v2/entity_type_services_pb.rb +0 -105
  40. data/lib/google/cloud/dialogflow/v2/entity_types_client.rb +0 -994
  41. data/lib/google/cloud/dialogflow/v2/entity_types_client_config.json +0 -76
  42. data/lib/google/cloud/dialogflow/v2/intent_pb.rb +0 -367
  43. data/lib/google/cloud/dialogflow/v2/intent_services_pb.rb +0 -93
  44. data/lib/google/cloud/dialogflow/v2/intents_client.rb +0 -760
  45. data/lib/google/cloud/dialogflow/v2/intents_client_config.json +0 -61
  46. data/lib/google/cloud/dialogflow/v2/session_entity_type_pb.rb +0 -65
  47. data/lib/google/cloud/dialogflow/v2/session_entity_type_services_pb.rb +0 -93
  48. data/lib/google/cloud/dialogflow/v2/session_entity_types_client.rb +0 -504
  49. data/lib/google/cloud/dialogflow/v2/session_entity_types_client_config.json +0 -51
  50. data/lib/google/cloud/dialogflow/v2/session_pb.rb +0 -141
  51. data/lib/google/cloud/dialogflow/v2/session_services_pb.rb +0 -56
  52. data/lib/google/cloud/dialogflow/v2/sessions_client.rb +0 -337
  53. data/lib/google/cloud/dialogflow/v2/sessions_client_config.json +0 -36
  54. data/lib/google/cloud/dialogflow/v2/validation_result_pb.rb +0 -36
  55. data/lib/google/cloud/dialogflow/v2/webhook_pb.rb +0 -46
@@ -1,71 +0,0 @@
1
- {
2
- "interfaces": {
3
- "google.cloud.dialogflow.v2.Agents": {
4
- "retry_codes": {
5
- "idempotent": [
6
- "DEADLINE_EXCEEDED",
7
- "UNAVAILABLE"
8
- ],
9
- "non_idempotent": []
10
- },
11
- "retry_params": {
12
- "default": {
13
- "initial_retry_delay_millis": 100,
14
- "retry_delay_multiplier": 1.3,
15
- "max_retry_delay_millis": 60000,
16
- "initial_rpc_timeout_millis": 20000,
17
- "rpc_timeout_multiplier": 1.0,
18
- "max_rpc_timeout_millis": 20000,
19
- "total_timeout_millis": 600000
20
- }
21
- },
22
- "methods": {
23
- "SetAgent": {
24
- "timeout_millis": 60000,
25
- "retry_codes_name": "idempotent",
26
- "retry_params_name": "default"
27
- },
28
- "DeleteAgent": {
29
- "timeout_millis": 60000,
30
- "retry_codes_name": "idempotent",
31
- "retry_params_name": "default"
32
- },
33
- "GetAgent": {
34
- "timeout_millis": 60000,
35
- "retry_codes_name": "idempotent",
36
- "retry_params_name": "default"
37
- },
38
- "SearchAgents": {
39
- "timeout_millis": 60000,
40
- "retry_codes_name": "idempotent",
41
- "retry_params_name": "default"
42
- },
43
- "TrainAgent": {
44
- "timeout_millis": 60000,
45
- "retry_codes_name": "idempotent",
46
- "retry_params_name": "default"
47
- },
48
- "ExportAgent": {
49
- "timeout_millis": 60000,
50
- "retry_codes_name": "idempotent",
51
- "retry_params_name": "default"
52
- },
53
- "ImportAgent": {
54
- "timeout_millis": 60000,
55
- "retry_codes_name": "non_idempotent",
56
- "retry_params_name": "default"
57
- },
58
- "RestoreAgent": {
59
- "timeout_millis": 60000,
60
- "retry_codes_name": "idempotent",
61
- "retry_params_name": "default"
62
- },
63
- "GetValidationResult": {
64
- "timeout_millis": 60000,
65
- "retry_codes_name": "idempotent",
66
- "retry_params_name": "default"
67
- }
68
- }
69
- }
70
- }
71
- }
@@ -1,96 +0,0 @@
1
- # Generated by the protocol buffer compiler. DO NOT EDIT!
2
- # source: google/cloud/dialogflow/v2/audio_config.proto
3
-
4
-
5
- require 'google/protobuf'
6
-
7
- require 'google/api/field_behavior_pb'
8
- require 'google/api/resource_pb'
9
- require 'google/protobuf/duration_pb'
10
- require 'google/api/annotations_pb'
11
- Google::Protobuf::DescriptorPool.generated_pool.build do
12
- add_message "google.cloud.dialogflow.v2.SpeechContext" do
13
- repeated :phrases, :string, 1
14
- optional :boost, :float, 2
15
- end
16
- add_message "google.cloud.dialogflow.v2.SpeechWordInfo" do
17
- optional :word, :string, 3
18
- optional :start_offset, :message, 1, "google.protobuf.Duration"
19
- optional :end_offset, :message, 2, "google.protobuf.Duration"
20
- optional :confidence, :float, 4
21
- end
22
- add_message "google.cloud.dialogflow.v2.InputAudioConfig" do
23
- optional :audio_encoding, :enum, 1, "google.cloud.dialogflow.v2.AudioEncoding"
24
- optional :sample_rate_hertz, :int32, 2
25
- optional :language_code, :string, 3
26
- optional :enable_word_info, :bool, 13
27
- repeated :phrase_hints, :string, 4
28
- repeated :speech_contexts, :message, 11, "google.cloud.dialogflow.v2.SpeechContext"
29
- optional :model, :string, 7
30
- optional :model_variant, :enum, 10, "google.cloud.dialogflow.v2.SpeechModelVariant"
31
- optional :single_utterance, :bool, 8
32
- end
33
- add_message "google.cloud.dialogflow.v2.VoiceSelectionParams" do
34
- optional :name, :string, 1
35
- optional :ssml_gender, :enum, 2, "google.cloud.dialogflow.v2.SsmlVoiceGender"
36
- end
37
- add_message "google.cloud.dialogflow.v2.SynthesizeSpeechConfig" do
38
- optional :speaking_rate, :double, 1
39
- optional :pitch, :double, 2
40
- optional :volume_gain_db, :double, 3
41
- repeated :effects_profile_id, :string, 5
42
- optional :voice, :message, 4, "google.cloud.dialogflow.v2.VoiceSelectionParams"
43
- end
44
- add_message "google.cloud.dialogflow.v2.OutputAudioConfig" do
45
- optional :audio_encoding, :enum, 1, "google.cloud.dialogflow.v2.OutputAudioEncoding"
46
- optional :sample_rate_hertz, :int32, 2
47
- optional :synthesize_speech_config, :message, 3, "google.cloud.dialogflow.v2.SynthesizeSpeechConfig"
48
- end
49
- add_enum "google.cloud.dialogflow.v2.AudioEncoding" do
50
- value :AUDIO_ENCODING_UNSPECIFIED, 0
51
- value :AUDIO_ENCODING_LINEAR_16, 1
52
- value :AUDIO_ENCODING_FLAC, 2
53
- value :AUDIO_ENCODING_MULAW, 3
54
- value :AUDIO_ENCODING_AMR, 4
55
- value :AUDIO_ENCODING_AMR_WB, 5
56
- value :AUDIO_ENCODING_OGG_OPUS, 6
57
- value :AUDIO_ENCODING_SPEEX_WITH_HEADER_BYTE, 7
58
- end
59
- add_enum "google.cloud.dialogflow.v2.SpeechModelVariant" do
60
- value :SPEECH_MODEL_VARIANT_UNSPECIFIED, 0
61
- value :USE_BEST_AVAILABLE, 1
62
- value :USE_STANDARD, 2
63
- value :USE_ENHANCED, 3
64
- end
65
- add_enum "google.cloud.dialogflow.v2.SsmlVoiceGender" do
66
- value :SSML_VOICE_GENDER_UNSPECIFIED, 0
67
- value :SSML_VOICE_GENDER_MALE, 1
68
- value :SSML_VOICE_GENDER_FEMALE, 2
69
- value :SSML_VOICE_GENDER_NEUTRAL, 3
70
- end
71
- add_enum "google.cloud.dialogflow.v2.OutputAudioEncoding" do
72
- value :OUTPUT_AUDIO_ENCODING_UNSPECIFIED, 0
73
- value :OUTPUT_AUDIO_ENCODING_LINEAR_16, 1
74
- value :OUTPUT_AUDIO_ENCODING_MP3, 2
75
- value :OUTPUT_AUDIO_ENCODING_OGG_OPUS, 3
76
- end
77
- end
78
-
79
- module Google
80
- module Cloud
81
- module Dialogflow
82
- module V2
83
- SpeechContext = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.SpeechContext").msgclass
84
- SpeechWordInfo = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.SpeechWordInfo").msgclass
85
- InputAudioConfig = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.InputAudioConfig").msgclass
86
- VoiceSelectionParams = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.VoiceSelectionParams").msgclass
87
- SynthesizeSpeechConfig = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.SynthesizeSpeechConfig").msgclass
88
- OutputAudioConfig = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.OutputAudioConfig").msgclass
89
- AudioEncoding = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.AudioEncoding").enummodule
90
- SpeechModelVariant = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.SpeechModelVariant").enummodule
91
- SsmlVoiceGender = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.SsmlVoiceGender").enummodule
92
- OutputAudioEncoding = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.OutputAudioEncoding").enummodule
93
- end
94
- end
95
- end
96
- end
@@ -1,63 +0,0 @@
1
- # Generated by the protocol buffer compiler. DO NOT EDIT!
2
- # source: google/cloud/dialogflow/v2/context.proto
3
-
4
-
5
- require 'google/protobuf'
6
-
7
- require 'google/api/annotations_pb'
8
- require 'google/api/client_pb'
9
- require 'google/api/field_behavior_pb'
10
- require 'google/api/resource_pb'
11
- require 'google/protobuf/empty_pb'
12
- require 'google/protobuf/field_mask_pb'
13
- require 'google/protobuf/struct_pb'
14
- Google::Protobuf::DescriptorPool.generated_pool.build do
15
- add_message "google.cloud.dialogflow.v2.Context" do
16
- optional :name, :string, 1
17
- optional :lifespan_count, :int32, 2
18
- optional :parameters, :message, 3, "google.protobuf.Struct"
19
- end
20
- add_message "google.cloud.dialogflow.v2.ListContextsRequest" do
21
- optional :parent, :string, 1
22
- optional :page_size, :int32, 2
23
- optional :page_token, :string, 3
24
- end
25
- add_message "google.cloud.dialogflow.v2.ListContextsResponse" do
26
- repeated :contexts, :message, 1, "google.cloud.dialogflow.v2.Context"
27
- optional :next_page_token, :string, 2
28
- end
29
- add_message "google.cloud.dialogflow.v2.GetContextRequest" do
30
- optional :name, :string, 1
31
- end
32
- add_message "google.cloud.dialogflow.v2.CreateContextRequest" do
33
- optional :parent, :string, 1
34
- optional :context, :message, 2, "google.cloud.dialogflow.v2.Context"
35
- end
36
- add_message "google.cloud.dialogflow.v2.UpdateContextRequest" do
37
- optional :context, :message, 1, "google.cloud.dialogflow.v2.Context"
38
- optional :update_mask, :message, 2, "google.protobuf.FieldMask"
39
- end
40
- add_message "google.cloud.dialogflow.v2.DeleteContextRequest" do
41
- optional :name, :string, 1
42
- end
43
- add_message "google.cloud.dialogflow.v2.DeleteAllContextsRequest" do
44
- optional :parent, :string, 1
45
- end
46
- end
47
-
48
- module Google
49
- module Cloud
50
- module Dialogflow
51
- module V2
52
- Context = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.Context").msgclass
53
- ListContextsRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.ListContextsRequest").msgclass
54
- ListContextsResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.ListContextsResponse").msgclass
55
- GetContextRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.GetContextRequest").msgclass
56
- CreateContextRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.CreateContextRequest").msgclass
57
- UpdateContextRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.UpdateContextRequest").msgclass
58
- DeleteContextRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.DeleteContextRequest").msgclass
59
- DeleteAllContextsRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.DeleteAllContextsRequest").msgclass
60
- end
61
- end
62
- end
63
- end
@@ -1,75 +0,0 @@
1
- # Generated by the protocol buffer compiler. DO NOT EDIT!
2
- # Source: google/cloud/dialogflow/v2/context.proto for package 'google.cloud.dialogflow.v2'
3
- # Original file comments:
4
- # Copyright 2020 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
-
20
- require 'grpc'
21
- require 'google/cloud/dialogflow/v2/context_pb'
22
-
23
- module Google
24
- module Cloud
25
- module Dialogflow
26
- module V2
27
- module Contexts
28
- # A context represents additional information included with user input or with
29
- # an intent returned by the Dialogflow API. Contexts are helpful for
30
- # differentiating user input which may be vague or have a different meaning
31
- # depending on additional details from your application such as user setting
32
- # and preferences, previous user input, where the user is in your application,
33
- # geographic location, and so on.
34
- #
35
- # You can include contexts as input parameters of a
36
- # [DetectIntent][google.cloud.dialogflow.v2.Sessions.DetectIntent] (or
37
- # [StreamingDetectIntent][google.cloud.dialogflow.v2.Sessions.StreamingDetectIntent]) request,
38
- # or as output contexts included in the returned intent.
39
- # Contexts expire when an intent is matched, after the number of `DetectIntent`
40
- # requests specified by the `lifespan_count` parameter, or after 20 minutes
41
- # if no intents are matched for a `DetectIntent` request.
42
- #
43
- # For more information about contexts, see the
44
- # [Dialogflow
45
- # documentation](https://cloud.google.com/dialogflow/docs/contexts-overview).
46
- class Service
47
-
48
- include GRPC::GenericService
49
-
50
- self.marshal_class_method = :encode
51
- self.unmarshal_class_method = :decode
52
- self.service_name = 'google.cloud.dialogflow.v2.Contexts'
53
-
54
- # Returns the list of all contexts in the specified session.
55
- rpc :ListContexts, ListContextsRequest, ListContextsResponse
56
- # Retrieves the specified context.
57
- rpc :GetContext, GetContextRequest, Context
58
- # Creates a context.
59
- #
60
- # If the specified context already exists, overrides the context.
61
- rpc :CreateContext, CreateContextRequest, Context
62
- # Updates the specified context.
63
- rpc :UpdateContext, UpdateContextRequest, Context
64
- # Deletes the specified context.
65
- rpc :DeleteContext, DeleteContextRequest, Google::Protobuf::Empty
66
- # Deletes all active contexts in the specified session.
67
- rpc :DeleteAllContexts, DeleteAllContextsRequest, Google::Protobuf::Empty
68
- end
69
-
70
- Stub = Service.rpc_stub_class
71
- end
72
- end
73
- end
74
- end
75
- end
@@ -1,519 +0,0 @@
1
- # Copyright 2020 Google LLC
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # https://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
- #
15
- # EDITING INSTRUCTIONS
16
- # This file was generated from the file
17
- # https://github.com/googleapis/googleapis/blob/master/google/cloud/dialogflow/v2/context.proto,
18
- # and updates to that file get reflected here through a refresh process.
19
- # For the short term, the refresh process will only be runnable by Google
20
- # engineers.
21
-
22
-
23
- require "json"
24
- require "pathname"
25
-
26
- require "google/gax"
27
-
28
- require "google/cloud/dialogflow/v2/context_pb"
29
- require "google/cloud/dialogflow/v2/credentials"
30
- require "google/cloud/dialogflow/version"
31
-
32
- module Google
33
- module Cloud
34
- module Dialogflow
35
- module V2
36
- # A context represents additional information included with user input or with
37
- # an intent returned by the Dialogflow API. Contexts are helpful for
38
- # differentiating user input which may be vague or have a different meaning
39
- # depending on additional details from your application such as user setting
40
- # and preferences, previous user input, where the user is in your application,
41
- # geographic location, and so on.
42
- #
43
- # You can include contexts as input parameters of a
44
- # {Google::Cloud::Dialogflow::V2::Sessions::DetectIntent DetectIntent} (or
45
- # {Google::Cloud::Dialogflow::V2::Sessions::StreamingDetectIntent StreamingDetectIntent}) request,
46
- # or as output contexts included in the returned intent.
47
- # Contexts expire when an intent is matched, after the number of `DetectIntent`
48
- # requests specified by the `lifespan_count` parameter, or after 20 minutes
49
- # if no intents are matched for a `DetectIntent` request.
50
- #
51
- # For more information about contexts, see the
52
- # [Dialogflow
53
- # documentation](https://cloud.google.com/dialogflow/docs/contexts-overview).
54
- #
55
- # @!attribute [r] contexts_stub
56
- # @return [Google::Cloud::Dialogflow::V2::Contexts::Stub]
57
- class ContextsClient
58
- # @private
59
- attr_reader :contexts_stub
60
-
61
- # The default address of the service.
62
- SERVICE_ADDRESS = "dialogflow.googleapis.com".freeze
63
-
64
- # The default port of the service.
65
- DEFAULT_SERVICE_PORT = 443
66
-
67
- # The default set of gRPC interceptors.
68
- GRPC_INTERCEPTORS = []
69
-
70
- DEFAULT_TIMEOUT = 30
71
-
72
- PAGE_DESCRIPTORS = {
73
- "list_contexts" => Google::Gax::PageDescriptor.new(
74
- "page_token",
75
- "next_page_token",
76
- "contexts")
77
- }.freeze
78
-
79
- private_constant :PAGE_DESCRIPTORS
80
-
81
- # The scopes needed to make gRPC calls to all of the methods defined in
82
- # this service.
83
- ALL_SCOPES = [
84
- "https://www.googleapis.com/auth/cloud-platform",
85
- "https://www.googleapis.com/auth/dialogflow"
86
- ].freeze
87
-
88
-
89
- CONTEXT_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
90
- "projects/{project}/agent/sessions/{session}/contexts/{context}"
91
- )
92
-
93
- private_constant :CONTEXT_PATH_TEMPLATE
94
-
95
- SESSION_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
96
- "projects/{project}/agent/sessions/{session}"
97
- )
98
-
99
- private_constant :SESSION_PATH_TEMPLATE
100
-
101
- # Returns a fully-qualified context resource name string.
102
- # @param project [String]
103
- # @param session [String]
104
- # @param context [String]
105
- # @return [String]
106
- def self.context_path project, session, context
107
- CONTEXT_PATH_TEMPLATE.render(
108
- :"project" => project,
109
- :"session" => session,
110
- :"context" => context
111
- )
112
- end
113
-
114
- # Returns a fully-qualified session resource name string.
115
- # @param project [String]
116
- # @param session [String]
117
- # @return [String]
118
- def self.session_path project, session
119
- SESSION_PATH_TEMPLATE.render(
120
- :"project" => project,
121
- :"session" => session
122
- )
123
- end
124
-
125
- # @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc]
126
- # Provides the means for authenticating requests made by the client. This parameter can
127
- # be many types.
128
- # A `Google::Auth::Credentials` uses a the properties of its represented keyfile for
129
- # authenticating requests made by this client.
130
- # A `String` will be treated as the path to the keyfile to be used for the construction of
131
- # credentials for this client.
132
- # A `Hash` will be treated as the contents of a keyfile to be used for the construction of
133
- # credentials for this client.
134
- # A `GRPC::Core::Channel` will be used to make calls through.
135
- # A `GRPC::Core::ChannelCredentials` for the setting up the RPC client. The channel credentials
136
- # should already be composed with a `GRPC::Core::CallCredentials` object.
137
- # A `Proc` will be used as an updater_proc for the Grpc channel. The proc transforms the
138
- # metadata for requests, generally, to give OAuth credentials.
139
- # @param scopes [Array<String>]
140
- # The OAuth scopes for this service. This parameter is ignored if
141
- # an updater_proc is supplied.
142
- # @param client_config [Hash]
143
- # A Hash for call options for each method. See
144
- # Google::Gax#construct_settings for the structure of
145
- # this data. Falls back to the default config if not specified
146
- # or the specified config is missing data points.
147
- # @param timeout [Numeric]
148
- # The default timeout, in seconds, for calls made through this client.
149
- # @param metadata [Hash]
150
- # Default metadata to be sent with each request. This can be overridden on a per call basis.
151
- # @param service_address [String]
152
- # Override for the service hostname, or `nil` to leave as the default.
153
- # @param service_port [Integer]
154
- # Override for the service port, or `nil` to leave as the default.
155
- # @param exception_transformer [Proc]
156
- # An optional proc that intercepts any exceptions raised during an API call to inject
157
- # custom error handling.
158
- def initialize \
159
- credentials: nil,
160
- scopes: ALL_SCOPES,
161
- client_config: {},
162
- timeout: DEFAULT_TIMEOUT,
163
- metadata: nil,
164
- service_address: nil,
165
- service_port: nil,
166
- exception_transformer: nil,
167
- lib_name: nil,
168
- lib_version: ""
169
- # These require statements are intentionally placed here to initialize
170
- # the gRPC module only when it's required.
171
- # See https://github.com/googleapis/toolkit/issues/446
172
- require "google/gax/grpc"
173
- require "google/cloud/dialogflow/v2/context_services_pb"
174
-
175
- credentials ||= Google::Cloud::Dialogflow::V2::Credentials.default
176
-
177
- if credentials.is_a?(String) || credentials.is_a?(Hash)
178
- updater_proc = Google::Cloud::Dialogflow::V2::Credentials.new(credentials).updater_proc
179
- end
180
- if credentials.is_a?(GRPC::Core::Channel)
181
- channel = credentials
182
- end
183
- if credentials.is_a?(GRPC::Core::ChannelCredentials)
184
- chan_creds = credentials
185
- end
186
- if credentials.is_a?(Proc)
187
- updater_proc = credentials
188
- end
189
- if credentials.is_a?(Google::Auth::Credentials)
190
- updater_proc = credentials.updater_proc
191
- end
192
-
193
- package_version = Google::Cloud::Dialogflow::VERSION
194
-
195
- google_api_client = "gl-ruby/#{RUBY_VERSION}"
196
- google_api_client << " #{lib_name}/#{lib_version}" if lib_name
197
- google_api_client << " gapic/#{package_version} gax/#{Google::Gax::VERSION}"
198
- google_api_client << " grpc/#{GRPC::VERSION}"
199
- google_api_client.freeze
200
-
201
- headers = { :"x-goog-api-client" => google_api_client }
202
- headers.merge!(metadata) unless metadata.nil?
203
- client_config_file = Pathname.new(__dir__).join(
204
- "contexts_client_config.json"
205
- )
206
- defaults = client_config_file.open do |f|
207
- Google::Gax.construct_settings(
208
- "google.cloud.dialogflow.v2.Contexts",
209
- JSON.parse(f.read),
210
- client_config,
211
- Google::Gax::Grpc::STATUS_CODE_NAMES,
212
- timeout,
213
- page_descriptors: PAGE_DESCRIPTORS,
214
- errors: Google::Gax::Grpc::API_ERRORS,
215
- metadata: headers
216
- )
217
- end
218
-
219
- # Allow overriding the service path/port in subclasses.
220
- service_path = service_address || self.class::SERVICE_ADDRESS
221
- port = service_port || self.class::DEFAULT_SERVICE_PORT
222
- interceptors = self.class::GRPC_INTERCEPTORS
223
- @contexts_stub = Google::Gax::Grpc.create_stub(
224
- service_path,
225
- port,
226
- chan_creds: chan_creds,
227
- channel: channel,
228
- updater_proc: updater_proc,
229
- scopes: scopes,
230
- interceptors: interceptors,
231
- &Google::Cloud::Dialogflow::V2::Contexts::Stub.method(:new)
232
- )
233
-
234
- @list_contexts = Google::Gax.create_api_call(
235
- @contexts_stub.method(:list_contexts),
236
- defaults["list_contexts"],
237
- exception_transformer: exception_transformer,
238
- params_extractor: proc do |request|
239
- {'parent' => request.parent}
240
- end
241
- )
242
- @get_context = Google::Gax.create_api_call(
243
- @contexts_stub.method(:get_context),
244
- defaults["get_context"],
245
- exception_transformer: exception_transformer,
246
- params_extractor: proc do |request|
247
- {'name' => request.name}
248
- end
249
- )
250
- @create_context = Google::Gax.create_api_call(
251
- @contexts_stub.method(:create_context),
252
- defaults["create_context"],
253
- exception_transformer: exception_transformer,
254
- params_extractor: proc do |request|
255
- {'parent' => request.parent}
256
- end
257
- )
258
- @update_context = Google::Gax.create_api_call(
259
- @contexts_stub.method(:update_context),
260
- defaults["update_context"],
261
- exception_transformer: exception_transformer,
262
- params_extractor: proc do |request|
263
- {'context.name' => request.context.name}
264
- end
265
- )
266
- @delete_context = Google::Gax.create_api_call(
267
- @contexts_stub.method(:delete_context),
268
- defaults["delete_context"],
269
- exception_transformer: exception_transformer,
270
- params_extractor: proc do |request|
271
- {'name' => request.name}
272
- end
273
- )
274
- @delete_all_contexts = Google::Gax.create_api_call(
275
- @contexts_stub.method(:delete_all_contexts),
276
- defaults["delete_all_contexts"],
277
- exception_transformer: exception_transformer,
278
- params_extractor: proc do |request|
279
- {'parent' => request.parent}
280
- end
281
- )
282
- end
283
-
284
- # Service calls
285
-
286
- # Returns the list of all contexts in the specified session.
287
- #
288
- # @param parent [String]
289
- # Required. The session to list all contexts from.
290
- # Format: `projects/<Project ID>/agent/sessions/<Session ID>`.
291
- # @param page_size [Integer]
292
- # The maximum number of resources contained in the underlying API
293
- # response. If page streaming is performed per-resource, this
294
- # parameter does not affect the return value. If page streaming is
295
- # performed per-page, this determines the maximum number of
296
- # resources in a page.
297
- # @param options [Google::Gax::CallOptions]
298
- # Overrides the default settings for this call, e.g, timeout,
299
- # retries, etc.
300
- # @yield [result, operation] Access the result along with the RPC operation
301
- # @yieldparam result [Google::Gax::PagedEnumerable<Google::Cloud::Dialogflow::V2::Context>]
302
- # @yieldparam operation [GRPC::ActiveCall::Operation]
303
- # @return [Google::Gax::PagedEnumerable<Google::Cloud::Dialogflow::V2::Context>]
304
- # An enumerable of Google::Cloud::Dialogflow::V2::Context instances.
305
- # See Google::Gax::PagedEnumerable documentation for other
306
- # operations such as per-page iteration or access to the response
307
- # object.
308
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
309
- # @example
310
- # require "google/cloud/dialogflow"
311
- #
312
- # contexts_client = Google::Cloud::Dialogflow::Contexts.new(version: :v2)
313
- # formatted_parent = Google::Cloud::Dialogflow::V2::ContextsClient.session_path("[PROJECT]", "[SESSION]")
314
- #
315
- # # Iterate over all results.
316
- # contexts_client.list_contexts(formatted_parent).each do |element|
317
- # # Process element.
318
- # end
319
- #
320
- # # Or iterate over results one page at a time.
321
- # contexts_client.list_contexts(formatted_parent).each_page do |page|
322
- # # Process each page at a time.
323
- # page.each do |element|
324
- # # Process element.
325
- # end
326
- # end
327
-
328
- def list_contexts \
329
- parent,
330
- page_size: nil,
331
- options: nil,
332
- &block
333
- req = {
334
- parent: parent,
335
- page_size: page_size
336
- }.delete_if { |_, v| v.nil? }
337
- req = Google::Gax::to_proto(req, Google::Cloud::Dialogflow::V2::ListContextsRequest)
338
- @list_contexts.call(req, options, &block)
339
- end
340
-
341
- # Retrieves the specified context.
342
- #
343
- # @param name [String]
344
- # Required. The name of the context. Format:
345
- # `projects/<Project ID>/agent/sessions/<Session ID>/contexts/<Context ID>`.
346
- # @param options [Google::Gax::CallOptions]
347
- # Overrides the default settings for this call, e.g, timeout,
348
- # retries, etc.
349
- # @yield [result, operation] Access the result along with the RPC operation
350
- # @yieldparam result [Google::Cloud::Dialogflow::V2::Context]
351
- # @yieldparam operation [GRPC::ActiveCall::Operation]
352
- # @return [Google::Cloud::Dialogflow::V2::Context]
353
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
354
- # @example
355
- # require "google/cloud/dialogflow"
356
- #
357
- # contexts_client = Google::Cloud::Dialogflow::Contexts.new(version: :v2)
358
- # formatted_name = Google::Cloud::Dialogflow::V2::ContextsClient.context_path("[PROJECT]", "[SESSION]", "[CONTEXT]")
359
- # response = contexts_client.get_context(formatted_name)
360
-
361
- def get_context \
362
- name,
363
- options: nil,
364
- &block
365
- req = {
366
- name: name
367
- }.delete_if { |_, v| v.nil? }
368
- req = Google::Gax::to_proto(req, Google::Cloud::Dialogflow::V2::GetContextRequest)
369
- @get_context.call(req, options, &block)
370
- end
371
-
372
- # Creates a context.
373
- #
374
- # If the specified context already exists, overrides the context.
375
- #
376
- # @param parent [String]
377
- # Required. The session to create a context for.
378
- # Format: `projects/<Project ID>/agent/sessions/<Session ID>`.
379
- # @param context [Google::Cloud::Dialogflow::V2::Context | Hash]
380
- # Required. The context to create.
381
- # A hash of the same form as `Google::Cloud::Dialogflow::V2::Context`
382
- # can also be provided.
383
- # @param options [Google::Gax::CallOptions]
384
- # Overrides the default settings for this call, e.g, timeout,
385
- # retries, etc.
386
- # @yield [result, operation] Access the result along with the RPC operation
387
- # @yieldparam result [Google::Cloud::Dialogflow::V2::Context]
388
- # @yieldparam operation [GRPC::ActiveCall::Operation]
389
- # @return [Google::Cloud::Dialogflow::V2::Context]
390
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
391
- # @example
392
- # require "google/cloud/dialogflow"
393
- #
394
- # contexts_client = Google::Cloud::Dialogflow::Contexts.new(version: :v2)
395
- # formatted_parent = Google::Cloud::Dialogflow::V2::ContextsClient.session_path("[PROJECT]", "[SESSION]")
396
- #
397
- # # TODO: Initialize `context`:
398
- # context = {}
399
- # response = contexts_client.create_context(formatted_parent, context)
400
-
401
- def create_context \
402
- parent,
403
- context,
404
- options: nil,
405
- &block
406
- req = {
407
- parent: parent,
408
- context: context
409
- }.delete_if { |_, v| v.nil? }
410
- req = Google::Gax::to_proto(req, Google::Cloud::Dialogflow::V2::CreateContextRequest)
411
- @create_context.call(req, options, &block)
412
- end
413
-
414
- # Updates the specified context.
415
- #
416
- # @param context [Google::Cloud::Dialogflow::V2::Context | Hash]
417
- # Required. The context to update.
418
- # A hash of the same form as `Google::Cloud::Dialogflow::V2::Context`
419
- # can also be provided.
420
- # @param update_mask [Google::Protobuf::FieldMask | Hash]
421
- # Optional. The mask to control which fields get updated.
422
- # A hash of the same form as `Google::Protobuf::FieldMask`
423
- # can also be provided.
424
- # @param options [Google::Gax::CallOptions]
425
- # Overrides the default settings for this call, e.g, timeout,
426
- # retries, etc.
427
- # @yield [result, operation] Access the result along with the RPC operation
428
- # @yieldparam result [Google::Cloud::Dialogflow::V2::Context]
429
- # @yieldparam operation [GRPC::ActiveCall::Operation]
430
- # @return [Google::Cloud::Dialogflow::V2::Context]
431
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
432
- # @example
433
- # require "google/cloud/dialogflow"
434
- #
435
- # contexts_client = Google::Cloud::Dialogflow::Contexts.new(version: :v2)
436
- #
437
- # # TODO: Initialize `context`:
438
- # context = {}
439
- # response = contexts_client.update_context(context)
440
-
441
- def update_context \
442
- context,
443
- update_mask: nil,
444
- options: nil,
445
- &block
446
- req = {
447
- context: context,
448
- update_mask: update_mask
449
- }.delete_if { |_, v| v.nil? }
450
- req = Google::Gax::to_proto(req, Google::Cloud::Dialogflow::V2::UpdateContextRequest)
451
- @update_context.call(req, options, &block)
452
- end
453
-
454
- # Deletes the specified context.
455
- #
456
- # @param name [String]
457
- # Required. The name of the context to delete. Format:
458
- # `projects/<Project ID>/agent/sessions/<Session ID>/contexts/<Context ID>`.
459
- # @param options [Google::Gax::CallOptions]
460
- # Overrides the default settings for this call, e.g, timeout,
461
- # retries, etc.
462
- # @yield [result, operation] Access the result along with the RPC operation
463
- # @yieldparam result []
464
- # @yieldparam operation [GRPC::ActiveCall::Operation]
465
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
466
- # @example
467
- # require "google/cloud/dialogflow"
468
- #
469
- # contexts_client = Google::Cloud::Dialogflow::Contexts.new(version: :v2)
470
- # formatted_name = Google::Cloud::Dialogflow::V2::ContextsClient.context_path("[PROJECT]", "[SESSION]", "[CONTEXT]")
471
- # contexts_client.delete_context(formatted_name)
472
-
473
- def delete_context \
474
- name,
475
- options: nil,
476
- &block
477
- req = {
478
- name: name
479
- }.delete_if { |_, v| v.nil? }
480
- req = Google::Gax::to_proto(req, Google::Cloud::Dialogflow::V2::DeleteContextRequest)
481
- @delete_context.call(req, options, &block)
482
- nil
483
- end
484
-
485
- # Deletes all active contexts in the specified session.
486
- #
487
- # @param parent [String]
488
- # Required. The name of the session to delete all contexts from. Format:
489
- # `projects/<Project ID>/agent/sessions/<Session ID>`.
490
- # @param options [Google::Gax::CallOptions]
491
- # Overrides the default settings for this call, e.g, timeout,
492
- # retries, etc.
493
- # @yield [result, operation] Access the result along with the RPC operation
494
- # @yieldparam result []
495
- # @yieldparam operation [GRPC::ActiveCall::Operation]
496
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
497
- # @example
498
- # require "google/cloud/dialogflow"
499
- #
500
- # contexts_client = Google::Cloud::Dialogflow::Contexts.new(version: :v2)
501
- # formatted_parent = Google::Cloud::Dialogflow::V2::ContextsClient.session_path("[PROJECT]", "[SESSION]")
502
- # contexts_client.delete_all_contexts(formatted_parent)
503
-
504
- def delete_all_contexts \
505
- parent,
506
- options: nil,
507
- &block
508
- req = {
509
- parent: parent
510
- }.delete_if { |_, v| v.nil? }
511
- req = Google::Gax::to_proto(req, Google::Cloud::Dialogflow::V2::DeleteAllContextsRequest)
512
- @delete_all_contexts.call(req, options, &block)
513
- nil
514
- end
515
- end
516
- end
517
- end
518
- end
519
- end