aws-sdk-agentdiscovery 1.1.0

AWS SDK for Agent Discovery
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
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
pub use ::aws_smithy_runtime_api::client::endpoint::EndpointFuture;
pub use ::aws_smithy_runtime_api::client::endpoint::SharedEndpointResolver;
pub use ::aws_smithy_types::endpoint::Endpoint;

/// Interceptor that tracks endpoint override business metric.
#[derive(Debug, Default)]
pub(crate) struct EndpointOverrideFeatureTrackerInterceptor;

#[::aws_smithy_runtime_api::client::interceptors::dyn_dispatch_hint]
impl ::aws_smithy_runtime_api::client::interceptors::Intercept for EndpointOverrideFeatureTrackerInterceptor {
    fn name(&self) -> &'static str {
        "EndpointOverrideFeatureTrackerInterceptor"
    }

    fn read_before_execution(
        &self,
        _context: &::aws_smithy_runtime_api::client::interceptors::context::BeforeSerializationInterceptorContextRef<'_>,
        cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
    ) -> ::std::result::Result<(), ::aws_smithy_runtime_api::box_error::BoxError> {
        if cfg.load::<::aws_types::endpoint_config::EndpointUrl>().is_some() {
            cfg.interceptor_state()
                .store_append(::aws_runtime::sdk_feature::AwsSdkFeature::EndpointOverride);
        }
        ::std::result::Result::Ok(())
    }
}

#[cfg(test)]
mod test {

    /// us-east-1 resolves to its own Regional endpoint and signs for us-east-1
    #[test]
    fn test_1() {
        let params = crate::config::endpoint::Params::builder()
            .region("us-east-1".to_string())
            .use_fips(false)
            .use_dual_stack(false)
            .build_without_validators()
            .expect("invalid params");
        let resolver = crate::config::endpoint::DefaultResolver::new();
        let endpoint = resolver.resolve_endpoint(&params);
        let endpoint = endpoint.expect("Expected valid endpoint: https://agent-discovery.us-east-1.api.aws");
        assert_eq!(
            endpoint,
            ::aws_smithy_types::endpoint::Endpoint::builder()
                .url("https://agent-discovery.us-east-1.api.aws")
                .auth_scheme(
                    ::aws_smithy_types::endpoint::EndpointAuthScheme::with_capacity("sigv4", 2)
                        .put("signingName", "agent-discovery".to_string())
                        .put("signingRegion", "us-east-1".to_string())
                )
                .build()
        );
    }

    /// ap-northeast-1 resolves to its own Regional endpoint and signs for ap-northeast-1
    #[test]
    fn test_2() {
        let params = crate::config::endpoint::Params::builder()
            .region("ap-northeast-1".to_string())
            .use_fips(false)
            .use_dual_stack(false)
            .build_without_validators()
            .expect("invalid params");
        let resolver = crate::config::endpoint::DefaultResolver::new();
        let endpoint = resolver.resolve_endpoint(&params);
        let endpoint = endpoint.expect("Expected valid endpoint: https://agent-discovery.ap-northeast-1.api.aws");
        assert_eq!(
            endpoint,
            ::aws_smithy_types::endpoint::Endpoint::builder()
                .url("https://agent-discovery.ap-northeast-1.api.aws")
                .auth_scheme(
                    ::aws_smithy_types::endpoint::EndpointAuthScheme::with_capacity("sigv4", 2)
                        .put("signingName", "agent-discovery".to_string())
                        .put("signingRegion", "ap-northeast-1".to_string())
                )
                .build()
        );
    }

    /// An aws Region where Agent Discovery doesn't serve gets the standard pattern, not another Region's endpoint
    #[test]
    fn test_3() {
        let params = crate::config::endpoint::Params::builder()
            .region("us-west-2".to_string())
            .use_fips(false)
            .use_dual_stack(false)
            .build_without_validators()
            .expect("invalid params");
        let resolver = crate::config::endpoint::DefaultResolver::new();
        let endpoint = resolver.resolve_endpoint(&params);
        let endpoint = endpoint.expect("Expected valid endpoint: https://agent-discovery.us-west-2.amazonaws.com");
        assert_eq!(
            endpoint,
            ::aws_smithy_types::endpoint::Endpoint::builder()
                .url("https://agent-discovery.us-west-2.amazonaws.com")
                .build()
        );
    }

    /// eu-west-1 resolves to its own Regional endpoint and signs for eu-west-1
    #[test]
    fn test_4() {
        let params = crate::config::endpoint::Params::builder()
            .region("eu-west-1".to_string())
            .build_without_validators()
            .expect("invalid params");
        let resolver = crate::config::endpoint::DefaultResolver::new();
        let endpoint = resolver.resolve_endpoint(&params);
        let endpoint = endpoint.expect("Expected valid endpoint: https://agent-discovery.eu-west-1.api.aws");
        assert_eq!(
            endpoint,
            ::aws_smithy_types::endpoint::Endpoint::builder()
                .url("https://agent-discovery.eu-west-1.api.aws")
                .auth_scheme(
                    ::aws_smithy_types::endpoint::EndpointAuthScheme::with_capacity("sigv4", 2)
                        .put("signingName", "agent-discovery".to_string())
                        .put("signingRegion", "eu-west-1".to_string())
                )
                .build()
        );
    }

    /// A Region in the aws-cn partition gets the standard Regional pattern
    #[test]
    fn test_5() {
        let params = crate::config::endpoint::Params::builder()
            .region("cn-north-1".to_string())
            .use_fips(false)
            .use_dual_stack(false)
            .build_without_validators()
            .expect("invalid params");
        let resolver = crate::config::endpoint::DefaultResolver::new();
        let endpoint = resolver.resolve_endpoint(&params);
        let endpoint = endpoint.expect("Expected valid endpoint: https://agent-discovery.cn-north-1.amazonaws.com.cn");
        assert_eq!(
            endpoint,
            ::aws_smithy_types::endpoint::Endpoint::builder()
                .url("https://agent-discovery.cn-north-1.amazonaws.com.cn")
                .build()
        );
    }

    /// A Region in the aws-us-gov partition gets the standard Regional pattern, not the commercial global endpoint
    #[test]
    fn test_6() {
        let params = crate::config::endpoint::Params::builder()
            .region("us-gov-west-1".to_string())
            .use_fips(false)
            .use_dual_stack(false)
            .build_without_validators()
            .expect("invalid params");
        let resolver = crate::config::endpoint::DefaultResolver::new();
        let endpoint = resolver.resolve_endpoint(&params);
        let endpoint = endpoint.expect("Expected valid endpoint: https://agent-discovery.us-gov-west-1.amazonaws.com");
        assert_eq!(
            endpoint,
            ::aws_smithy_types::endpoint::Endpoint::builder()
                .url("https://agent-discovery.us-gov-west-1.amazonaws.com")
                .build()
        );
    }

    /// FIPS is an error
    #[test]
    fn test_7() {
        let params = crate::config::endpoint::Params::builder()
            .region("us-east-1".to_string())
            .use_fips(true)
            .use_dual_stack(false)
            .build_without_validators()
            .expect("invalid params");
        let resolver = crate::config::endpoint::DefaultResolver::new();
        let endpoint = resolver.resolve_endpoint(&params);
        let error = endpoint.expect_err("expected error: FIPS is enabled but Agent Discovery does not have a FIPS endpoint [FIPS is an error]");
        assert_eq!(format!("{}", error), "FIPS is enabled but Agent Discovery does not have a FIPS endpoint")
    }

    /// Dual-stack resolves to the same Regional endpoint, which is already dual-stack
    #[test]
    fn test_8() {
        let params = crate::config::endpoint::Params::builder()
            .region("us-east-1".to_string())
            .use_fips(false)
            .use_dual_stack(true)
            .build_without_validators()
            .expect("invalid params");
        let resolver = crate::config::endpoint::DefaultResolver::new();
        let endpoint = resolver.resolve_endpoint(&params);
        let endpoint = endpoint.expect("Expected valid endpoint: https://agent-discovery.us-east-1.api.aws");
        assert_eq!(
            endpoint,
            ::aws_smithy_types::endpoint::Endpoint::builder()
                .url("https://agent-discovery.us-east-1.api.aws")
                .auth_scheme(
                    ::aws_smithy_types::endpoint::EndpointAuthScheme::with_capacity("sigv4", 2)
                        .put("signingName", "agent-discovery".to_string())
                        .put("signingRegion", "us-east-1".to_string())
                )
                .build()
        );
    }

    /// Dual-stack in a Region Agent Discovery doesn't serve gets the dual-stack standard pattern
    #[test]
    fn test_9() {
        let params = crate::config::endpoint::Params::builder()
            .region("us-west-2".to_string())
            .use_fips(false)
            .use_dual_stack(true)
            .build_without_validators()
            .expect("invalid params");
        let resolver = crate::config::endpoint::DefaultResolver::new();
        let endpoint = resolver.resolve_endpoint(&params);
        let endpoint = endpoint.expect("Expected valid endpoint: https://agent-discovery.us-west-2.api.aws");
        assert_eq!(
            endpoint,
            ::aws_smithy_types::endpoint::Endpoint::builder()
                .url("https://agent-discovery.us-west-2.api.aws")
                .build()
        );
    }

    /// An endpoint override wins over the Region
    #[test]
    fn test_10() {
        let params = crate::config::endpoint::Params::builder()
            .region("us-east-1".to_string())
            .use_fips(false)
            .use_dual_stack(false)
            .endpoint("https://example.com".to_string())
            .build_without_validators()
            .expect("invalid params");
        let resolver = crate::config::endpoint::DefaultResolver::new();
        let endpoint = resolver.resolve_endpoint(&params);
        let endpoint = endpoint.expect("Expected valid endpoint: https://example.com");
        assert_eq!(
            endpoint,
            ::aws_smithy_types::endpoint::Endpoint::builder().url("https://example.com").build()
        );
    }

    /// An endpoint override needs no Region
    #[test]
    fn test_11() {
        let params = crate::config::endpoint::Params::builder()
            .use_fips(false)
            .use_dual_stack(false)
            .endpoint("https://example.com".to_string())
            .build_without_validators()
            .expect("invalid params");
        let resolver = crate::config::endpoint::DefaultResolver::new();
        let endpoint = resolver.resolve_endpoint(&params);
        let endpoint = endpoint.expect("Expected valid endpoint: https://example.com");
        assert_eq!(
            endpoint,
            ::aws_smithy_types::endpoint::Endpoint::builder().url("https://example.com").build()
        );
    }

    /// An endpoint override with FIPS is an error
    #[test]
    fn test_12() {
        let params = crate::config::endpoint::Params::builder()
            .region("us-east-1".to_string())
            .use_fips(true)
            .use_dual_stack(false)
            .endpoint("https://example.com".to_string())
            .build_without_validators()
            .expect("invalid params");
        let resolver = crate::config::endpoint::DefaultResolver::new();
        let endpoint = resolver.resolve_endpoint(&params);
        let error = endpoint.expect_err(
            "expected error: Invalid Configuration: FIPS and custom endpoint are not supported [An endpoint override with FIPS is an error]",
        );
        assert_eq!(format!("{}", error), "Invalid Configuration: FIPS and custom endpoint are not supported")
    }

    /// An endpoint override with dual-stack is an error
    #[test]
    fn test_13() {
        let params = crate::config::endpoint::Params::builder()
            .region("us-east-1".to_string())
            .use_fips(false)
            .use_dual_stack(true)
            .endpoint("https://example.com".to_string())
            .build_without_validators()
            .expect("invalid params");
        let resolver = crate::config::endpoint::DefaultResolver::new();
        let endpoint = resolver.resolve_endpoint(&params);
        let error = endpoint.expect_err("expected error: Invalid Configuration: Dualstack and custom endpoint are not supported [An endpoint override with dual-stack is an error]");
        assert_eq!(
            format!("{}", error),
            "Invalid Configuration: Dualstack and custom endpoint are not supported"
        )
    }

    /// No Region and no endpoint override is an error
    #[test]
    fn test_14() {
        let params = crate::config::endpoint::Params::builder()
            .use_fips(false)
            .use_dual_stack(false)
            .build_without_validators()
            .expect("invalid params");
        let resolver = crate::config::endpoint::DefaultResolver::new();
        let endpoint = resolver.resolve_endpoint(&params);
        let error = endpoint.expect_err("expected error: Invalid Configuration: Missing Region [No Region and no endpoint override is an error]");
        assert_eq!(format!("{}", error), "Invalid Configuration: Missing Region")
    }
}

/// Endpoint resolver trait specific to Agent Discovery
pub trait ResolveEndpoint: ::std::marker::Send + ::std::marker::Sync + ::std::fmt::Debug {
    /// Resolve an endpoint with the given parameters
    fn resolve_endpoint<'a>(&'a self, params: &'a crate::config::endpoint::Params) -> ::aws_smithy_runtime_api::client::endpoint::EndpointFuture<'a>;

    /// Convert this service-specific resolver into a `SharedEndpointResolver`
    ///
    /// The resulting resolver will downcast `EndpointResolverParams` into `crate::config::endpoint::Params`.
    fn into_shared_resolver(self) -> ::aws_smithy_runtime_api::client::endpoint::SharedEndpointResolver
    where
        Self: Sized + 'static,
    {
        ::aws_smithy_runtime_api::client::endpoint::SharedEndpointResolver::new(DowncastParams(self))
    }
}

#[derive(Debug)]
struct DowncastParams<T>(T);
impl<T> ::aws_smithy_runtime_api::client::endpoint::ResolveEndpoint for DowncastParams<T>
where
    T: ResolveEndpoint,
{
    fn resolve_endpoint<'a>(
        &'a self,
        params: &'a ::aws_smithy_runtime_api::client::endpoint::EndpointResolverParams,
    ) -> ::aws_smithy_runtime_api::client::endpoint::EndpointFuture<'a> {
        let ep = match params.get::<crate::config::endpoint::Params>() {
            Some(params) => self.0.resolve_endpoint(params),
            None => ::aws_smithy_runtime_api::client::endpoint::EndpointFuture::ready(Err("params of expected type was not present".into())),
        };
        ep
    }
}

#[derive(Debug)]
/// The default endpoint resolver.
pub struct DefaultResolver {
    partition_resolver: &'static crate::endpoint_lib::partition::PartitionResolver,
    endpoint_cache: ::arc_swap::ArcSwap<::std::option::Option<(Params, ::aws_smithy_types::endpoint::Endpoint)>>,
}

impl Default for DefaultResolver {
    fn default() -> Self {
        Self::new()
    }
}

impl DefaultResolver {
    /// Create a new DefaultResolver
    pub fn new() -> Self {
        Self {
            partition_resolver: &crate::endpoint_lib::DEFAULT_PARTITION_RESOLVER,
            endpoint_cache: ::arc_swap::ArcSwap::from_pointee(None),
        }
    }

    #[allow(
        unused_variables,
        unused_parens,
        clippy::double_parens,
        clippy::useless_conversion,
        clippy::bool_comparison,
        clippy::comparison_to_empty,
        clippy::needless_borrow,
        clippy::useless_asref,
        clippy::redundant_closure_call,
        clippy::clone_on_copy,
        clippy::single_char_add_str
    )]
    fn resolve_endpoint<'a>(
        &'a self,
        params: &'a crate::config::endpoint::Params,
    ) -> ::std::result::Result<::aws_smithy_types::endpoint::Endpoint, ::aws_smithy_runtime_api::box_error::BoxError> {
        let mut _diagnostic_collector = crate::endpoint_lib::diagnostic::DiagnosticCollector::new();
        #[allow(unused_mut)]
        let mut context = ConditionContext::default();

        // Param bindings
        let region = &params.region;
        let use_fips = &params.use_fips;
        let use_dual_stack = &params.use_dual_stack;
        let endpoint = &params.endpoint;

        let mut current_ref: i32 = 2;
        loop {
            match current_ref {
                ref_val if ref_val >= 100_000_000 => {
                    return match (ref_val - 100_000_000) as usize {
                        0 => ::std::result::Result::Err(Box::new(::aws_smithy_http::endpoint::ResolveEndpointError::message(
                            "No endpoint rule matched",
                        )) as ::aws_smithy_runtime_api::box_error::BoxError),
                        1 => ::std::result::Result::Err(Box::new(::aws_smithy_http::endpoint::ResolveEndpointError::message(
                            "Invalid Configuration: FIPS and custom endpoint are not supported".to_string(),
                        )) as ::aws_smithy_runtime_api::box_error::BoxError),
                        2 => ::std::result::Result::Err(Box::new(::aws_smithy_http::endpoint::ResolveEndpointError::message(
                            "Invalid Configuration: Dualstack and custom endpoint are not supported".to_string(),
                        )) as ::aws_smithy_runtime_api::box_error::BoxError),
                        3 => {
                            let endpoint = params.endpoint.as_deref().unwrap_or_default();
                            ::std::result::Result::Ok(::aws_smithy_types::endpoint::Endpoint::builder().url(endpoint.to_owned()).build())
                        }
                        4 => ::std::result::Result::Err(Box::new(::aws_smithy_http::endpoint::ResolveEndpointError::message(
                            "FIPS is enabled but Agent Discovery does not have a FIPS endpoint".to_string(),
                        )) as ::aws_smithy_runtime_api::box_error::BoxError),
                        5 => ::std::result::Result::Ok(
                            ::aws_smithy_types::endpoint::Endpoint::builder()
                                .url("https://agent-discovery.us-east-1.api.aws".to_string())
                                .auth_scheme(
                                    ::aws_smithy_types::endpoint::EndpointAuthScheme::with_capacity("sigv4".to_string(), 2)
                                        .put("signingName", "agent-discovery")
                                        .put("signingRegion", "us-east-1"),
                                )
                                .build(),
                        ),
                        6 => ::std::result::Result::Ok(
                            ::aws_smithy_types::endpoint::Endpoint::builder()
                                .url("https://agent-discovery.eu-west-1.api.aws".to_string())
                                .auth_scheme(
                                    ::aws_smithy_types::endpoint::EndpointAuthScheme::with_capacity("sigv4".to_string(), 2)
                                        .put("signingName", "agent-discovery")
                                        .put("signingRegion", "eu-west-1"),
                                )
                                .build(),
                        ),
                        7 => ::std::result::Result::Ok(
                            ::aws_smithy_types::endpoint::Endpoint::builder()
                                .url("https://agent-discovery.ap-northeast-1.api.aws".to_string())
                                .auth_scheme(
                                    ::aws_smithy_types::endpoint::EndpointAuthScheme::with_capacity("sigv4".to_string(), 2)
                                        .put("signingName", "agent-discovery")
                                        .put("signingRegion", "ap-northeast-1"),
                                )
                                .build(),
                        ),
                        8 => {
                            let region = params.region.as_deref().unwrap_or_default();
                            let partition_result = context.partition_result.as_ref().expect("Guaranteed to have a value by earlier checks.");
                            ::std::result::Result::Ok(
                                ::aws_smithy_types::endpoint::Endpoint::builder()
                                    .url({
                                        let mut out = String::new();
                                        out.push_str("https://agent-discovery.");
                                        #[allow(clippy::needless_borrow)]
                                        out.push_str(&region.as_ref());
                                        out.push_str(".");
                                        #[allow(clippy::needless_borrow)]
                                        out.push_str(&partition_result.dual_stack_dns_suffix());
                                        out
                                    })
                                    .build(),
                            )
                        }
                        9 => {
                            let region = params.region.as_deref().unwrap_or_default();
                            let partition_result = context.partition_result.as_ref().expect("Guaranteed to have a value by earlier checks.");
                            ::std::result::Result::Ok(
                                ::aws_smithy_types::endpoint::Endpoint::builder()
                                    .url({
                                        let mut out = String::new();
                                        out.push_str("https://agent-discovery.");
                                        #[allow(clippy::needless_borrow)]
                                        out.push_str(&region.as_ref());
                                        out.push_str(".");
                                        #[allow(clippy::needless_borrow)]
                                        out.push_str(&partition_result.dns_suffix());
                                        out
                                    })
                                    .build(),
                            )
                        }
                        10 => ::std::result::Result::Err(Box::new(::aws_smithy_http::endpoint::ResolveEndpointError::message(
                            "Invalid Configuration: Missing Region".to_string(),
                        )) as ::aws_smithy_runtime_api::box_error::BoxError),
                        _ => ::std::result::Result::Err(Box::new(::aws_smithy_http::endpoint::ResolveEndpointError::message(
                            "No endpoint rule matched",
                        )) as ::aws_smithy_runtime_api::box_error::BoxError),
                    };
                }
                1 | -1 => {
                    return ::std::result::Result::Err(
                        Box::new(::aws_smithy_http::endpoint::ResolveEndpointError::message("No endpoint rule matched"))
                            as ::aws_smithy_runtime_api::box_error::BoxError,
                    )
                }
                ref_val => {
                    let is_complement = ref_val < 0;
                    let node = &NODES[(ref_val.unsigned_abs() as usize) - 1];
                    let condition_result = match node.condition_index {
                        0 => endpoint.is_some(),
                        1 => region.is_some(),
                        2 => (|_diagnostic_collector: &mut crate::endpoint_lib::diagnostic::DiagnosticCollector| -> bool {
                            let partition_result = &mut context.partition_result;
                            let partition_resolver = &self.partition_resolver;
                            {
                                *partition_result = partition_resolver
                                    .resolve_partition(if let Some(param) = region { param } else { return false }, _diagnostic_collector)
                                    .map(|inner| inner.into());
                                partition_result.is_some()
                            }
                        })(&mut _diagnostic_collector),
                        3 => (use_fips) == (&true),
                        4 => (|_diagnostic_collector: &mut crate::endpoint_lib::diagnostic::DiagnosticCollector| -> bool {
                            let partition_resolver = &self.partition_resolver;
                            (region) == &mut Some(("us-east-1".to_string().into()))
                        })(&mut _diagnostic_collector),
                        5 => (|_diagnostic_collector: &mut crate::endpoint_lib::diagnostic::DiagnosticCollector| -> bool {
                            let partition_resolver = &self.partition_resolver;
                            (region) == &mut Some(("eu-west-1".to_string().into()))
                        })(&mut _diagnostic_collector),
                        6 => (|_diagnostic_collector: &mut crate::endpoint_lib::diagnostic::DiagnosticCollector| -> bool {
                            let partition_resolver = &self.partition_resolver;
                            (region) == &mut Some(("ap-northeast-1".to_string().into()))
                        })(&mut _diagnostic_collector),
                        7 => (use_dual_stack) == (&true),
                        _ => unreachable!("Invalid condition index"),
                    };
                    current_ref = if is_complement ^ condition_result { node.high_ref } else { node.low_ref };
                }
            }
        }
    }
}

impl crate::config::endpoint::ResolveEndpoint for DefaultResolver {
    fn resolve_endpoint<'a>(&'a self, params: &'a crate::config::endpoint::Params) -> ::aws_smithy_runtime_api::client::endpoint::EndpointFuture<'a> {
        // Check single-entry cache (lock-free read via ArcSwap)
        let cached = self.endpoint_cache.load();
        if let Some((cached_params, cached_endpoint)) = cached.as_ref() {
            if cached_params == params {
                return ::aws_smithy_runtime_api::client::endpoint::EndpointFuture::ready(::std::result::Result::Ok(cached_endpoint.clone()));
            }
        }
        drop(cached);
        let result = self.resolve_endpoint(params);
        if let ::std::result::Result::Ok(ref endpoint) = result {
            self.endpoint_cache.store(::std::sync::Arc::new(Some((params.clone(), endpoint.clone()))));
        }
        ::aws_smithy_runtime_api::client::endpoint::EndpointFuture::ready(result)
    }
}
const NODES: [crate::endpoint_lib::bdd_interpreter::BddNode; 11] = [
    crate::endpoint_lib::bdd_interpreter::BddNode {
        condition_index: -1,
        high_ref: 1,
        low_ref: -1,
    },
    crate::endpoint_lib::bdd_interpreter::BddNode {
        condition_index: 0,
        high_ref: 10,
        low_ref: 3,
    },
    crate::endpoint_lib::bdd_interpreter::BddNode {
        condition_index: 1,
        high_ref: 4,
        low_ref: 100000010,
    },
    crate::endpoint_lib::bdd_interpreter::BddNode {
        condition_index: 2,
        high_ref: 5,
        low_ref: 100000010,
    },
    crate::endpoint_lib::bdd_interpreter::BddNode {
        condition_index: 3,
        high_ref: 100000004,
        low_ref: 6,
    },
    crate::endpoint_lib::bdd_interpreter::BddNode {
        condition_index: 4,
        high_ref: 100000005,
        low_ref: 7,
    },
    crate::endpoint_lib::bdd_interpreter::BddNode {
        condition_index: 5,
        high_ref: 100000006,
        low_ref: 8,
    },
    crate::endpoint_lib::bdd_interpreter::BddNode {
        condition_index: 6,
        high_ref: 100000007,
        low_ref: 9,
    },
    crate::endpoint_lib::bdd_interpreter::BddNode {
        condition_index: 7,
        high_ref: 100000008,
        low_ref: 100000009,
    },
    crate::endpoint_lib::bdd_interpreter::BddNode {
        condition_index: 3,
        high_ref: 100000001,
        low_ref: 11,
    },
    crate::endpoint_lib::bdd_interpreter::BddNode {
        condition_index: 7,
        high_ref: 100000002,
        low_ref: 100000003,
    },
];
// These are all optional since they are set by conditions and will
// all be unset when we start evaluation
#[derive(Default)]
#[allow(unused_lifetimes)]
pub(crate) struct ConditionContext<'a> {
    pub(crate) partition_result: Option<crate::endpoint_lib::partition::Partition<'a>>,
    // Sometimes none of the members reference the lifetime, this makes it still valid
    phantom: std::marker::PhantomData<&'a ()>,
}

#[non_exhaustive]
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)]
/// Configuration parameters for resolving the correct endpoint
pub struct Params {
    /// The AWS Region the client is configured for. us-east-1, eu-west-1 and ap-northeast-1 resolve to their own Regional endpoint; any other Region resolves to the standard Regional pattern, which Agent Discovery does not serve.
    pub(crate) region: ::std::option::Option<::std::string::String>,
    /// When true, send the request to a FIPS-compliant endpoint. Agent Discovery has none, so this is an error.
    pub(crate) use_fips: bool,
    /// When true, send the request to a dual-stack endpoint. Agent Discovery's Regional endpoints already are, so they resolve unchanged.
    pub(crate) use_dual_stack: bool,
    /// Override the endpoint used to send this request.
    pub(crate) endpoint: ::std::option::Option<::std::string::String>,
}
impl Params {
    /// Create a builder for [`Params`]
    pub fn builder() -> crate::config::endpoint::ParamsBuilder {
        crate::config::endpoint::ParamsBuilder::default()
    }
    /// The AWS Region the client is configured for. us-east-1, eu-west-1 and ap-northeast-1 resolve to their own Regional endpoint; any other Region resolves to the standard Regional pattern, which Agent Discovery does not serve.
    pub fn region(&self) -> ::std::option::Option<&str> {
        self.region.as_deref()
    }
    /// When true, send the request to a FIPS-compliant endpoint. Agent Discovery has none, so this is an error.
    pub fn use_fips(&self) -> ::std::option::Option<bool> {
        Some(self.use_fips)
    }
    /// When true, send the request to a dual-stack endpoint. Agent Discovery's Regional endpoints already are, so they resolve unchanged.
    pub fn use_dual_stack(&self) -> ::std::option::Option<bool> {
        Some(self.use_dual_stack)
    }
    /// Override the endpoint used to send this request.
    pub fn endpoint(&self) -> ::std::option::Option<&str> {
        self.endpoint.as_deref()
    }
}

/// Builder for [`Params`]
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
pub struct ParamsBuilder {
    region: ::std::option::Option<::std::string::String>,
    use_fips: ::std::option::Option<bool>,
    use_dual_stack: ::std::option::Option<bool>,
    endpoint: ::std::option::Option<::std::string::String>,
}
impl ParamsBuilder {
    /// Consume this builder, creating [`Params`].
    pub fn build(self) -> ::std::result::Result<crate::config::endpoint::Params, crate::config::endpoint::InvalidParams> {
        if let Some(region) = &self.region {
            if !crate::endpoint_lib::host::is_valid_host_label(
                region.as_ref() as &str,
                true,
                &mut crate::endpoint_lib::diagnostic::DiagnosticCollector::new(),
            ) {
                return Err(crate::config::endpoint::InvalidParams::invalid_value(
                    "region",
                    "must be a valid host label",
                ));
            }
        };
        self.build_without_validators()
    }
    /// Consume this builder, creating [`Params`] without the validators run by `build()`.
    ///
    /// Endpoint rule-set tests use this so they test the rules as the model defines them.
    fn build_without_validators(self) -> ::std::result::Result<crate::config::endpoint::Params, crate::config::endpoint::InvalidParams> {
        Ok(
            #[allow(clippy::unnecessary_lazy_evaluations)]
            crate::config::endpoint::Params {
                region: self.region,
                use_fips: self
                    .use_fips
                    .or_else(|| Some(false))
                    .ok_or_else(|| crate::config::endpoint::InvalidParams::missing("use_fips"))?,
                use_dual_stack: self
                    .use_dual_stack
                    .or_else(|| Some(false))
                    .ok_or_else(|| crate::config::endpoint::InvalidParams::missing("use_dual_stack"))?,
                endpoint: self.endpoint,
            },
        )
    }
    /// Sets the value for region
    ///
    /// The AWS Region the client is configured for. us-east-1, eu-west-1 and ap-northeast-1 resolve to their own Regional endpoint; any other Region resolves to the standard Regional pattern, which Agent Discovery does not serve.
    pub fn region(mut self, value: impl Into<::std::string::String>) -> Self {
        self.region = Some(value.into());
        self
    }

    /// Sets the value for region
    ///
    /// The AWS Region the client is configured for. us-east-1, eu-west-1 and ap-northeast-1 resolve to their own Regional endpoint; any other Region resolves to the standard Regional pattern, which Agent Discovery does not serve.
    pub fn set_region(mut self, param: Option<::std::string::String>) -> Self {
        self.region = param;
        self
    }
    /// Sets the value for use_fips
    ///
    /// When unset, this parameter has a default value of `false`.
    /// When true, send the request to a FIPS-compliant endpoint. Agent Discovery has none, so this is an error.
    pub fn use_fips(mut self, value: impl Into<bool>) -> Self {
        self.use_fips = Some(value.into());
        self
    }

    /// Sets the value for use_fips
    ///
    /// When unset, this parameter has a default value of `false`.
    /// When true, send the request to a FIPS-compliant endpoint. Agent Discovery has none, so this is an error.
    pub fn set_use_fips(mut self, param: Option<bool>) -> Self {
        self.use_fips = param;
        self
    }
    /// Sets the value for use_dual_stack
    ///
    /// When unset, this parameter has a default value of `false`.
    /// When true, send the request to a dual-stack endpoint. Agent Discovery's Regional endpoints already are, so they resolve unchanged.
    pub fn use_dual_stack(mut self, value: impl Into<bool>) -> Self {
        self.use_dual_stack = Some(value.into());
        self
    }

    /// Sets the value for use_dual_stack
    ///
    /// When unset, this parameter has a default value of `false`.
    /// When true, send the request to a dual-stack endpoint. Agent Discovery's Regional endpoints already are, so they resolve unchanged.
    pub fn set_use_dual_stack(mut self, param: Option<bool>) -> Self {
        self.use_dual_stack = param;
        self
    }
    /// Sets the value for endpoint
    ///
    /// Override the endpoint used to send this request.
    pub fn endpoint(mut self, value: impl Into<::std::string::String>) -> Self {
        self.endpoint = Some(value.into());
        self
    }

    /// Sets the value for endpoint
    ///
    /// Override the endpoint used to send this request.
    pub fn set_endpoint(mut self, param: Option<::std::string::String>) -> Self {
        self.endpoint = param;
        self
    }
}

/// An error that occurred during endpoint resolution
#[derive(Debug)]
pub struct InvalidParams {
    field: std::borrow::Cow<'static, str>,
    kind: InvalidParamsErrorKind,
}

/// The kind of invalid parameter error
#[derive(Debug)]
enum InvalidParamsErrorKind {
    MissingField,
    InvalidValue { message: &'static str },
}

impl InvalidParams {
    #[allow(dead_code)]
    fn missing(field: &'static str) -> Self {
        Self {
            field: field.into(),
            kind: InvalidParamsErrorKind::MissingField,
        }
    }

    #[allow(dead_code)]
    fn invalid_value(field: &'static str, message: &'static str) -> Self {
        Self {
            field: field.into(),
            kind: InvalidParamsErrorKind::InvalidValue { message },
        }
    }
}

impl std::fmt::Display for InvalidParams {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        match self.kind {
            InvalidParamsErrorKind::MissingField => write!(f, "a required field was missing: `{}`", self.field),
            InvalidParamsErrorKind::InvalidValue { message } => write!(f, "invalid value for field: `{}` - {}", self.field, message),
        }
    }
}

impl std::error::Error for InvalidParams {}