Skip to main content

objectiveai_sdk/functions/
http.rs

1//! HTTP functions for function management.
2
3use crate::{HttpClient, HttpError};
4
5/// Lists all functions accessible to the authenticated user.
6pub async fn list_functions(
7    client: &HttpClient,
8    params: super::request::ListFunctionsRequest,
9) -> Result<super::response::ListFunctionResponse, HttpError> {
10    client
11        .send_unary(reqwest::Method::POST, "functions/list", Some(params))
12        .await
13}
14
15/// Retrieves a function definition.
16pub async fn get_function(
17    client: &HttpClient,
18    params: super::request::GetFunctionRequest,
19) -> Result<super::response::GetFunctionResponse, HttpError> {
20    client
21        .send_unary(reqwest::Method::POST, "functions", Some(params))
22        .await
23}
24
25/// Gets usage statistics for a specific function.
26pub async fn get_function_usage(
27    client: &HttpClient,
28    params: super::request::GetFunctionRequest,
29) -> Result<super::response::UsageFunctionResponse, HttpError> {
30    client
31        .send_unary(reqwest::Method::POST, "functions/usage", Some(params))
32        .await
33}
34
35/// Lists all function-profile pairs accessible to the authenticated user.
36pub async fn list_function_profile_pairs(
37    client: &HttpClient,
38    params: super::request::ListFunctionProfilePairsRequest,
39) -> Result<super::response::ListFunctionProfilePairResponse, HttpError> {
40    client
41        .send_unary(reqwest::Method::POST, "functions/profiles/pairs/list", Some(params))
42        .await
43}
44
45/// Gets usage statistics for a specific function-profile pair.
46pub async fn get_function_profile_pair_usage(
47    client: &HttpClient,
48    params: super::request::GetFunctionProfilePairUsageRequest,
49) -> Result<super::response::UsageFunctionProfilePairResponse, HttpError> {
50    client
51        .send_unary(reqwest::Method::POST, "functions/profiles/pairs/usage", Some(params))
52        .await
53}