Skip to main content

hey_sdk/generated/services/
collections.rs

1// Generated by hey-sdk-generator from openapi.json and behavior-model.json. DO NOT EDIT.
2
3#![allow(missing_docs, unreachable_pub, clippy::all, clippy::pedantic)]
4
5use crate::client::Client;
6use crate::error::Error;
7use crate::generated::routes;
8use crate::generated::types::*;
9use crate::pagination::Page;
10
11/// Optional query parameters for `GetCollection`.
12#[derive(Debug, Clone, Default, PartialEq)]
13pub struct GetCollectionParams {
14    pub page: Option<String>,
15}
16
17pub struct Collections<'a> {
18    client: &'a Client,
19}
20
21impl<'a> Collections<'a> {
22    pub(crate) fn new(client: &'a Client) -> Self {
23        Self { client }
24    }
25
26    /// The client this service sends through.
27    pub fn client(&self) -> &'a Client {
28        self.client
29    }
30
31    /// Get a collection and one page of its active, accessible threads
32    pub async fn get(
33        &self,
34        collection_id: i64,
35        params: &GetCollectionParams,
36    ) -> Result<Page<GetCollectionResponseContent>, Error> {
37        let mut operation = self
38            .client
39            .operation(&routes::GET_COLLECTION, &[&collection_id]);
40        operation.resource_id(collection_id);
41        operation.query_optional("page", params.page.as_ref());
42        self.client.send_page(operation).await
43    }
44
45    /// List collections
46    pub async fn list(&self) -> Result<ListCollectionsResponseContent, Error> {
47        let operation = self.client.operation(&routes::LIST_COLLECTIONS, &[]);
48        self.client.send(operation).await
49    }
50
51    /// Rename a collection or change its summary
52    pub async fn update(
53        &self,
54        collection_id: i64,
55        body: &UpdateCollectionRequestContent,
56    ) -> Result<(), Error> {
57        let mut operation = self
58            .client
59            .operation(&routes::UPDATE_COLLECTION, &[&collection_id]);
60        operation.resource_id(collection_id);
61        operation.json(body)?;
62        self.client.send_unit(operation).await
63    }
64}