use crate::YdbIssue;
use ydb_grpc::ydb_proto::status_ids::StatusCode;
#[derive(Debug, Clone)]
#[cfg_attr(not(feature = "force-exhaustive-all"), non_exhaustive)]
pub struct OperationInfo {
pub id: String,
pub ready: bool,
pub status: i32,
pub issues: Vec<YdbIssue>,
pub consumed_units: Option<f64>,
}
impl OperationInfo {
pub fn status_code(&self) -> Option<StatusCode> {
StatusCode::try_from(self.status).ok()
}
pub fn is_success(&self) -> bool {
self.status_code() == Some(StatusCode::Success)
}
}
#[derive(Debug, Clone)]
#[cfg_attr(not(feature = "force-exhaustive-all"), non_exhaustive)]
pub struct ListOperationsRequest {
pub kind: String,
pub page_size: u64,
pub page_token: String,
}
impl ListOperationsRequest {
pub fn new(kind: impl Into<String>) -> Self {
Self {
kind: kind.into(),
page_size: 0,
page_token: String::new(),
}
}
pub fn with_page_size(mut self, page_size: u64) -> Self {
self.page_size = page_size;
self
}
pub fn with_page_token(mut self, page_token: impl Into<String>) -> Self {
self.page_token = page_token.into();
self
}
}
#[derive(Debug, Clone)]
#[cfg_attr(not(feature = "force-exhaustive-all"), non_exhaustive)]
pub struct ListOperationsResult {
pub operations: Vec<OperationInfo>,
pub next_page_token: String,
}
pub struct OperationKind;
impl OperationKind {
pub const EXECUTE_QUERY: &'static str = "scriptexec";
pub const BUILD_INDEX: &'static str = "buildindex";
pub const IMPORT_FROM_S3: &'static str = "import/s3";
pub const EXPORT_TO_S3: &'static str = "export/s3";
pub const EXPORT_TO_YT: &'static str = "export/yt";
}