Skip to main content

objectiveai_sdk/functions/
request.rs

1//! Request types for function listing endpoints.
2
3use schemars::JsonSchema;
4use serde::{Deserialize, Serialize};
5
6/// Query parameters for the list functions endpoint.
7#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
8#[schemars(rename = "functions.ListFunctionsRequest")]
9pub struct ListFunctionsRequest {
10    /// Optional source filter for listing functions.
11    #[serde(skip_serializing_if = "Option::is_none")]
12    #[schemars(extend("omitempty" = true))]
13    pub source: Option<ListFunctionsSource>,
14}
15
16/// Source filter for listing functions.
17#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
18#[schemars(rename = "functions.ListFunctionsSource")]
19#[serde(rename_all = "snake_case")]
20pub enum ListFunctionsSource {
21    All,
22    Mock,
23    Filesystem,
24    Objectiveai,
25}
26
27impl ListFunctionsSource {
28    pub fn as_str(&self) -> &str {
29        match self {
30            ListFunctionsSource::All => "all",
31            ListFunctionsSource::Mock => "mock",
32            ListFunctionsSource::Filesystem => "filesystem",
33            ListFunctionsSource::Objectiveai => "objectiveai",
34        }
35    }
36}
37
38/// Query parameters for the list function-profile pairs endpoint.
39#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
40#[schemars(rename = "functions.ListFunctionProfilePairsRequest")]
41pub struct ListFunctionProfilePairsRequest {
42    /// Optional source filter for listing function-profile pairs.
43    #[serde(skip_serializing_if = "Option::is_none")]
44    #[schemars(extend("omitempty" = true))]
45    pub source: Option<ListFunctionProfilePairsSource>,
46}
47
48/// Source filter for listing function-profile pairs.
49#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
50#[schemars(rename = "functions.ListFunctionProfilePairsSource")]
51#[serde(rename_all = "snake_case")]
52pub enum ListFunctionProfilePairsSource {
53    Objectiveai,
54}
55
56/// Request parameters for getting a specific function.
57pub type GetFunctionRequest = crate::RemotePathCommitOptional;
58
59/// Request parameters for getting usage of a specific function-profile pair.
60#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
61#[schemars(rename = "functions.GetFunctionProfilePairUsageRequest")]
62pub struct GetFunctionProfilePairUsageRequest {
63    /// The function path.
64    pub function: crate::RemotePathCommitOptional,
65    /// The profile path.
66    pub profile: crate::RemotePathCommitOptional,
67}
68
69impl ListFunctionProfilePairsSource {
70    pub fn as_str(&self) -> &str {
71        match self {
72            ListFunctionProfilePairsSource::Objectiveai => "objectiveai",
73        }
74    }
75}