Skip to content

Commit

Permalink
Move to new client and use PagedVec
Browse files Browse the repository at this point in the history
  • Loading branch information
hatchan committed Feb 22, 2024
1 parent 71cecb9 commit 278d968
Showing 1 changed file with 15 additions and 17 deletions.
32 changes: 15 additions & 17 deletions src/integrations/pagerduty_receivers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use crate::utils::{clear_or_update, override_pagination, override_sorting};
use anyhow::Result;
use clap::{Parser, ValueEnum};
use cli_table::Table;
use fiberplane::api_client;
use fiberplane::base64uuid::Base64Uuid;
use fiberplane::models::names::Name;
use fiberplane::models::pagerduty::{
Expand Down Expand Up @@ -106,12 +105,11 @@ async fn handle_create(args: CreateArgs) -> Result<()> {
)?;

let new_pagerduty_receiver = NewPagerDutyReceiver::builder()
.name(name)
.creation_template(args.incident_creation_template)
.build();
let pagerduty_receiver =
api_client::pagerduty_receiver_create(&client, workspace_id, new_pagerduty_receiver)
.await?;
let pagerduty_receiver = client
.pagerduty_receiver_create(workspace_id, name, new_pagerduty_receiver)
.await?;

match args.output {
PagerDutyWebhookOutput::Table => {
Expand Down Expand Up @@ -151,8 +149,7 @@ async fn handle_get(args: GetArgs) -> Result<()> {
let workspace_id = workspace_picker(&client, args.workspace_id).await?;
let name = name_req("PagerDuty webhook receiver name", args.name, None)?;

let pagerduty_receiver =
api_client::pagerduty_receiver_get(&client, workspace_id, name).await?;
let pagerduty_receiver = client.pagerduty_receiver_get(workspace_id, name).await?;

match args.output {
PagerDutyWebhookOutput::Table => {
Expand Down Expand Up @@ -219,13 +216,9 @@ async fn handle_update(args: UpdateArgs) -> Result<()> {
.regenerate_security_key(args.regenerate_security_key)
.build();

let pagerduty_receiver = api_client::pagerduty_receiver_update(
&client,
workspace_id,
name,
update_pagerduty_receiver,
)
.await?;
let pagerduty_receiver = client
.pagerduty_receiver_update(workspace_id, name, update_pagerduty_receiver)
.await?;

match args.output {
PagerDutyWebhookOutput::Table => {
Expand Down Expand Up @@ -261,7 +254,7 @@ async fn handle_delete(args: DeleteArgs) -> Result<()> {
let workspace_id = workspace_picker(&client, args.workspace_id).await?;
let name = name_req("PagerDuty webhook receiver name", args.name, None)?;

api_client::pagerduty_receiver_delete(&client, workspace_id, name).await?;
client.pagerduty_receiver_delete(workspace_id, name).await?;

info!("Deleted Pagerduty receiver");
Ok(())
Expand Down Expand Up @@ -310,8 +303,13 @@ async fn handle_list(args: ListArgs) -> Result<()> {
let sorting = override_sorting(args.sort_by, args.sort_direction);
let pagination = override_pagination(args.page, args.limit);

let pagerduty_receivers =
api_client::pagerduty_receiver_list(&client, workspace_id, sorting, pagination).await?;
let pagerduty_receivers = client
.pagerduty_receiver_list(workspace_id, sorting, pagination)
.await?;

if pagerduty_receivers.has_more_results {
info!(total_results = pagerduty_receivers.total_results, "There are more results available. Please use the --page and --limit flags to paginate through the results.")
}

match args.output {
PagerDutyWebhookOutput::Table => {
Expand Down

0 comments on commit 278d968

Please sign in to comment.