| 907 | } |
| 908 | |
| 909 | async fn list_regions( |
| 910 | &self, |
| 911 | request: Request<()>, |
| 912 | ) -> Result<Response<api::ListRegionsResponse>, Status> { |
| 913 | self.validator |
| 914 | .validate(request.extensions(), validator::ValidateActiveUser::new()) |
| 915 | .await?; |
| 916 | |
| 917 | let conf = config::get(); |
| 918 | |
| 919 | let mut out: api::ListRegionsResponse = Default::default(); |
| 920 | |
| 921 | for region_config in &conf.regions { |
| 922 | // Check if region is enabled. |
| 923 | if !conf.network.enabled_regions.contains(®ion_config.id) { |
| 924 | continue; |
| 925 | } |
| 926 | |
| 927 | out.regions.push(api::RegionListItem { |
| 928 | id: region_config.id.clone(), |
| 929 | description: if region_config.description.is_empty() { |
| 930 | region_config.id.clone() |
| 931 | } else { |
| 932 | region_config.description.clone() |
| 933 | }, |
| 934 | region: region_config.common_name.to_proto().into(), |
| 935 | }); |
| 936 | } |
| 937 | |
| 938 | out.regions.sort_by(|a, b| a.id.cmp(&b.id)); |
| 939 | Ok(Response::new(out)) |
| 940 | } |
| 941 | |
| 942 | async fn get_region( |
| 943 | &self, |