Skip to main content

rusticity_term/
dynamodb.rs

1pub mod actions;
2pub mod items;
3pub mod table;
4
5use std::collections::HashMap;
6
7pub fn init(i18n: &mut HashMap<String, String>) {
8    table::init(i18n);
9}
10
11pub fn console_url_tables(region: &str) -> String {
12    format!(
13        "https://{}.console.aws.amazon.com/dynamodbv2/home?region={}#tables",
14        region, region
15    )
16}
17
18/// Table detail URL. `tab` is a dynamodbv2 console tab id (e.g. "overview").
19pub fn console_url_table(region: &str, table_name: &str, tab: &str) -> String {
20    format!(
21        "https://{}.console.aws.amazon.com/dynamodbv2/home?region={}#table?name={}&tab={}",
22        region, region, table_name, tab
23    )
24}
25
26#[cfg(test)]
27mod tests {
28    use super::*;
29
30    #[test]
31    fn test_console_urls() {
32        assert_eq!(
33            console_url_tables("us-east-2"),
34            "https://us-east-2.console.aws.amazon.com/dynamodbv2/home?region=us-east-2#tables"
35        );
36        assert_eq!(
37            console_url_table("eu-west-1", "orders", "indexes"),
38            "https://eu-west-1.console.aws.amazon.com/dynamodbv2/home?region=eu-west-1#table?name=orders&tab=indexes"
39        );
40    }
41}