diff --git a/src/requests/playbook.rs b/src/requests/playbook.rs index 7973d42..ceeb207 100644 --- a/src/requests/playbook.rs +++ b/src/requests/playbook.rs @@ -12,7 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -use amp_common::resource::Preface; use serde::{Deserialize, Serialize}; use utoipa::ToSchema; use uuid::Uuid; @@ -21,7 +20,7 @@ use uuid::Uuid; pub struct CreatePlaybookRequest { pub title: String, pub description: Option, - pub preface: Preface, + pub repo: String, } #[derive(Debug, Serialize, Deserialize, ToSchema)] diff --git a/src/services/playbook.rs b/src/services/playbook.rs index c88e45b..98976d1 100644 --- a/src/services/playbook.rs +++ b/src/services/playbook.rs @@ -13,7 +13,8 @@ // limitations under the License. use amp_client::playbooks::PlaybookPayload; -use amp_common::resource::PlaybookSpec; +use amp_common::resource::{PlaybookSpec, Preface}; +use amp_common::schema::GitReference; use amp_common::scm::content::Content; use amp_common::scm::git::Tree; use amp_common::sync::Synchronization; @@ -89,10 +90,15 @@ impl PlaybookService { } pub async fn create(ctx: Arc, req: &CreatePlaybookRequest) -> Result { + let mut preface = Preface::default(); + let mut reference = GitReference::default(); + preface.name = req.repo.clone(); + reference.repo = req.repo.clone(); + preface.repository = Some(reference); let payload = PlaybookPayload { title: req.title.clone(), description: req.description.clone().unwrap_or_default(), - preface: req.preface.clone(), + preface: preface.clone(), }; ctx.client.playbooks().create(payload).map_err(ApiError::FailedToCreatePlaybook) }