asana_cli/api/
custom_fields.rs1use crate::api::api_get;
4use crate::{
5 api::{ApiClient, ApiError},
6 models::CustomField,
7};
8use futures_util::{StreamExt, pin_mut};
9
10pub async fn list_custom_fields(
15 client: &ApiClient,
16 workspace_gid: &str,
17 limit: Option<usize>,
18) -> Result<Vec<CustomField>, ApiError> {
19 let endpoint = format!("/workspaces/{workspace_gid}/custom_fields");
20 let stream = client.paginate_with_limit::<CustomField>(&endpoint, vec![], limit);
21 pin_mut!(stream);
22
23 let mut fields = Vec::new();
24 while let Some(page) = stream.next().await {
25 let mut page = page?;
26 fields.append(&mut page);
27 }
28
29 Ok(fields)
30}
31
32pub async fn get_custom_field(
37 client: &ApiClient,
38 field_gid: &str,
39) -> Result<CustomField, ApiError> {
40 api_get(client, &format!("/custom_fields/{field_gid}")).await
41}