google-cloud-dialogflow-v2 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.yardopts +12 -0
- data/AUTHENTICATION.md +169 -0
- data/LICENSE.md +201 -0
- data/README.md +24 -0
- data/lib/google-cloud-dialogflow-v2.rb +1 -0
- data/lib/google/cloud/common_resources_pb.rb +15 -0
- data/lib/google/cloud/dialogflow/v2.rb +24 -0
- data/lib/google/cloud/dialogflow/v2/agent_pb.rb +122 -0
- data/lib/google/cloud/dialogflow/v2/agent_services_pb.rb +110 -0
- data/lib/google/cloud/dialogflow/v2/agents.rb +21 -0
- data/lib/google/cloud/dialogflow/v2/agents/client.rb +1047 -0
- data/lib/google/cloud/dialogflow/v2/agents/credentials.rb +53 -0
- data/lib/google/cloud/dialogflow/v2/agents/operations.rb +559 -0
- data/lib/google/cloud/dialogflow/v2/agents/paths.rb +59 -0
- data/lib/google/cloud/dialogflow/v2/audio_config_pb.rb +97 -0
- data/lib/google/cloud/dialogflow/v2/context_pb.rb +64 -0
- data/lib/google/cloud/dialogflow/v2/context_services_pb.rb +74 -0
- data/lib/google/cloud/dialogflow/v2/contexts.rb +20 -0
- data/lib/google/cloud/dialogflow/v2/contexts/client.rb +756 -0
- data/lib/google/cloud/dialogflow/v2/contexts/credentials.rb +53 -0
- data/lib/google/cloud/dialogflow/v2/contexts/paths.rb +50 -0
- data/lib/google/cloud/dialogflow/v2/entity_type_pb.rb +126 -0
- data/lib/google/cloud/dialogflow/v2/entity_type_services_pb.rb +104 -0
- data/lib/google/cloud/dialogflow/v2/entity_types.rb +21 -0
- data/lib/google/cloud/dialogflow/v2/entity_types/client.rb +1150 -0
- data/lib/google/cloud/dialogflow/v2/entity_types/credentials.rb +53 -0
- data/lib/google/cloud/dialogflow/v2/entity_types/operations.rb +559 -0
- data/lib/google/cloud/dialogflow/v2/entity_types/paths.rb +62 -0
- data/lib/google/cloud/dialogflow/v2/intent_pb.rb +368 -0
- data/lib/google/cloud/dialogflow/v2/intent_services_pb.rb +92 -0
- data/lib/google/cloud/dialogflow/v2/intents.rb +21 -0
- data/lib/google/cloud/dialogflow/v2/intents/client.rb +893 -0
- data/lib/google/cloud/dialogflow/v2/intents/credentials.rb +53 -0
- data/lib/google/cloud/dialogflow/v2/intents/operations.rb +559 -0
- data/lib/google/cloud/dialogflow/v2/intents/paths.rb +81 -0
- data/lib/google/cloud/dialogflow/v2/session_entity_type_pb.rb +66 -0
- data/lib/google/cloud/dialogflow/v2/session_entity_type_services_pb.rb +92 -0
- data/lib/google/cloud/dialogflow/v2/session_entity_types.rb +20 -0
- data/lib/google/cloud/dialogflow/v2/session_entity_types/client.rb +727 -0
- data/lib/google/cloud/dialogflow/v2/session_entity_types/credentials.rb +53 -0
- data/lib/google/cloud/dialogflow/v2/session_entity_types/paths.rb +69 -0
- data/lib/google/cloud/dialogflow/v2/session_pb.rb +142 -0
- data/lib/google/cloud/dialogflow/v2/session_services_pb.rb +55 -0
- data/lib/google/cloud/dialogflow/v2/sessions.rb +20 -0
- data/lib/google/cloud/dialogflow/v2/sessions/client.rb +472 -0
- data/lib/google/cloud/dialogflow/v2/sessions/credentials.rb +53 -0
- data/lib/google/cloud/dialogflow/v2/sessions/paths.rb +110 -0
- data/lib/google/cloud/dialogflow/v2/validation_result_pb.rb +37 -0
- data/lib/google/cloud/dialogflow/v2/version.rb +28 -0
- data/lib/google/cloud/dialogflow/v2/webhook_pb.rb +47 -0
- data/proto_docs/README.md +4 -0
- data/proto_docs/google/api/field_behavior.rb +59 -0
- data/proto_docs/google/api/resource.rb +247 -0
- data/proto_docs/google/cloud/dialogflow/v2/agent.rb +287 -0
- data/proto_docs/google/cloud/dialogflow/v2/audio_config.rb +363 -0
- data/proto_docs/google/cloud/dialogflow/v2/context.rb +144 -0
- data/proto_docs/google/cloud/dialogflow/v2/entity_type.rb +354 -0
- data/proto_docs/google/cloud/dialogflow/v2/intent.rb +1070 -0
- data/proto_docs/google/cloud/dialogflow/v2/session.rb +541 -0
- data/proto_docs/google/cloud/dialogflow/v2/session_entity_type.rb +155 -0
- data/proto_docs/google/cloud/dialogflow/v2/validation_result.rb +81 -0
- data/proto_docs/google/cloud/dialogflow/v2/webhook.rb +153 -0
- data/proto_docs/google/longrunning/operations.rb +150 -0
- data/proto_docs/google/protobuf/any.rb +137 -0
- data/proto_docs/google/protobuf/duration.rb +98 -0
- data/proto_docs/google/protobuf/empty.rb +36 -0
- data/proto_docs/google/protobuf/field_mask.rb +237 -0
- data/proto_docs/google/protobuf/struct.rb +96 -0
- data/proto_docs/google/rpc/status.rb +46 -0
- data/proto_docs/google/type/latlng.rb +38 -0
- metadata +225 -0
@@ -0,0 +1,59 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright 2020 Google LLC
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# https://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
|
17
|
+
# Auto-generated by gapic-generator-ruby. DO NOT EDIT!
|
18
|
+
|
19
|
+
|
20
|
+
module Google
|
21
|
+
module Cloud
|
22
|
+
module Dialogflow
|
23
|
+
module V2
|
24
|
+
module Agents
|
25
|
+
# Path helper methods for the Agents API.
|
26
|
+
module Paths
|
27
|
+
##
|
28
|
+
# Create a fully-qualified Agent resource string.
|
29
|
+
#
|
30
|
+
# The resource will be in the following format:
|
31
|
+
#
|
32
|
+
# `projects/{project}/agent`
|
33
|
+
#
|
34
|
+
# @param project [String]
|
35
|
+
#
|
36
|
+
# @return [String]
|
37
|
+
def agent_path project:
|
38
|
+
"projects/#{project}/agent"
|
39
|
+
end
|
40
|
+
|
41
|
+
##
|
42
|
+
# Create a fully-qualified Project resource string.
|
43
|
+
#
|
44
|
+
# The resource will be in the following format:
|
45
|
+
#
|
46
|
+
# `projects/{project}`
|
47
|
+
#
|
48
|
+
# @param project [String]
|
49
|
+
#
|
50
|
+
# @return [String]
|
51
|
+
def project_path project:
|
52
|
+
"projects/#{project}"
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,97 @@
|
|
1
|
+
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
2
|
+
# source: google/cloud/dialogflow/v2/audio_config.proto
|
3
|
+
|
4
|
+
require 'google/protobuf'
|
5
|
+
|
6
|
+
require 'google/api/field_behavior_pb'
|
7
|
+
require 'google/api/resource_pb'
|
8
|
+
require 'google/protobuf/duration_pb'
|
9
|
+
require 'google/api/annotations_pb'
|
10
|
+
Google::Protobuf::DescriptorPool.generated_pool.build do
|
11
|
+
add_file("google/cloud/dialogflow/v2/audio_config.proto", :syntax => :proto3) 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
|
+
end
|
79
|
+
|
80
|
+
module Google
|
81
|
+
module Cloud
|
82
|
+
module Dialogflow
|
83
|
+
module V2
|
84
|
+
SpeechContext = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.SpeechContext").msgclass
|
85
|
+
SpeechWordInfo = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.SpeechWordInfo").msgclass
|
86
|
+
InputAudioConfig = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.InputAudioConfig").msgclass
|
87
|
+
VoiceSelectionParams = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.VoiceSelectionParams").msgclass
|
88
|
+
SynthesizeSpeechConfig = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.SynthesizeSpeechConfig").msgclass
|
89
|
+
OutputAudioConfig = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.OutputAudioConfig").msgclass
|
90
|
+
AudioEncoding = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.AudioEncoding").enummodule
|
91
|
+
SpeechModelVariant = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.SpeechModelVariant").enummodule
|
92
|
+
SsmlVoiceGender = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.SsmlVoiceGender").enummodule
|
93
|
+
OutputAudioEncoding = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.OutputAudioEncoding").enummodule
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
2
|
+
# source: google/cloud/dialogflow/v2/context.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
|
+
require 'google/protobuf/struct_pb'
|
13
|
+
Google::Protobuf::DescriptorPool.generated_pool.build do
|
14
|
+
add_file("google/cloud/dialogflow/v2/context.proto", :syntax => :proto3) 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
|
+
end
|
48
|
+
|
49
|
+
module Google
|
50
|
+
module Cloud
|
51
|
+
module Dialogflow
|
52
|
+
module V2
|
53
|
+
Context = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.Context").msgclass
|
54
|
+
ListContextsRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.ListContextsRequest").msgclass
|
55
|
+
ListContextsResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.ListContextsResponse").msgclass
|
56
|
+
GetContextRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.GetContextRequest").msgclass
|
57
|
+
CreateContextRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.CreateContextRequest").msgclass
|
58
|
+
UpdateContextRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.UpdateContextRequest").msgclass
|
59
|
+
DeleteContextRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.DeleteContextRequest").msgclass
|
60
|
+
DeleteAllContextsRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.v2.DeleteAllContextsRequest").msgclass
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,74 @@
|
|
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
|
+
require 'grpc'
|
20
|
+
require 'google/cloud/dialogflow/v2/context_pb'
|
21
|
+
|
22
|
+
module Google
|
23
|
+
module Cloud
|
24
|
+
module Dialogflow
|
25
|
+
module V2
|
26
|
+
module Contexts
|
27
|
+
# A context represents additional information included with user input or with
|
28
|
+
# an intent returned by the Dialogflow API. Contexts are helpful for
|
29
|
+
# differentiating user input which may be vague or have a different meaning
|
30
|
+
# depending on additional details from your application such as user setting
|
31
|
+
# and preferences, previous user input, where the user is in your application,
|
32
|
+
# geographic location, and so on.
|
33
|
+
#
|
34
|
+
# You can include contexts as input parameters of a
|
35
|
+
# [DetectIntent][google.cloud.dialogflow.v2.Sessions.DetectIntent] (or
|
36
|
+
# [StreamingDetectIntent][google.cloud.dialogflow.v2.Sessions.StreamingDetectIntent]) request,
|
37
|
+
# or as output contexts included in the returned intent.
|
38
|
+
# Contexts expire when an intent is matched, after the number of `DetectIntent`
|
39
|
+
# requests specified by the `lifespan_count` parameter, or after 20 minutes
|
40
|
+
# if no intents are matched for a `DetectIntent` request.
|
41
|
+
#
|
42
|
+
# For more information about contexts, see the
|
43
|
+
# [Dialogflow
|
44
|
+
# documentation](https://cloud.google.com/dialogflow/docs/contexts-overview).
|
45
|
+
class Service
|
46
|
+
|
47
|
+
include GRPC::GenericService
|
48
|
+
|
49
|
+
self.marshal_class_method = :encode
|
50
|
+
self.unmarshal_class_method = :decode
|
51
|
+
self.service_name = 'google.cloud.dialogflow.v2.Contexts'
|
52
|
+
|
53
|
+
# Returns the list of all contexts in the specified session.
|
54
|
+
rpc :ListContexts, ListContextsRequest, ListContextsResponse
|
55
|
+
# Retrieves the specified context.
|
56
|
+
rpc :GetContext, GetContextRequest, Context
|
57
|
+
# Creates a context.
|
58
|
+
#
|
59
|
+
# If the specified context already exists, overrides the context.
|
60
|
+
rpc :CreateContext, CreateContextRequest, Context
|
61
|
+
# Updates the specified context.
|
62
|
+
rpc :UpdateContext, UpdateContextRequest, Context
|
63
|
+
# Deletes the specified context.
|
64
|
+
rpc :DeleteContext, DeleteContextRequest, Google::Protobuf::Empty
|
65
|
+
# Deletes all active contexts in the specified session.
|
66
|
+
rpc :DeleteAllContexts, DeleteAllContextsRequest, Google::Protobuf::Empty
|
67
|
+
end
|
68
|
+
|
69
|
+
Stub = Service.rpc_stub_class
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright 2020 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 "google/cloud/dialogflow/v2/contexts/client"
|
20
|
+
require "google/cloud/dialogflow/v2/contexts/credentials"
|
@@ -0,0 +1,756 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright 2020 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/errors"
|
24
|
+
require "google/cloud/dialogflow/v2/version"
|
25
|
+
require "google/cloud/dialogflow/v2/context_pb"
|
26
|
+
require "google/cloud/dialogflow/v2/contexts/credentials"
|
27
|
+
require "google/cloud/dialogflow/v2/contexts/paths"
|
28
|
+
|
29
|
+
|
30
|
+
module Google
|
31
|
+
module Cloud
|
32
|
+
module Dialogflow
|
33
|
+
module V2
|
34
|
+
module Contexts
|
35
|
+
# Service that implements Contexts API.
|
36
|
+
class Client
|
37
|
+
include Paths
|
38
|
+
|
39
|
+
# @private
|
40
|
+
attr_reader :contexts_stub
|
41
|
+
|
42
|
+
##
|
43
|
+
# Configure the Contexts Client class.
|
44
|
+
#
|
45
|
+
# See {Google::Cloud::Dialogflow::V2::Contexts::Client::Configuration}
|
46
|
+
# for a description of the configuration fields.
|
47
|
+
#
|
48
|
+
# ## Example
|
49
|
+
#
|
50
|
+
# To modify the configuration for all Contexts clients:
|
51
|
+
#
|
52
|
+
# Google::Cloud::Dialogflow::V2::Contexts::Client.configure do |config|
|
53
|
+
# config.timeout = 10_000
|
54
|
+
# end
|
55
|
+
#
|
56
|
+
# @yield [config] Configure the Client client.
|
57
|
+
# @yieldparam config [Client::Configuration]
|
58
|
+
#
|
59
|
+
# @return [Client::Configuration]
|
60
|
+
#
|
61
|
+
def self.configure
|
62
|
+
@configure ||= begin
|
63
|
+
namespace = ["Google", "Cloud", "Dialogflow", "V2"]
|
64
|
+
parent_config = while namespace.any?
|
65
|
+
parent_name = namespace.join "::"
|
66
|
+
parent_const = const_get parent_name
|
67
|
+
break parent_const.configure if parent_const&.respond_to? :configure
|
68
|
+
namespace.pop
|
69
|
+
end
|
70
|
+
default_config = Client::Configuration.new parent_config
|
71
|
+
|
72
|
+
default_config.rpcs.list_contexts.timeout = 60.0
|
73
|
+
default_config.rpcs.list_contexts.retry_policy = {
|
74
|
+
initial_delay: 0.1,
|
75
|
+
max_delay: 60.0,
|
76
|
+
multiplier: 1.3,
|
77
|
+
retry_codes: ["UNAVAILABLE", "DEADLINE_EXCEEDED"]
|
78
|
+
}
|
79
|
+
|
80
|
+
default_config.rpcs.get_context.timeout = 60.0
|
81
|
+
default_config.rpcs.get_context.retry_policy = {
|
82
|
+
initial_delay: 0.1,
|
83
|
+
max_delay: 60.0,
|
84
|
+
multiplier: 1.3,
|
85
|
+
retry_codes: ["UNAVAILABLE", "DEADLINE_EXCEEDED"]
|
86
|
+
}
|
87
|
+
|
88
|
+
default_config.rpcs.create_context.timeout = 60.0
|
89
|
+
|
90
|
+
default_config.rpcs.update_context.timeout = 60.0
|
91
|
+
|
92
|
+
default_config.rpcs.delete_context.timeout = 60.0
|
93
|
+
default_config.rpcs.delete_context.retry_policy = {
|
94
|
+
initial_delay: 0.1,
|
95
|
+
max_delay: 60.0,
|
96
|
+
multiplier: 1.3,
|
97
|
+
retry_codes: ["UNAVAILABLE", "DEADLINE_EXCEEDED"]
|
98
|
+
}
|
99
|
+
|
100
|
+
default_config.rpcs.delete_all_contexts.timeout = 60.0
|
101
|
+
default_config.rpcs.delete_all_contexts.retry_policy = {
|
102
|
+
initial_delay: 0.1,
|
103
|
+
max_delay: 60.0,
|
104
|
+
multiplier: 1.3,
|
105
|
+
retry_codes: ["UNAVAILABLE", "DEADLINE_EXCEEDED"]
|
106
|
+
}
|
107
|
+
|
108
|
+
default_config
|
109
|
+
end
|
110
|
+
yield @configure if block_given?
|
111
|
+
@configure
|
112
|
+
end
|
113
|
+
|
114
|
+
##
|
115
|
+
# Configure the Contexts Client instance.
|
116
|
+
#
|
117
|
+
# The configuration is set to the derived mode, meaning that values can be changed,
|
118
|
+
# but structural changes (adding new fields, etc.) are not allowed. Structural changes
|
119
|
+
# should be made on {Client.configure}.
|
120
|
+
#
|
121
|
+
# See {Google::Cloud::Dialogflow::V2::Contexts::Client::Configuration}
|
122
|
+
# for a description of the configuration fields.
|
123
|
+
#
|
124
|
+
# @yield [config] Configure the Client client.
|
125
|
+
# @yieldparam config [Client::Configuration]
|
126
|
+
#
|
127
|
+
# @return [Client::Configuration]
|
128
|
+
#
|
129
|
+
def configure
|
130
|
+
yield @config if block_given?
|
131
|
+
@config
|
132
|
+
end
|
133
|
+
|
134
|
+
##
|
135
|
+
# Create a new Contexts client object.
|
136
|
+
#
|
137
|
+
# ## Examples
|
138
|
+
#
|
139
|
+
# To create a new Contexts client with the default
|
140
|
+
# configuration:
|
141
|
+
#
|
142
|
+
# client = Google::Cloud::Dialogflow::V2::Contexts::Client.new
|
143
|
+
#
|
144
|
+
# To create a new Contexts client with a custom
|
145
|
+
# configuration:
|
146
|
+
#
|
147
|
+
# client = Google::Cloud::Dialogflow::V2::Contexts::Client.new do |config|
|
148
|
+
# config.timeout = 10_000
|
149
|
+
# end
|
150
|
+
#
|
151
|
+
# @yield [config] Configure the Contexts client.
|
152
|
+
# @yieldparam config [Client::Configuration]
|
153
|
+
#
|
154
|
+
def initialize
|
155
|
+
# These require statements are intentionally placed here to initialize
|
156
|
+
# the gRPC module only when it's required.
|
157
|
+
# See https://github.com/googleapis/toolkit/issues/446
|
158
|
+
require "gapic/grpc"
|
159
|
+
require "google/cloud/dialogflow/v2/context_services_pb"
|
160
|
+
|
161
|
+
# Create the configuration object
|
162
|
+
@config = Configuration.new Client.configure
|
163
|
+
|
164
|
+
# Yield the configuration if needed
|
165
|
+
yield @config if block_given?
|
166
|
+
|
167
|
+
# Create credentials
|
168
|
+
credentials = @config.credentials
|
169
|
+
credentials ||= Credentials.default scope: @config.scope
|
170
|
+
if credentials.is_a?(String) || credentials.is_a?(Hash)
|
171
|
+
credentials = Credentials.new credentials, scope: @config.scope
|
172
|
+
end
|
173
|
+
@quota_project_id = credentials.respond_to?(:quota_project_id) ? credentials.quota_project_id : nil
|
174
|
+
|
175
|
+
@contexts_stub = Gapic::ServiceStub.new(
|
176
|
+
Google::Cloud::Dialogflow::V2::Contexts::Stub,
|
177
|
+
credentials: credentials,
|
178
|
+
endpoint: @config.endpoint,
|
179
|
+
channel_args: @config.channel_args,
|
180
|
+
interceptors: @config.interceptors
|
181
|
+
)
|
182
|
+
end
|
183
|
+
|
184
|
+
# Service calls
|
185
|
+
|
186
|
+
##
|
187
|
+
# Returns the list of all contexts in the specified session.
|
188
|
+
#
|
189
|
+
# @overload list_contexts(request, options = nil)
|
190
|
+
# @param request [Google::Cloud::Dialogflow::V2::ListContextsRequest | Hash]
|
191
|
+
# Returns the list of all contexts in the specified session.
|
192
|
+
# @param options [Gapic::CallOptions, Hash]
|
193
|
+
# Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
|
194
|
+
#
|
195
|
+
# @overload list_contexts(parent: nil, page_size: nil, page_token: nil)
|
196
|
+
# @param parent [String]
|
197
|
+
# Required. The session to list all contexts from.
|
198
|
+
# Format: `projects/<Project ID>/agent/sessions/<Session ID>`.
|
199
|
+
# @param page_size [Integer]
|
200
|
+
# Optional. The maximum number of items to return in a single page. By
|
201
|
+
# default 100 and at most 1000.
|
202
|
+
# @param page_token [String]
|
203
|
+
# Optional. The next_page_token value returned from a previous list request.
|
204
|
+
#
|
205
|
+
#
|
206
|
+
# @yield [response, operation] Access the result along with the RPC operation
|
207
|
+
# @yieldparam response [Gapic::PagedEnumerable<Google::Cloud::Dialogflow::V2::Context>]
|
208
|
+
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
209
|
+
#
|
210
|
+
# @return [Gapic::PagedEnumerable<Google::Cloud::Dialogflow::V2::Context>]
|
211
|
+
#
|
212
|
+
# @raise [Google::Cloud::Error] if the RPC is aborted.
|
213
|
+
#
|
214
|
+
def list_contexts request, options = nil
|
215
|
+
raise ArgumentError, "request must be provided" if request.nil?
|
216
|
+
|
217
|
+
request = Gapic::Protobuf.coerce request, to: Google::Cloud::Dialogflow::V2::ListContextsRequest
|
218
|
+
|
219
|
+
# Converts hash and nil to an options object
|
220
|
+
options = Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
|
221
|
+
|
222
|
+
# Customize the options with defaults
|
223
|
+
metadata = @config.rpcs.list_contexts.metadata.to_h
|
224
|
+
|
225
|
+
# Set x-goog-api-client and x-goog-user-project headers
|
226
|
+
metadata[:"x-goog-api-client"] ||= Gapic::Headers.x_goog_api_client \
|
227
|
+
lib_name: @config.lib_name, lib_version: @config.lib_version,
|
228
|
+
gapic_version: ::Google::Cloud::Dialogflow::V2::VERSION
|
229
|
+
metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
|
230
|
+
|
231
|
+
header_params = {
|
232
|
+
"parent" => request.parent
|
233
|
+
}
|
234
|
+
request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
|
235
|
+
metadata[:"x-goog-request-params"] ||= request_params_header
|
236
|
+
|
237
|
+
options.apply_defaults timeout: @config.rpcs.list_contexts.timeout,
|
238
|
+
metadata: metadata,
|
239
|
+
retry_policy: @config.rpcs.list_contexts.retry_policy
|
240
|
+
options.apply_defaults metadata: @config.metadata,
|
241
|
+
retry_policy: @config.retry_policy
|
242
|
+
|
243
|
+
@contexts_stub.call_rpc :list_contexts, request, options: options do |response, operation|
|
244
|
+
response = Gapic::PagedEnumerable.new @contexts_stub, :list_contexts, request, response, operation, options
|
245
|
+
yield response, operation if block_given?
|
246
|
+
return response
|
247
|
+
end
|
248
|
+
rescue GRPC::BadStatus => e
|
249
|
+
raise Google::Cloud::Error.from_error(e)
|
250
|
+
end
|
251
|
+
|
252
|
+
##
|
253
|
+
# Retrieves the specified context.
|
254
|
+
#
|
255
|
+
# @overload get_context(request, options = nil)
|
256
|
+
# @param request [Google::Cloud::Dialogflow::V2::GetContextRequest | Hash]
|
257
|
+
# Retrieves the specified context.
|
258
|
+
# @param options [Gapic::CallOptions, Hash]
|
259
|
+
# Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
|
260
|
+
#
|
261
|
+
# @overload get_context(name: nil)
|
262
|
+
# @param name [String]
|
263
|
+
# Required. The name of the context. Format:
|
264
|
+
# `projects/<Project ID>/agent/sessions/<Session ID>/contexts/<Context ID>`.
|
265
|
+
#
|
266
|
+
#
|
267
|
+
# @yield [response, operation] Access the result along with the RPC operation
|
268
|
+
# @yieldparam response [Google::Cloud::Dialogflow::V2::Context]
|
269
|
+
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
270
|
+
#
|
271
|
+
# @return [Google::Cloud::Dialogflow::V2::Context]
|
272
|
+
#
|
273
|
+
# @raise [Google::Cloud::Error] if the RPC is aborted.
|
274
|
+
#
|
275
|
+
def get_context request, options = nil
|
276
|
+
raise ArgumentError, "request must be provided" if request.nil?
|
277
|
+
|
278
|
+
request = Gapic::Protobuf.coerce request, to: Google::Cloud::Dialogflow::V2::GetContextRequest
|
279
|
+
|
280
|
+
# Converts hash and nil to an options object
|
281
|
+
options = Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
|
282
|
+
|
283
|
+
# Customize the options with defaults
|
284
|
+
metadata = @config.rpcs.get_context.metadata.to_h
|
285
|
+
|
286
|
+
# Set x-goog-api-client and x-goog-user-project headers
|
287
|
+
metadata[:"x-goog-api-client"] ||= Gapic::Headers.x_goog_api_client \
|
288
|
+
lib_name: @config.lib_name, lib_version: @config.lib_version,
|
289
|
+
gapic_version: ::Google::Cloud::Dialogflow::V2::VERSION
|
290
|
+
metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
|
291
|
+
|
292
|
+
header_params = {
|
293
|
+
"name" => request.name
|
294
|
+
}
|
295
|
+
request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
|
296
|
+
metadata[:"x-goog-request-params"] ||= request_params_header
|
297
|
+
|
298
|
+
options.apply_defaults timeout: @config.rpcs.get_context.timeout,
|
299
|
+
metadata: metadata,
|
300
|
+
retry_policy: @config.rpcs.get_context.retry_policy
|
301
|
+
options.apply_defaults metadata: @config.metadata,
|
302
|
+
retry_policy: @config.retry_policy
|
303
|
+
|
304
|
+
@contexts_stub.call_rpc :get_context, request, options: options do |response, operation|
|
305
|
+
yield response, operation if block_given?
|
306
|
+
return response
|
307
|
+
end
|
308
|
+
rescue GRPC::BadStatus => e
|
309
|
+
raise Google::Cloud::Error.from_error(e)
|
310
|
+
end
|
311
|
+
|
312
|
+
##
|
313
|
+
# Creates a context.
|
314
|
+
#
|
315
|
+
# If the specified context already exists, overrides the context.
|
316
|
+
#
|
317
|
+
# @overload create_context(request, options = nil)
|
318
|
+
# @param request [Google::Cloud::Dialogflow::V2::CreateContextRequest | Hash]
|
319
|
+
# Creates a context.
|
320
|
+
#
|
321
|
+
# If the specified context already exists, overrides the context.
|
322
|
+
# @param options [Gapic::CallOptions, Hash]
|
323
|
+
# Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
|
324
|
+
#
|
325
|
+
# @overload create_context(parent: nil, context: nil)
|
326
|
+
# @param parent [String]
|
327
|
+
# Required. The session to create a context for.
|
328
|
+
# Format: `projects/<Project ID>/agent/sessions/<Session ID>`.
|
329
|
+
# @param context [Google::Cloud::Dialogflow::V2::Context | Hash]
|
330
|
+
# Required. The context to create.
|
331
|
+
#
|
332
|
+
#
|
333
|
+
# @yield [response, operation] Access the result along with the RPC operation
|
334
|
+
# @yieldparam response [Google::Cloud::Dialogflow::V2::Context]
|
335
|
+
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
336
|
+
#
|
337
|
+
# @return [Google::Cloud::Dialogflow::V2::Context]
|
338
|
+
#
|
339
|
+
# @raise [Google::Cloud::Error] if the RPC is aborted.
|
340
|
+
#
|
341
|
+
def create_context request, options = nil
|
342
|
+
raise ArgumentError, "request must be provided" if request.nil?
|
343
|
+
|
344
|
+
request = Gapic::Protobuf.coerce request, to: Google::Cloud::Dialogflow::V2::CreateContextRequest
|
345
|
+
|
346
|
+
# Converts hash and nil to an options object
|
347
|
+
options = Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
|
348
|
+
|
349
|
+
# Customize the options with defaults
|
350
|
+
metadata = @config.rpcs.create_context.metadata.to_h
|
351
|
+
|
352
|
+
# Set x-goog-api-client and x-goog-user-project headers
|
353
|
+
metadata[:"x-goog-api-client"] ||= Gapic::Headers.x_goog_api_client \
|
354
|
+
lib_name: @config.lib_name, lib_version: @config.lib_version,
|
355
|
+
gapic_version: ::Google::Cloud::Dialogflow::V2::VERSION
|
356
|
+
metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
|
357
|
+
|
358
|
+
header_params = {
|
359
|
+
"parent" => request.parent
|
360
|
+
}
|
361
|
+
request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
|
362
|
+
metadata[:"x-goog-request-params"] ||= request_params_header
|
363
|
+
|
364
|
+
options.apply_defaults timeout: @config.rpcs.create_context.timeout,
|
365
|
+
metadata: metadata,
|
366
|
+
retry_policy: @config.rpcs.create_context.retry_policy
|
367
|
+
options.apply_defaults metadata: @config.metadata,
|
368
|
+
retry_policy: @config.retry_policy
|
369
|
+
|
370
|
+
@contexts_stub.call_rpc :create_context, request, options: options do |response, operation|
|
371
|
+
yield response, operation if block_given?
|
372
|
+
return response
|
373
|
+
end
|
374
|
+
rescue GRPC::BadStatus => e
|
375
|
+
raise Google::Cloud::Error.from_error(e)
|
376
|
+
end
|
377
|
+
|
378
|
+
##
|
379
|
+
# Updates the specified context.
|
380
|
+
#
|
381
|
+
# @overload update_context(request, options = nil)
|
382
|
+
# @param request [Google::Cloud::Dialogflow::V2::UpdateContextRequest | Hash]
|
383
|
+
# Updates the specified context.
|
384
|
+
# @param options [Gapic::CallOptions, Hash]
|
385
|
+
# Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
|
386
|
+
#
|
387
|
+
# @overload update_context(context: nil, update_mask: nil)
|
388
|
+
# @param context [Google::Cloud::Dialogflow::V2::Context | Hash]
|
389
|
+
# Required. The context to update.
|
390
|
+
# @param update_mask [Google::Protobuf::FieldMask | Hash]
|
391
|
+
# Optional. The mask to control which fields get updated.
|
392
|
+
#
|
393
|
+
#
|
394
|
+
# @yield [response, operation] Access the result along with the RPC operation
|
395
|
+
# @yieldparam response [Google::Cloud::Dialogflow::V2::Context]
|
396
|
+
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
397
|
+
#
|
398
|
+
# @return [Google::Cloud::Dialogflow::V2::Context]
|
399
|
+
#
|
400
|
+
# @raise [Google::Cloud::Error] if the RPC is aborted.
|
401
|
+
#
|
402
|
+
def update_context request, options = nil
|
403
|
+
raise ArgumentError, "request must be provided" if request.nil?
|
404
|
+
|
405
|
+
request = Gapic::Protobuf.coerce request, to: Google::Cloud::Dialogflow::V2::UpdateContextRequest
|
406
|
+
|
407
|
+
# Converts hash and nil to an options object
|
408
|
+
options = Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
|
409
|
+
|
410
|
+
# Customize the options with defaults
|
411
|
+
metadata = @config.rpcs.update_context.metadata.to_h
|
412
|
+
|
413
|
+
# Set x-goog-api-client and x-goog-user-project headers
|
414
|
+
metadata[:"x-goog-api-client"] ||= Gapic::Headers.x_goog_api_client \
|
415
|
+
lib_name: @config.lib_name, lib_version: @config.lib_version,
|
416
|
+
gapic_version: ::Google::Cloud::Dialogflow::V2::VERSION
|
417
|
+
metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
|
418
|
+
|
419
|
+
header_params = {
|
420
|
+
"context.name" => request.context.name
|
421
|
+
}
|
422
|
+
request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
|
423
|
+
metadata[:"x-goog-request-params"] ||= request_params_header
|
424
|
+
|
425
|
+
options.apply_defaults timeout: @config.rpcs.update_context.timeout,
|
426
|
+
metadata: metadata,
|
427
|
+
retry_policy: @config.rpcs.update_context.retry_policy
|
428
|
+
options.apply_defaults metadata: @config.metadata,
|
429
|
+
retry_policy: @config.retry_policy
|
430
|
+
|
431
|
+
@contexts_stub.call_rpc :update_context, request, options: options do |response, operation|
|
432
|
+
yield response, operation if block_given?
|
433
|
+
return response
|
434
|
+
end
|
435
|
+
rescue GRPC::BadStatus => e
|
436
|
+
raise Google::Cloud::Error.from_error(e)
|
437
|
+
end
|
438
|
+
|
439
|
+
##
|
440
|
+
# Deletes the specified context.
|
441
|
+
#
|
442
|
+
# @overload delete_context(request, options = nil)
|
443
|
+
# @param request [Google::Cloud::Dialogflow::V2::DeleteContextRequest | Hash]
|
444
|
+
# Deletes the specified context.
|
445
|
+
# @param options [Gapic::CallOptions, Hash]
|
446
|
+
# Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
|
447
|
+
#
|
448
|
+
# @overload delete_context(name: nil)
|
449
|
+
# @param name [String]
|
450
|
+
# Required. The name of the context to delete. Format:
|
451
|
+
# `projects/<Project ID>/agent/sessions/<Session ID>/contexts/<Context ID>`.
|
452
|
+
#
|
453
|
+
#
|
454
|
+
# @yield [response, operation] Access the result along with the RPC operation
|
455
|
+
# @yieldparam response [Google::Protobuf::Empty]
|
456
|
+
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
457
|
+
#
|
458
|
+
# @return [Google::Protobuf::Empty]
|
459
|
+
#
|
460
|
+
# @raise [Google::Cloud::Error] if the RPC is aborted.
|
461
|
+
#
|
462
|
+
def delete_context request, options = nil
|
463
|
+
raise ArgumentError, "request must be provided" if request.nil?
|
464
|
+
|
465
|
+
request = Gapic::Protobuf.coerce request, to: Google::Cloud::Dialogflow::V2::DeleteContextRequest
|
466
|
+
|
467
|
+
# Converts hash and nil to an options object
|
468
|
+
options = Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
|
469
|
+
|
470
|
+
# Customize the options with defaults
|
471
|
+
metadata = @config.rpcs.delete_context.metadata.to_h
|
472
|
+
|
473
|
+
# Set x-goog-api-client and x-goog-user-project headers
|
474
|
+
metadata[:"x-goog-api-client"] ||= Gapic::Headers.x_goog_api_client \
|
475
|
+
lib_name: @config.lib_name, lib_version: @config.lib_version,
|
476
|
+
gapic_version: ::Google::Cloud::Dialogflow::V2::VERSION
|
477
|
+
metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
|
478
|
+
|
479
|
+
header_params = {
|
480
|
+
"name" => request.name
|
481
|
+
}
|
482
|
+
request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
|
483
|
+
metadata[:"x-goog-request-params"] ||= request_params_header
|
484
|
+
|
485
|
+
options.apply_defaults timeout: @config.rpcs.delete_context.timeout,
|
486
|
+
metadata: metadata,
|
487
|
+
retry_policy: @config.rpcs.delete_context.retry_policy
|
488
|
+
options.apply_defaults metadata: @config.metadata,
|
489
|
+
retry_policy: @config.retry_policy
|
490
|
+
|
491
|
+
@contexts_stub.call_rpc :delete_context, request, options: options do |response, operation|
|
492
|
+
yield response, operation if block_given?
|
493
|
+
return response
|
494
|
+
end
|
495
|
+
rescue GRPC::BadStatus => e
|
496
|
+
raise Google::Cloud::Error.from_error(e)
|
497
|
+
end
|
498
|
+
|
499
|
+
##
|
500
|
+
# Deletes all active contexts in the specified session.
|
501
|
+
#
|
502
|
+
# @overload delete_all_contexts(request, options = nil)
|
503
|
+
# @param request [Google::Cloud::Dialogflow::V2::DeleteAllContextsRequest | Hash]
|
504
|
+
# Deletes all active contexts in the specified session.
|
505
|
+
# @param options [Gapic::CallOptions, Hash]
|
506
|
+
# Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
|
507
|
+
#
|
508
|
+
# @overload delete_all_contexts(parent: nil)
|
509
|
+
# @param parent [String]
|
510
|
+
# Required. The name of the session to delete all contexts from. Format:
|
511
|
+
# `projects/<Project ID>/agent/sessions/<Session ID>`.
|
512
|
+
#
|
513
|
+
#
|
514
|
+
# @yield [response, operation] Access the result along with the RPC operation
|
515
|
+
# @yieldparam response [Google::Protobuf::Empty]
|
516
|
+
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
517
|
+
#
|
518
|
+
# @return [Google::Protobuf::Empty]
|
519
|
+
#
|
520
|
+
# @raise [Google::Cloud::Error] if the RPC is aborted.
|
521
|
+
#
|
522
|
+
def delete_all_contexts request, options = nil
|
523
|
+
raise ArgumentError, "request must be provided" if request.nil?
|
524
|
+
|
525
|
+
request = Gapic::Protobuf.coerce request, to: Google::Cloud::Dialogflow::V2::DeleteAllContextsRequest
|
526
|
+
|
527
|
+
# Converts hash and nil to an options object
|
528
|
+
options = Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
|
529
|
+
|
530
|
+
# Customize the options with defaults
|
531
|
+
metadata = @config.rpcs.delete_all_contexts.metadata.to_h
|
532
|
+
|
533
|
+
# Set x-goog-api-client and x-goog-user-project headers
|
534
|
+
metadata[:"x-goog-api-client"] ||= Gapic::Headers.x_goog_api_client \
|
535
|
+
lib_name: @config.lib_name, lib_version: @config.lib_version,
|
536
|
+
gapic_version: ::Google::Cloud::Dialogflow::V2::VERSION
|
537
|
+
metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
|
538
|
+
|
539
|
+
header_params = {
|
540
|
+
"parent" => request.parent
|
541
|
+
}
|
542
|
+
request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
|
543
|
+
metadata[:"x-goog-request-params"] ||= request_params_header
|
544
|
+
|
545
|
+
options.apply_defaults timeout: @config.rpcs.delete_all_contexts.timeout,
|
546
|
+
metadata: metadata,
|
547
|
+
retry_policy: @config.rpcs.delete_all_contexts.retry_policy
|
548
|
+
options.apply_defaults metadata: @config.metadata,
|
549
|
+
retry_policy: @config.retry_policy
|
550
|
+
|
551
|
+
@contexts_stub.call_rpc :delete_all_contexts, request, options: options do |response, operation|
|
552
|
+
yield response, operation if block_given?
|
553
|
+
return response
|
554
|
+
end
|
555
|
+
rescue GRPC::BadStatus => e
|
556
|
+
raise Google::Cloud::Error.from_error(e)
|
557
|
+
end
|
558
|
+
|
559
|
+
##
|
560
|
+
# Configuration class for the Contexts API.
|
561
|
+
#
|
562
|
+
# This class represents the configuration for Contexts,
|
563
|
+
# providing control over timeouts, retry behavior, logging, transport
|
564
|
+
# parameters, and other low-level controls. Certain parameters can also be
|
565
|
+
# applied individually to specific RPCs. See
|
566
|
+
# {Google::Cloud::Dialogflow::V2::Contexts::Client::Configuration::Rpcs}
|
567
|
+
# for a list of RPCs that can be configured independently.
|
568
|
+
#
|
569
|
+
# Configuration can be applied globally to all clients, or to a single client
|
570
|
+
# on construction.
|
571
|
+
#
|
572
|
+
# # Examples
|
573
|
+
#
|
574
|
+
# To modify the global config, setting the timeout for list_contexts
|
575
|
+
# to 20 seconds, and all remaining timeouts to 10 seconds:
|
576
|
+
#
|
577
|
+
# Google::Cloud::Dialogflow::V2::Contexts::Client.configure do |config|
|
578
|
+
# config.timeout = 10_000
|
579
|
+
# config.rpcs.list_contexts.timeout = 20_000
|
580
|
+
# end
|
581
|
+
#
|
582
|
+
# To apply the above configuration only to a new client:
|
583
|
+
#
|
584
|
+
# client = Google::Cloud::Dialogflow::V2::Contexts::Client.new do |config|
|
585
|
+
# config.timeout = 10_000
|
586
|
+
# config.rpcs.list_contexts.timeout = 20_000
|
587
|
+
# end
|
588
|
+
#
|
589
|
+
# @!attribute [rw] endpoint
|
590
|
+
# The hostname or hostname:port of the service endpoint.
|
591
|
+
# Defaults to `"dialogflow.googleapis.com"`.
|
592
|
+
# @return [String]
|
593
|
+
# @!attribute [rw] credentials
|
594
|
+
# Credentials to send with calls. You may provide any of the following types:
|
595
|
+
# * (`String`) The path to a service account key file in JSON format
|
596
|
+
# * (`Hash`) A service account key as a Hash
|
597
|
+
# * (`Google::Auth::Credentials`) A googleauth credentials object
|
598
|
+
# (see the [googleauth docs](https://googleapis.dev/ruby/googleauth/latest/index.html))
|
599
|
+
# * (`Signet::OAuth2::Client`) A signet oauth2 client object
|
600
|
+
# (see the [signet docs](https://googleapis.dev/ruby/signet/latest/Signet/OAuth2/Client.html))
|
601
|
+
# * (`GRPC::Core::Channel`) a gRPC channel with included credentials
|
602
|
+
# * (`GRPC::Core::ChannelCredentials`) a gRPC credentails object
|
603
|
+
# * (`nil`) indicating no credentials
|
604
|
+
# @return [Object]
|
605
|
+
# @!attribute [rw] scope
|
606
|
+
# The OAuth scopes
|
607
|
+
# @return [Array<String>]
|
608
|
+
# @!attribute [rw] lib_name
|
609
|
+
# The library name as recorded in instrumentation and logging
|
610
|
+
# @return [String]
|
611
|
+
# @!attribute [rw] lib_version
|
612
|
+
# The library version as recorded in instrumentation and logging
|
613
|
+
# @return [String]
|
614
|
+
# @!attribute [rw] channel_args
|
615
|
+
# Extra parameters passed to the gRPC channel. Note: this is ignored if a
|
616
|
+
# `GRPC::Core::Channel` object is provided as the credential.
|
617
|
+
# @return [Hash]
|
618
|
+
# @!attribute [rw] interceptors
|
619
|
+
# An array of interceptors that are run before calls are executed.
|
620
|
+
# @return [Array<GRPC::ClientInterceptor>]
|
621
|
+
# @!attribute [rw] timeout
|
622
|
+
# The call timeout in milliseconds.
|
623
|
+
# @return [Numeric]
|
624
|
+
# @!attribute [rw] metadata
|
625
|
+
# Additional gRPC headers to be sent with the call.
|
626
|
+
# @return [Hash{Symbol=>String}]
|
627
|
+
# @!attribute [rw] retry_policy
|
628
|
+
# The retry policy. The value is a hash with the following keys:
|
629
|
+
# * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
|
630
|
+
# * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
|
631
|
+
# * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
|
632
|
+
# * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
|
633
|
+
# trigger a retry.
|
634
|
+
# @return [Hash]
|
635
|
+
#
|
636
|
+
class Configuration
|
637
|
+
extend Gapic::Config
|
638
|
+
|
639
|
+
config_attr :endpoint, "dialogflow.googleapis.com", String
|
640
|
+
config_attr :credentials, nil do |value|
|
641
|
+
allowed = [::String, ::Hash, ::Proc, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
|
642
|
+
allowed += [::GRPC::Core::Channel, ::GRPC::Core::ChannelCredentials] if defined? ::GRPC
|
643
|
+
allowed.any? { |klass| klass === value }
|
644
|
+
end
|
645
|
+
config_attr :scope, nil, String, Array, nil
|
646
|
+
config_attr :lib_name, nil, String, nil
|
647
|
+
config_attr :lib_version, nil, String, nil
|
648
|
+
config_attr(:channel_args, { "grpc.service_config_disable_resolution"=>1 }, Hash, nil)
|
649
|
+
config_attr :interceptors, nil, Array, nil
|
650
|
+
config_attr :timeout, nil, Numeric, nil
|
651
|
+
config_attr :metadata, nil, Hash, nil
|
652
|
+
config_attr :retry_policy, nil, Hash, Proc, nil
|
653
|
+
|
654
|
+
# @private
|
655
|
+
def initialize parent_config = nil
|
656
|
+
@parent_config = parent_config unless parent_config.nil?
|
657
|
+
|
658
|
+
yield self if block_given?
|
659
|
+
end
|
660
|
+
|
661
|
+
##
|
662
|
+
# Configurations for individual RPCs
|
663
|
+
# @return [Rpcs]
|
664
|
+
#
|
665
|
+
def rpcs
|
666
|
+
@rpcs ||= begin
|
667
|
+
parent_rpcs = nil
|
668
|
+
parent_rpcs = @parent_config.rpcs if @parent_config&.respond_to? :rpcs
|
669
|
+
Rpcs.new parent_rpcs
|
670
|
+
end
|
671
|
+
end
|
672
|
+
|
673
|
+
##
|
674
|
+
# Configuration RPC class for the Contexts API.
|
675
|
+
#
|
676
|
+
# Includes fields providing the configuration for each RPC in this service.
|
677
|
+
# Each configuration object is of type `Gapic::Config::Method` and includes
|
678
|
+
# the following configuration fields:
|
679
|
+
#
|
680
|
+
# * `timeout` (*type:* `Numeric`) - The call timeout in milliseconds
|
681
|
+
# * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional gRPC headers
|
682
|
+
# * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
|
683
|
+
# include the following keys:
|
684
|
+
# * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
|
685
|
+
# * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
|
686
|
+
# * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
|
687
|
+
# * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
|
688
|
+
# trigger a retry.
|
689
|
+
#
|
690
|
+
class Rpcs
|
691
|
+
##
|
692
|
+
# RPC-specific configuration for `list_contexts`
|
693
|
+
# @return [Gapic::Config::Method]
|
694
|
+
#
|
695
|
+
attr_reader :list_contexts
|
696
|
+
##
|
697
|
+
# RPC-specific configuration for `get_context`
|
698
|
+
# @return [Gapic::Config::Method]
|
699
|
+
#
|
700
|
+
attr_reader :get_context
|
701
|
+
##
|
702
|
+
# RPC-specific configuration for `create_context`
|
703
|
+
# @return [Gapic::Config::Method]
|
704
|
+
#
|
705
|
+
attr_reader :create_context
|
706
|
+
##
|
707
|
+
# RPC-specific configuration for `update_context`
|
708
|
+
# @return [Gapic::Config::Method]
|
709
|
+
#
|
710
|
+
attr_reader :update_context
|
711
|
+
##
|
712
|
+
# RPC-specific configuration for `delete_context`
|
713
|
+
# @return [Gapic::Config::Method]
|
714
|
+
#
|
715
|
+
attr_reader :delete_context
|
716
|
+
##
|
717
|
+
# RPC-specific configuration for `delete_all_contexts`
|
718
|
+
# @return [Gapic::Config::Method]
|
719
|
+
#
|
720
|
+
attr_reader :delete_all_contexts
|
721
|
+
|
722
|
+
# @private
|
723
|
+
def initialize parent_rpcs = nil
|
724
|
+
list_contexts_config = parent_rpcs&.list_contexts if parent_rpcs&.respond_to? :list_contexts
|
725
|
+
@list_contexts = Gapic::Config::Method.new list_contexts_config
|
726
|
+
get_context_config = parent_rpcs&.get_context if parent_rpcs&.respond_to? :get_context
|
727
|
+
@get_context = Gapic::Config::Method.new get_context_config
|
728
|
+
create_context_config = parent_rpcs&.create_context if parent_rpcs&.respond_to? :create_context
|
729
|
+
@create_context = Gapic::Config::Method.new create_context_config
|
730
|
+
update_context_config = parent_rpcs&.update_context if parent_rpcs&.respond_to? :update_context
|
731
|
+
@update_context = Gapic::Config::Method.new update_context_config
|
732
|
+
delete_context_config = parent_rpcs&.delete_context if parent_rpcs&.respond_to? :delete_context
|
733
|
+
@delete_context = Gapic::Config::Method.new delete_context_config
|
734
|
+
delete_all_contexts_config = parent_rpcs&.delete_all_contexts if parent_rpcs&.respond_to? :delete_all_contexts
|
735
|
+
@delete_all_contexts = Gapic::Config::Method.new delete_all_contexts_config
|
736
|
+
|
737
|
+
yield self if block_given?
|
738
|
+
end
|
739
|
+
end
|
740
|
+
end
|
741
|
+
end
|
742
|
+
end
|
743
|
+
end
|
744
|
+
end
|
745
|
+
end
|
746
|
+
end
|
747
|
+
|
748
|
+
# rubocop:disable Lint/HandleExceptions
|
749
|
+
|
750
|
+
# Once client is loaded, load helpers.rb if it exists.
|
751
|
+
begin
|
752
|
+
require "google/cloud/dialogflow/v2/contexts/helpers"
|
753
|
+
rescue LoadError
|
754
|
+
end
|
755
|
+
|
756
|
+
# rubocop:enable Lint/HandleExceptions
|