MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / provider_create_with_options

Function provider_create_with_options

crates/openshell-cli/src/run.rs:4615–4837  ·  view source on GitHub ↗
(
    server: &str,
    name: &str,
    provider_type: &str,
    from_existing: bool,
    credentials: &[String],
    from_gcloud_adc: bool,
    runtime_credentials: bool,
    config: &[String],
    t

Source from the content-addressed store, hash-verified

4613
4614#[allow(clippy::too_many_arguments)]
4615pub async fn provider_create_with_options(
4616 server: &str,
4617 name: &str,
4618 provider_type: &str,
4619 from_existing: bool,
4620 credentials: &[String],
4621 from_gcloud_adc: bool,
4622 runtime_credentials: bool,
4623 config: &[String],
4624 tls: &TlsOptions,
4625) -> Result<()> {
4626 if from_gcloud_adc && (from_existing || !credentials.is_empty() || runtime_credentials) {
4627 return Err(miette::miette!(
4628 "--from-gcloud-adc cannot be combined with --from-existing or --credential; it also cannot be combined with --runtime-credentials"
4629 ));
4630 }
4631 if from_existing && (!credentials.is_empty() || runtime_credentials) {
4632 return Err(miette::miette!(
4633 "--from-existing cannot be combined with --credential or --runtime-credentials"
4634 ));
4635 }
4636 if runtime_credentials && !credentials.is_empty() {
4637 return Err(miette::miette!(
4638 "--runtime-credentials cannot be combined with --credential"
4639 ));
4640 }
4641
4642 let mut client = grpc_client(server, tls).await?;
4643
4644 let provider_type = if let Some(provider_type) = normalize_provider_type(provider_type) {
4645 provider_type.to_string()
4646 } else {
4647 let profile_id = provider_type.trim();
4648 if profile_id.is_empty() {
4649 return Err(miette::miette!("provider type is required"));
4650 }
4651 let response = client
4652 .get_provider_profile(GetProviderProfileRequest {
4653 id: profile_id.to_string(),
4654 })
4655 .await;
4656 match response {
4657 Ok(response) => response
4658 .into_inner()
4659 .profile
4660 .map(|profile| profile.id)
4661 .filter(|id| !id.trim().is_empty())
4662 .unwrap_or_else(|| profile_id.to_string()),
4663 Err(status) if status.code() == Code::NotFound => {
4664 return Err(miette::miette!(
4665 "unsupported provider type or profile: {provider_type}"
4666 ));
4667 }
4668 Err(status) => return Err(status).into_diagnostic(),
4669 }
4670 };
4671
4672 let adc_credential_key = if from_gcloud_adc {

Calls 15

grpc_clientFunction · 0.85
normalize_provider_typeFunction · 0.85
get_default_profileFunction · 0.85
parse_credential_pairsFunction · 0.85
parse_key_value_pairsFunction · 0.85
fetch_provider_profileFunction · 0.85
read_gcloud_adcFunction · 0.85
codeMethod · 0.80