google-cloud-dialogflow 0.15.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
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 +397 -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 +368 -506
  9. data/lib/google/cloud/dialogflow/version.rb +1 -1
  10. metadata +88 -83
  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 -810
  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 -522
  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 -997
  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 -763
  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 -507
  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 -340
  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,522 +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
- if credentials.respond_to?(:quota_project_id) && credentials.quota_project_id
203
- headers[:"x-goog-user-project"] = credentials.quota_project_id
204
- end
205
- headers.merge!(metadata) unless metadata.nil?
206
- client_config_file = Pathname.new(__dir__).join(
207
- "contexts_client_config.json"
208
- )
209
- defaults = client_config_file.open do |f|
210
- Google::Gax.construct_settings(
211
- "google.cloud.dialogflow.v2.Contexts",
212
- JSON.parse(f.read),
213
- client_config,
214
- Google::Gax::Grpc::STATUS_CODE_NAMES,
215
- timeout,
216
- page_descriptors: PAGE_DESCRIPTORS,
217
- errors: Google::Gax::Grpc::API_ERRORS,
218
- metadata: headers
219
- )
220
- end
221
-
222
- # Allow overriding the service path/port in subclasses.
223
- service_path = service_address || self.class::SERVICE_ADDRESS
224
- port = service_port || self.class::DEFAULT_SERVICE_PORT
225
- interceptors = self.class::GRPC_INTERCEPTORS
226
- @contexts_stub = Google::Gax::Grpc.create_stub(
227
- service_path,
228
- port,
229
- chan_creds: chan_creds,
230
- channel: channel,
231
- updater_proc: updater_proc,
232
- scopes: scopes,
233
- interceptors: interceptors,
234
- &Google::Cloud::Dialogflow::V2::Contexts::Stub.method(:new)
235
- )
236
-
237
- @list_contexts = Google::Gax.create_api_call(
238
- @contexts_stub.method(:list_contexts),
239
- defaults["list_contexts"],
240
- exception_transformer: exception_transformer,
241
- params_extractor: proc do |request|
242
- {'parent' => request.parent}
243
- end
244
- )
245
- @get_context = Google::Gax.create_api_call(
246
- @contexts_stub.method(:get_context),
247
- defaults["get_context"],
248
- exception_transformer: exception_transformer,
249
- params_extractor: proc do |request|
250
- {'name' => request.name}
251
- end
252
- )
253
- @create_context = Google::Gax.create_api_call(
254
- @contexts_stub.method(:create_context),
255
- defaults["create_context"],
256
- exception_transformer: exception_transformer,
257
- params_extractor: proc do |request|
258
- {'parent' => request.parent}
259
- end
260
- )
261
- @update_context = Google::Gax.create_api_call(
262
- @contexts_stub.method(:update_context),
263
- defaults["update_context"],
264
- exception_transformer: exception_transformer,
265
- params_extractor: proc do |request|
266
- {'context.name' => request.context.name}
267
- end
268
- )
269
- @delete_context = Google::Gax.create_api_call(
270
- @contexts_stub.method(:delete_context),
271
- defaults["delete_context"],
272
- exception_transformer: exception_transformer,
273
- params_extractor: proc do |request|
274
- {'name' => request.name}
275
- end
276
- )
277
- @delete_all_contexts = Google::Gax.create_api_call(
278
- @contexts_stub.method(:delete_all_contexts),
279
- defaults["delete_all_contexts"],
280
- exception_transformer: exception_transformer,
281
- params_extractor: proc do |request|
282
- {'parent' => request.parent}
283
- end
284
- )
285
- end
286
-
287
- # Service calls
288
-
289
- # Returns the list of all contexts in the specified session.
290
- #
291
- # @param parent [String]
292
- # Required. The session to list all contexts from.
293
- # Format: `projects/<Project ID>/agent/sessions/<Session ID>`.
294
- # @param page_size [Integer]
295
- # The maximum number of resources contained in the underlying API
296
- # response. If page streaming is performed per-resource, this
297
- # parameter does not affect the return value. If page streaming is
298
- # performed per-page, this determines the maximum number of
299
- # resources in a page.
300
- # @param options [Google::Gax::CallOptions]
301
- # Overrides the default settings for this call, e.g, timeout,
302
- # retries, etc.
303
- # @yield [result, operation] Access the result along with the RPC operation
304
- # @yieldparam result [Google::Gax::PagedEnumerable<Google::Cloud::Dialogflow::V2::Context>]
305
- # @yieldparam operation [GRPC::ActiveCall::Operation]
306
- # @return [Google::Gax::PagedEnumerable<Google::Cloud::Dialogflow::V2::Context>]
307
- # An enumerable of Google::Cloud::Dialogflow::V2::Context instances.
308
- # See Google::Gax::PagedEnumerable documentation for other
309
- # operations such as per-page iteration or access to the response
310
- # object.
311
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
312
- # @example
313
- # require "google/cloud/dialogflow"
314
- #
315
- # contexts_client = Google::Cloud::Dialogflow::Contexts.new(version: :v2)
316
- # formatted_parent = Google::Cloud::Dialogflow::V2::ContextsClient.session_path("[PROJECT]", "[SESSION]")
317
- #
318
- # # Iterate over all results.
319
- # contexts_client.list_contexts(formatted_parent).each do |element|
320
- # # Process element.
321
- # end
322
- #
323
- # # Or iterate over results one page at a time.
324
- # contexts_client.list_contexts(formatted_parent).each_page do |page|
325
- # # Process each page at a time.
326
- # page.each do |element|
327
- # # Process element.
328
- # end
329
- # end
330
-
331
- def list_contexts \
332
- parent,
333
- page_size: nil,
334
- options: nil,
335
- &block
336
- req = {
337
- parent: parent,
338
- page_size: page_size
339
- }.delete_if { |_, v| v.nil? }
340
- req = Google::Gax::to_proto(req, Google::Cloud::Dialogflow::V2::ListContextsRequest)
341
- @list_contexts.call(req, options, &block)
342
- end
343
-
344
- # Retrieves the specified context.
345
- #
346
- # @param name [String]
347
- # Required. The name of the context. Format:
348
- # `projects/<Project ID>/agent/sessions/<Session ID>/contexts/<Context ID>`.
349
- # @param options [Google::Gax::CallOptions]
350
- # Overrides the default settings for this call, e.g, timeout,
351
- # retries, etc.
352
- # @yield [result, operation] Access the result along with the RPC operation
353
- # @yieldparam result [Google::Cloud::Dialogflow::V2::Context]
354
- # @yieldparam operation [GRPC::ActiveCall::Operation]
355
- # @return [Google::Cloud::Dialogflow::V2::Context]
356
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
357
- # @example
358
- # require "google/cloud/dialogflow"
359
- #
360
- # contexts_client = Google::Cloud::Dialogflow::Contexts.new(version: :v2)
361
- # formatted_name = Google::Cloud::Dialogflow::V2::ContextsClient.context_path("[PROJECT]", "[SESSION]", "[CONTEXT]")
362
- # response = contexts_client.get_context(formatted_name)
363
-
364
- def get_context \
365
- name,
366
- options: nil,
367
- &block
368
- req = {
369
- name: name
370
- }.delete_if { |_, v| v.nil? }
371
- req = Google::Gax::to_proto(req, Google::Cloud::Dialogflow::V2::GetContextRequest)
372
- @get_context.call(req, options, &block)
373
- end
374
-
375
- # Creates a context.
376
- #
377
- # If the specified context already exists, overrides the context.
378
- #
379
- # @param parent [String]
380
- # Required. The session to create a context for.
381
- # Format: `projects/<Project ID>/agent/sessions/<Session ID>`.
382
- # @param context [Google::Cloud::Dialogflow::V2::Context | Hash]
383
- # Required. The context to create.
384
- # A hash of the same form as `Google::Cloud::Dialogflow::V2::Context`
385
- # can also be provided.
386
- # @param options [Google::Gax::CallOptions]
387
- # Overrides the default settings for this call, e.g, timeout,
388
- # retries, etc.
389
- # @yield [result, operation] Access the result along with the RPC operation
390
- # @yieldparam result [Google::Cloud::Dialogflow::V2::Context]
391
- # @yieldparam operation [GRPC::ActiveCall::Operation]
392
- # @return [Google::Cloud::Dialogflow::V2::Context]
393
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
394
- # @example
395
- # require "google/cloud/dialogflow"
396
- #
397
- # contexts_client = Google::Cloud::Dialogflow::Contexts.new(version: :v2)
398
- # formatted_parent = Google::Cloud::Dialogflow::V2::ContextsClient.session_path("[PROJECT]", "[SESSION]")
399
- #
400
- # # TODO: Initialize `context`:
401
- # context = {}
402
- # response = contexts_client.create_context(formatted_parent, context)
403
-
404
- def create_context \
405
- parent,
406
- context,
407
- options: nil,
408
- &block
409
- req = {
410
- parent: parent,
411
- context: context
412
- }.delete_if { |_, v| v.nil? }
413
- req = Google::Gax::to_proto(req, Google::Cloud::Dialogflow::V2::CreateContextRequest)
414
- @create_context.call(req, options, &block)
415
- end
416
-
417
- # Updates the specified context.
418
- #
419
- # @param context [Google::Cloud::Dialogflow::V2::Context | Hash]
420
- # Required. The context to update.
421
- # A hash of the same form as `Google::Cloud::Dialogflow::V2::Context`
422
- # can also be provided.
423
- # @param update_mask [Google::Protobuf::FieldMask | Hash]
424
- # Optional. The mask to control which fields get updated.
425
- # A hash of the same form as `Google::Protobuf::FieldMask`
426
- # can also be provided.
427
- # @param options [Google::Gax::CallOptions]
428
- # Overrides the default settings for this call, e.g, timeout,
429
- # retries, etc.
430
- # @yield [result, operation] Access the result along with the RPC operation
431
- # @yieldparam result [Google::Cloud::Dialogflow::V2::Context]
432
- # @yieldparam operation [GRPC::ActiveCall::Operation]
433
- # @return [Google::Cloud::Dialogflow::V2::Context]
434
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
435
- # @example
436
- # require "google/cloud/dialogflow"
437
- #
438
- # contexts_client = Google::Cloud::Dialogflow::Contexts.new(version: :v2)
439
- #
440
- # # TODO: Initialize `context`:
441
- # context = {}
442
- # response = contexts_client.update_context(context)
443
-
444
- def update_context \
445
- context,
446
- update_mask: nil,
447
- options: nil,
448
- &block
449
- req = {
450
- context: context,
451
- update_mask: update_mask
452
- }.delete_if { |_, v| v.nil? }
453
- req = Google::Gax::to_proto(req, Google::Cloud::Dialogflow::V2::UpdateContextRequest)
454
- @update_context.call(req, options, &block)
455
- end
456
-
457
- # Deletes the specified context.
458
- #
459
- # @param name [String]
460
- # Required. The name of the context to delete. Format:
461
- # `projects/<Project ID>/agent/sessions/<Session ID>/contexts/<Context ID>`.
462
- # @param options [Google::Gax::CallOptions]
463
- # Overrides the default settings for this call, e.g, timeout,
464
- # retries, etc.
465
- # @yield [result, operation] Access the result along with the RPC operation
466
- # @yieldparam result []
467
- # @yieldparam operation [GRPC::ActiveCall::Operation]
468
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
469
- # @example
470
- # require "google/cloud/dialogflow"
471
- #
472
- # contexts_client = Google::Cloud::Dialogflow::Contexts.new(version: :v2)
473
- # formatted_name = Google::Cloud::Dialogflow::V2::ContextsClient.context_path("[PROJECT]", "[SESSION]", "[CONTEXT]")
474
- # contexts_client.delete_context(formatted_name)
475
-
476
- def delete_context \
477
- name,
478
- options: nil,
479
- &block
480
- req = {
481
- name: name
482
- }.delete_if { |_, v| v.nil? }
483
- req = Google::Gax::to_proto(req, Google::Cloud::Dialogflow::V2::DeleteContextRequest)
484
- @delete_context.call(req, options, &block)
485
- nil
486
- end
487
-
488
- # Deletes all active contexts in the specified session.
489
- #
490
- # @param parent [String]
491
- # Required. The name of the session to delete all contexts from. Format:
492
- # `projects/<Project ID>/agent/sessions/<Session ID>`.
493
- # @param options [Google::Gax::CallOptions]
494
- # Overrides the default settings for this call, e.g, timeout,
495
- # retries, etc.
496
- # @yield [result, operation] Access the result along with the RPC operation
497
- # @yieldparam result []
498
- # @yieldparam operation [GRPC::ActiveCall::Operation]
499
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
500
- # @example
501
- # require "google/cloud/dialogflow"
502
- #
503
- # contexts_client = Google::Cloud::Dialogflow::Contexts.new(version: :v2)
504
- # formatted_parent = Google::Cloud::Dialogflow::V2::ContextsClient.session_path("[PROJECT]", "[SESSION]")
505
- # contexts_client.delete_all_contexts(formatted_parent)
506
-
507
- def delete_all_contexts \
508
- parent,
509
- options: nil,
510
- &block
511
- req = {
512
- parent: parent
513
- }.delete_if { |_, v| v.nil? }
514
- req = Google::Gax::to_proto(req, Google::Cloud::Dialogflow::V2::DeleteAllContextsRequest)
515
- @delete_all_contexts.call(req, options, &block)
516
- nil
517
- end
518
- end
519
- end
520
- end
521
- end
522
- end