1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.

/// <p>The <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS">cross-origin resource sharing (CORS)</a> settings for your Lambda function URL. Use CORS to grant access to your function URL from any origin. You can also use CORS to control access for specific HTTP headers and methods in requests to your function URL.</p>
#[non_exhaustive]
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)]
pub struct Cors {
    /// <p>Whether to allow cookies or other credentials in requests to your function URL. The default is <code>false</code>.</p>
    pub allow_credentials: ::std::option::Option<bool>,
    /// <p>The HTTP headers that origins can include in requests to your function URL. For example: <code>Date</code>, <code>Keep-Alive</code>, <code>X-Custom-Header</code>.</p>
    pub allow_headers: ::std::option::Option<::std::vec::Vec<::std::string::String>>,
    /// <p>The HTTP methods that are allowed when calling your function URL. For example: <code>GET</code>, <code>POST</code>, <code>DELETE</code>, or the wildcard character (<code>*</code>).</p>
    pub allow_methods: ::std::option::Option<::std::vec::Vec<::std::string::String>>,
    /// <p>The origins that can access your function URL. You can list any number of specific origins, separated by a comma. For example: <code>https://www.example.com</code>, <code>http://localhost:60905</code>.</p>
    /// <p>Alternatively, you can grant access to all origins using the wildcard character (<code>*</code>).</p>
    pub allow_origins: ::std::option::Option<::std::vec::Vec<::std::string::String>>,
    /// <p>The HTTP headers in your function response that you want to expose to origins that call your function URL. For example: <code>Date</code>, <code>Keep-Alive</code>, <code>X-Custom-Header</code>.</p>
    pub expose_headers: ::std::option::Option<::std::vec::Vec<::std::string::String>>,
    /// <p>The maximum amount of time, in seconds, that web browsers can cache results of a preflight request. By default, this is set to <code>0</code>, which means that the browser doesn't cache results.</p>
    pub max_age: ::std::option::Option<i32>,
}
impl Cors {
    /// <p>Whether to allow cookies or other credentials in requests to your function URL. The default is <code>false</code>.</p>
    pub fn allow_credentials(&self) -> ::std::option::Option<bool> {
        self.allow_credentials
    }
    /// <p>The HTTP headers that origins can include in requests to your function URL. For example: <code>Date</code>, <code>Keep-Alive</code>, <code>X-Custom-Header</code>.</p>
    pub fn allow_headers(&self) -> ::std::option::Option<&[::std::string::String]> {
        self.allow_headers.as_deref()
    }
    /// <p>The HTTP methods that are allowed when calling your function URL. For example: <code>GET</code>, <code>POST</code>, <code>DELETE</code>, or the wildcard character (<code>*</code>).</p>
    pub fn allow_methods(&self) -> ::std::option::Option<&[::std::string::String]> {
        self.allow_methods.as_deref()
    }
    /// <p>The origins that can access your function URL. You can list any number of specific origins, separated by a comma. For example: <code>https://www.example.com</code>, <code>http://localhost:60905</code>.</p>
    /// <p>Alternatively, you can grant access to all origins using the wildcard character (<code>*</code>).</p>
    pub fn allow_origins(&self) -> ::std::option::Option<&[::std::string::String]> {
        self.allow_origins.as_deref()
    }
    /// <p>The HTTP headers in your function response that you want to expose to origins that call your function URL. For example: <code>Date</code>, <code>Keep-Alive</code>, <code>X-Custom-Header</code>.</p>
    pub fn expose_headers(&self) -> ::std::option::Option<&[::std::string::String]> {
        self.expose_headers.as_deref()
    }
    /// <p>The maximum amount of time, in seconds, that web browsers can cache results of a preflight request. By default, this is set to <code>0</code>, which means that the browser doesn't cache results.</p>
    pub fn max_age(&self) -> ::std::option::Option<i32> {
        self.max_age
    }
}
impl Cors {
    /// Creates a new builder-style object to manufacture [`Cors`](crate::types::Cors).
    pub fn builder() -> crate::types::builders::CorsBuilder {
        crate::types::builders::CorsBuilder::default()
    }
}

/// A builder for [`Cors`](crate::types::Cors).
#[non_exhaustive]
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
pub struct CorsBuilder {
    pub(crate) allow_credentials: ::std::option::Option<bool>,
    pub(crate) allow_headers: ::std::option::Option<::std::vec::Vec<::std::string::String>>,
    pub(crate) allow_methods: ::std::option::Option<::std::vec::Vec<::std::string::String>>,
    pub(crate) allow_origins: ::std::option::Option<::std::vec::Vec<::std::string::String>>,
    pub(crate) expose_headers: ::std::option::Option<::std::vec::Vec<::std::string::String>>,
    pub(crate) max_age: ::std::option::Option<i32>,
}
impl CorsBuilder {
    /// <p>Whether to allow cookies or other credentials in requests to your function URL. The default is <code>false</code>.</p>
    pub fn allow_credentials(mut self, input: bool) -> Self {
        self.allow_credentials = ::std::option::Option::Some(input);
        self
    }
    /// <p>Whether to allow cookies or other credentials in requests to your function URL. The default is <code>false</code>.</p>
    pub fn set_allow_credentials(mut self, input: ::std::option::Option<bool>) -> Self {
        self.allow_credentials = input;
        self
    }
    /// <p>Whether to allow cookies or other credentials in requests to your function URL. The default is <code>false</code>.</p>
    pub fn get_allow_credentials(&self) -> &::std::option::Option<bool> {
        &self.allow_credentials
    }
    /// Appends an item to `allow_headers`.
    ///
    /// To override the contents of this collection use [`set_allow_headers`](Self::set_allow_headers).
    ///
    /// <p>The HTTP headers that origins can include in requests to your function URL. For example: <code>Date</code>, <code>Keep-Alive</code>, <code>X-Custom-Header</code>.</p>
    pub fn allow_headers(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
        let mut v = self.allow_headers.unwrap_or_default();
        v.push(input.into());
        self.allow_headers = ::std::option::Option::Some(v);
        self
    }
    /// <p>The HTTP headers that origins can include in requests to your function URL. For example: <code>Date</code>, <code>Keep-Alive</code>, <code>X-Custom-Header</code>.</p>
    pub fn set_allow_headers(mut self, input: ::std::option::Option<::std::vec::Vec<::std::string::String>>) -> Self {
        self.allow_headers = input;
        self
    }
    /// <p>The HTTP headers that origins can include in requests to your function URL. For example: <code>Date</code>, <code>Keep-Alive</code>, <code>X-Custom-Header</code>.</p>
    pub fn get_allow_headers(&self) -> &::std::option::Option<::std::vec::Vec<::std::string::String>> {
        &self.allow_headers
    }
    /// Appends an item to `allow_methods`.
    ///
    /// To override the contents of this collection use [`set_allow_methods`](Self::set_allow_methods).
    ///
    /// <p>The HTTP methods that are allowed when calling your function URL. For example: <code>GET</code>, <code>POST</code>, <code>DELETE</code>, or the wildcard character (<code>*</code>).</p>
    pub fn allow_methods(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
        let mut v = self.allow_methods.unwrap_or_default();
        v.push(input.into());
        self.allow_methods = ::std::option::Option::Some(v);
        self
    }
    /// <p>The HTTP methods that are allowed when calling your function URL. For example: <code>GET</code>, <code>POST</code>, <code>DELETE</code>, or the wildcard character (<code>*</code>).</p>
    pub fn set_allow_methods(mut self, input: ::std::option::Option<::std::vec::Vec<::std::string::String>>) -> Self {
        self.allow_methods = input;
        self
    }
    /// <p>The HTTP methods that are allowed when calling your function URL. For example: <code>GET</code>, <code>POST</code>, <code>DELETE</code>, or the wildcard character (<code>*</code>).</p>
    pub fn get_allow_methods(&self) -> &::std::option::Option<::std::vec::Vec<::std::string::String>> {
        &self.allow_methods
    }
    /// Appends an item to `allow_origins`.
    ///
    /// To override the contents of this collection use [`set_allow_origins`](Self::set_allow_origins).
    ///
    /// <p>The origins that can access your function URL. You can list any number of specific origins, separated by a comma. For example: <code>https://www.example.com</code>, <code>http://localhost:60905</code>.</p>
    /// <p>Alternatively, you can grant access to all origins using the wildcard character (<code>*</code>).</p>
    pub fn allow_origins(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
        let mut v = self.allow_origins.unwrap_or_default();
        v.push(input.into());
        self.allow_origins = ::std::option::Option::Some(v);
        self
    }
    /// <p>The origins that can access your function URL. You can list any number of specific origins, separated by a comma. For example: <code>https://www.example.com</code>, <code>http://localhost:60905</code>.</p>
    /// <p>Alternatively, you can grant access to all origins using the wildcard character (<code>*</code>).</p>
    pub fn set_allow_origins(mut self, input: ::std::option::Option<::std::vec::Vec<::std::string::String>>) -> Self {
        self.allow_origins = input;
        self
    }
    /// <p>The origins that can access your function URL. You can list any number of specific origins, separated by a comma. For example: <code>https://www.example.com</code>, <code>http://localhost:60905</code>.</p>
    /// <p>Alternatively, you can grant access to all origins using the wildcard character (<code>*</code>).</p>
    pub fn get_allow_origins(&self) -> &::std::option::Option<::std::vec::Vec<::std::string::String>> {
        &self.allow_origins
    }
    /// Appends an item to `expose_headers`.
    ///
    /// To override the contents of this collection use [`set_expose_headers`](Self::set_expose_headers).
    ///
    /// <p>The HTTP headers in your function response that you want to expose to origins that call your function URL. For example: <code>Date</code>, <code>Keep-Alive</code>, <code>X-Custom-Header</code>.</p>
    pub fn expose_headers(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
        let mut v = self.expose_headers.unwrap_or_default();
        v.push(input.into());
        self.expose_headers = ::std::option::Option::Some(v);
        self
    }
    /// <p>The HTTP headers in your function response that you want to expose to origins that call your function URL. For example: <code>Date</code>, <code>Keep-Alive</code>, <code>X-Custom-Header</code>.</p>
    pub fn set_expose_headers(mut self, input: ::std::option::Option<::std::vec::Vec<::std::string::String>>) -> Self {
        self.expose_headers = input;
        self
    }
    /// <p>The HTTP headers in your function response that you want to expose to origins that call your function URL. For example: <code>Date</code>, <code>Keep-Alive</code>, <code>X-Custom-Header</code>.</p>
    pub fn get_expose_headers(&self) -> &::std::option::Option<::std::vec::Vec<::std::string::String>> {
        &self.expose_headers
    }
    /// <p>The maximum amount of time, in seconds, that web browsers can cache results of a preflight request. By default, this is set to <code>0</code>, which means that the browser doesn't cache results.</p>
    pub fn max_age(mut self, input: i32) -> Self {
        self.max_age = ::std::option::Option::Some(input);
        self
    }
    /// <p>The maximum amount of time, in seconds, that web browsers can cache results of a preflight request. By default, this is set to <code>0</code>, which means that the browser doesn't cache results.</p>
    pub fn set_max_age(mut self, input: ::std::option::Option<i32>) -> Self {
        self.max_age = input;
        self
    }
    /// <p>The maximum amount of time, in seconds, that web browsers can cache results of a preflight request. By default, this is set to <code>0</code>, which means that the browser doesn't cache results.</p>
    pub fn get_max_age(&self) -> &::std::option::Option<i32> {
        &self.max_age
    }
    /// Consumes the builder and constructs a [`Cors`](crate::types::Cors).
    pub fn build(self) -> crate::types::Cors {
        crate::types::Cors {
            allow_credentials: self.allow_credentials,
            allow_headers: self.allow_headers,
            allow_methods: self.allow_methods,
            allow_origins: self.allow_origins,
            expose_headers: self.expose_headers,
            max_age: self.max_age,
        }
    }
}