MCPcopy Create free account
hub / github.com/aws/amazon-q-developer-cli / configured_value

Method configured_value

crates/chat-cli/src/api_client/endpoints.rs:27–59  ·  view source on GitHub ↗
(database: &Database)

Source from the content-addressed store, hash-verified

25 };
26
27 pub fn configured_value(database: &Database) -> Self {
28 let (endpoint, region) = if let Some(Value::Object(o)) = database.settings.get(Setting::ApiCodeWhispererService)
29 {
30 // The following branch is evaluated in case the user has set their own endpoint.
31 (
32 o.get("endpoint").and_then(|v| v.as_str()).map(|v| v.to_owned()),
33 o.get("region").and_then(|v| v.as_str()).map(|v| v.to_owned()),
34 )
35 } else if let Ok(Some(profile)) = database.get_auth_profile() {
36 // The following branch is evaluated in the case of user profile being set.
37 let region = profile.arn.split(':').nth(3).unwrap_or_default().to_owned();
38 match Self::CODEWHISPERER_ENDPOINTS
39 .iter()
40 .find(|e| e.region().as_ref() == region)
41 {
42 Some(endpoint) => (Some(endpoint.url().to_owned()), Some(region)),
43 None => {
44 error!("Failed to find endpoint for region: {region}");
45 (None, None)
46 },
47 }
48 } else {
49 (None, None)
50 };
51
52 match (endpoint, region) {
53 (Some(endpoint), Some(region)) => Self {
54 url: endpoint.clone().into(),
55 region: Region::new(region.clone()),
56 },
57 _ => Endpoint::DEFAULT_ENDPOINT,
58 }
59 }
60
61 pub(crate) fn url(&self) -> &str {
62 &self.url

Callers

nothing calls this directly

Calls 8

mapMethod · 0.80
get_auth_profileMethod · 0.80
getMethod · 0.45
as_strMethod · 0.45
as_refMethod · 0.45
regionMethod · 0.45
urlMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected