Dialogflow API C++ Client 2.13.0
A C++ Client Library for the Dialogflow API
Loading...
Searching...
No Matches
sessions_client.h
1// Copyright 2022 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// Generated by the Codegen C++ plugin.
16// If you make any local changes, they will be lost.
17// source: google/cloud/dialogflow/v2/session.proto
18
19#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_DIALOGFLOW_ES_SESSIONS_CLIENT_H
20#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_DIALOGFLOW_ES_SESSIONS_CLIENT_H
21
22#include "google/cloud/dialogflow_es/sessions_connection.h"
23#include "google/cloud/future.h"
24#include "google/cloud/options.h"
25#include "google/cloud/polling_policy.h"
26#include "google/cloud/status_or.h"
27#include "google/cloud/version.h"
28#include <memory>
29
30namespace google {
31namespace cloud {
32namespace dialogflow_es {
33GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN
34
35///
36/// A service used for session interactions.
37///
38/// For more information, see the [API interactions
39/// guide](https://cloud.google.com/dialogflow/docs/api-overview).
40///
41/// @par Equality
42///
43/// Instances of this class created via copy-construction or copy-assignment
44/// always compare equal. Instances created with equal
45/// `std::shared_ptr<*Connection>` objects compare equal. Objects that compare
46/// equal share the same underlying resources.
47///
48/// @par Performance
49///
50/// Creating a new instance of this class is a relatively expensive operation,
51/// new objects establish new connections to the service. In contrast,
52/// copy-construction, move-construction, and the corresponding assignment
53/// operations are relatively efficient as the copies share all underlying
54/// resources.
55///
56/// @par Thread Safety
57///
58/// Concurrent access to different instances of this class, even if they compare
59/// equal, is guaranteed to work. Two or more threads operating on the same
60/// instance of this class is not guaranteed to work. Since copy-construction
61/// and move-construction is a relatively efficient operation, consider using
62/// such a copy when using this class from multiple threads.
63///
64class SessionsClient {
65 public:
66 explicit SessionsClient(std::shared_ptr<SessionsConnection> connection,
67 Options opts = {});
69
70 ///@{
71 /// @name Copy and move support
72 SessionsClient(SessionsClient const&) = default;
73 SessionsClient& operator=(SessionsClient const&) = default;
74 SessionsClient(SessionsClient&&) = default;
76 ///@}
77
78 ///@{
79 /// @name Equality
80 friend bool operator==(SessionsClient const& a, SessionsClient const& b) {
81 return a.connection_ == b.connection_;
82 }
83 friend bool operator!=(SessionsClient const& a, SessionsClient const& b) {
84 return !(a == b);
85 }
86 ///@}
87
88 // clang-format off
89 ///
90 /// Processes a natural language query and returns structured, actionable data
91 /// as a result. This method is not idempotent, because it may cause contexts
92 /// and session entity types to be updated, which in turn might affect
93 /// results of future queries.
94 ///
95 /// If you might use
96 /// [Agent Assist](https://cloud.google.com/dialogflow/docs/#aa)
97 /// or other CCAI products now or in the future, consider using
98 /// [AnalyzeContent][google.cloud.dialogflow.v2.Participants.AnalyzeContent]
99 /// instead of `DetectIntent`. `AnalyzeContent` has additional
100 /// functionality for Agent Assist and other CCAI products.
101 ///
102 /// Note: Always use agent versions for production traffic.
103 /// See [Versions and
104 /// environments](https://cloud.google.com/dialogflow/es/docs/agents-versions).
105 ///
106 /// @param session Required. The name of the session this query is sent to. Format:
107 /// `projects/<Project ID>/agent/sessions/<Session ID>`, or
108 /// `projects/<Project ID>/agent/environments/<Environment ID>/users/<User
109 /// ID>/sessions/<Session ID>`. If `Environment ID` is not specified, we assume
110 /// default 'draft' environment (`Environment ID` might be referred to as
111 /// environment name at some places). If `User ID` is not specified, we are
112 /// using "-". It's up to the API caller to choose an appropriate `Session ID`
113 /// and `User Id`. They can be a random number or some type of user and session
114 /// identifiers (preferably hashed). The length of the `Session ID` and
115 /// `User ID` must not exceed 36 characters.
116 /// @n
117 /// For more information, see the [API interactions
118 /// guide](https://cloud.google.com/dialogflow/docs/api-overview).
119 /// @n
120 /// Note: Always use agent versions for production traffic.
121 /// See [Versions and
122 /// environments](https://cloud.google.com/dialogflow/es/docs/agents-versions).
123 /// @param query_input Required. The input specification. It can be set to:
124 /// @n
125 /// 1. an audio config
126 /// which instructs the speech recognizer how to process the speech audio,
127 /// @n
128 /// 2. a conversational query in the form of text, or
129 /// @n
130 /// 3. an event that specifies which intent to trigger.
131 /// @param opts Optional. Override the class-level options, such as retry and
132 /// backoff policies.
133 /// @return the result of the RPC. The response message type
134 /// ([google.cloud.dialogflow.v2.DetectIntentResponse])
135 /// is mapped to a C++ class using the [Protobuf mapping rules].
136 /// If the request fails, the [`StatusOr`] contains the error details.
137 ///
138 /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/
139 /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator
140 /// [Long Running Operation]: https://google.aip.dev/151
141 /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string
142 /// [`future`]: @ref google::cloud::future
143 /// [`StatusOr`]: @ref google::cloud::StatusOr
144 /// [`Status`]: @ref google::cloud::Status
145 /// [google.cloud.dialogflow.v2.DetectIntentRequest]: @googleapis_reference_link{google/cloud/dialogflow/v2/session.proto#L112}
146 /// [google.cloud.dialogflow.v2.DetectIntentResponse]: @googleapis_reference_link{google/cloud/dialogflow/v2/session.proto#L172}
147 ///
148 // clang-format on
149 StatusOr<google::cloud::dialogflow::v2::DetectIntentResponse> DetectIntent(
150 std::string const& session,
151 google::cloud::dialogflow::v2::QueryInput const& query_input,
152 Options opts = {});
153
154 // clang-format off
155 ///
156 /// Processes a natural language query and returns structured, actionable data
157 /// as a result. This method is not idempotent, because it may cause contexts
158 /// and session entity types to be updated, which in turn might affect
159 /// results of future queries.
160 ///
161 /// If you might use
162 /// [Agent Assist](https://cloud.google.com/dialogflow/docs/#aa)
163 /// or other CCAI products now or in the future, consider using
164 /// [AnalyzeContent][google.cloud.dialogflow.v2.Participants.AnalyzeContent]
165 /// instead of `DetectIntent`. `AnalyzeContent` has additional
166 /// functionality for Agent Assist and other CCAI products.
167 ///
168 /// Note: Always use agent versions for production traffic.
169 /// See [Versions and
170 /// environments](https://cloud.google.com/dialogflow/es/docs/agents-versions).
171 ///
172 /// @param request Unary RPCs, such as the one wrapped by this
173 /// function, receive a single `request` proto message which includes all
174 /// the inputs for the RPC. In this case, the proto message is a
175 /// [google.cloud.dialogflow.v2.DetectIntentRequest].
176 /// Proto messages are converted to C++ classes by Protobuf, using the
177 /// [Protobuf mapping rules].
178 /// @param opts Optional. Override the class-level options, such as retry and
179 /// backoff policies.
180 /// @return the result of the RPC. The response message type
181 /// ([google.cloud.dialogflow.v2.DetectIntentResponse])
182 /// is mapped to a C++ class using the [Protobuf mapping rules].
183 /// If the request fails, the [`StatusOr`] contains the error details.
184 ///
185 /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/
186 /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator
187 /// [Long Running Operation]: https://google.aip.dev/151
188 /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string
189 /// [`future`]: @ref google::cloud::future
190 /// [`StatusOr`]: @ref google::cloud::StatusOr
191 /// [`Status`]: @ref google::cloud::Status
192 /// [google.cloud.dialogflow.v2.DetectIntentRequest]: @googleapis_reference_link{google/cloud/dialogflow/v2/session.proto#L112}
193 /// [google.cloud.dialogflow.v2.DetectIntentResponse]: @googleapis_reference_link{google/cloud/dialogflow/v2/session.proto#L172}
194 ///
195 // clang-format on
196 StatusOr<google::cloud::dialogflow::v2::DetectIntentResponse> DetectIntent(
197 google::cloud::dialogflow::v2::DetectIntentRequest const& request,
198 Options opts = {});
199
200 // clang-format off
201 ///
202 /// Processes a natural language query in audio format in a streaming fashion
203 /// and returns structured, actionable data as a result. This method is only
204 /// available via the gRPC API (not REST).
205 ///
206 /// If you might use
207 /// [Agent Assist](https://cloud.google.com/dialogflow/docs/#aa)
208 /// or other CCAI products now or in the future, consider using
209 /// [StreamingAnalyzeContent][google.cloud.dialogflow.v2.Participants.StreamingAnalyzeContent]
210 /// instead of `StreamingDetectIntent`. `StreamingAnalyzeContent` has
211 /// additional functionality for Agent Assist and other CCAI products.
212 ///
213 /// Note: Always use agent versions for production traffic.
214 /// See [Versions and
215 /// environments](https://cloud.google.com/dialogflow/es/docs/agents-versions).
216 ///
217 /// @param opts Optional. Override the class-level options, such as retry and
218 /// backoff policies.
219 /// @return An object representing the bidirectional streaming
220 /// RPC. Applications can send multiple request messages and receive
221 /// multiple response messages through this API. Bidirectional streaming
222 /// RPCs can impose restrictions on the sequence of request and response
223 /// messages. Please consult the service documentation for details.
224 /// The request message type ([google.cloud.dialogflow.v2.StreamingDetectIntentRequest]) and response messages
225 /// ([google.cloud.dialogflow.v2.StreamingDetectIntentResponse]) are mapped to C++ classes using the
226 /// [Protobuf mapping rules].
227 ///
228 /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/
229 /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator
230 /// [Long Running Operation]: https://google.aip.dev/151
231 /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string
232 /// [`future`]: @ref google::cloud::future
233 /// [`StatusOr`]: @ref google::cloud::StatusOr
234 /// [`Status`]: @ref google::cloud::Status
235 /// [google.cloud.dialogflow.v2.StreamingDetectIntentRequest]: @googleapis_reference_link{google/cloud/dialogflow/v2/session.proto#L418}
236 /// [google.cloud.dialogflow.v2.StreamingDetectIntentResponse]: @googleapis_reference_link{google/cloud/dialogflow/v2/session.proto#L570}
237 ///
238 // clang-format on
239 std::unique_ptr<::google::cloud::AsyncStreamingReadWriteRpc<
240 google::cloud::dialogflow::v2::StreamingDetectIntentRequest,
241 google::cloud::dialogflow::v2::StreamingDetectIntentResponse>>
243
244 private:
245 std::shared_ptr<SessionsConnection> connection_;
246 Options options_;
247};
248
249GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END
250} // namespace dialogflow_es
251} // namespace cloud
252} // namespace google
253
254#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_DIALOGFLOW_ES_SESSIONS_CLIENT_H
A service used for session interactions.
Definition: sessions_client.h:64
SessionsClient(SessionsClient const &)=default
friend bool operator!=(SessionsClient const &a, SessionsClient const &b)
Definition: sessions_client.h:83
StatusOr< google::cloud::dialogflow::v2::DetectIntentResponse > DetectIntent(google::cloud::dialogflow::v2::DetectIntentRequest const &request, Options opts={})
Processes a natural language query and returns structured, actionable data as a result.
SessionsClient(std::shared_ptr< SessionsConnection > connection, Options opts={})
SessionsClient & operator=(SessionsClient const &)=default
SessionsClient(SessionsClient &&)=default
std::unique_ptr<::google::cloud::AsyncStreamingReadWriteRpc< google::cloud::dialogflow::v2::StreamingDetectIntentRequest, google::cloud::dialogflow::v2::StreamingDetectIntentResponse > > AsyncStreamingDetectIntent(Options opts={})
Processes a natural language query in audio format in a streaming fashion and returns structured,...
friend bool operator==(SessionsClient const &a, SessionsClient const &b)
Definition: sessions_client.h:80
StatusOr< google::cloud::dialogflow::v2::DetectIntentResponse > DetectIntent(std::string const &session, google::cloud::dialogflow::v2::QueryInput const &query_input, Options opts={})
Processes a natural language query and returns structured, actionable data as a result.
SessionsClient & operator=(SessionsClient &&)=default
The SessionsConnection object for SessionsClient.
Definition: sessions_connection.h:61
Definition: agents_client.h:33