uarp-sdk 0.5.7

Async Rust client for the UARP (Snaga) Universal Agent Runtime Platform API
Documentation
// Code generated by @uarp/codegen from spec/openapi.json. DO NOT EDIT.
//!
//! LLM provider API key management

#![allow(unused_imports, clippy::too_many_arguments)]

use reqwest::Method;
use serde::{Deserialize, Serialize};

use crate::client::{Client, Request, NO_BODY, NO_QUERY};
use crate::error::Result;
use crate::generated::models;
use crate::multipart::{field_text, FilePart};
use crate::util::encode_path;

/// LLM provider API key management
#[derive(Debug, Clone)]
pub struct LLMCredentialsApi {
    pub(crate) client: Client,
}

impl Client {
    /// LLM provider API key management
    pub fn llm_credentials(&self) -> LLMCredentialsApi {
        LLMCredentialsApi { client: self.clone() }
    }
}

impl LLMCredentialsApi {
    /// Remove stored API key for an LLM provider
    ///
    /// `DELETE /api/v1/llm-credentials/{provider}`
    ///
    /// Required scopes: `agents:write`.
    pub async fn delete_llm_provider_key(&self, provider: &models::SetLLMProviderKeyProvider) -> Result<models::DeleteLLMProviderKeyResponse> {
        self.client
            .request_json(Request {
                method: Method::DELETE,
                path: format!("/api/v1/llm-credentials/{}", encode_path(&provider.to_string())),
                query: NO_QUERY,
                body: NO_BODY,
                headers: Vec::new(),
                idempotent: true,
            })
            .await
    }

    /// List LLM providers with configured status for current user
    ///
    /// `GET /api/v1/llm-credentials/providers`
    ///
    /// Required scopes: `agents:read`.
    pub async fn list_llm_credentials_providers(&self) -> Result<models::ListLLMCredentialsProvidersResponse> {
        self.client
            .request_json(Request {
                method: Method::GET,
                path: "/api/v1/llm-credentials/providers".to_string(),
                query: NO_QUERY,
                body: NO_BODY,
                headers: Vec::new(),
                idempotent: false,
            })
            .await
    }

    /// Set or update API key for an LLM provider
    ///
    /// `PUT /api/v1/llm-credentials/{provider}`
    ///
    /// Required scopes: `agents:write`.
    pub async fn set_llm_provider_key(&self, provider: &models::SetLLMProviderKeyProvider, body: &models::SetLLMProviderKeyRequest) -> Result<models::SetLLMProviderKeyResponse> {
        self.client
            .request_json(Request {
                method: Method::PUT,
                path: format!("/api/v1/llm-credentials/{}", encode_path(&provider.to_string())),
                query: NO_QUERY,
                body: Some(body),
                headers: Vec::new(),
                idempotent: true,
            })
            .await
    }

    /// Test configured API key for an LLM provider
    ///
    /// `POST /api/v1/llm-credentials/{provider}/test`
    ///
    /// Required scopes: `agents:write`.
    pub async fn test_llm_provider_key(&self, provider: &models::SetLLMProviderKeyProvider) -> Result<models::TestLLMProviderKeyResponse> {
        self.client
            .request_json(Request {
                method: Method::POST,
                path: format!("/api/v1/llm-credentials/{}/test", encode_path(&provider.to_string())),
                query: NO_QUERY,
                body: NO_BODY,
                headers: Vec::new(),
                idempotent: true,
            })
            .await
    }
}