fizzy-sdk 0.2.4

Official Fizzy API client, generated from the Smithy model in spec/
Documentation
// Generated by fizzy-sdk-generator from openapi.json and behavior-model.json. DO NOT EDIT.

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

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

/// The `Boards` operations.
pub struct BoardsService<'a> {
    scope: Scope<'a>,
}

impl<'a> BoardsService<'a> {
    pub(crate) fn new(scope: Scope<'a>) -> Self {
        Self { scope }
    }

    /// The client and account these operations send through.
    pub fn scope(&self) -> &Scope<'a> {
        &self.scope
    }

    /// `CreateBoard` — `POST /{accountId}/boards.json`.
    ///
    /// Sent once and never resent.
    pub async fn create(&self, body: &CreateBoardRequestContent) -> Result<Board, Error> {
        let mut operation = self.scope.operation(&routes::CREATE_BOARD, &[])?;
        operation.json(body)?;
        self.scope.client().send(operation).await
    }

    /// `DeleteBoard` — `DELETE /{accountId}/boards/{boardId}`.
    ///
    /// Sent up to 3 times, backing off from 1000 ms, when the answer is 429, 500 or 503.
    pub async fn delete(&self, board_id: &str) -> Result<(), Error> {
        let mut operation = self.scope.operation(&routes::DELETE_BOARD, &[&board_id])?;
        operation.resource_id(board_id);
        self.scope.client().send_unit(operation).await
    }

    /// `GetBoard` — `GET /{accountId}/boards/{boardId}`.
    ///
    /// Sent up to 3 times, backing off from 1000 ms, when the answer is 429, 500 or 503.
    pub async fn get(&self, board_id: &str) -> Result<Board, Error> {
        let mut operation = self.scope.operation(&routes::GET_BOARD, &[&board_id])?;
        operation.resource_id(board_id);
        self.scope.client().send(operation).await
    }

    /// `ListBoards` — `GET /{accountId}/boards.json`.
    ///
    /// Sent up to 3 times, backing off from 1000 ms, when the answer is 429, 500 or 503.
    ///
    /// Paginated: the answer is a page with `page` as its cursor, and the next one is read with `next_page`.
    pub async fn list(&self) -> Result<Page<Vec<Board>>, Error> {
        let operation = self.scope.operation(&routes::LIST_BOARDS, &[])?;
        self.scope.client().send_page(operation).await
    }

    /// `ListBoardAccesses` — `GET /{accountId}/boards/{boardId}/accesses.json`.
    ///
    /// Sent up to 3 times, backing off from 1000 ms, when the answer is 429, 500 or 503.
    pub async fn list_board_accesses(
        &self,
        board_id: &str,
        params: &ListBoardAccessesParams,
    ) -> Result<BoardAccesses, Error> {
        let mut operation = self
            .scope
            .operation(&routes::LIST_BOARD_ACCESSES, &[&board_id])?;
        operation.resource_id(board_id);
        operation.query_optional("page", params.page.as_ref());
        self.scope.client().send(operation).await
    }

    /// `ListClosedCards` — `GET /{accountId}/boards/{boardId}/columns/closed.json`.
    ///
    /// Sent up to 3 times, backing off from 1000 ms, when the answer is 429, 500 or 503.
    ///
    /// Paginated: the answer is a page with `page` as its cursor, and the next one is read with `next_page`.
    pub async fn list_closed(&self, board_id: &str) -> Result<Page<Vec<Card>>, Error> {
        let mut operation = self
            .scope
            .operation(&routes::LIST_CLOSED_CARDS, &[&board_id])?;
        operation.resource_id(board_id);
        self.scope.client().send_page(operation).await
    }

    /// `ListPostponedCards` — `GET /{accountId}/boards/{boardId}/columns/not_now.json`.
    ///
    /// Sent up to 3 times, backing off from 1000 ms, when the answer is 429, 500 or 503.
    ///
    /// Paginated: the answer is a page with `page` as its cursor, and the next one is read with `next_page`.
    pub async fn list_postponed(&self, board_id: &str) -> Result<Page<Vec<Card>>, Error> {
        let mut operation = self
            .scope
            .operation(&routes::LIST_POSTPONED_CARDS, &[&board_id])?;
        operation.resource_id(board_id);
        self.scope.client().send_page(operation).await
    }

    /// `ListStreamCards` — `GET /{accountId}/boards/{boardId}/columns/stream.json`.
    ///
    /// Sent up to 3 times, backing off from 1000 ms, when the answer is 429, 500 or 503.
    ///
    /// Paginated: the answer is a page with `page` as its cursor, and the next one is read with `next_page`.
    pub async fn list_stream(&self, board_id: &str) -> Result<Page<Vec<Card>>, Error> {
        let mut operation = self
            .scope
            .operation(&routes::LIST_STREAM_CARDS, &[&board_id])?;
        operation.resource_id(board_id);
        self.scope.client().send_page(operation).await
    }

    /// `PublishBoard` — `POST /{accountId}/boards/{boardId}/publication.json`.
    ///
    /// Sent up to 3 times, backing off from 1000 ms, when the answer is 429, 500 or 503. Idempotent, so a resend is safe.
    pub async fn publish(&self, board_id: &str) -> Result<(), Error> {
        let mut operation = self.scope.operation(&routes::PUBLISH_BOARD, &[&board_id])?;
        operation.resource_id(board_id);
        self.scope.client().send_unit(operation).await
    }

    /// `UnpublishBoard` — `DELETE /{accountId}/boards/{boardId}/publication.json`.
    ///
    /// Sent up to 3 times, backing off from 1000 ms, when the answer is 429, 500 or 503.
    pub async fn unpublish(&self, board_id: &str) -> Result<(), Error> {
        let mut operation = self
            .scope
            .operation(&routes::UNPUBLISH_BOARD, &[&board_id])?;
        operation.resource_id(board_id);
        self.scope.client().send_unit(operation).await
    }

    /// `UpdateBoard` — `PATCH /{accountId}/boards/{boardId}`.
    ///
    /// Sent up to 3 times, backing off from 1000 ms, when the answer is 429, 500 or 503.
    pub async fn update(
        &self,
        board_id: &str,
        body: &UpdateBoardRequestContent,
    ) -> Result<Board, Error> {
        let mut operation = self.scope.operation(&routes::UPDATE_BOARD, &[&board_id])?;
        operation.resource_id(board_id);
        operation.json(body)?;
        self.scope.client().send(operation).await
    }

    /// `UpdateBoardEntropy` — `PUT /{accountId}/boards/{boardId}/entropy.json`.
    ///
    /// Sent up to 3 times, backing off from 1000 ms, when the answer is 429, 500 or 503.
    pub async fn update_entropy(
        &self,
        board_id: &str,
        body: &UpdateBoardEntropyRequestContent,
    ) -> Result<Board, Error> {
        let mut operation = self
            .scope
            .operation(&routes::UPDATE_BOARD_ENTROPY, &[&board_id])?;
        operation.resource_id(board_id);
        operation.json(body)?;
        self.scope.client().send(operation).await
    }

    /// `UpdateBoardInvolvement` — `PATCH /{accountId}/boards/{boardId}/involvement.json`.
    ///
    /// Sent up to 3 times, backing off from 1000 ms, when the answer is 429, 500 or 503.
    pub async fn update_involvement(
        &self,
        board_id: &str,
        body: &UpdateBoardInvolvementRequestContent,
    ) -> Result<(), Error> {
        let mut operation = self
            .scope
            .operation(&routes::UPDATE_BOARD_INVOLVEMENT, &[&board_id])?;
        operation.resource_id(board_id);
        operation.json(body)?;
        self.scope.client().send_unit(operation).await
    }
}