hey-sdk 0.30.0

Rust client for the HEY API, generated from a Smithy model of the API
Documentation
// Generated by hey-sdk-generator from openapi.json and behavior-model.json. DO NOT EDIT.

#![allow(clippy::too_many_arguments)]

use crate::client::Client;
use crate::error::Error;
use crate::generated::routes;
use crate::generated::types::*;
use crate::pagination::Page;

/// Optional query parameters for `GetCollection`.
#[derive(Debug, Clone, Default, PartialEq)]
pub struct GetCollectionParams {
    pub page: Option<String>,
}

pub struct Collections<'a> {
    client: &'a Client,
}

impl<'a> Collections<'a> {
    pub(crate) fn new(client: &'a Client) -> Self {
        Self { client }
    }

    /// The client this service sends through.
    pub fn client(&self) -> &'a Client {
        self.client
    }

    /// Get a collection and one page of its active, accessible threads
    pub async fn get(
        &self,
        collection_id: i64,
        params: &GetCollectionParams,
    ) -> Result<Page<GetCollectionResponseContent>, Error> {
        let mut operation = self
            .client
            .operation(&routes::GET_COLLECTION, &[&collection_id]);
        operation.resource_id(collection_id);
        operation.query_optional("page", params.page.as_ref());
        self.client.send_page(operation).await
    }

    /// List collections
    pub async fn list(&self) -> Result<ListCollectionsResponseContent, Error> {
        let operation = self.client.operation(&routes::LIST_COLLECTIONS, &[]);
        self.client.send(operation).await
    }

    /// Rename a collection or change its summary
    pub async fn update(
        &self,
        collection_id: i64,
        body: &UpdateCollectionRequestContent,
    ) -> Result<(), Error> {
        let mut operation = self
            .client
            .operation(&routes::UPDATE_COLLECTION, &[&collection_id]);
        operation.resource_id(collection_id);
        operation.json(body)?;
        self.client.send_unit(operation).await
    }
}