made-client 0.7.8

Reusable operator client for MADE's public gRPC API.
Documentation
use made_proto::v1::{
    ArtifactRecord, GetArtifactRequest, ListArtifactsRequest, ListArtifactsResponse,
};

use crate::{MadeClient, MadeClientError};

impl MadeClient {
    pub async fn get_artifact(
        &self,
        artifact_id: impl Into<String>,
    ) -> Result<ArtifactRecord, MadeClientError> {
        let response = self
            .rpc()
            .get_artifact(Self::request(
                &self.context(),
                "/underpass.made.v1.MadeService/GetArtifact",
                GetArtifactRequest {
                    artifact_id: artifact_id.into(),
                },
            ))
            .await
            .map_err(MadeClientError::from_status)?
            .into_inner();
        response.record.ok_or_else(|| {
            MadeClientError::ProtocolViolation("get artifact response has no record".to_owned())
        })
    }

    pub async fn list_artifacts(
        &self,
        cursor: Option<String>,
        limit: u32,
    ) -> Result<ListArtifactsResponse, MadeClientError> {
        self.rpc()
            .list_artifacts(Self::request(
                &self.context(),
                "/underpass.made.v1.MadeService/ListArtifacts",
                ListArtifactsRequest { cursor, limit },
            ))
            .await
            .map(tonic::Response::into_inner)
            .map_err(MadeClientError::from_status)
    }
}