aws_sdk_verifiedpermissions/operation/create_policy/
builders.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub use crate::operation::create_policy::_create_policy_output::CreatePolicyOutputBuilder;
3
4pub use crate::operation::create_policy::_create_policy_input::CreatePolicyInputBuilder;
5
6impl crate::operation::create_policy::builders::CreatePolicyInputBuilder {
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_policy::CreatePolicyOutput,
13        ::aws_smithy_runtime_api::client::result::SdkError<
14            crate::operation::create_policy::CreatePolicyError,
15            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
16        >,
17    > {
18        let mut fluent_builder = client.create_policy();
19        fluent_builder.inner = self;
20        fluent_builder.send().await
21    }
22}
23/// Fluent builder constructing a request to `CreatePolicy`.
24///
25/// <p>Creates a Cedar policy and saves it in the specified policy store. You can create either a static policy or a policy linked to a policy template.</p>
26/// <ul>
27/// <li>
28/// <p>To create a static policy, provide the Cedar policy text in the <code>StaticPolicy</code> section of the <code>PolicyDefinition</code>.</p></li>
29/// <li>
30/// <p>To create a policy that is dynamically linked to a policy template, specify the policy template ID and the principal and resource to associate with this policy in the <code>templateLinked</code> section of the <code>PolicyDefinition</code>. If the policy template is ever updated, any policies linked to the policy template automatically use the updated template.</p></li>
31/// </ul><note>
32/// <p>Creating a policy causes it to be validated against the schema in the policy store. If the policy doesn't pass validation, the operation fails and the policy isn't stored.</p>
33/// </note> <note>
34/// <p>Verified Permissions is <i> <a href="https://wikipedia.org/wiki/Eventual_consistency">eventually consistent</a> </i>. It can take a few seconds for a new or changed element to propagate through the service and be visible in the results of other Verified Permissions operations.</p>
35/// </note>
36#[derive(::std::clone::Clone, ::std::fmt::Debug)]
37pub struct CreatePolicyFluentBuilder {
38    handle: ::std::sync::Arc<crate::client::Handle>,
39    inner: crate::operation::create_policy::builders::CreatePolicyInputBuilder,
40    config_override: ::std::option::Option<crate::config::Builder>,
41}
42impl
43    crate::client::customize::internal::CustomizableSend<
44        crate::operation::create_policy::CreatePolicyOutput,
45        crate::operation::create_policy::CreatePolicyError,
46    > for CreatePolicyFluentBuilder
47{
48    fn send(
49        self,
50        config_override: crate::config::Builder,
51    ) -> crate::client::customize::internal::BoxFuture<
52        crate::client::customize::internal::SendResult<
53            crate::operation::create_policy::CreatePolicyOutput,
54            crate::operation::create_policy::CreatePolicyError,
55        >,
56    > {
57        ::std::boxed::Box::pin(async move { self.config_override(config_override).send().await })
58    }
59}
60impl CreatePolicyFluentBuilder {
61    /// Creates a new `CreatePolicyFluentBuilder`.
62    pub(crate) fn new(handle: ::std::sync::Arc<crate::client::Handle>) -> Self {
63        Self {
64            handle,
65            inner: ::std::default::Default::default(),
66            config_override: ::std::option::Option::None,
67        }
68    }
69    /// Access the CreatePolicy as a reference.
70    pub fn as_input(&self) -> &crate::operation::create_policy::builders::CreatePolicyInputBuilder {
71        &self.inner
72    }
73    /// Sends the request and returns the response.
74    ///
75    /// If an error occurs, an `SdkError` will be returned with additional details that
76    /// can be matched against.
77    ///
78    /// By default, any retryable failures will be retried twice. Retry behavior
79    /// is configurable with the [RetryConfig](aws_smithy_types::retry::RetryConfig), which can be
80    /// set when configuring the client.
81    pub async fn send(
82        self,
83    ) -> ::std::result::Result<
84        crate::operation::create_policy::CreatePolicyOutput,
85        ::aws_smithy_runtime_api::client::result::SdkError<
86            crate::operation::create_policy::CreatePolicyError,
87            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
88        >,
89    > {
90        let input = self
91            .inner
92            .build()
93            .map_err(::aws_smithy_runtime_api::client::result::SdkError::construction_failure)?;
94        let runtime_plugins = crate::operation::create_policy::CreatePolicy::operation_runtime_plugins(
95            self.handle.runtime_plugins.clone(),
96            &self.handle.conf,
97            self.config_override,
98        );
99        crate::operation::create_policy::CreatePolicy::orchestrate(&runtime_plugins, input).await
100    }
101
102    /// Consumes this builder, creating a customizable operation that can be modified before being sent.
103    pub fn customize(
104        self,
105    ) -> crate::client::customize::CustomizableOperation<
106        crate::operation::create_policy::CreatePolicyOutput,
107        crate::operation::create_policy::CreatePolicyError,
108        Self,
109    > {
110        crate::client::customize::CustomizableOperation::new(self)
111    }
112    pub(crate) fn config_override(mut self, config_override: impl ::std::convert::Into<crate::config::Builder>) -> Self {
113        self.set_config_override(::std::option::Option::Some(config_override.into()));
114        self
115    }
116
117    pub(crate) fn set_config_override(&mut self, config_override: ::std::option::Option<crate::config::Builder>) -> &mut Self {
118        self.config_override = config_override;
119        self
120    }
121    /// <p>Specifies a unique, case-sensitive ID that you provide to ensure the idempotency of the request. This lets you safely retry the request without accidentally performing the same operation a second time. Passing the same value to a later call to an operation requires that you also pass the same value for all other parameters. We recommend that you use a <a href="https://wikipedia.org/wiki/Universally_unique_identifier">UUID type of value.</a>.</p>
122    /// <p>If you don't provide this value, then Amazon Web Services generates a random one for you.</p>
123    /// <p>If you retry the operation with the same <code>ClientToken</code>, but with different parameters, the retry fails with an <code>ConflictException</code> error.</p>
124    /// <p>Verified Permissions recognizes a <code>ClientToken</code> for eight hours. After eight hours, the next request with the same parameters performs the operation again regardless of the value of <code>ClientToken</code>.</p>
125    pub fn client_token(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
126        self.inner = self.inner.client_token(input.into());
127        self
128    }
129    /// <p>Specifies a unique, case-sensitive ID that you provide to ensure the idempotency of the request. This lets you safely retry the request without accidentally performing the same operation a second time. Passing the same value to a later call to an operation requires that you also pass the same value for all other parameters. We recommend that you use a <a href="https://wikipedia.org/wiki/Universally_unique_identifier">UUID type of value.</a>.</p>
130    /// <p>If you don't provide this value, then Amazon Web Services generates a random one for you.</p>
131    /// <p>If you retry the operation with the same <code>ClientToken</code>, but with different parameters, the retry fails with an <code>ConflictException</code> error.</p>
132    /// <p>Verified Permissions recognizes a <code>ClientToken</code> for eight hours. After eight hours, the next request with the same parameters performs the operation again regardless of the value of <code>ClientToken</code>.</p>
133    pub fn set_client_token(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
134        self.inner = self.inner.set_client_token(input);
135        self
136    }
137    /// <p>Specifies a unique, case-sensitive ID that you provide to ensure the idempotency of the request. This lets you safely retry the request without accidentally performing the same operation a second time. Passing the same value to a later call to an operation requires that you also pass the same value for all other parameters. We recommend that you use a <a href="https://wikipedia.org/wiki/Universally_unique_identifier">UUID type of value.</a>.</p>
138    /// <p>If you don't provide this value, then Amazon Web Services generates a random one for you.</p>
139    /// <p>If you retry the operation with the same <code>ClientToken</code>, but with different parameters, the retry fails with an <code>ConflictException</code> error.</p>
140    /// <p>Verified Permissions recognizes a <code>ClientToken</code> for eight hours. After eight hours, the next request with the same parameters performs the operation again regardless of the value of <code>ClientToken</code>.</p>
141    pub fn get_client_token(&self) -> &::std::option::Option<::std::string::String> {
142        self.inner.get_client_token()
143    }
144    /// <p>Specifies the <code>PolicyStoreId</code> of the policy store you want to store the policy in.</p>
145    pub fn policy_store_id(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
146        self.inner = self.inner.policy_store_id(input.into());
147        self
148    }
149    /// <p>Specifies the <code>PolicyStoreId</code> of the policy store you want to store the policy in.</p>
150    pub fn set_policy_store_id(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
151        self.inner = self.inner.set_policy_store_id(input);
152        self
153    }
154    /// <p>Specifies the <code>PolicyStoreId</code> of the policy store you want to store the policy in.</p>
155    pub fn get_policy_store_id(&self) -> &::std::option::Option<::std::string::String> {
156        self.inner.get_policy_store_id()
157    }
158    /// <p>A structure that specifies the policy type and content to use for the new policy. You must include either a static or a templateLinked element. The policy content must be written in the Cedar policy language.</p>
159    pub fn definition(mut self, input: crate::types::PolicyDefinition) -> Self {
160        self.inner = self.inner.definition(input);
161        self
162    }
163    /// <p>A structure that specifies the policy type and content to use for the new policy. You must include either a static or a templateLinked element. The policy content must be written in the Cedar policy language.</p>
164    pub fn set_definition(mut self, input: ::std::option::Option<crate::types::PolicyDefinition>) -> Self {
165        self.inner = self.inner.set_definition(input);
166        self
167    }
168    /// <p>A structure that specifies the policy type and content to use for the new policy. You must include either a static or a templateLinked element. The policy content must be written in the Cedar policy language.</p>
169    pub fn get_definition(&self) -> &::std::option::Option<crate::types::PolicyDefinition> {
170        self.inner.get_definition()
171    }
172}