aws_sdk_apigateway/operation/create_authorizer/
builders.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub use crate::operation::create_authorizer::_create_authorizer_output::CreateAuthorizerOutputBuilder;
3
4pub use crate::operation::create_authorizer::_create_authorizer_input::CreateAuthorizerInputBuilder;
5
6impl crate::operation::create_authorizer::builders::CreateAuthorizerInputBuilder {
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::create_authorizer::CreateAuthorizerOutput,
13        ::aws_smithy_runtime_api::client::result::SdkError<
14            crate::operation::create_authorizer::CreateAuthorizerError,
15            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
16        >,
17    > {
18        let mut fluent_builder = client.create_authorizer();
19        fluent_builder.inner = self;
20        fluent_builder.send().await
21    }
22}
23/// Fluent builder constructing a request to `CreateAuthorizer`.
24///
25/// <p>Adds a new Authorizer resource to an existing RestApi resource.</p>
26#[derive(::std::clone::Clone, ::std::fmt::Debug)]
27pub struct CreateAuthorizerFluentBuilder {
28    handle: ::std::sync::Arc<crate::client::Handle>,
29    inner: crate::operation::create_authorizer::builders::CreateAuthorizerInputBuilder,
30    config_override: ::std::option::Option<crate::config::Builder>,
31}
32impl
33    crate::client::customize::internal::CustomizableSend<
34        crate::operation::create_authorizer::CreateAuthorizerOutput,
35        crate::operation::create_authorizer::CreateAuthorizerError,
36    > for CreateAuthorizerFluentBuilder
37{
38    fn send(
39        self,
40        config_override: crate::config::Builder,
41    ) -> crate::client::customize::internal::BoxFuture<
42        crate::client::customize::internal::SendResult<
43            crate::operation::create_authorizer::CreateAuthorizerOutput,
44            crate::operation::create_authorizer::CreateAuthorizerError,
45        >,
46    > {
47        ::std::boxed::Box::pin(async move { self.config_override(config_override).send().await })
48    }
49}
50impl CreateAuthorizerFluentBuilder {
51    /// Creates a new `CreateAuthorizerFluentBuilder`.
52    pub(crate) fn new(handle: ::std::sync::Arc<crate::client::Handle>) -> Self {
53        Self {
54            handle,
55            inner: ::std::default::Default::default(),
56            config_override: ::std::option::Option::None,
57        }
58    }
59    /// Access the CreateAuthorizer as a reference.
60    pub fn as_input(&self) -> &crate::operation::create_authorizer::builders::CreateAuthorizerInputBuilder {
61        &self.inner
62    }
63    /// Sends the request and returns the response.
64    ///
65    /// If an error occurs, an `SdkError` will be returned with additional details that
66    /// can be matched against.
67    ///
68    /// By default, any retryable failures will be retried twice. Retry behavior
69    /// is configurable with the [RetryConfig](aws_smithy_types::retry::RetryConfig), which can be
70    /// set when configuring the client.
71    pub async fn send(
72        self,
73    ) -> ::std::result::Result<
74        crate::operation::create_authorizer::CreateAuthorizerOutput,
75        ::aws_smithy_runtime_api::client::result::SdkError<
76            crate::operation::create_authorizer::CreateAuthorizerError,
77            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
78        >,
79    > {
80        let input = self
81            .inner
82            .build()
83            .map_err(::aws_smithy_runtime_api::client::result::SdkError::construction_failure)?;
84        let runtime_plugins = crate::operation::create_authorizer::CreateAuthorizer::operation_runtime_plugins(
85            self.handle.runtime_plugins.clone(),
86            &self.handle.conf,
87            self.config_override,
88        );
89        crate::operation::create_authorizer::CreateAuthorizer::orchestrate(&runtime_plugins, input).await
90    }
91
92    /// Consumes this builder, creating a customizable operation that can be modified before being sent.
93    pub fn customize(
94        self,
95    ) -> crate::client::customize::CustomizableOperation<
96        crate::operation::create_authorizer::CreateAuthorizerOutput,
97        crate::operation::create_authorizer::CreateAuthorizerError,
98        Self,
99    > {
100        crate::client::customize::CustomizableOperation::new(self)
101    }
102    pub(crate) fn config_override(mut self, config_override: impl ::std::convert::Into<crate::config::Builder>) -> Self {
103        self.set_config_override(::std::option::Option::Some(config_override.into()));
104        self
105    }
106
107    pub(crate) fn set_config_override(&mut self, config_override: ::std::option::Option<crate::config::Builder>) -> &mut Self {
108        self.config_override = config_override;
109        self
110    }
111    /// <p>The string identifier of the associated RestApi.</p>
112    pub fn rest_api_id(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
113        self.inner = self.inner.rest_api_id(input.into());
114        self
115    }
116    /// <p>The string identifier of the associated RestApi.</p>
117    pub fn set_rest_api_id(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
118        self.inner = self.inner.set_rest_api_id(input);
119        self
120    }
121    /// <p>The string identifier of the associated RestApi.</p>
122    pub fn get_rest_api_id(&self) -> &::std::option::Option<::std::string::String> {
123        self.inner.get_rest_api_id()
124    }
125    /// <p>The name of the authorizer.</p>
126    pub fn name(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
127        self.inner = self.inner.name(input.into());
128        self
129    }
130    /// <p>The name of the authorizer.</p>
131    pub fn set_name(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
132        self.inner = self.inner.set_name(input);
133        self
134    }
135    /// <p>The name of the authorizer.</p>
136    pub fn get_name(&self) -> &::std::option::Option<::std::string::String> {
137        self.inner.get_name()
138    }
139    /// <p>The authorizer type. Valid values are <code>TOKEN</code> for a Lambda function using a single authorization token submitted in a custom header, <code>REQUEST</code> for a Lambda function using incoming request parameters, and <code>COGNITO_USER_POOLS</code> for using an Amazon Cognito user pool.</p>
140    pub fn r#type(mut self, input: crate::types::AuthorizerType) -> Self {
141        self.inner = self.inner.r#type(input);
142        self
143    }
144    /// <p>The authorizer type. Valid values are <code>TOKEN</code> for a Lambda function using a single authorization token submitted in a custom header, <code>REQUEST</code> for a Lambda function using incoming request parameters, and <code>COGNITO_USER_POOLS</code> for using an Amazon Cognito user pool.</p>
145    pub fn set_type(mut self, input: ::std::option::Option<crate::types::AuthorizerType>) -> Self {
146        self.inner = self.inner.set_type(input);
147        self
148    }
149    /// <p>The authorizer type. Valid values are <code>TOKEN</code> for a Lambda function using a single authorization token submitted in a custom header, <code>REQUEST</code> for a Lambda function using incoming request parameters, and <code>COGNITO_USER_POOLS</code> for using an Amazon Cognito user pool.</p>
150    pub fn get_type(&self) -> &::std::option::Option<crate::types::AuthorizerType> {
151        self.inner.get_type()
152    }
153    ///
154    /// Appends an item to `providerARNs`.
155    ///
156    /// To override the contents of this collection use [`set_provider_arns`](Self::set_provider_arns).
157    ///
158    /// <p>A list of the Amazon Cognito user pool ARNs for the <code>COGNITO_USER_POOLS</code> authorizer. Each element is of this format: <code>arn:aws:cognito-idp:{region}:{account_id}:userpool/{user_pool_id}</code>. For a <code>TOKEN</code> or <code>REQUEST</code> authorizer, this is not defined.</p>
159    pub fn provider_arns(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
160        self.inner = self.inner.provider_arns(input.into());
161        self
162    }
163    /// <p>A list of the Amazon Cognito user pool ARNs for the <code>COGNITO_USER_POOLS</code> authorizer. Each element is of this format: <code>arn:aws:cognito-idp:{region}:{account_id}:userpool/{user_pool_id}</code>. For a <code>TOKEN</code> or <code>REQUEST</code> authorizer, this is not defined.</p>
164    pub fn set_provider_arns(mut self, input: ::std::option::Option<::std::vec::Vec<::std::string::String>>) -> Self {
165        self.inner = self.inner.set_provider_arns(input);
166        self
167    }
168    /// <p>A list of the Amazon Cognito user pool ARNs for the <code>COGNITO_USER_POOLS</code> authorizer. Each element is of this format: <code>arn:aws:cognito-idp:{region}:{account_id}:userpool/{user_pool_id}</code>. For a <code>TOKEN</code> or <code>REQUEST</code> authorizer, this is not defined.</p>
169    pub fn get_provider_arns(&self) -> &::std::option::Option<::std::vec::Vec<::std::string::String>> {
170        self.inner.get_provider_arns()
171    }
172    /// <p>Optional customer-defined field, used in OpenAPI imports and exports without functional impact.</p>
173    pub fn auth_type(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
174        self.inner = self.inner.auth_type(input.into());
175        self
176    }
177    /// <p>Optional customer-defined field, used in OpenAPI imports and exports without functional impact.</p>
178    pub fn set_auth_type(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
179        self.inner = self.inner.set_auth_type(input);
180        self
181    }
182    /// <p>Optional customer-defined field, used in OpenAPI imports and exports without functional impact.</p>
183    pub fn get_auth_type(&self) -> &::std::option::Option<::std::string::String> {
184        self.inner.get_auth_type()
185    }
186    /// <p>Specifies the authorizer's Uniform Resource Identifier (URI). For <code>TOKEN</code> or <code>REQUEST</code> authorizers, this must be a well-formed Lambda function URI, for example, <code>arn:aws:apigateway:us-west-2:lambda:path/2015-03-31/functions/arn:aws:lambda:us-west-2:{account_id}:function:{lambda_function_name}/invocations</code>. In general, the URI has this form <code>arn:aws:apigateway:{region}:lambda:path/{service_api}</code>, where <code>{region}</code> is the same as the region hosting the Lambda function, <code>path</code> indicates that the remaining substring in the URI should be treated as the path to the resource, including the initial <code>/</code>. For Lambda functions, this is usually of the form <code>/2015-03-31/functions/\[FunctionARN\]/invocations</code>.</p>
187    pub fn authorizer_uri(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
188        self.inner = self.inner.authorizer_uri(input.into());
189        self
190    }
191    /// <p>Specifies the authorizer's Uniform Resource Identifier (URI). For <code>TOKEN</code> or <code>REQUEST</code> authorizers, this must be a well-formed Lambda function URI, for example, <code>arn:aws:apigateway:us-west-2:lambda:path/2015-03-31/functions/arn:aws:lambda:us-west-2:{account_id}:function:{lambda_function_name}/invocations</code>. In general, the URI has this form <code>arn:aws:apigateway:{region}:lambda:path/{service_api}</code>, where <code>{region}</code> is the same as the region hosting the Lambda function, <code>path</code> indicates that the remaining substring in the URI should be treated as the path to the resource, including the initial <code>/</code>. For Lambda functions, this is usually of the form <code>/2015-03-31/functions/\[FunctionARN\]/invocations</code>.</p>
192    pub fn set_authorizer_uri(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
193        self.inner = self.inner.set_authorizer_uri(input);
194        self
195    }
196    /// <p>Specifies the authorizer's Uniform Resource Identifier (URI). For <code>TOKEN</code> or <code>REQUEST</code> authorizers, this must be a well-formed Lambda function URI, for example, <code>arn:aws:apigateway:us-west-2:lambda:path/2015-03-31/functions/arn:aws:lambda:us-west-2:{account_id}:function:{lambda_function_name}/invocations</code>. In general, the URI has this form <code>arn:aws:apigateway:{region}:lambda:path/{service_api}</code>, where <code>{region}</code> is the same as the region hosting the Lambda function, <code>path</code> indicates that the remaining substring in the URI should be treated as the path to the resource, including the initial <code>/</code>. For Lambda functions, this is usually of the form <code>/2015-03-31/functions/\[FunctionARN\]/invocations</code>.</p>
197    pub fn get_authorizer_uri(&self) -> &::std::option::Option<::std::string::String> {
198        self.inner.get_authorizer_uri()
199    }
200    /// <p>Specifies the required credentials as an IAM role for API Gateway to invoke the authorizer. To specify an IAM role for API Gateway to assume, use the role's Amazon Resource Name (ARN). To use resource-based permissions on the Lambda function, specify null.</p>
201    pub fn authorizer_credentials(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
202        self.inner = self.inner.authorizer_credentials(input.into());
203        self
204    }
205    /// <p>Specifies the required credentials as an IAM role for API Gateway to invoke the authorizer. To specify an IAM role for API Gateway to assume, use the role's Amazon Resource Name (ARN). To use resource-based permissions on the Lambda function, specify null.</p>
206    pub fn set_authorizer_credentials(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
207        self.inner = self.inner.set_authorizer_credentials(input);
208        self
209    }
210    /// <p>Specifies the required credentials as an IAM role for API Gateway to invoke the authorizer. To specify an IAM role for API Gateway to assume, use the role's Amazon Resource Name (ARN). To use resource-based permissions on the Lambda function, specify null.</p>
211    pub fn get_authorizer_credentials(&self) -> &::std::option::Option<::std::string::String> {
212        self.inner.get_authorizer_credentials()
213    }
214    /// <p>The identity source for which authorization is requested. For a <code>TOKEN</code> or <code>COGNITO_USER_POOLS</code> authorizer, this is required and specifies the request header mapping expression for the custom header holding the authorization token submitted by the client. For example, if the token header name is <code>Auth</code>, the header mapping expression is <code>method.request.header.Auth</code>. For the <code>REQUEST</code> authorizer, this is required when authorization caching is enabled. The value is a comma-separated string of one or more mapping expressions of the specified request parameters. For example, if an <code>Auth</code> header, a <code>Name</code> query string parameter are defined as identity sources, this value is <code>method.request.header.Auth, method.request.querystring.Name</code>. These parameters will be used to derive the authorization caching key and to perform runtime validation of the <code>REQUEST</code> authorizer by verifying all of the identity-related request parameters are present, not null and non-empty. Only when this is true does the authorizer invoke the authorizer Lambda function, otherwise, it returns a 401 Unauthorized response without calling the Lambda function. The valid value is a string of comma-separated mapping expressions of the specified request parameters. When the authorization caching is not enabled, this property is optional.</p>
215    pub fn identity_source(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
216        self.inner = self.inner.identity_source(input.into());
217        self
218    }
219    /// <p>The identity source for which authorization is requested. For a <code>TOKEN</code> or <code>COGNITO_USER_POOLS</code> authorizer, this is required and specifies the request header mapping expression for the custom header holding the authorization token submitted by the client. For example, if the token header name is <code>Auth</code>, the header mapping expression is <code>method.request.header.Auth</code>. For the <code>REQUEST</code> authorizer, this is required when authorization caching is enabled. The value is a comma-separated string of one or more mapping expressions of the specified request parameters. For example, if an <code>Auth</code> header, a <code>Name</code> query string parameter are defined as identity sources, this value is <code>method.request.header.Auth, method.request.querystring.Name</code>. These parameters will be used to derive the authorization caching key and to perform runtime validation of the <code>REQUEST</code> authorizer by verifying all of the identity-related request parameters are present, not null and non-empty. Only when this is true does the authorizer invoke the authorizer Lambda function, otherwise, it returns a 401 Unauthorized response without calling the Lambda function. The valid value is a string of comma-separated mapping expressions of the specified request parameters. When the authorization caching is not enabled, this property is optional.</p>
220    pub fn set_identity_source(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
221        self.inner = self.inner.set_identity_source(input);
222        self
223    }
224    /// <p>The identity source for which authorization is requested. For a <code>TOKEN</code> or <code>COGNITO_USER_POOLS</code> authorizer, this is required and specifies the request header mapping expression for the custom header holding the authorization token submitted by the client. For example, if the token header name is <code>Auth</code>, the header mapping expression is <code>method.request.header.Auth</code>. For the <code>REQUEST</code> authorizer, this is required when authorization caching is enabled. The value is a comma-separated string of one or more mapping expressions of the specified request parameters. For example, if an <code>Auth</code> header, a <code>Name</code> query string parameter are defined as identity sources, this value is <code>method.request.header.Auth, method.request.querystring.Name</code>. These parameters will be used to derive the authorization caching key and to perform runtime validation of the <code>REQUEST</code> authorizer by verifying all of the identity-related request parameters are present, not null and non-empty. Only when this is true does the authorizer invoke the authorizer Lambda function, otherwise, it returns a 401 Unauthorized response without calling the Lambda function. The valid value is a string of comma-separated mapping expressions of the specified request parameters. When the authorization caching is not enabled, this property is optional.</p>
225    pub fn get_identity_source(&self) -> &::std::option::Option<::std::string::String> {
226        self.inner.get_identity_source()
227    }
228    /// <p>A validation expression for the incoming identity token. For <code>TOKEN</code> authorizers, this value is a regular expression. For <code>COGNITO_USER_POOLS</code> authorizers, API Gateway will match the <code>aud</code> field of the incoming token from the client against the specified regular expression. It will invoke the authorizer's Lambda function when there is a match. Otherwise, it will return a 401 Unauthorized response without calling the Lambda function. The validation expression does not apply to the <code>REQUEST</code> authorizer.</p>
229    pub fn identity_validation_expression(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
230        self.inner = self.inner.identity_validation_expression(input.into());
231        self
232    }
233    /// <p>A validation expression for the incoming identity token. For <code>TOKEN</code> authorizers, this value is a regular expression. For <code>COGNITO_USER_POOLS</code> authorizers, API Gateway will match the <code>aud</code> field of the incoming token from the client against the specified regular expression. It will invoke the authorizer's Lambda function when there is a match. Otherwise, it will return a 401 Unauthorized response without calling the Lambda function. The validation expression does not apply to the <code>REQUEST</code> authorizer.</p>
234    pub fn set_identity_validation_expression(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
235        self.inner = self.inner.set_identity_validation_expression(input);
236        self
237    }
238    /// <p>A validation expression for the incoming identity token. For <code>TOKEN</code> authorizers, this value is a regular expression. For <code>COGNITO_USER_POOLS</code> authorizers, API Gateway will match the <code>aud</code> field of the incoming token from the client against the specified regular expression. It will invoke the authorizer's Lambda function when there is a match. Otherwise, it will return a 401 Unauthorized response without calling the Lambda function. The validation expression does not apply to the <code>REQUEST</code> authorizer.</p>
239    pub fn get_identity_validation_expression(&self) -> &::std::option::Option<::std::string::String> {
240        self.inner.get_identity_validation_expression()
241    }
242    /// <p>The TTL in seconds of cached authorizer results. If it equals 0, authorization caching is disabled. If it is greater than 0, API Gateway will cache authorizer responses. If this field is not set, the default value is 300. The maximum value is 3600, or 1 hour.</p>
243    pub fn authorizer_result_ttl_in_seconds(mut self, input: i32) -> Self {
244        self.inner = self.inner.authorizer_result_ttl_in_seconds(input);
245        self
246    }
247    /// <p>The TTL in seconds of cached authorizer results. If it equals 0, authorization caching is disabled. If it is greater than 0, API Gateway will cache authorizer responses. If this field is not set, the default value is 300. The maximum value is 3600, or 1 hour.</p>
248    pub fn set_authorizer_result_ttl_in_seconds(mut self, input: ::std::option::Option<i32>) -> Self {
249        self.inner = self.inner.set_authorizer_result_ttl_in_seconds(input);
250        self
251    }
252    /// <p>The TTL in seconds of cached authorizer results. If it equals 0, authorization caching is disabled. If it is greater than 0, API Gateway will cache authorizer responses. If this field is not set, the default value is 300. The maximum value is 3600, or 1 hour.</p>
253    pub fn get_authorizer_result_ttl_in_seconds(&self) -> &::std::option::Option<i32> {
254        self.inner.get_authorizer_result_ttl_in_seconds()
255    }
256}