aws_sdk_apigateway/
client.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2#[derive(Debug)]
3pub(crate) struct Handle {
4    pub(crate) conf: crate::Config,
5    #[allow(dead_code)] // unused when a service does not provide any operations
6    pub(crate) runtime_plugins: ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins,
7}
8
9/// Client for Amazon API Gateway
10///
11/// Client for invoking operations on Amazon API Gateway. Each operation on Amazon API Gateway is a method on this
12/// this struct. `.send()` MUST be invoked on the generated operations to dispatch the request to the service.
13/// ## Constructing a `Client`
14///
15/// A [`Config`] is required to construct a client. For most use cases, the [`aws-config`]
16/// crate should be used to automatically resolve this config using
17/// [`aws_config::load_from_env()`], since this will resolve an [`SdkConfig`] which can be shared
18/// across multiple different AWS SDK clients. This config resolution process can be customized
19/// by calling [`aws_config::from_env()`] instead, which returns a [`ConfigLoader`] that uses
20/// the [builder pattern] to customize the default config.
21///
22/// In the simplest case, creating a client looks as follows:
23/// ```rust,no_run
24/// # async fn wrapper() {
25/// let config = aws_config::load_from_env().await;
26/// let client = aws_sdk_apigateway::Client::new(&config);
27/// # }
28/// ```
29///
30/// Occasionally, SDKs may have additional service-specific values that can be set on the [`Config`] that
31/// is absent from [`SdkConfig`], or slightly different settings for a specific client may be desired.
32/// The [`Builder`](crate::config::Builder) struct implements `From<&SdkConfig>`, so setting these specific settings can be
33/// done as follows:
34///
35/// ```rust,no_run
36/// # async fn wrapper() {
37/// let sdk_config = ::aws_config::load_from_env().await;
38/// let config = aws_sdk_apigateway::config::Builder::from(&sdk_config)
39/// # /*
40///     .some_service_specific_setting("value")
41/// # */
42///     .build();
43/// # }
44/// ```
45///
46/// See the [`aws-config` docs] and [`Config`] for more information on customizing configuration.
47///
48/// _Note:_ Client construction is expensive due to connection thread pool initialization, and should
49/// be done once at application start-up.
50///
51/// [`Config`]: crate::Config
52/// [`ConfigLoader`]: https://docs.rs/aws-config/*/aws_config/struct.ConfigLoader.html
53/// [`SdkConfig`]: https://docs.rs/aws-config/*/aws_config/struct.SdkConfig.html
54/// [`aws-config` docs]: https://docs.rs/aws-config/*
55/// [`aws-config`]: https://crates.io/crates/aws-config
56/// [`aws_config::from_env()`]: https://docs.rs/aws-config/*/aws_config/fn.from_env.html
57/// [`aws_config::load_from_env()`]: https://docs.rs/aws-config/*/aws_config/fn.load_from_env.html
58/// [builder pattern]: https://rust-lang.github.io/api-guidelines/type-safety.html#builders-enable-construction-of-complex-values-c-builder
59/// # Using the `Client`
60///
61/// A client has a function for every operation that can be performed by the service.
62/// For example, the [`CreateApiKey`](crate::operation::create_api_key) operation has
63/// a [`Client::create_api_key`], function which returns a builder for that operation.
64/// The fluent builder ultimately has a `send()` function that returns an async future that
65/// returns a result, as illustrated below:
66///
67/// ```rust,ignore
68/// let result = client.create_api_key()
69///     .name("example")
70///     .send()
71///     .await;
72/// ```
73///
74/// The underlying HTTP requests that get made by this can be modified with the `customize_operation`
75/// function on the fluent builder. See the [`customize`](crate::client::customize) module for more
76/// information.
77#[derive(::std::clone::Clone, ::std::fmt::Debug)]
78pub struct Client {
79    handle: ::std::sync::Arc<Handle>,
80}
81
82impl Client {
83    /// Creates a new client from the service [`Config`](crate::Config).
84    ///
85    /// # Panics
86    ///
87    /// This method will panic in the following cases:
88    ///
89    /// - Retries or timeouts are enabled without a `sleep_impl` configured.
90    /// - Identity caching is enabled without a `sleep_impl` and `time_source` configured.
91    /// - No `behavior_version` is provided.
92    ///
93    /// The panic message for each of these will have instructions on how to resolve them.
94    #[track_caller]
95    pub fn from_conf(conf: crate::Config) -> Self {
96        let handle = Handle {
97            conf: conf.clone(),
98            runtime_plugins: crate::config::base_client_runtime_plugins(conf),
99        };
100        if let Err(err) = Self::validate_config(&handle) {
101            panic!("Invalid client configuration: {err}");
102        }
103        Self {
104            handle: ::std::sync::Arc::new(handle),
105        }
106    }
107
108    /// Returns the client's configuration.
109    pub fn config(&self) -> &crate::Config {
110        &self.handle.conf
111    }
112
113    fn validate_config(handle: &Handle) -> ::std::result::Result<(), ::aws_smithy_runtime_api::box_error::BoxError> {
114        let mut cfg = ::aws_smithy_types::config_bag::ConfigBag::base();
115        handle
116            .runtime_plugins
117            .apply_client_configuration(&mut cfg)?
118            .validate_base_client_config(&cfg)?;
119        Ok(())
120    }
121}
122
123impl Client {
124    /// Creates a new client from an [SDK Config](::aws_types::sdk_config::SdkConfig).
125    ///
126    /// # Panics
127    ///
128    /// - This method will panic if the `sdk_config` is missing an async sleep implementation. If you experience this panic, set
129    ///   the `sleep_impl` on the Config passed into this function to fix it.
130    /// - This method will panic if the `sdk_config` is missing an HTTP connector. If you experience this panic, set the
131    ///   `http_connector` on the Config passed into this function to fix it.
132    /// - This method will panic if no `BehaviorVersion` is provided. If you experience this panic, set `behavior_version` on the Config or enable the `behavior-version-latest` Cargo feature.
133    #[track_caller]
134    pub fn new(sdk_config: &::aws_types::sdk_config::SdkConfig) -> Self {
135        Self::from_conf(sdk_config.into())
136    }
137}
138
139mod create_api_key;
140
141mod create_authorizer;
142
143mod create_base_path_mapping;
144
145mod create_deployment;
146
147mod create_documentation_part;
148
149mod create_documentation_version;
150
151mod create_domain_name;
152
153mod create_domain_name_access_association;
154
155mod create_model;
156
157mod create_request_validator;
158
159mod create_resource;
160
161mod create_rest_api;
162
163mod create_stage;
164
165mod create_usage_plan;
166
167mod create_usage_plan_key;
168
169mod create_vpc_link;
170
171/// Operation customization and supporting types.
172///
173/// The underlying HTTP requests made during an operation can be customized
174/// by calling the `customize()` method on the builder returned from a client
175/// operation call. For example, this can be used to add an additional HTTP header:
176///
177/// ```ignore
178/// # async fn wrapper() -> ::std::result::Result<(), aws_sdk_apigateway::Error> {
179/// # let client: aws_sdk_apigateway::Client = unimplemented!();
180/// use ::http::header::{HeaderName, HeaderValue};
181///
182/// let result = client.create_api_key()
183///     .customize()
184///     .mutate_request(|req| {
185///         // Add `x-example-header` with value
186///         req.headers_mut()
187///             .insert(
188///                 HeaderName::from_static("x-example-header"),
189///                 HeaderValue::from_static("1"),
190///             );
191///     })
192///     .send()
193///     .await;
194/// # }
195/// ```
196pub mod customize;
197
198mod delete_api_key;
199
200mod delete_authorizer;
201
202mod delete_base_path_mapping;
203
204mod delete_client_certificate;
205
206mod delete_deployment;
207
208mod delete_documentation_part;
209
210mod delete_documentation_version;
211
212mod delete_domain_name;
213
214mod delete_domain_name_access_association;
215
216mod delete_gateway_response;
217
218mod delete_integration;
219
220mod delete_integration_response;
221
222mod delete_method;
223
224mod delete_method_response;
225
226mod delete_model;
227
228mod delete_request_validator;
229
230mod delete_resource;
231
232mod delete_rest_api;
233
234mod delete_stage;
235
236mod delete_usage_plan;
237
238mod delete_usage_plan_key;
239
240mod delete_vpc_link;
241
242mod flush_stage_authorizers_cache;
243
244mod flush_stage_cache;
245
246mod generate_client_certificate;
247
248mod get_account;
249
250mod get_api_key;
251
252mod get_api_keys;
253
254mod get_authorizer;
255
256mod get_authorizers;
257
258mod get_base_path_mapping;
259
260mod get_base_path_mappings;
261
262mod get_client_certificate;
263
264mod get_client_certificates;
265
266mod get_deployment;
267
268mod get_deployments;
269
270mod get_documentation_part;
271
272mod get_documentation_parts;
273
274mod get_documentation_version;
275
276mod get_documentation_versions;
277
278mod get_domain_name;
279
280mod get_domain_name_access_associations;
281
282mod get_domain_names;
283
284mod get_export;
285
286mod get_gateway_response;
287
288mod get_gateway_responses;
289
290mod get_integration;
291
292mod get_integration_response;
293
294mod get_method;
295
296mod get_method_response;
297
298mod get_model;
299
300mod get_model_template;
301
302mod get_models;
303
304mod get_request_validator;
305
306mod get_request_validators;
307
308mod get_resource;
309
310mod get_resources;
311
312mod get_rest_api;
313
314mod get_rest_apis;
315
316mod get_sdk;
317
318mod get_sdk_type;
319
320mod get_sdk_types;
321
322mod get_stage;
323
324mod get_stages;
325
326mod get_tags;
327
328mod get_usage;
329
330mod get_usage_plan;
331
332mod get_usage_plan_key;
333
334mod get_usage_plan_keys;
335
336mod get_usage_plans;
337
338mod get_vpc_link;
339
340mod get_vpc_links;
341
342mod import_api_keys;
343
344mod import_documentation_parts;
345
346mod import_rest_api;
347
348mod put_gateway_response;
349
350mod put_integration;
351
352mod put_integration_response;
353
354mod put_method;
355
356mod put_method_response;
357
358mod put_rest_api;
359
360mod reject_domain_name_access_association;
361
362mod tag_resource;
363
364mod test_invoke_authorizer;
365
366mod test_invoke_method;
367
368mod untag_resource;
369
370mod update_account;
371
372mod update_api_key;
373
374mod update_authorizer;
375
376mod update_base_path_mapping;
377
378mod update_client_certificate;
379
380mod update_deployment;
381
382mod update_documentation_part;
383
384mod update_documentation_version;
385
386mod update_domain_name;
387
388mod update_gateway_response;
389
390mod update_integration;
391
392mod update_integration_response;
393
394mod update_method;
395
396mod update_method_response;
397
398mod update_model;
399
400mod update_request_validator;
401
402mod update_resource;
403
404mod update_rest_api;
405
406mod update_stage;
407
408mod update_usage;
409
410mod update_usage_plan;
411
412mod update_vpc_link;