rivet_matchmaker/client.rs
1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2#[derive(Debug)]
3pub(crate) struct Handle<C, M, R = aws_smithy_client::retry::Standard> {
4 pub(crate) client: aws_smithy_client::Client<C, M, R>,
5 pub(crate) conf: crate::Config,
6}
7
8/// An ergonomic service client for `MatchmakerService`.
9///
10/// This client allows ergonomic access to a `MatchmakerService`-shaped service.
11/// Each method corresponds to an endpoint defined in the service's Smithy model,
12/// and the request and response shapes are auto-generated from that same model.
13///
14/// # Constructing a Client
15///
16/// To construct a client, you need a few different things:
17///
18/// - A [`Config`](crate::Config) that specifies additional configuration
19/// required by the service.
20/// - A connector (`C`) that specifies how HTTP requests are translated
21/// into HTTP responses. This will typically be an HTTP client (like
22/// `hyper`), though you can also substitute in your own, like a mock
23/// mock connector for testing.
24/// - A "middleware" (`M`) that modifies requests prior to them being
25/// sent to the request. Most commonly, middleware will decide what
26/// endpoint the requests should be sent to, as well as perform
27/// authentication and authorization of requests (such as SigV4).
28/// You can also have middleware that performs request/response
29/// tracing, throttling, or other middleware-like tasks.
30/// - A retry policy (`R`) that dictates the behavior for requests that
31/// fail and should (potentially) be retried. The default type is
32/// generally what you want, as it implements a well-vetted retry
33/// policy implemented in [`RetryMode::Standard`](aws_smithy_types::retry::RetryMode::Standard).
34///
35/// To construct a client, you will generally want to call
36/// [`Client::with_config`], which takes a [`aws_smithy_client::Client`] (a
37/// Smithy client that isn't specialized to a particular service),
38/// and a [`Config`](crate::Config). Both of these are constructed using
39/// the [builder pattern] where you first construct a `Builder` type,
40/// then configure it with the necessary parameters, and then call
41/// `build` to construct the finalized output type. The
42/// [`aws_smithy_client::Client`] builder is re-exported in this crate as
43/// [`Builder`] for convenience.
44///
45/// In _most_ circumstances, you will want to use the following pattern
46/// to construct a client:
47///
48/// ```
49/// use rivet_matchmaker::{Builder, Client, Config};
50/// let raw_client =
51/// Builder::dyn_https()
52/// # /*
53/// .middleware(/* discussed below */)
54/// # */
55/// # .middleware_fn(|r| r)
56/// .build();
57/// let config = Config::builder().build();
58/// let client = Client::with_config(raw_client, config);
59/// ```
60///
61/// For the middleware, you'll want to use whatever matches the
62/// routing, authentication and authorization required by the target
63/// service. For example, for the standard AWS SDK which uses
64/// [SigV4-signed requests], the middleware looks like this:
65///
66// Ignored as otherwise we'd need to pull in all these dev-dependencies.
67/// ```rust,ignore
68/// use aws_endpoint::AwsEndpointStage;
69/// use aws_http::auth::CredentialsStage;
70/// use aws_http::recursion_detection::RecursionDetectionStage;
71/// use aws_http::user_agent::UserAgentStage;
72/// use aws_sig_auth::middleware::SigV4SigningStage;
73/// use aws_sig_auth::signer::SigV4Signer;
74/// use aws_smithy_client::retry::Config as RetryConfig;
75/// use aws_smithy_http_tower::map_request::{AsyncMapRequestLayer, MapRequestLayer};
76/// use std::fmt::Debug;
77/// use tower::layer::util::{Identity, Stack};
78/// use tower::ServiceBuilder;
79///
80/// type AwsMiddlewareStack = Stack<
81/// MapRequestLayer<RecursionDetectionStage>,
82/// Stack<
83/// MapRequestLayer<SigV4SigningStage>,
84/// Stack<
85/// AsyncMapRequestLayer<CredentialsStage>,
86/// Stack<
87/// MapRequestLayer<UserAgentStage>,
88/// Stack<MapRequestLayer<AwsEndpointStage>, Identity>,
89/// >,
90/// >,
91/// >,
92/// >;
93///
94/// /// AWS Middleware Stack
95/// ///
96/// /// This implements the middleware stack for this service. It will:
97/// /// 1. Load credentials asynchronously into the property bag
98/// /// 2. Sign the request with SigV4
99/// /// 3. Resolve an Endpoint for the request
100/// /// 4. Add a user agent to the request
101/// #[derive(Debug, Default, Clone)]
102/// #[non_exhaustive]
103/// pub struct AwsMiddleware;
104///
105/// impl AwsMiddleware {
106/// /// Create a new `AwsMiddleware` stack
107/// ///
108/// /// Note: `AwsMiddleware` holds no state.
109/// pub fn new() -> Self {
110/// AwsMiddleware::default()
111/// }
112/// }
113///
114/// // define the middleware stack in a non-generic location to reduce code bloat.
115/// fn base() -> ServiceBuilder<AwsMiddlewareStack> {
116/// let credential_provider = AsyncMapRequestLayer::for_mapper(CredentialsStage::new());
117/// let signer = MapRequestLayer::for_mapper(SigV4SigningStage::new(SigV4Signer::new()));
118/// let endpoint_resolver = MapRequestLayer::for_mapper(AwsEndpointStage);
119/// let user_agent = MapRequestLayer::for_mapper(UserAgentStage::new());
120/// let recursion_detection = MapRequestLayer::for_mapper(RecursionDetectionStage::new());
121/// // These layers can be considered as occurring in order, that is:
122/// // 1. Resolve an endpoint
123/// // 2. Add a user agent
124/// // 3. Acquire credentials
125/// // 4. Sign with credentials
126/// // (5. Dispatch over the wire)
127/// ServiceBuilder::new()
128/// .layer(endpoint_resolver)
129/// .layer(user_agent)
130/// .layer(credential_provider)
131/// .layer(signer)
132/// .layer(recursion_detection)
133/// }
134///
135/// impl<S> tower::Layer<S> for AwsMiddleware {
136/// type Service = <AwsMiddlewareStack as tower::Layer<S>>::Service;
137///
138/// fn layer(&self, inner: S) -> Self::Service {
139/// base().service(inner)
140/// }
141/// }
142/// ```
143///
144/// # Using a Client
145///
146/// Once you have a client set up, you can access the service's endpoints
147/// by calling the appropriate method on [`Client`]. Each such method
148/// returns a request builder for that endpoint, with methods for setting
149/// the various fields of the request. Once your request is complete, use
150/// the `send` method to send the request. `send` returns a future, which
151/// you then have to `.await` to get the service's response.
152///
153/// [builder pattern]: https://rust-lang.github.io/api-guidelines/type-safety.html#c-builder
154/// [SigV4-signed requests]: https://docs.aws.amazon.com/general/latest/gr/signature-version-4.html
155#[derive(std::fmt::Debug)]
156pub struct Client<C, M, R = aws_smithy_client::retry::Standard> {
157 handle: std::sync::Arc<Handle<C, M, R>>,
158}
159
160impl<C, M, R> std::clone::Clone for Client<C, M, R> {
161 fn clone(&self) -> Self {
162 Self {
163 handle: self.handle.clone(),
164 }
165 }
166}
167
168#[doc(inline)]
169pub use aws_smithy_client::Builder;
170
171impl<C, M, R> From<aws_smithy_client::Client<C, M, R>> for Client<C, M, R> {
172 fn from(client: aws_smithy_client::Client<C, M, R>) -> Self {
173 Self::with_config(client, crate::Config::builder().build())
174 }
175}
176
177impl<C, M, R> Client<C, M, R> {
178 /// Creates a client with the given service configuration.
179 pub fn with_config(client: aws_smithy_client::Client<C, M, R>, conf: crate::Config) -> Self {
180 Self {
181 handle: std::sync::Arc::new(Handle { client, conf }),
182 }
183 }
184
185 /// Returns the client's configuration.
186 pub fn conf(&self) -> &crate::Config {
187 &self.handle.conf
188 }
189}
190impl<C, M, R> Client<C, M, R>
191where
192 C: aws_smithy_client::bounds::SmithyConnector,
193 M: aws_smithy_client::bounds::SmithyMiddleware<C>,
194 R: aws_smithy_client::retry::NewRequestPolicy,
195{
196 /// Constructs a fluent builder for the [`FindLobby`](crate::client::fluent_builders::FindLobby) operation.
197 ///
198 /// - The fluent builder is configurable:
199 /// - [`game_modes(Vec<String>)`](crate::client::fluent_builders::FindLobby::game_modes) / [`set_game_modes(Option<Vec<String>>)`](crate::client::fluent_builders::FindLobby::set_game_modes): Game modes to match lobbies against.
200 /// - [`regions(Vec<String>)`](crate::client::fluent_builders::FindLobby::regions) / [`set_regions(Option<Vec<String>>)`](crate::client::fluent_builders::FindLobby::set_regions): Regions to match lobbies against. If not specified, the optimal region will be determined and will attempt to find lobbies in that region.
201 /// - [`prevent_auto_create_lobby(bool)`](crate::client::fluent_builders::FindLobby::prevent_auto_create_lobby) / [`set_prevent_auto_create_lobby(Option<bool>)`](crate::client::fluent_builders::FindLobby::set_prevent_auto_create_lobby): Prevents a new lobby from being created when finding a lobby. If no lobby is found, a `MATCHMAKER_LOBBY_NOT_FOUND` error will be thrown.
202 /// - [`captcha(CaptchaConfig)`](crate::client::fluent_builders::FindLobby::captcha) / [`set_captcha(Option<CaptchaConfig>)`](crate::client::fluent_builders::FindLobby::set_captcha): Methods to verify a captcha.
203 /// - [`origin(impl Into<String>)`](crate::client::fluent_builders::FindLobby::origin) / [`set_origin(Option<String>)`](crate::client::fluent_builders::FindLobby::set_origin): (undocumented)
204 /// - On success, responds with [`FindLobbyOutput`](crate::output::FindLobbyOutput) with field(s):
205 /// - [`lobby(Option<MatchmakerLobbyJoinInfo>)`](crate::output::FindLobbyOutput::lobby): A matchmaker lobby.
206 /// - On failure, responds with [`SdkError<FindLobbyError>`](crate::error::FindLobbyError)
207 pub fn find_lobby(&self) -> fluent_builders::FindLobby<C, M, R> {
208 fluent_builders::FindLobby::new(self.handle.clone())
209 }
210 /// Constructs a fluent builder for the [`JoinLobby`](crate::client::fluent_builders::JoinLobby) operation.
211 ///
212 /// - The fluent builder is configurable:
213 /// - [`lobby_id(impl Into<String>)`](crate::client::fluent_builders::JoinLobby::lobby_id) / [`set_lobby_id(Option<String>)`](crate::client::fluent_builders::JoinLobby::set_lobby_id): A universally unique identifier.
214 /// - [`captcha(CaptchaConfig)`](crate::client::fluent_builders::JoinLobby::captcha) / [`set_captcha(Option<CaptchaConfig>)`](crate::client::fluent_builders::JoinLobby::set_captcha): Methods to verify a captcha.
215 /// - On success, responds with [`JoinLobbyOutput`](crate::output::JoinLobbyOutput) with field(s):
216 /// - [`lobby(Option<MatchmakerLobbyJoinInfo>)`](crate::output::JoinLobbyOutput::lobby): A matchmaker lobby.
217 /// - On failure, responds with [`SdkError<JoinLobbyError>`](crate::error::JoinLobbyError)
218 pub fn join_lobby(&self) -> fluent_builders::JoinLobby<C, M, R> {
219 fluent_builders::JoinLobby::new(self.handle.clone())
220 }
221 /// Constructs a fluent builder for the [`ListLobbies`](crate::client::fluent_builders::ListLobbies) operation.
222 ///
223 /// - The fluent builder takes no input, just [`send`](crate::client::fluent_builders::ListLobbies::send) it.
224
225 /// - On success, responds with [`ListLobbiesOutput`](crate::output::ListLobbiesOutput) with field(s):
226 /// - [`game_modes(Option<Vec<GameModeInfo>>)`](crate::output::ListLobbiesOutput::game_modes): (undocumented)
227 /// - [`regions(Option<Vec<RegionInfo>>)`](crate::output::ListLobbiesOutput::regions): (undocumented)
228 /// - [`lobbies(Option<Vec<LobbyInfo>>)`](crate::output::ListLobbiesOutput::lobbies): (undocumented)
229 /// - On failure, responds with [`SdkError<ListLobbiesError>`](crate::error::ListLobbiesError)
230 pub fn list_lobbies(&self) -> fluent_builders::ListLobbies<C, M, R> {
231 fluent_builders::ListLobbies::new(self.handle.clone())
232 }
233 /// Constructs a fluent builder for the [`ListRegions`](crate::client::fluent_builders::ListRegions) operation.
234 ///
235 /// - The fluent builder takes no input, just [`send`](crate::client::fluent_builders::ListRegions::send) it.
236
237 /// - On success, responds with [`ListRegionsOutput`](crate::output::ListRegionsOutput) with field(s):
238 /// - [`regions(Option<Vec<RegionInfo>>)`](crate::output::ListRegionsOutput::regions): (undocumented)
239 /// - On failure, responds with [`SdkError<ListRegionsError>`](crate::error::ListRegionsError)
240 pub fn list_regions(&self) -> fluent_builders::ListRegions<C, M, R> {
241 fluent_builders::ListRegions::new(self.handle.clone())
242 }
243 /// Constructs a fluent builder for the [`LobbyReady`](crate::client::fluent_builders::LobbyReady) operation.
244 ///
245 /// - The fluent builder takes no input, just [`send`](crate::client::fluent_builders::LobbyReady::send) it.
246
247 /// - On success, responds with [`LobbyReadyOutput`](crate::output::LobbyReadyOutput)
248
249 /// - On failure, responds with [`SdkError<LobbyReadyError>`](crate::error::LobbyReadyError)
250 pub fn lobby_ready(&self) -> fluent_builders::LobbyReady<C, M, R> {
251 fluent_builders::LobbyReady::new(self.handle.clone())
252 }
253 /// Constructs a fluent builder for the [`PlayerConnected`](crate::client::fluent_builders::PlayerConnected) operation.
254 ///
255 /// - The fluent builder is configurable:
256 /// - [`player_token(impl Into<String>)`](crate::client::fluent_builders::PlayerConnected::player_token) / [`set_player_token(Option<String>)`](crate::client::fluent_builders::PlayerConnected::set_player_token): A JSON Web Token. Slightly modified to include a description prefix and use Protobufs of JSON.
257 /// - On success, responds with [`PlayerConnectedOutput`](crate::output::PlayerConnectedOutput)
258
259 /// - On failure, responds with [`SdkError<PlayerConnectedError>`](crate::error::PlayerConnectedError)
260 pub fn player_connected(&self) -> fluent_builders::PlayerConnected<C, M, R> {
261 fluent_builders::PlayerConnected::new(self.handle.clone())
262 }
263 /// Constructs a fluent builder for the [`PlayerDisconnected`](crate::client::fluent_builders::PlayerDisconnected) operation.
264 ///
265 /// - The fluent builder is configurable:
266 /// - [`player_token(impl Into<String>)`](crate::client::fluent_builders::PlayerDisconnected::player_token) / [`set_player_token(Option<String>)`](crate::client::fluent_builders::PlayerDisconnected::set_player_token): A JSON Web Token. Slightly modified to include a description prefix and use Protobufs of JSON.
267 /// - On success, responds with [`PlayerDisconnectedOutput`](crate::output::PlayerDisconnectedOutput)
268
269 /// - On failure, responds with [`SdkError<PlayerDisconnectedError>`](crate::error::PlayerDisconnectedError)
270 pub fn player_disconnected(&self) -> fluent_builders::PlayerDisconnected<C, M, R> {
271 fluent_builders::PlayerDisconnected::new(self.handle.clone())
272 }
273 /// Constructs a fluent builder for the [`SetLobbyClosed`](crate::client::fluent_builders::SetLobbyClosed) operation.
274 ///
275 /// - The fluent builder is configurable:
276 /// - [`is_closed(bool)`](crate::client::fluent_builders::SetLobbyClosed::is_closed) / [`set_is_closed(Option<bool>)`](crate::client::fluent_builders::SetLobbyClosed::set_is_closed): (undocumented)
277 /// - On success, responds with [`SetLobbyClosedOutput`](crate::output::SetLobbyClosedOutput)
278
279 /// - On failure, responds with [`SdkError<SetLobbyClosedError>`](crate::error::SetLobbyClosedError)
280 pub fn set_lobby_closed(&self) -> fluent_builders::SetLobbyClosed<C, M, R> {
281 fluent_builders::SetLobbyClosed::new(self.handle.clone())
282 }
283}
284pub mod fluent_builders {
285 //!
286 //! Utilities to ergonomically construct a request to the service.
287 //!
288 //! Fluent builders are created through the [`Client`](crate::client::Client) by calling
289 //! one if its operation methods. After parameters are set using the builder methods,
290 //! the `send` method can be called to initiate the request.
291 //!
292 /// Fluent builder constructing a request to `FindLobby`.
293 ///
294 /// Finds a lobby based on the given criteria. If a lobby is not found and `prevent_auto_create_lobby` is `true`, a new lobby will be created.
295 #[derive(std::clone::Clone, std::fmt::Debug)]
296 pub struct FindLobby<C, M, R = aws_smithy_client::retry::Standard> {
297 handle: std::sync::Arc<super::Handle<C, M, R>>,
298 inner: crate::input::find_lobby_input::Builder,
299 }
300 impl<C, M, R> FindLobby<C, M, R>
301 where
302 C: aws_smithy_client::bounds::SmithyConnector,
303 M: aws_smithy_client::bounds::SmithyMiddleware<C>,
304 R: aws_smithy_client::retry::NewRequestPolicy,
305 {
306 /// Creates a new `FindLobby`.
307 pub(crate) fn new(handle: std::sync::Arc<super::Handle<C, M, R>>) -> Self {
308 Self {
309 handle,
310 inner: Default::default(),
311 }
312 }
313
314 /// Sends the request and returns the response.
315 ///
316 /// If an error occurs, an `SdkError` will be returned with additional details that
317 /// can be matched against.
318 ///
319 /// By default, any retryable failures will be retried twice. Retry behavior
320 /// is configurable with the [RetryConfig](aws_smithy_types::retry::RetryConfig), which can be
321 /// set when configuring the client.
322 pub async fn send(
323 self,
324 ) -> std::result::Result<
325 crate::output::FindLobbyOutput,
326 aws_smithy_http::result::SdkError<crate::error::FindLobbyError>,
327 >
328 where
329 R::Policy: aws_smithy_client::bounds::SmithyRetryPolicy<
330 crate::input::FindLobbyInputOperationOutputAlias,
331 crate::output::FindLobbyOutput,
332 crate::error::FindLobbyError,
333 crate::input::FindLobbyInputOperationRetryAlias,
334 >,
335 {
336 let op = self
337 .inner
338 .build()
339 .map_err(|err| aws_smithy_http::result::SdkError::ConstructionFailure(err.into()))?
340 .make_operation(&self.handle.conf)
341 .await
342 .map_err(|err| {
343 aws_smithy_http::result::SdkError::ConstructionFailure(err.into())
344 })?;
345 self.handle.client.call(op).await
346 }
347 /// Appends an item to `game_modes`.
348 ///
349 /// To override the contents of this collection use [`set_game_modes`](Self::set_game_modes).
350 ///
351 /// Game modes to match lobbies against.
352 pub fn game_modes(mut self, input: impl Into<std::string::String>) -> Self {
353 self.inner = self.inner.game_modes(input.into());
354 self
355 }
356 /// Game modes to match lobbies against.
357 pub fn set_game_modes(
358 mut self,
359 input: std::option::Option<std::vec::Vec<std::string::String>>,
360 ) -> Self {
361 self.inner = self.inner.set_game_modes(input);
362 self
363 }
364 /// Appends an item to `regions`.
365 ///
366 /// To override the contents of this collection use [`set_regions`](Self::set_regions).
367 ///
368 /// Regions to match lobbies against. If not specified, the optimal region will be determined and will attempt to find lobbies in that region.
369 pub fn regions(mut self, input: impl Into<std::string::String>) -> Self {
370 self.inner = self.inner.regions(input.into());
371 self
372 }
373 /// Regions to match lobbies against. If not specified, the optimal region will be determined and will attempt to find lobbies in that region.
374 pub fn set_regions(
375 mut self,
376 input: std::option::Option<std::vec::Vec<std::string::String>>,
377 ) -> Self {
378 self.inner = self.inner.set_regions(input);
379 self
380 }
381 /// Prevents a new lobby from being created when finding a lobby. If no lobby is found, a `MATCHMAKER_LOBBY_NOT_FOUND` error will be thrown.
382 pub fn prevent_auto_create_lobby(mut self, input: bool) -> Self {
383 self.inner = self.inner.prevent_auto_create_lobby(input);
384 self
385 }
386 /// Prevents a new lobby from being created when finding a lobby. If no lobby is found, a `MATCHMAKER_LOBBY_NOT_FOUND` error will be thrown.
387 pub fn set_prevent_auto_create_lobby(mut self, input: std::option::Option<bool>) -> Self {
388 self.inner = self.inner.set_prevent_auto_create_lobby(input);
389 self
390 }
391 /// Methods to verify a captcha.
392 pub fn captcha(mut self, input: crate::model::CaptchaConfig) -> Self {
393 self.inner = self.inner.captcha(input);
394 self
395 }
396 /// Methods to verify a captcha.
397 pub fn set_captcha(
398 mut self,
399 input: std::option::Option<crate::model::CaptchaConfig>,
400 ) -> Self {
401 self.inner = self.inner.set_captcha(input);
402 self
403 }
404 #[allow(missing_docs)] // documentation missing in model
405 pub fn origin(mut self, input: impl Into<std::string::String>) -> Self {
406 self.inner = self.inner.origin(input.into());
407 self
408 }
409 #[allow(missing_docs)] // documentation missing in model
410 pub fn set_origin(mut self, input: std::option::Option<std::string::String>) -> Self {
411 self.inner = self.inner.set_origin(input);
412 self
413 }
414 }
415 /// Fluent builder constructing a request to `JoinLobby`.
416 ///
417 /// Joins a specific lobby. This request will use the direct player count configured for the lobby group.
418 #[derive(std::clone::Clone, std::fmt::Debug)]
419 pub struct JoinLobby<C, M, R = aws_smithy_client::retry::Standard> {
420 handle: std::sync::Arc<super::Handle<C, M, R>>,
421 inner: crate::input::join_lobby_input::Builder,
422 }
423 impl<C, M, R> JoinLobby<C, M, R>
424 where
425 C: aws_smithy_client::bounds::SmithyConnector,
426 M: aws_smithy_client::bounds::SmithyMiddleware<C>,
427 R: aws_smithy_client::retry::NewRequestPolicy,
428 {
429 /// Creates a new `JoinLobby`.
430 pub(crate) fn new(handle: std::sync::Arc<super::Handle<C, M, R>>) -> Self {
431 Self {
432 handle,
433 inner: Default::default(),
434 }
435 }
436
437 /// Sends the request and returns the response.
438 ///
439 /// If an error occurs, an `SdkError` will be returned with additional details that
440 /// can be matched against.
441 ///
442 /// By default, any retryable failures will be retried twice. Retry behavior
443 /// is configurable with the [RetryConfig](aws_smithy_types::retry::RetryConfig), which can be
444 /// set when configuring the client.
445 pub async fn send(
446 self,
447 ) -> std::result::Result<
448 crate::output::JoinLobbyOutput,
449 aws_smithy_http::result::SdkError<crate::error::JoinLobbyError>,
450 >
451 where
452 R::Policy: aws_smithy_client::bounds::SmithyRetryPolicy<
453 crate::input::JoinLobbyInputOperationOutputAlias,
454 crate::output::JoinLobbyOutput,
455 crate::error::JoinLobbyError,
456 crate::input::JoinLobbyInputOperationRetryAlias,
457 >,
458 {
459 let op = self
460 .inner
461 .build()
462 .map_err(|err| aws_smithy_http::result::SdkError::ConstructionFailure(err.into()))?
463 .make_operation(&self.handle.conf)
464 .await
465 .map_err(|err| {
466 aws_smithy_http::result::SdkError::ConstructionFailure(err.into())
467 })?;
468 self.handle.client.call(op).await
469 }
470 /// A universally unique identifier.
471 pub fn lobby_id(mut self, input: impl Into<std::string::String>) -> Self {
472 self.inner = self.inner.lobby_id(input.into());
473 self
474 }
475 /// A universally unique identifier.
476 pub fn set_lobby_id(mut self, input: std::option::Option<std::string::String>) -> Self {
477 self.inner = self.inner.set_lobby_id(input);
478 self
479 }
480 /// Methods to verify a captcha.
481 pub fn captcha(mut self, input: crate::model::CaptchaConfig) -> Self {
482 self.inner = self.inner.captcha(input);
483 self
484 }
485 /// Methods to verify a captcha.
486 pub fn set_captcha(
487 mut self,
488 input: std::option::Option<crate::model::CaptchaConfig>,
489 ) -> Self {
490 self.inner = self.inner.set_captcha(input);
491 self
492 }
493 }
494 /// Fluent builder constructing a request to `ListLobbies`.
495 ///
496 /// Lists all open lobbies.
497 #[derive(std::clone::Clone, std::fmt::Debug)]
498 pub struct ListLobbies<C, M, R = aws_smithy_client::retry::Standard> {
499 handle: std::sync::Arc<super::Handle<C, M, R>>,
500 inner: crate::input::list_lobbies_input::Builder,
501 }
502 impl<C, M, R> ListLobbies<C, M, R>
503 where
504 C: aws_smithy_client::bounds::SmithyConnector,
505 M: aws_smithy_client::bounds::SmithyMiddleware<C>,
506 R: aws_smithy_client::retry::NewRequestPolicy,
507 {
508 /// Creates a new `ListLobbies`.
509 pub(crate) fn new(handle: std::sync::Arc<super::Handle<C, M, R>>) -> Self {
510 Self {
511 handle,
512 inner: Default::default(),
513 }
514 }
515
516 /// Sends the request and returns the response.
517 ///
518 /// If an error occurs, an `SdkError` will be returned with additional details that
519 /// can be matched against.
520 ///
521 /// By default, any retryable failures will be retried twice. Retry behavior
522 /// is configurable with the [RetryConfig](aws_smithy_types::retry::RetryConfig), which can be
523 /// set when configuring the client.
524 pub async fn send(
525 self,
526 ) -> std::result::Result<
527 crate::output::ListLobbiesOutput,
528 aws_smithy_http::result::SdkError<crate::error::ListLobbiesError>,
529 >
530 where
531 R::Policy: aws_smithy_client::bounds::SmithyRetryPolicy<
532 crate::input::ListLobbiesInputOperationOutputAlias,
533 crate::output::ListLobbiesOutput,
534 crate::error::ListLobbiesError,
535 crate::input::ListLobbiesInputOperationRetryAlias,
536 >,
537 {
538 let op = self
539 .inner
540 .build()
541 .map_err(|err| aws_smithy_http::result::SdkError::ConstructionFailure(err.into()))?
542 .make_operation(&self.handle.conf)
543 .await
544 .map_err(|err| {
545 aws_smithy_http::result::SdkError::ConstructionFailure(err.into())
546 })?;
547 self.handle.client.call(op).await
548 }
549 }
550 /// Fluent builder constructing a request to `ListRegions`.
551 ///
552 /// Returns a list of regions available to this namespace. Regions are sorted by most optimal to least optimal. The player's IP address is used to calculate the regions' optimality.
553 #[derive(std::clone::Clone, std::fmt::Debug)]
554 pub struct ListRegions<C, M, R = aws_smithy_client::retry::Standard> {
555 handle: std::sync::Arc<super::Handle<C, M, R>>,
556 inner: crate::input::list_regions_input::Builder,
557 }
558 impl<C, M, R> ListRegions<C, M, R>
559 where
560 C: aws_smithy_client::bounds::SmithyConnector,
561 M: aws_smithy_client::bounds::SmithyMiddleware<C>,
562 R: aws_smithy_client::retry::NewRequestPolicy,
563 {
564 /// Creates a new `ListRegions`.
565 pub(crate) fn new(handle: std::sync::Arc<super::Handle<C, M, R>>) -> Self {
566 Self {
567 handle,
568 inner: Default::default(),
569 }
570 }
571
572 /// Sends the request and returns the response.
573 ///
574 /// If an error occurs, an `SdkError` will be returned with additional details that
575 /// can be matched against.
576 ///
577 /// By default, any retryable failures will be retried twice. Retry behavior
578 /// is configurable with the [RetryConfig](aws_smithy_types::retry::RetryConfig), which can be
579 /// set when configuring the client.
580 pub async fn send(
581 self,
582 ) -> std::result::Result<
583 crate::output::ListRegionsOutput,
584 aws_smithy_http::result::SdkError<crate::error::ListRegionsError>,
585 >
586 where
587 R::Policy: aws_smithy_client::bounds::SmithyRetryPolicy<
588 crate::input::ListRegionsInputOperationOutputAlias,
589 crate::output::ListRegionsOutput,
590 crate::error::ListRegionsError,
591 crate::input::ListRegionsInputOperationRetryAlias,
592 >,
593 {
594 let op = self
595 .inner
596 .build()
597 .map_err(|err| aws_smithy_http::result::SdkError::ConstructionFailure(err.into()))?
598 .make_operation(&self.handle.conf)
599 .await
600 .map_err(|err| {
601 aws_smithy_http::result::SdkError::ConstructionFailure(err.into())
602 })?;
603 self.handle.client.call(op).await
604 }
605 }
606 /// Fluent builder constructing a request to `LobbyReady`.
607 ///
608 /// Marks the current lobby as ready to accept connections. Players will not be able to connect to this lobby until the lobby is flagged as ready.
609 #[derive(std::clone::Clone, std::fmt::Debug)]
610 pub struct LobbyReady<C, M, R = aws_smithy_client::retry::Standard> {
611 handle: std::sync::Arc<super::Handle<C, M, R>>,
612 inner: crate::input::lobby_ready_input::Builder,
613 }
614 impl<C, M, R> LobbyReady<C, M, R>
615 where
616 C: aws_smithy_client::bounds::SmithyConnector,
617 M: aws_smithy_client::bounds::SmithyMiddleware<C>,
618 R: aws_smithy_client::retry::NewRequestPolicy,
619 {
620 /// Creates a new `LobbyReady`.
621 pub(crate) fn new(handle: std::sync::Arc<super::Handle<C, M, R>>) -> Self {
622 Self {
623 handle,
624 inner: Default::default(),
625 }
626 }
627
628 /// Sends the request and returns the response.
629 ///
630 /// If an error occurs, an `SdkError` will be returned with additional details that
631 /// can be matched against.
632 ///
633 /// By default, any retryable failures will be retried twice. Retry behavior
634 /// is configurable with the [RetryConfig](aws_smithy_types::retry::RetryConfig), which can be
635 /// set when configuring the client.
636 pub async fn send(
637 self,
638 ) -> std::result::Result<
639 crate::output::LobbyReadyOutput,
640 aws_smithy_http::result::SdkError<crate::error::LobbyReadyError>,
641 >
642 where
643 R::Policy: aws_smithy_client::bounds::SmithyRetryPolicy<
644 crate::input::LobbyReadyInputOperationOutputAlias,
645 crate::output::LobbyReadyOutput,
646 crate::error::LobbyReadyError,
647 crate::input::LobbyReadyInputOperationRetryAlias,
648 >,
649 {
650 let op = self
651 .inner
652 .build()
653 .map_err(|err| aws_smithy_http::result::SdkError::ConstructionFailure(err.into()))?
654 .make_operation(&self.handle.conf)
655 .await
656 .map_err(|err| {
657 aws_smithy_http::result::SdkError::ConstructionFailure(err.into())
658 })?;
659 self.handle.client.call(op).await
660 }
661 }
662 /// Fluent builder constructing a request to `PlayerConnected`.
663 ///
664 /// Validates the player token is valid and has not already been consumed then marks the player as connected. # Player Tokens and Reserved Slots Player tokens reserve a spot in the lobby until they expire. This allows for precise matchmaking up to exactly the lobby's player limit, which is important for games with small lobbies and a high influx of players. By calling this endpoint with the player token, the player's spot is marked as connected and will not expire. If this endpoint is never called, the player's token will expire and this spot will be filled by another player. # Anti-Botting Player tokens are only issued by caling `rivet.api.matchmaker#JoinLobby`, calling `rivet.api.matchmaker#FindLobby`, or from the `rivet.api.identity.common#GlobalEventMatchmakerLobbyJoin` event. These endpoints have anti-botting measures (i.e. enforcing max player limits, captchas, and detecting bots), so valid player tokens provide some confidence that the player is not a bot. Therefore, it's important to make sure the token is valid by waiting for this endpoint to return OK before allowing the connected socket to do anything else. If this endpoint returns an error, the socket should be disconnected immediately. # How to Transmit the Player Token The client is responsible for acquiring the player token by caling `rivet.api.matchmaker#JoinLobby`, calling `rivet.api.matchmaker#FindLobby`, or from the `rivet.api.identity.common#GlobalEventMatchmakerLobbyJoin` event. Beyond that, it's up to the developer how the player token is transmitted to the lobby. If using WebSockets, the player token can be transmitted as a query paramter. Otherwise, the player token will likely be automatically sent by the client once the socket opens. As mentioned above, nothing else should happen until the player token is validated.
665 #[derive(std::clone::Clone, std::fmt::Debug)]
666 pub struct PlayerConnected<C, M, R = aws_smithy_client::retry::Standard> {
667 handle: std::sync::Arc<super::Handle<C, M, R>>,
668 inner: crate::input::player_connected_input::Builder,
669 }
670 impl<C, M, R> PlayerConnected<C, M, R>
671 where
672 C: aws_smithy_client::bounds::SmithyConnector,
673 M: aws_smithy_client::bounds::SmithyMiddleware<C>,
674 R: aws_smithy_client::retry::NewRequestPolicy,
675 {
676 /// Creates a new `PlayerConnected`.
677 pub(crate) fn new(handle: std::sync::Arc<super::Handle<C, M, R>>) -> Self {
678 Self {
679 handle,
680 inner: Default::default(),
681 }
682 }
683
684 /// Sends the request and returns the response.
685 ///
686 /// If an error occurs, an `SdkError` will be returned with additional details that
687 /// can be matched against.
688 ///
689 /// By default, any retryable failures will be retried twice. Retry behavior
690 /// is configurable with the [RetryConfig](aws_smithy_types::retry::RetryConfig), which can be
691 /// set when configuring the client.
692 pub async fn send(
693 self,
694 ) -> std::result::Result<
695 crate::output::PlayerConnectedOutput,
696 aws_smithy_http::result::SdkError<crate::error::PlayerConnectedError>,
697 >
698 where
699 R::Policy: aws_smithy_client::bounds::SmithyRetryPolicy<
700 crate::input::PlayerConnectedInputOperationOutputAlias,
701 crate::output::PlayerConnectedOutput,
702 crate::error::PlayerConnectedError,
703 crate::input::PlayerConnectedInputOperationRetryAlias,
704 >,
705 {
706 let op = self
707 .inner
708 .build()
709 .map_err(|err| aws_smithy_http::result::SdkError::ConstructionFailure(err.into()))?
710 .make_operation(&self.handle.conf)
711 .await
712 .map_err(|err| {
713 aws_smithy_http::result::SdkError::ConstructionFailure(err.into())
714 })?;
715 self.handle.client.call(op).await
716 }
717 /// A JSON Web Token. Slightly modified to include a description prefix and use Protobufs of JSON.
718 pub fn player_token(mut self, input: impl Into<std::string::String>) -> Self {
719 self.inner = self.inner.player_token(input.into());
720 self
721 }
722 /// A JSON Web Token. Slightly modified to include a description prefix and use Protobufs of JSON.
723 pub fn set_player_token(mut self, input: std::option::Option<std::string::String>) -> Self {
724 self.inner = self.inner.set_player_token(input);
725 self
726 }
727 }
728 /// Fluent builder constructing a request to `PlayerDisconnected`.
729 ///
730 /// Marks a player as disconnected. # Ghost Players If players are not marked as disconnected, lobbies will result with "ghost players" that the matchmaker thinks exist but are no longer connected to the lobby.
731 #[derive(std::clone::Clone, std::fmt::Debug)]
732 pub struct PlayerDisconnected<C, M, R = aws_smithy_client::retry::Standard> {
733 handle: std::sync::Arc<super::Handle<C, M, R>>,
734 inner: crate::input::player_disconnected_input::Builder,
735 }
736 impl<C, M, R> PlayerDisconnected<C, M, R>
737 where
738 C: aws_smithy_client::bounds::SmithyConnector,
739 M: aws_smithy_client::bounds::SmithyMiddleware<C>,
740 R: aws_smithy_client::retry::NewRequestPolicy,
741 {
742 /// Creates a new `PlayerDisconnected`.
743 pub(crate) fn new(handle: std::sync::Arc<super::Handle<C, M, R>>) -> Self {
744 Self {
745 handle,
746 inner: Default::default(),
747 }
748 }
749
750 /// Sends the request and returns the response.
751 ///
752 /// If an error occurs, an `SdkError` will be returned with additional details that
753 /// can be matched against.
754 ///
755 /// By default, any retryable failures will be retried twice. Retry behavior
756 /// is configurable with the [RetryConfig](aws_smithy_types::retry::RetryConfig), which can be
757 /// set when configuring the client.
758 pub async fn send(
759 self,
760 ) -> std::result::Result<
761 crate::output::PlayerDisconnectedOutput,
762 aws_smithy_http::result::SdkError<crate::error::PlayerDisconnectedError>,
763 >
764 where
765 R::Policy: aws_smithy_client::bounds::SmithyRetryPolicy<
766 crate::input::PlayerDisconnectedInputOperationOutputAlias,
767 crate::output::PlayerDisconnectedOutput,
768 crate::error::PlayerDisconnectedError,
769 crate::input::PlayerDisconnectedInputOperationRetryAlias,
770 >,
771 {
772 let op = self
773 .inner
774 .build()
775 .map_err(|err| aws_smithy_http::result::SdkError::ConstructionFailure(err.into()))?
776 .make_operation(&self.handle.conf)
777 .await
778 .map_err(|err| {
779 aws_smithy_http::result::SdkError::ConstructionFailure(err.into())
780 })?;
781 self.handle.client.call(op).await
782 }
783 /// A JSON Web Token. Slightly modified to include a description prefix and use Protobufs of JSON.
784 pub fn player_token(mut self, input: impl Into<std::string::String>) -> Self {
785 self.inner = self.inner.player_token(input.into());
786 self
787 }
788 /// A JSON Web Token. Slightly modified to include a description prefix and use Protobufs of JSON.
789 pub fn set_player_token(mut self, input: std::option::Option<std::string::String>) -> Self {
790 self.inner = self.inner.set_player_token(input);
791 self
792 }
793 }
794 /// Fluent builder constructing a request to `SetLobbyClosed`.
795 ///
796 /// If `is_closed` is `true`, players will be prevented from joining the lobby. Does not shutdown the lobby.
797 #[derive(std::clone::Clone, std::fmt::Debug)]
798 pub struct SetLobbyClosed<C, M, R = aws_smithy_client::retry::Standard> {
799 handle: std::sync::Arc<super::Handle<C, M, R>>,
800 inner: crate::input::set_lobby_closed_input::Builder,
801 }
802 impl<C, M, R> SetLobbyClosed<C, M, R>
803 where
804 C: aws_smithy_client::bounds::SmithyConnector,
805 M: aws_smithy_client::bounds::SmithyMiddleware<C>,
806 R: aws_smithy_client::retry::NewRequestPolicy,
807 {
808 /// Creates a new `SetLobbyClosed`.
809 pub(crate) fn new(handle: std::sync::Arc<super::Handle<C, M, R>>) -> Self {
810 Self {
811 handle,
812 inner: Default::default(),
813 }
814 }
815
816 /// Sends the request and returns the response.
817 ///
818 /// If an error occurs, an `SdkError` will be returned with additional details that
819 /// can be matched against.
820 ///
821 /// By default, any retryable failures will be retried twice. Retry behavior
822 /// is configurable with the [RetryConfig](aws_smithy_types::retry::RetryConfig), which can be
823 /// set when configuring the client.
824 pub async fn send(
825 self,
826 ) -> std::result::Result<
827 crate::output::SetLobbyClosedOutput,
828 aws_smithy_http::result::SdkError<crate::error::SetLobbyClosedError>,
829 >
830 where
831 R::Policy: aws_smithy_client::bounds::SmithyRetryPolicy<
832 crate::input::SetLobbyClosedInputOperationOutputAlias,
833 crate::output::SetLobbyClosedOutput,
834 crate::error::SetLobbyClosedError,
835 crate::input::SetLobbyClosedInputOperationRetryAlias,
836 >,
837 {
838 let op = self
839 .inner
840 .build()
841 .map_err(|err| aws_smithy_http::result::SdkError::ConstructionFailure(err.into()))?
842 .make_operation(&self.handle.conf)
843 .await
844 .map_err(|err| {
845 aws_smithy_http::result::SdkError::ConstructionFailure(err.into())
846 })?;
847 self.handle.client.call(op).await
848 }
849 #[allow(missing_docs)] // documentation missing in model
850 pub fn is_closed(mut self, input: bool) -> Self {
851 self.inner = self.inner.is_closed(input);
852 self
853 }
854 #[allow(missing_docs)] // documentation missing in model
855 pub fn set_is_closed(mut self, input: std::option::Option<bool>) -> Self {
856 self.inner = self.inner.set_is_closed(input);
857 self
858 }
859 }
860}
861/// A wrapper around [`Client`]. Helps reduce external imports.
862pub struct ClientWrapper {
863 pub(crate) client: Client<aws_smithy_client::erase::DynConnector, tower::layer::util::Identity>,
864}
865
866impl std::ops::Deref for ClientWrapper {
867 type Target = Client<aws_smithy_client::erase::DynConnector, tower::layer::util::Identity>;
868
869 fn deref(&self) -> &Self::Target {
870 &self.client
871 }
872}