The inferred access intent.
(&self)
| 163 | |
| 164 | /// The inferred access intent. |
| 165 | pub fn intent(&self) -> PolicyIntent { |
| 166 | if self.protocol.is_empty() { |
| 167 | return PolicyIntent::L4Only; |
| 168 | } |
| 169 | match self.access.as_str() { |
| 170 | "read-only" => PolicyIntent::ReadOnly, |
| 171 | "read-write" => PolicyIntent::ReadWrite, |
| 172 | "full" => PolicyIntent::Full, |
| 173 | _ => { |
| 174 | if self.rules.is_empty() { |
| 175 | return PolicyIntent::Custom; |
| 176 | } |
| 177 | let methods: HashSet<String> = |
| 178 | self.rules.iter().map(|r| r.method.to_uppercase()).collect(); |
| 179 | let read_only: HashSet<String> = ["GET", "HEAD", "OPTIONS"] |
| 180 | .iter() |
| 181 | .map(|s| (*s).to_owned()) |
| 182 | .collect(); |
| 183 | if methods.is_subset(&read_only) { |
| 184 | PolicyIntent::ReadOnly |
| 185 | } else if !methods.contains("DELETE") { |
| 186 | PolicyIntent::ReadWrite |
| 187 | } else { |
| 188 | PolicyIntent::Full |
| 189 | } |
| 190 | } |
| 191 | } |
| 192 | } |
| 193 | |
| 194 | /// The effective list of ports for this endpoint. |
| 195 | pub fn effective_ports(&self) -> Vec<u16> { |