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/cx/v3/session.proto
18
19#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_DIALOGFLOW_CX_SESSIONS_CLIENT_H
20#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_DIALOGFLOW_CX_SESSIONS_CLIENT_H
21
22#include "google/cloud/dialogflow_cx/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_cx {
33GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN
34
35///
36/// A session represents an interaction with a user. You retrieve user input
37/// and pass it to the
38/// [DetectIntent][google.cloud.dialogflow.cx.v3.Sessions.DetectIntent] method
39/// to determine user intent and respond.
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///
64/// [google.cloud.dialogflow.cx.v3.Sessions.DetectIntent]:
65/// @googleapis_reference_link{google/cloud/dialogflow/cx/v3/session.proto#L65}
66///
67class SessionsClient {
68 public:
69 explicit SessionsClient(std::shared_ptr<SessionsConnection> connection,
70 Options opts = {});
72
73 ///@{
74 /// @name Copy and move support
75 SessionsClient(SessionsClient const&) = default;
76 SessionsClient& operator=(SessionsClient const&) = default;
77 SessionsClient(SessionsClient&&) = default;
79 ///@}
80
81 ///@{
82 /// @name Equality
83 friend bool operator==(SessionsClient const& a, SessionsClient const& b) {
84 return a.connection_ == b.connection_;
85 }
86 friend bool operator!=(SessionsClient const& a, SessionsClient const& b) {
87 return !(a == b);
88 }
89 ///@}
90
91 // clang-format off
92 ///
93 /// Processes a natural language query and returns structured, actionable data
94 /// as a result. This method is not idempotent, because it may cause session
95 /// entity types to be updated, which in turn might affect results of future
96 /// queries.
97 ///
98 /// Note: Always use agent versions for production traffic.
99 /// See [Versions and
100 /// environments](https://cloud.google.com/dialogflow/cx/docs/concept/version).
101 ///
102 /// @param request Unary RPCs, such as the one wrapped by this
103 /// function, receive a single `request` proto message which includes all
104 /// the inputs for the RPC. In this case, the proto message is a
105 /// [google.cloud.dialogflow.cx.v3.DetectIntentRequest].
106 /// Proto messages are converted to C++ classes by Protobuf, using the
107 /// [Protobuf mapping rules].
108 /// @param opts Optional. Override the class-level options, such as retry and
109 /// backoff policies.
110 /// @return the result of the RPC. The response message type
111 /// ([google.cloud.dialogflow.cx.v3.DetectIntentResponse])
112 /// is mapped to a C++ class using the [Protobuf mapping rules].
113 /// If the request fails, the [`StatusOr`] contains the error details.
114 ///
115 /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/
116 /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator
117 /// [Long Running Operation]: https://google.aip.dev/151
118 /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string
119 /// [`future`]: @ref google::cloud::future
120 /// [`StatusOr`]: @ref google::cloud::StatusOr
121 /// [`Status`]: @ref google::cloud::Status
122 /// [google.cloud.dialogflow.cx.v3.DetectIntentRequest]: @googleapis_reference_link{google/cloud/dialogflow/cx/v3/session.proto#L119}
123 /// [google.cloud.dialogflow.cx.v3.DetectIntentResponse]: @googleapis_reference_link{google/cloud/dialogflow/cx/v3/session.proto#L154}
124 ///
125 // clang-format on
126 StatusOr<google::cloud::dialogflow::cx::v3::DetectIntentResponse>
128 google::cloud::dialogflow::cx::v3::DetectIntentRequest const& request,
129 Options opts = {});
130
131 // clang-format off
132 ///
133 /// Processes a natural language query in audio format in a streaming fashion
134 /// and returns structured, actionable data as a result. This method is only
135 /// available via the gRPC API (not REST).
136 ///
137 /// Note: Always use agent versions for production traffic.
138 /// See [Versions and
139 /// environments](https://cloud.google.com/dialogflow/cx/docs/concept/version).
140 ///
141 /// @param opts Optional. Override the class-level options, such as retry and
142 /// backoff policies.
143 /// @return An object representing the bidirectional streaming
144 /// RPC. Applications can send multiple request messages and receive
145 /// multiple response messages through this API. Bidirectional streaming
146 /// RPCs can impose restrictions on the sequence of request and response
147 /// messages. Please consult the service documentation for details.
148 /// The request message type ([google.cloud.dialogflow.cx.v3.StreamingDetectIntentRequest]) and response messages
149 /// ([google.cloud.dialogflow.cx.v3.StreamingDetectIntentResponse]) are mapped to C++ classes using the
150 /// [Protobuf mapping rules].
151 ///
152 /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/
153 /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator
154 /// [Long Running Operation]: https://google.aip.dev/151
155 /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string
156 /// [`future`]: @ref google::cloud::future
157 /// [`StatusOr`]: @ref google::cloud::StatusOr
158 /// [`Status`]: @ref google::cloud::Status
159 /// [google.cloud.dialogflow.cx.v3.StreamingDetectIntentRequest]: @googleapis_reference_link{google/cloud/dialogflow/cx/v3/session.proto#L234}
160 /// [google.cloud.dialogflow.cx.v3.StreamingDetectIntentResponse]: @googleapis_reference_link{google/cloud/dialogflow/cx/v3/session.proto#L368}
161 ///
162 // clang-format on
163 std::unique_ptr<::google::cloud::AsyncStreamingReadWriteRpc<
164 google::cloud::dialogflow::cx::v3::StreamingDetectIntentRequest,
165 google::cloud::dialogflow::cx::v3::StreamingDetectIntentResponse>>
167
168 // clang-format off
169 ///
170 /// Returns preliminary intent match results, doesn't change the session
171 /// status.
172 ///
173 /// @param request Unary RPCs, such as the one wrapped by this
174 /// function, receive a single `request` proto message which includes all
175 /// the inputs for the RPC. In this case, the proto message is a
176 /// [google.cloud.dialogflow.cx.v3.MatchIntentRequest].
177 /// Proto messages are converted to C++ classes by Protobuf, using the
178 /// [Protobuf mapping rules].
179 /// @param opts Optional. Override the class-level options, such as retry and
180 /// backoff policies.
181 /// @return the result of the RPC. The response message type
182 /// ([google.cloud.dialogflow.cx.v3.MatchIntentResponse])
183 /// is mapped to a C++ class using the [Protobuf mapping rules].
184 /// If the request fails, the [`StatusOr`] contains the error details.
185 ///
186 /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/
187 /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator
188 /// [Long Running Operation]: https://google.aip.dev/151
189 /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string
190 /// [`future`]: @ref google::cloud::future
191 /// [`StatusOr`]: @ref google::cloud::StatusOr
192 /// [`Status`]: @ref google::cloud::Status
193 /// [google.cloud.dialogflow.cx.v3.MatchIntentRequest]: @googleapis_reference_link{google/cloud/dialogflow/cx/v3/session.proto#L892}
194 /// [google.cloud.dialogflow.cx.v3.MatchIntentResponse]: @googleapis_reference_link{google/cloud/dialogflow/cx/v3/session.proto#L923}
195 ///
196 // clang-format on
197 StatusOr<google::cloud::dialogflow::cx::v3::MatchIntentResponse> MatchIntent(
198 google::cloud::dialogflow::cx::v3::MatchIntentRequest const& request,
199 Options opts = {});
200
201 // clang-format off
202 ///
203 /// Fulfills a matched intent returned by
204 /// [MatchIntent][google.cloud.dialogflow.cx.v3.Sessions.MatchIntent]. Must be
205 /// called after
206 /// [MatchIntent][google.cloud.dialogflow.cx.v3.Sessions.MatchIntent], with
207 /// input from
208 /// [MatchIntentResponse][google.cloud.dialogflow.cx.v3.MatchIntentResponse].
209 /// Otherwise, the behavior is undefined.
210 ///
211 /// @param request Unary RPCs, such as the one wrapped by this
212 /// function, receive a single `request` proto message which includes all
213 /// the inputs for the RPC. In this case, the proto message is a
214 /// [google.cloud.dialogflow.cx.v3.FulfillIntentRequest].
215 /// Proto messages are converted to C++ classes by Protobuf, using the
216 /// [Protobuf mapping rules].
217 /// @param opts Optional. Override the class-level options, such as retry and
218 /// backoff policies.
219 /// @return the result of the RPC. The response message type
220 /// ([google.cloud.dialogflow.cx.v3.FulfillIntentResponse])
221 /// is mapped to a C++ class using the [Protobuf mapping rules].
222 /// If the request fails, the [`StatusOr`] contains the error details.
223 ///
224 /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/
225 /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator
226 /// [Long Running Operation]: https://google.aip.dev/151
227 /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string
228 /// [`future`]: @ref google::cloud::future
229 /// [`StatusOr`]: @ref google::cloud::StatusOr
230 /// [`Status`]: @ref google::cloud::Status
231 /// [google.cloud.dialogflow.cx.v3.FulfillIntentRequest]: @googleapis_reference_link{google/cloud/dialogflow/cx/v3/session.proto#L959}
232 /// [google.cloud.dialogflow.cx.v3.FulfillIntentResponse]: @googleapis_reference_link{google/cloud/dialogflow/cx/v3/session.proto#L972}
233 /// [google.cloud.dialogflow.cx.v3.MatchIntentResponse]: @googleapis_reference_link{google/cloud/dialogflow/cx/v3/session.proto#L923}
234 /// [google.cloud.dialogflow.cx.v3.Sessions.MatchIntent]: @googleapis_reference_link{google/cloud/dialogflow/cx/v3/session.proto#L88}
235 ///
236 // clang-format on
237 StatusOr<google::cloud::dialogflow::cx::v3::FulfillIntentResponse>
239 google::cloud::dialogflow::cx::v3::FulfillIntentRequest const& request,
240 Options opts = {});
241
242 private:
243 std::shared_ptr<SessionsConnection> connection_;
244 Options options_;
245};
246
247GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END
248} // namespace dialogflow_cx
249} // namespace cloud
250} // namespace google
251
252#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_DIALOGFLOW_CX_SESSIONS_CLIENT_H
A session represents an interaction with a user.
Definition: sessions_client.h:67
StatusOr< google::cloud::dialogflow::cx::v3::FulfillIntentResponse > FulfillIntent(google::cloud::dialogflow::cx::v3::FulfillIntentRequest const &request, Options opts={})
Fulfills a matched intent returned by MatchIntent.
SessionsClient & operator=(SessionsClient const &)=default
friend bool operator!=(SessionsClient const &a, SessionsClient const &b)
Definition: sessions_client.h:86
StatusOr< google::cloud::dialogflow::cx::v3::DetectIntentResponse > DetectIntent(google::cloud::dialogflow::cx::v3::DetectIntentRequest const &request, Options opts={})
Processes a natural language query and returns structured, actionable data as a result.
std::unique_ptr<::google::cloud::AsyncStreamingReadWriteRpc< google::cloud::dialogflow::cx::v3::StreamingDetectIntentRequest, google::cloud::dialogflow::cx::v3::StreamingDetectIntentResponse > > AsyncStreamingDetectIntent(Options opts={})
Processes a natural language query in audio format in a streaming fashion and returns structured,...
SessionsClient & operator=(SessionsClient &&)=default
SessionsClient(std::shared_ptr< SessionsConnection > connection, Options opts={})
friend bool operator==(SessionsClient const &a, SessionsClient const &b)
Definition: sessions_client.h:83
SessionsClient(SessionsClient const &)=default
SessionsClient(SessionsClient &&)=default
StatusOr< google::cloud::dialogflow::cx::v3::MatchIntentResponse > MatchIntent(google::cloud::dialogflow::cx::v3::MatchIntentRequest const &request, Options opts={})
Returns preliminary intent match results, doesn't change the session status.
The SessionsConnection object for SessionsClient.
Definition: sessions_connection.h:61
Definition: agents_client.h:33