Skip to content

Commit

Permalink
Modify create parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
jiahao6635 committed Jan 18, 2024
1 parent 4299efe commit 5e20d16
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
3 changes: 1 addition & 2 deletions src/requests/playbook.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -21,7 +20,7 @@ use uuid::Uuid;
pub struct CreatePlaybookRequest {
pub title: String,
pub description: Option<String>,
pub preface: Preface,
pub repo: String,
}

#[derive(Debug, Serialize, Deserialize, ToSchema)]
Expand Down
10 changes: 8 additions & 2 deletions src/services/playbook.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -89,10 +90,15 @@ impl PlaybookService {
}

pub async fn create(ctx: Arc<Context>, req: &CreatePlaybookRequest) -> Result<PlaybookSpec> {
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)
}
Expand Down

0 comments on commit 5e20d16

Please sign in to comment.