use super::Options;
use crate::storage::{Error, object_store::ObjectStore};
use async_trait::async_trait;
use pbbson::Model;
use std::path::Path;
use tempfile::NamedTempFile;

const ERR_MSG: &str = "Object storage has not been configured";

pub struct ServiceUnavailableObjectStore {}

impl ServiceUnavailableObjectStore {
    pub fn new(_options: Options) -> Self {
        Self {}
    }
}

#[async_trait]
impl ObjectStore for ServiceUnavailableObjectStore {
    async fn create(&self, _metadata: Model, _path: &Path) -> Result<Model, Error> {
        Err(Error::unavailable(ERR_MSG))
    }

    async fn delete(&self, _id: &str, _by_account_id: Option<String>) -> Result<(), Error> {
        Err(Error::unavailable(ERR_MSG))
    }

    async fn download(&self, _id: &str) -> Result<NamedTempFile, Error> {
        Err(Error::unavailable(ERR_MSG))
    }

    async fn find(&self, _id: &str) -> Result<Model, Error> {
        Err(Error::unavailable(ERR_MSG))
    }

    async fn find_many(&self, _filter: Model, _ordering: Option<Model>) -> Result<Vec<Model>, Error> {
        Err(Error::unavailable(ERR_MSG))
    }

    async fn update(&self, _metadata: Model) -> Result<Model, Error> {
        Err(Error::unavailable(ERR_MSG))
    }
}
