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(
42            reqwest::Method::POST,
43            "functions/profiles/pairs/list",
44            Some(params),
45        )
46        .await
47}
48
49/// Gets usage statistics for a specific function-profile pair.
50pub async fn get_function_profile_pair_usage(
51    client: &HttpClient,
52    params: super::request::GetFunctionProfilePairUsageRequest,
53) -> Result<super::response::UsageFunctionProfilePairResponse, HttpError> {
54    client
55        .send_unary(
56            reqwest::Method::POST,
57            "functions/profiles/pairs/usage",
58            Some(params),
59        )
60        .await
61}