Skip to main content

aws_sdk_apigateway/types/
_gateway_response.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2
3/// <p>A gateway response of a given response type and status code, with optional response parameters and mapping templates.</p>
4#[non_exhaustive]
5#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)]
6pub struct GatewayResponse {
7    /// <p>The response type of the associated GatewayResponse.</p>
8    pub response_type: ::std::option::Option<crate::types::GatewayResponseType>,
9    /// <p>The HTTP status code for this GatewayResponse.</p>
10    pub status_code: ::std::option::Option<::std::string::String>,
11    /// <p>Response parameters (paths, query strings and headers) of the GatewayResponse as a string-to-string map of key-value pairs.</p>
12    pub response_parameters: ::std::option::Option<::std::collections::HashMap<::std::string::String, ::std::string::String>>,
13    /// <p>Response templates of the GatewayResponse as a string-to-string map of key-value pairs.</p>
14    pub response_templates: ::std::option::Option<::std::collections::HashMap<::std::string::String, ::std::string::String>>,
15    /// <p>A Boolean flag to indicate whether this GatewayResponse is the default gateway response (<code>true</code>) or not (<code>false</code>). A default gateway response is one generated by API Gateway without any customization by an API developer.</p>
16    pub default_response: bool,
17}
18impl GatewayResponse {
19    /// <p>The response type of the associated GatewayResponse.</p>
20    pub fn response_type(&self) -> ::std::option::Option<&crate::types::GatewayResponseType> {
21        self.response_type.as_ref()
22    }
23    /// <p>The HTTP status code for this GatewayResponse.</p>
24    pub fn status_code(&self) -> ::std::option::Option<&str> {
25        self.status_code.as_deref()
26    }
27    /// <p>Response parameters (paths, query strings and headers) of the GatewayResponse as a string-to-string map of key-value pairs.</p>
28    pub fn response_parameters(&self) -> ::std::option::Option<&::std::collections::HashMap<::std::string::String, ::std::string::String>> {
29        self.response_parameters.as_ref()
30    }
31    /// <p>Response templates of the GatewayResponse as a string-to-string map of key-value pairs.</p>
32    pub fn response_templates(&self) -> ::std::option::Option<&::std::collections::HashMap<::std::string::String, ::std::string::String>> {
33        self.response_templates.as_ref()
34    }
35    /// <p>A Boolean flag to indicate whether this GatewayResponse is the default gateway response (<code>true</code>) or not (<code>false</code>). A default gateway response is one generated by API Gateway without any customization by an API developer.</p>
36    pub fn default_response(&self) -> bool {
37        self.default_response
38    }
39}
40impl GatewayResponse {
41    /// Creates a new builder-style object to manufacture [`GatewayResponse`](crate::types::GatewayResponse).
42    pub fn builder() -> crate::types::builders::GatewayResponseBuilder {
43        crate::types::builders::GatewayResponseBuilder::default()
44    }
45}
46
47/// A builder for [`GatewayResponse`](crate::types::GatewayResponse).
48#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
49#[non_exhaustive]
50pub struct GatewayResponseBuilder {
51    pub(crate) response_type: ::std::option::Option<crate::types::GatewayResponseType>,
52    pub(crate) status_code: ::std::option::Option<::std::string::String>,
53    pub(crate) response_parameters: ::std::option::Option<::std::collections::HashMap<::std::string::String, ::std::string::String>>,
54    pub(crate) response_templates: ::std::option::Option<::std::collections::HashMap<::std::string::String, ::std::string::String>>,
55    pub(crate) default_response: ::std::option::Option<bool>,
56}
57impl GatewayResponseBuilder {
58    /// <p>The response type of the associated GatewayResponse.</p>
59    pub fn response_type(mut self, input: crate::types::GatewayResponseType) -> Self {
60        self.response_type = ::std::option::Option::Some(input);
61        self
62    }
63    /// <p>The response type of the associated GatewayResponse.</p>
64    pub fn set_response_type(mut self, input: ::std::option::Option<crate::types::GatewayResponseType>) -> Self {
65        self.response_type = input;
66        self
67    }
68    /// <p>The response type of the associated GatewayResponse.</p>
69    pub fn get_response_type(&self) -> &::std::option::Option<crate::types::GatewayResponseType> {
70        &self.response_type
71    }
72    /// <p>The HTTP status code for this GatewayResponse.</p>
73    pub fn status_code(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
74        self.status_code = ::std::option::Option::Some(input.into());
75        self
76    }
77    /// <p>The HTTP status code for this GatewayResponse.</p>
78    pub fn set_status_code(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
79        self.status_code = input;
80        self
81    }
82    /// <p>The HTTP status code for this GatewayResponse.</p>
83    pub fn get_status_code(&self) -> &::std::option::Option<::std::string::String> {
84        &self.status_code
85    }
86    /// Adds a key-value pair to `response_parameters`.
87    ///
88    /// To override the contents of this collection use [`set_response_parameters`](Self::set_response_parameters).
89    ///
90    /// <p>Response parameters (paths, query strings and headers) of the GatewayResponse as a string-to-string map of key-value pairs.</p>
91    pub fn response_parameters(
92        mut self,
93        k: impl ::std::convert::Into<::std::string::String>,
94        v: impl ::std::convert::Into<::std::string::String>,
95    ) -> Self {
96        let mut hash_map = self.response_parameters.unwrap_or_default();
97        hash_map.insert(k.into(), v.into());
98        self.response_parameters = ::std::option::Option::Some(hash_map);
99        self
100    }
101    /// <p>Response parameters (paths, query strings and headers) of the GatewayResponse as a string-to-string map of key-value pairs.</p>
102    pub fn set_response_parameters(
103        mut self,
104        input: ::std::option::Option<::std::collections::HashMap<::std::string::String, ::std::string::String>>,
105    ) -> Self {
106        self.response_parameters = input;
107        self
108    }
109    /// <p>Response parameters (paths, query strings and headers) of the GatewayResponse as a string-to-string map of key-value pairs.</p>
110    pub fn get_response_parameters(&self) -> &::std::option::Option<::std::collections::HashMap<::std::string::String, ::std::string::String>> {
111        &self.response_parameters
112    }
113    /// Adds a key-value pair to `response_templates`.
114    ///
115    /// To override the contents of this collection use [`set_response_templates`](Self::set_response_templates).
116    ///
117    /// <p>Response templates of the GatewayResponse as a string-to-string map of key-value pairs.</p>
118    pub fn response_templates(
119        mut self,
120        k: impl ::std::convert::Into<::std::string::String>,
121        v: impl ::std::convert::Into<::std::string::String>,
122    ) -> Self {
123        let mut hash_map = self.response_templates.unwrap_or_default();
124        hash_map.insert(k.into(), v.into());
125        self.response_templates = ::std::option::Option::Some(hash_map);
126        self
127    }
128    /// <p>Response templates of the GatewayResponse as a string-to-string map of key-value pairs.</p>
129    pub fn set_response_templates(
130        mut self,
131        input: ::std::option::Option<::std::collections::HashMap<::std::string::String, ::std::string::String>>,
132    ) -> Self {
133        self.response_templates = input;
134        self
135    }
136    /// <p>Response templates of the GatewayResponse as a string-to-string map of key-value pairs.</p>
137    pub fn get_response_templates(&self) -> &::std::option::Option<::std::collections::HashMap<::std::string::String, ::std::string::String>> {
138        &self.response_templates
139    }
140    /// <p>A Boolean flag to indicate whether this GatewayResponse is the default gateway response (<code>true</code>) or not (<code>false</code>). A default gateway response is one generated by API Gateway without any customization by an API developer.</p>
141    pub fn default_response(mut self, input: bool) -> Self {
142        self.default_response = ::std::option::Option::Some(input);
143        self
144    }
145    /// <p>A Boolean flag to indicate whether this GatewayResponse is the default gateway response (<code>true</code>) or not (<code>false</code>). A default gateway response is one generated by API Gateway without any customization by an API developer.</p>
146    pub fn set_default_response(mut self, input: ::std::option::Option<bool>) -> Self {
147        self.default_response = input;
148        self
149    }
150    /// <p>A Boolean flag to indicate whether this GatewayResponse is the default gateway response (<code>true</code>) or not (<code>false</code>). A default gateway response is one generated by API Gateway without any customization by an API developer.</p>
151    pub fn get_default_response(&self) -> &::std::option::Option<bool> {
152        &self.default_response
153    }
154    /// Consumes the builder and constructs a [`GatewayResponse`](crate::types::GatewayResponse).
155    pub fn build(self) -> crate::types::GatewayResponse {
156        crate::types::GatewayResponse {
157            response_type: self.response_type,
158            status_code: self.status_code,
159            response_parameters: self.response_parameters,
160            response_templates: self.response_templates,
161            default_response: self.default_response.unwrap_or_default(),
162        }
163    }
164}