aws-sdk-accessanalyzer 1.106.0

AWS SDK for Access Analyzer
Documentation
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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.

/// <p>Contains information about a finding.</p>
#[non_exhaustive]
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)]
pub struct Finding {
    /// <p>The ID of the finding.</p>
    pub id: ::std::string::String,
    /// <p>The external principal that has access to a resource within the zone of trust.</p>
    pub principal: ::std::option::Option<::std::collections::HashMap<::std::string::String, ::std::string::String>>,
    /// <p>The action in the analyzed policy statement that an external principal has permission to use.</p>
    pub action: ::std::option::Option<::std::vec::Vec<::std::string::String>>,
    /// <p>The resource that an external principal has access to.</p>
    pub resource: ::std::option::Option<::std::string::String>,
    /// <p>Indicates whether the policy that generated the finding allows public access to the resource.</p>
    pub is_public: ::std::option::Option<bool>,
    /// <p>The type of the resource identified in the finding.</p>
    pub resource_type: crate::types::ResourceType,
    /// <p>The condition in the analyzed policy statement that resulted in a finding.</p>
    pub condition: ::std::collections::HashMap<::std::string::String, ::std::string::String>,
    /// <p>The time at which the finding was generated.</p>
    pub created_at: ::aws_smithy_types::DateTime,
    /// <p>The time at which the resource was analyzed.</p>
    pub analyzed_at: ::aws_smithy_types::DateTime,
    /// <p>The time at which the finding was updated.</p>
    pub updated_at: ::aws_smithy_types::DateTime,
    /// <p>The current status of the finding.</p>
    pub status: crate::types::FindingStatus,
    /// <p>The Amazon Web Services account ID that owns the resource.</p>
    pub resource_owner_account: ::std::string::String,
    /// <p>An error.</p>
    pub error: ::std::option::Option<::std::string::String>,
    /// <p>The sources of the finding. This indicates how the access that generated the finding is granted. It is populated for Amazon S3 bucket findings.</p>
    pub sources: ::std::option::Option<::std::vec::Vec<crate::types::FindingSource>>,
    /// <p>The type of restriction applied to the finding by the resource owner with an Organizations resource control policy (RCP).</p>
    pub resource_control_policy_restriction: ::std::option::Option<crate::types::ResourceControlPolicyRestriction>,
}
impl Finding {
    /// <p>The ID of the finding.</p>
    pub fn id(&self) -> &str {
        use std::ops::Deref;
        self.id.deref()
    }
    /// <p>The external principal that has access to a resource within the zone of trust.</p>
    pub fn principal(&self) -> ::std::option::Option<&::std::collections::HashMap<::std::string::String, ::std::string::String>> {
        self.principal.as_ref()
    }
    /// <p>The action in the analyzed policy statement that an external principal has permission to use.</p>
    ///
    /// If no value was sent for this field, a default will be set. If you want to determine if no value was sent, use `.action.is_none()`.
    pub fn action(&self) -> &[::std::string::String] {
        self.action.as_deref().unwrap_or_default()
    }
    /// <p>The resource that an external principal has access to.</p>
    pub fn resource(&self) -> ::std::option::Option<&str> {
        self.resource.as_deref()
    }
    /// <p>Indicates whether the policy that generated the finding allows public access to the resource.</p>
    pub fn is_public(&self) -> ::std::option::Option<bool> {
        self.is_public
    }
    /// <p>The type of the resource identified in the finding.</p>
    pub fn resource_type(&self) -> &crate::types::ResourceType {
        &self.resource_type
    }
    /// <p>The condition in the analyzed policy statement that resulted in a finding.</p>
    pub fn condition(&self) -> &::std::collections::HashMap<::std::string::String, ::std::string::String> {
        &self.condition
    }
    /// <p>The time at which the finding was generated.</p>
    pub fn created_at(&self) -> &::aws_smithy_types::DateTime {
        &self.created_at
    }
    /// <p>The time at which the resource was analyzed.</p>
    pub fn analyzed_at(&self) -> &::aws_smithy_types::DateTime {
        &self.analyzed_at
    }
    /// <p>The time at which the finding was updated.</p>
    pub fn updated_at(&self) -> &::aws_smithy_types::DateTime {
        &self.updated_at
    }
    /// <p>The current status of the finding.</p>
    pub fn status(&self) -> &crate::types::FindingStatus {
        &self.status
    }
    /// <p>The Amazon Web Services account ID that owns the resource.</p>
    pub fn resource_owner_account(&self) -> &str {
        use std::ops::Deref;
        self.resource_owner_account.deref()
    }
    /// <p>An error.</p>
    pub fn error(&self) -> ::std::option::Option<&str> {
        self.error.as_deref()
    }
    /// <p>The sources of the finding. This indicates how the access that generated the finding is granted. It is populated for Amazon S3 bucket findings.</p>
    ///
    /// If no value was sent for this field, a default will be set. If you want to determine if no value was sent, use `.sources.is_none()`.
    pub fn sources(&self) -> &[crate::types::FindingSource] {
        self.sources.as_deref().unwrap_or_default()
    }
    /// <p>The type of restriction applied to the finding by the resource owner with an Organizations resource control policy (RCP).</p>
    pub fn resource_control_policy_restriction(&self) -> ::std::option::Option<&crate::types::ResourceControlPolicyRestriction> {
        self.resource_control_policy_restriction.as_ref()
    }
}
impl Finding {
    /// Creates a new builder-style object to manufacture [`Finding`](crate::types::Finding).
    pub fn builder() -> crate::types::builders::FindingBuilder {
        crate::types::builders::FindingBuilder::default()
    }
}

/// A builder for [`Finding`](crate::types::Finding).
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
#[non_exhaustive]
pub struct FindingBuilder {
    pub(crate) id: ::std::option::Option<::std::string::String>,
    pub(crate) principal: ::std::option::Option<::std::collections::HashMap<::std::string::String, ::std::string::String>>,
    pub(crate) action: ::std::option::Option<::std::vec::Vec<::std::string::String>>,
    pub(crate) resource: ::std::option::Option<::std::string::String>,
    pub(crate) is_public: ::std::option::Option<bool>,
    pub(crate) resource_type: ::std::option::Option<crate::types::ResourceType>,
    pub(crate) condition: ::std::option::Option<::std::collections::HashMap<::std::string::String, ::std::string::String>>,
    pub(crate) created_at: ::std::option::Option<::aws_smithy_types::DateTime>,
    pub(crate) analyzed_at: ::std::option::Option<::aws_smithy_types::DateTime>,
    pub(crate) updated_at: ::std::option::Option<::aws_smithy_types::DateTime>,
    pub(crate) status: ::std::option::Option<crate::types::FindingStatus>,
    pub(crate) resource_owner_account: ::std::option::Option<::std::string::String>,
    pub(crate) error: ::std::option::Option<::std::string::String>,
    pub(crate) sources: ::std::option::Option<::std::vec::Vec<crate::types::FindingSource>>,
    pub(crate) resource_control_policy_restriction: ::std::option::Option<crate::types::ResourceControlPolicyRestriction>,
}
impl FindingBuilder {
    /// <p>The ID of the finding.</p>
    /// This field is required.
    pub fn id(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
        self.id = ::std::option::Option::Some(input.into());
        self
    }
    /// <p>The ID of the finding.</p>
    pub fn set_id(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
        self.id = input;
        self
    }
    /// <p>The ID of the finding.</p>
    pub fn get_id(&self) -> &::std::option::Option<::std::string::String> {
        &self.id
    }
    /// Adds a key-value pair to `principal`.
    ///
    /// To override the contents of this collection use [`set_principal`](Self::set_principal).
    ///
    /// <p>The external principal that has access to a resource within the zone of trust.</p>
    pub fn principal(mut self, k: impl ::std::convert::Into<::std::string::String>, v: impl ::std::convert::Into<::std::string::String>) -> Self {
        let mut hash_map = self.principal.unwrap_or_default();
        hash_map.insert(k.into(), v.into());
        self.principal = ::std::option::Option::Some(hash_map);
        self
    }
    /// <p>The external principal that has access to a resource within the zone of trust.</p>
    pub fn set_principal(mut self, input: ::std::option::Option<::std::collections::HashMap<::std::string::String, ::std::string::String>>) -> Self {
        self.principal = input;
        self
    }
    /// <p>The external principal that has access to a resource within the zone of trust.</p>
    pub fn get_principal(&self) -> &::std::option::Option<::std::collections::HashMap<::std::string::String, ::std::string::String>> {
        &self.principal
    }
    /// Appends an item to `action`.
    ///
    /// To override the contents of this collection use [`set_action`](Self::set_action).
    ///
    /// <p>The action in the analyzed policy statement that an external principal has permission to use.</p>
    pub fn action(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
        let mut v = self.action.unwrap_or_default();
        v.push(input.into());
        self.action = ::std::option::Option::Some(v);
        self
    }
    /// <p>The action in the analyzed policy statement that an external principal has permission to use.</p>
    pub fn set_action(mut self, input: ::std::option::Option<::std::vec::Vec<::std::string::String>>) -> Self {
        self.action = input;
        self
    }
    /// <p>The action in the analyzed policy statement that an external principal has permission to use.</p>
    pub fn get_action(&self) -> &::std::option::Option<::std::vec::Vec<::std::string::String>> {
        &self.action
    }
    /// <p>The resource that an external principal has access to.</p>
    pub fn resource(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
        self.resource = ::std::option::Option::Some(input.into());
        self
    }
    /// <p>The resource that an external principal has access to.</p>
    pub fn set_resource(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
        self.resource = input;
        self
    }
    /// <p>The resource that an external principal has access to.</p>
    pub fn get_resource(&self) -> &::std::option::Option<::std::string::String> {
        &self.resource
    }
    /// <p>Indicates whether the policy that generated the finding allows public access to the resource.</p>
    pub fn is_public(mut self, input: bool) -> Self {
        self.is_public = ::std::option::Option::Some(input);
        self
    }
    /// <p>Indicates whether the policy that generated the finding allows public access to the resource.</p>
    pub fn set_is_public(mut self, input: ::std::option::Option<bool>) -> Self {
        self.is_public = input;
        self
    }
    /// <p>Indicates whether the policy that generated the finding allows public access to the resource.</p>
    pub fn get_is_public(&self) -> &::std::option::Option<bool> {
        &self.is_public
    }
    /// <p>The type of the resource identified in the finding.</p>
    /// This field is required.
    pub fn resource_type(mut self, input: crate::types::ResourceType) -> Self {
        self.resource_type = ::std::option::Option::Some(input);
        self
    }
    /// <p>The type of the resource identified in the finding.</p>
    pub fn set_resource_type(mut self, input: ::std::option::Option<crate::types::ResourceType>) -> Self {
        self.resource_type = input;
        self
    }
    /// <p>The type of the resource identified in the finding.</p>
    pub fn get_resource_type(&self) -> &::std::option::Option<crate::types::ResourceType> {
        &self.resource_type
    }
    /// Adds a key-value pair to `condition`.
    ///
    /// To override the contents of this collection use [`set_condition`](Self::set_condition).
    ///
    /// <p>The condition in the analyzed policy statement that resulted in a finding.</p>
    pub fn condition(mut self, k: impl ::std::convert::Into<::std::string::String>, v: impl ::std::convert::Into<::std::string::String>) -> Self {
        let mut hash_map = self.condition.unwrap_or_default();
        hash_map.insert(k.into(), v.into());
        self.condition = ::std::option::Option::Some(hash_map);
        self
    }
    /// <p>The condition in the analyzed policy statement that resulted in a finding.</p>
    pub fn set_condition(mut self, input: ::std::option::Option<::std::collections::HashMap<::std::string::String, ::std::string::String>>) -> Self {
        self.condition = input;
        self
    }
    /// <p>The condition in the analyzed policy statement that resulted in a finding.</p>
    pub fn get_condition(&self) -> &::std::option::Option<::std::collections::HashMap<::std::string::String, ::std::string::String>> {
        &self.condition
    }
    /// <p>The time at which the finding was generated.</p>
    /// This field is required.
    pub fn created_at(mut self, input: ::aws_smithy_types::DateTime) -> Self {
        self.created_at = ::std::option::Option::Some(input);
        self
    }
    /// <p>The time at which the finding was generated.</p>
    pub fn set_created_at(mut self, input: ::std::option::Option<::aws_smithy_types::DateTime>) -> Self {
        self.created_at = input;
        self
    }
    /// <p>The time at which the finding was generated.</p>
    pub fn get_created_at(&self) -> &::std::option::Option<::aws_smithy_types::DateTime> {
        &self.created_at
    }
    /// <p>The time at which the resource was analyzed.</p>
    /// This field is required.
    pub fn analyzed_at(mut self, input: ::aws_smithy_types::DateTime) -> Self {
        self.analyzed_at = ::std::option::Option::Some(input);
        self
    }
    /// <p>The time at which the resource was analyzed.</p>
    pub fn set_analyzed_at(mut self, input: ::std::option::Option<::aws_smithy_types::DateTime>) -> Self {
        self.analyzed_at = input;
        self
    }
    /// <p>The time at which the resource was analyzed.</p>
    pub fn get_analyzed_at(&self) -> &::std::option::Option<::aws_smithy_types::DateTime> {
        &self.analyzed_at
    }
    /// <p>The time at which the finding was updated.</p>
    /// This field is required.
    pub fn updated_at(mut self, input: ::aws_smithy_types::DateTime) -> Self {
        self.updated_at = ::std::option::Option::Some(input);
        self
    }
    /// <p>The time at which the finding was updated.</p>
    pub fn set_updated_at(mut self, input: ::std::option::Option<::aws_smithy_types::DateTime>) -> Self {
        self.updated_at = input;
        self
    }
    /// <p>The time at which the finding was updated.</p>
    pub fn get_updated_at(&self) -> &::std::option::Option<::aws_smithy_types::DateTime> {
        &self.updated_at
    }
    /// <p>The current status of the finding.</p>
    /// This field is required.
    pub fn status(mut self, input: crate::types::FindingStatus) -> Self {
        self.status = ::std::option::Option::Some(input);
        self
    }
    /// <p>The current status of the finding.</p>
    pub fn set_status(mut self, input: ::std::option::Option<crate::types::FindingStatus>) -> Self {
        self.status = input;
        self
    }
    /// <p>The current status of the finding.</p>
    pub fn get_status(&self) -> &::std::option::Option<crate::types::FindingStatus> {
        &self.status
    }
    /// <p>The Amazon Web Services account ID that owns the resource.</p>
    /// This field is required.
    pub fn resource_owner_account(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
        self.resource_owner_account = ::std::option::Option::Some(input.into());
        self
    }
    /// <p>The Amazon Web Services account ID that owns the resource.</p>
    pub fn set_resource_owner_account(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
        self.resource_owner_account = input;
        self
    }
    /// <p>The Amazon Web Services account ID that owns the resource.</p>
    pub fn get_resource_owner_account(&self) -> &::std::option::Option<::std::string::String> {
        &self.resource_owner_account
    }
    /// <p>An error.</p>
    pub fn error(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
        self.error = ::std::option::Option::Some(input.into());
        self
    }
    /// <p>An error.</p>
    pub fn set_error(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
        self.error = input;
        self
    }
    /// <p>An error.</p>
    pub fn get_error(&self) -> &::std::option::Option<::std::string::String> {
        &self.error
    }
    /// Appends an item to `sources`.
    ///
    /// To override the contents of this collection use [`set_sources`](Self::set_sources).
    ///
    /// <p>The sources of the finding. This indicates how the access that generated the finding is granted. It is populated for Amazon S3 bucket findings.</p>
    pub fn sources(mut self, input: crate::types::FindingSource) -> Self {
        let mut v = self.sources.unwrap_or_default();
        v.push(input);
        self.sources = ::std::option::Option::Some(v);
        self
    }
    /// <p>The sources of the finding. This indicates how the access that generated the finding is granted. It is populated for Amazon S3 bucket findings.</p>
    pub fn set_sources(mut self, input: ::std::option::Option<::std::vec::Vec<crate::types::FindingSource>>) -> Self {
        self.sources = input;
        self
    }
    /// <p>The sources of the finding. This indicates how the access that generated the finding is granted. It is populated for Amazon S3 bucket findings.</p>
    pub fn get_sources(&self) -> &::std::option::Option<::std::vec::Vec<crate::types::FindingSource>> {
        &self.sources
    }
    /// <p>The type of restriction applied to the finding by the resource owner with an Organizations resource control policy (RCP).</p>
    pub fn resource_control_policy_restriction(mut self, input: crate::types::ResourceControlPolicyRestriction) -> Self {
        self.resource_control_policy_restriction = ::std::option::Option::Some(input);
        self
    }
    /// <p>The type of restriction applied to the finding by the resource owner with an Organizations resource control policy (RCP).</p>
    pub fn set_resource_control_policy_restriction(mut self, input: ::std::option::Option<crate::types::ResourceControlPolicyRestriction>) -> Self {
        self.resource_control_policy_restriction = input;
        self
    }
    /// <p>The type of restriction applied to the finding by the resource owner with an Organizations resource control policy (RCP).</p>
    pub fn get_resource_control_policy_restriction(&self) -> &::std::option::Option<crate::types::ResourceControlPolicyRestriction> {
        &self.resource_control_policy_restriction
    }
    /// Consumes the builder and constructs a [`Finding`](crate::types::Finding).
    /// This method will fail if any of the following fields are not set:
    /// - [`id`](crate::types::builders::FindingBuilder::id)
    /// - [`resource_type`](crate::types::builders::FindingBuilder::resource_type)
    /// - [`condition`](crate::types::builders::FindingBuilder::condition)
    /// - [`created_at`](crate::types::builders::FindingBuilder::created_at)
    /// - [`analyzed_at`](crate::types::builders::FindingBuilder::analyzed_at)
    /// - [`updated_at`](crate::types::builders::FindingBuilder::updated_at)
    /// - [`status`](crate::types::builders::FindingBuilder::status)
    /// - [`resource_owner_account`](crate::types::builders::FindingBuilder::resource_owner_account)
    pub fn build(self) -> ::std::result::Result<crate::types::Finding, ::aws_smithy_types::error::operation::BuildError> {
        ::std::result::Result::Ok(crate::types::Finding {
            id: self.id.ok_or_else(|| {
                ::aws_smithy_types::error::operation::BuildError::missing_field("id", "id was not specified but it is required when building Finding")
            })?,
            principal: self.principal,
            action: self.action,
            resource: self.resource,
            is_public: self.is_public,
            resource_type: self.resource_type.ok_or_else(|| {
                ::aws_smithy_types::error::operation::BuildError::missing_field(
                    "resource_type",
                    "resource_type was not specified but it is required when building Finding",
                )
            })?,
            condition: self.condition.ok_or_else(|| {
                ::aws_smithy_types::error::operation::BuildError::missing_field(
                    "condition",
                    "condition was not specified but it is required when building Finding",
                )
            })?,
            created_at: self.created_at.ok_or_else(|| {
                ::aws_smithy_types::error::operation::BuildError::missing_field(
                    "created_at",
                    "created_at was not specified but it is required when building Finding",
                )
            })?,
            analyzed_at: self.analyzed_at.ok_or_else(|| {
                ::aws_smithy_types::error::operation::BuildError::missing_field(
                    "analyzed_at",
                    "analyzed_at was not specified but it is required when building Finding",
                )
            })?,
            updated_at: self.updated_at.ok_or_else(|| {
                ::aws_smithy_types::error::operation::BuildError::missing_field(
                    "updated_at",
                    "updated_at was not specified but it is required when building Finding",
                )
            })?,
            status: self.status.ok_or_else(|| {
                ::aws_smithy_types::error::operation::BuildError::missing_field(
                    "status",
                    "status was not specified but it is required when building Finding",
                )
            })?,
            resource_owner_account: self.resource_owner_account.ok_or_else(|| {
                ::aws_smithy_types::error::operation::BuildError::missing_field(
                    "resource_owner_account",
                    "resource_owner_account was not specified but it is required when building Finding",
                )
            })?,
            error: self.error,
            sources: self.sources,
            resource_control_policy_restriction: self.resource_control_policy_restriction,
        })
    }
}