aws_sdk_iot/types/
_http_context.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2
3/// <p>Specifies the HTTP context to use for the test authorizer request.</p>
4#[non_exhaustive]
5#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)]
6pub struct HttpContext {
7    /// <p>The header keys and values in an HTTP authorization request.</p>
8    pub headers: ::std::option::Option<::std::collections::HashMap<::std::string::String, ::std::string::String>>,
9    /// <p>The query string keys and values in an HTTP authorization request.</p>
10    pub query_string: ::std::option::Option<::std::string::String>,
11}
12impl HttpContext {
13    /// <p>The header keys and values in an HTTP authorization request.</p>
14    pub fn headers(&self) -> ::std::option::Option<&::std::collections::HashMap<::std::string::String, ::std::string::String>> {
15        self.headers.as_ref()
16    }
17    /// <p>The query string keys and values in an HTTP authorization request.</p>
18    pub fn query_string(&self) -> ::std::option::Option<&str> {
19        self.query_string.as_deref()
20    }
21}
22impl HttpContext {
23    /// Creates a new builder-style object to manufacture [`HttpContext`](crate::types::HttpContext).
24    pub fn builder() -> crate::types::builders::HttpContextBuilder {
25        crate::types::builders::HttpContextBuilder::default()
26    }
27}
28
29/// A builder for [`HttpContext`](crate::types::HttpContext).
30#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
31#[non_exhaustive]
32pub struct HttpContextBuilder {
33    pub(crate) headers: ::std::option::Option<::std::collections::HashMap<::std::string::String, ::std::string::String>>,
34    pub(crate) query_string: ::std::option::Option<::std::string::String>,
35}
36impl HttpContextBuilder {
37    /// Adds a key-value pair to `headers`.
38    ///
39    /// To override the contents of this collection use [`set_headers`](Self::set_headers).
40    ///
41    /// <p>The header keys and values in an HTTP authorization request.</p>
42    pub fn headers(mut self, k: impl ::std::convert::Into<::std::string::String>, v: impl ::std::convert::Into<::std::string::String>) -> Self {
43        let mut hash_map = self.headers.unwrap_or_default();
44        hash_map.insert(k.into(), v.into());
45        self.headers = ::std::option::Option::Some(hash_map);
46        self
47    }
48    /// <p>The header keys and values in an HTTP authorization request.</p>
49    pub fn set_headers(mut self, input: ::std::option::Option<::std::collections::HashMap<::std::string::String, ::std::string::String>>) -> Self {
50        self.headers = input;
51        self
52    }
53    /// <p>The header keys and values in an HTTP authorization request.</p>
54    pub fn get_headers(&self) -> &::std::option::Option<::std::collections::HashMap<::std::string::String, ::std::string::String>> {
55        &self.headers
56    }
57    /// <p>The query string keys and values in an HTTP authorization request.</p>
58    pub fn query_string(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
59        self.query_string = ::std::option::Option::Some(input.into());
60        self
61    }
62    /// <p>The query string keys and values in an HTTP authorization request.</p>
63    pub fn set_query_string(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
64        self.query_string = input;
65        self
66    }
67    /// <p>The query string keys and values in an HTTP authorization request.</p>
68    pub fn get_query_string(&self) -> &::std::option::Option<::std::string::String> {
69        &self.query_string
70    }
71    /// Consumes the builder and constructs a [`HttpContext`](crate::types::HttpContext).
72    pub fn build(self) -> crate::types::HttpContext {
73        crate::types::HttpContext {
74            headers: self.headers,
75            query_string: self.query_string,
76        }
77    }
78}