aws_sdk_gamelift/operation/terminate_game_session/
builders.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub use crate::operation::terminate_game_session::_terminate_game_session_output::TerminateGameSessionOutputBuilder;
3
4pub use crate::operation::terminate_game_session::_terminate_game_session_input::TerminateGameSessionInputBuilder;
5
6impl crate::operation::terminate_game_session::builders::TerminateGameSessionInputBuilder {
7    /// Sends a request with this input using the given client.
8    pub async fn send_with(
9        self,
10        client: &crate::Client,
11    ) -> ::std::result::Result<
12        crate::operation::terminate_game_session::TerminateGameSessionOutput,
13        ::aws_smithy_runtime_api::client::result::SdkError<
14            crate::operation::terminate_game_session::TerminateGameSessionError,
15            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
16        >,
17    > {
18        let mut fluent_builder = client.terminate_game_session();
19        fluent_builder.inner = self;
20        fluent_builder.send().await
21    }
22}
23/// Fluent builder constructing a request to `TerminateGameSession`.
24///
25/// <p><b>This API works with the following fleet types:</b> EC2, Anywhere, Container</p>
26/// <p>Ends a game session that's currently in progress. Use this action to terminate any game session that isn't in <code>ERROR</code> status. Terminating a game session is the most efficient way to free up a server process when it's hosting a game session that's in a bad state or not ending properly. You can use this action to terminate a game session that's being hosted on any type of Amazon GameLift Servers fleet compute, including computes for managed EC2, managed container, and Anywhere fleets. The game server must be integrated with Amazon GameLift Servers server SDK 5.x or greater.</p>
27/// <p><b>Request options</b></p>
28/// <p>Request termination for a single game session. Provide the game session ID and the termination mode. There are two potential methods for terminating a game session:</p>
29/// <ul>
30/// <li>
31/// <p>Initiate a graceful termination using the normal game session shutdown sequence. With this mode, the Amazon GameLift Servers service prompts the server process that's hosting the game session by calling the server SDK callback method <code>OnProcessTerminate()</code>. The callback implementation is part of the custom game server code. It might involve a variety of actions to gracefully end a game session, such as notifying players, before stopping the server process.</p></li>
32/// <li>
33/// <p>Force an immediate game session termination. With this mode, the Amazon GameLift Servers service takes action to stop the server process, which ends the game session without the normal game session shutdown sequence.</p></li>
34/// </ul>
35/// <p><b>Results</b></p>
36/// <p>If successful, game session termination is initiated. During this activity, the game session status is changed to <code>TERMINATING</code>. When completed, the server process that was hosting the game session has been stopped and replaced with a new server process that's ready to host a new game session. The old game session's status is changed to <code>TERMINATED</code> with a status reason that indicates the termination method used.</p>
37/// <p><b>Learn more</b></p>
38/// <p><a href="https://docs.aws.amazon.com/gamelift/latest/developerguide/gamelift-sdk-server-api.html">Add Amazon GameLift Servers to your game server</a></p>
39/// <p>Amazon GameLift Servers server SDK 5 reference guide for <code>OnProcessTerminate()</code> (<a href="https://docs.aws.amazon.com/gamelift/latest/developerguide/integration-server-sdk5-cpp-initsdk.html">C++</a>) (<a href="https://docs.aws.amazon.com/gamelift/latest/developerguide/integration-server-sdk5-csharp-initsdk.html">C#</a>) (<a href="https://docs.aws.amazon.com/gamelift/latest/developerguide/integration-server-sdk5-unreal-initsdk.html">Unreal</a>) (<a href="https://docs.aws.amazon.com/gamelift/latest/developerguide/integration-server-sdk-go-initsdk.html">Go</a>)</p>
40#[derive(::std::clone::Clone, ::std::fmt::Debug)]
41pub struct TerminateGameSessionFluentBuilder {
42    handle: ::std::sync::Arc<crate::client::Handle>,
43    inner: crate::operation::terminate_game_session::builders::TerminateGameSessionInputBuilder,
44    config_override: ::std::option::Option<crate::config::Builder>,
45}
46impl
47    crate::client::customize::internal::CustomizableSend<
48        crate::operation::terminate_game_session::TerminateGameSessionOutput,
49        crate::operation::terminate_game_session::TerminateGameSessionError,
50    > for TerminateGameSessionFluentBuilder
51{
52    fn send(
53        self,
54        config_override: crate::config::Builder,
55    ) -> crate::client::customize::internal::BoxFuture<
56        crate::client::customize::internal::SendResult<
57            crate::operation::terminate_game_session::TerminateGameSessionOutput,
58            crate::operation::terminate_game_session::TerminateGameSessionError,
59        >,
60    > {
61        ::std::boxed::Box::pin(async move { self.config_override(config_override).send().await })
62    }
63}
64impl TerminateGameSessionFluentBuilder {
65    /// Creates a new `TerminateGameSessionFluentBuilder`.
66    pub(crate) fn new(handle: ::std::sync::Arc<crate::client::Handle>) -> Self {
67        Self {
68            handle,
69            inner: ::std::default::Default::default(),
70            config_override: ::std::option::Option::None,
71        }
72    }
73    /// Access the TerminateGameSession as a reference.
74    pub fn as_input(&self) -> &crate::operation::terminate_game_session::builders::TerminateGameSessionInputBuilder {
75        &self.inner
76    }
77    /// Sends the request and returns the response.
78    ///
79    /// If an error occurs, an `SdkError` will be returned with additional details that
80    /// can be matched against.
81    ///
82    /// By default, any retryable failures will be retried twice. Retry behavior
83    /// is configurable with the [RetryConfig](aws_smithy_types::retry::RetryConfig), which can be
84    /// set when configuring the client.
85    pub async fn send(
86        self,
87    ) -> ::std::result::Result<
88        crate::operation::terminate_game_session::TerminateGameSessionOutput,
89        ::aws_smithy_runtime_api::client::result::SdkError<
90            crate::operation::terminate_game_session::TerminateGameSessionError,
91            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
92        >,
93    > {
94        let input = self
95            .inner
96            .build()
97            .map_err(::aws_smithy_runtime_api::client::result::SdkError::construction_failure)?;
98        let runtime_plugins = crate::operation::terminate_game_session::TerminateGameSession::operation_runtime_plugins(
99            self.handle.runtime_plugins.clone(),
100            &self.handle.conf,
101            self.config_override,
102        );
103        crate::operation::terminate_game_session::TerminateGameSession::orchestrate(&runtime_plugins, input).await
104    }
105
106    /// Consumes this builder, creating a customizable operation that can be modified before being sent.
107    pub fn customize(
108        self,
109    ) -> crate::client::customize::CustomizableOperation<
110        crate::operation::terminate_game_session::TerminateGameSessionOutput,
111        crate::operation::terminate_game_session::TerminateGameSessionError,
112        Self,
113    > {
114        crate::client::customize::CustomizableOperation::new(self)
115    }
116    pub(crate) fn config_override(mut self, config_override: impl ::std::convert::Into<crate::config::Builder>) -> Self {
117        self.set_config_override(::std::option::Option::Some(config_override.into()));
118        self
119    }
120
121    pub(crate) fn set_config_override(&mut self, config_override: ::std::option::Option<crate::config::Builder>) -> &mut Self {
122        self.config_override = config_override;
123        self
124    }
125    /// <p>A unique identifier for the game session to be terminated. A game session ARN has the following format: <code>arn:aws:gamelift:<location>
126    /// ::gamesession/
127    /// <fleet id>
128    /// /
129    /// <custom id string or idempotency token></custom>
130    /// </fleet>
131    /// </location></code>.</p>
132    pub fn game_session_id(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
133        self.inner = self.inner.game_session_id(input.into());
134        self
135    }
136    /// <p>A unique identifier for the game session to be terminated. A game session ARN has the following format: <code>arn:aws:gamelift:<location>
137    /// ::gamesession/
138    /// <fleet id>
139    /// /
140    /// <custom id string or idempotency token></custom>
141    /// </fleet>
142    /// </location></code>.</p>
143    pub fn set_game_session_id(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
144        self.inner = self.inner.set_game_session_id(input);
145        self
146    }
147    /// <p>A unique identifier for the game session to be terminated. A game session ARN has the following format: <code>arn:aws:gamelift:<location>
148    /// ::gamesession/
149    /// <fleet id>
150    /// /
151    /// <custom id string or idempotency token></custom>
152    /// </fleet>
153    /// </location></code>.</p>
154    pub fn get_game_session_id(&self) -> &::std::option::Option<::std::string::String> {
155        self.inner.get_game_session_id()
156    }
157    /// <p>The method to use to terminate the game session. Available methods include:</p>
158    /// <ul>
159    /// <li>
160    /// <p><code>TRIGGER_ON_PROCESS_TERMINATE</code> – Prompts the Amazon GameLift Servers service to send an <code>OnProcessTerminate()</code> callback to the server process and initiate the normal game session shutdown sequence. The <code>OnProcessTerminate</code> method, which is implemented in the game server code, must include a call to the server SDK action <code>ProcessEnding()</code>, which is how the server process signals to Amazon GameLift Servers that a game session is ending. If the server process doesn't call <code>ProcessEnding()</code>, the game session termination won't conclude successfully.</p></li>
161    /// <li>
162    /// <p><code>FORCE_TERMINATE</code> – Prompts the Amazon GameLift Servers service to stop the server process immediately. Amazon GameLift Servers takes action (depending on the type of fleet) to shut down the server process without the normal game session shutdown sequence.</p><note>
163    /// <p>This method is not available for game sessions that are running on Anywhere fleets unless the fleet is deployed with the Amazon GameLift Servers Agent. In this scenario, a force terminate request results in an invalid or bad request exception.</p>
164    /// </note></li>
165    /// </ul>
166    pub fn termination_mode(mut self, input: crate::types::TerminationMode) -> Self {
167        self.inner = self.inner.termination_mode(input);
168        self
169    }
170    /// <p>The method to use to terminate the game session. Available methods include:</p>
171    /// <ul>
172    /// <li>
173    /// <p><code>TRIGGER_ON_PROCESS_TERMINATE</code> – Prompts the Amazon GameLift Servers service to send an <code>OnProcessTerminate()</code> callback to the server process and initiate the normal game session shutdown sequence. The <code>OnProcessTerminate</code> method, which is implemented in the game server code, must include a call to the server SDK action <code>ProcessEnding()</code>, which is how the server process signals to Amazon GameLift Servers that a game session is ending. If the server process doesn't call <code>ProcessEnding()</code>, the game session termination won't conclude successfully.</p></li>
174    /// <li>
175    /// <p><code>FORCE_TERMINATE</code> – Prompts the Amazon GameLift Servers service to stop the server process immediately. Amazon GameLift Servers takes action (depending on the type of fleet) to shut down the server process without the normal game session shutdown sequence.</p><note>
176    /// <p>This method is not available for game sessions that are running on Anywhere fleets unless the fleet is deployed with the Amazon GameLift Servers Agent. In this scenario, a force terminate request results in an invalid or bad request exception.</p>
177    /// </note></li>
178    /// </ul>
179    pub fn set_termination_mode(mut self, input: ::std::option::Option<crate::types::TerminationMode>) -> Self {
180        self.inner = self.inner.set_termination_mode(input);
181        self
182    }
183    /// <p>The method to use to terminate the game session. Available methods include:</p>
184    /// <ul>
185    /// <li>
186    /// <p><code>TRIGGER_ON_PROCESS_TERMINATE</code> – Prompts the Amazon GameLift Servers service to send an <code>OnProcessTerminate()</code> callback to the server process and initiate the normal game session shutdown sequence. The <code>OnProcessTerminate</code> method, which is implemented in the game server code, must include a call to the server SDK action <code>ProcessEnding()</code>, which is how the server process signals to Amazon GameLift Servers that a game session is ending. If the server process doesn't call <code>ProcessEnding()</code>, the game session termination won't conclude successfully.</p></li>
187    /// <li>
188    /// <p><code>FORCE_TERMINATE</code> – Prompts the Amazon GameLift Servers service to stop the server process immediately. Amazon GameLift Servers takes action (depending on the type of fleet) to shut down the server process without the normal game session shutdown sequence.</p><note>
189    /// <p>This method is not available for game sessions that are running on Anywhere fleets unless the fleet is deployed with the Amazon GameLift Servers Agent. In this scenario, a force terminate request results in an invalid or bad request exception.</p>
190    /// </note></li>
191    /// </ul>
192    pub fn get_termination_mode(&self) -> &::std::option::Option<crate::types::TerminationMode> {
193        self.inner.get_termination_mode()
194    }
195}