From 47cd643b571c5178b1001f22e1435c36e5e82c4f Mon Sep 17 00:00:00 2001 From: Brad Heller Date: Tue, 16 Sep 2025 14:54:32 +0200 Subject: [PATCH 1/3] Initial pass at environments management --- crates/config/src/error.rs | 4 +- crates/config/src/lib.rs | 5 +- crates/config/src/session.rs | 22 +- crates/config/src/towerfile.rs | 13 +- crates/crypto/src/lib.rs | 30 +- crates/testutils/src/crypto.rs | 7 +- crates/testutils/src/fs.rs | 4 +- crates/testutils/src/lib.rs | 2 +- crates/tower-api/src/apis/configuration.rs | 3 - crates/tower-api/src/apis/default_api.rs | 2096 +++++++++++++---- .../tower-api/src/apis/feature_flags_api.rs | 38 +- crates/tower-api/src/apis/mod.rs | 18 +- crates/tower-api/src/lib.rs | 4 +- crates/tower-api/src/models/account.rs | 8 +- .../src/models/acknowledge_alert_response.rs | 3 +- .../models/acknowledge_all_alerts_response.rs | 3 +- crates/tower-api/src/models/alert.rs | 13 +- crates/tower-api/src/models/api_key.rs | 10 +- crates/tower-api/src/models/app.rs | 14 +- crates/tower-api/src/models/app_statistics.rs | 10 +- crates/tower-api/src/models/app_summary.rs | 8 +- crates/tower-api/src/models/app_version.rs | 10 +- .../src/models/cancel_run_response.rs | 8 +- crates/tower-api/src/models/catalog.rs | 11 +- .../tower-api/src/models/catalog_property.rs | 8 +- .../claim_device_login_ticket_params.rs | 3 +- .../claim_device_login_ticket_response.rs | 3 +- .../src/models/create_account_params.rs | 3 +- .../create_account_params_flags_struct.rs | 7 +- .../src/models/create_account_response.rs | 3 +- .../src/models/create_api_key_params.rs | 8 +- .../src/models/create_api_key_response.rs | 3 +- .../tower-api/src/models/create_app_params.rs | 8 +- .../src/models/create_app_response.rs | 8 +- .../src/models/create_authenticator_params.rs | 3 +- .../models/create_authenticator_response.rs | 3 +- .../src/models/create_catalog_params.rs | 19 +- .../src/models/create_catalog_response.rs | 3 +- .../create_device_login_ticket_response.rs | 13 +- .../src/models/create_environment_params.rs | 8 +- .../src/models/create_environment_response.rs | 3 +- .../models/create_password_reset_params.rs | 3 +- .../models/create_password_reset_response.rs | 8 +- .../src/models/create_schedule_params.rs | 10 +- .../src/models/create_schedule_response.rs | 3 +- .../src/models/create_secret_params.rs | 10 +- .../src/models/create_secret_response.rs | 3 +- .../src/models/create_session_params.rs | 3 +- .../src/models/create_session_response.rs | 3 +- .../src/models/create_team_params.rs | 8 +- .../src/models/create_team_response.rs | 8 +- .../src/models/delete_api_key_params.rs | 3 +- .../src/models/delete_api_key_response.rs | 3 +- .../src/models/delete_app_response.rs | 8 +- .../src/models/delete_authenticator_params.rs | 3 +- .../models/delete_authenticator_response.rs | 3 +- .../src/models/delete_catalog_response.rs | 3 +- .../src/models/delete_schedule_params.rs | 8 +- .../src/models/delete_schedule_response.rs | 7 +- .../src/models/delete_secret_response.rs | 3 +- .../models/delete_team_invitation_params.rs | 3 +- .../models/delete_team_invitation_response.rs | 3 +- .../src/models/delete_team_params.rs | 8 +- .../src/models/delete_team_response.rs | 8 +- .../src/models/deploy_app_response.rs | 3 +- .../src/models/describe_app_response.rs | 3 +- .../models/describe_app_version_response.rs | 3 +- .../describe_device_login_session_response.rs | 3 +- .../src/models/describe_run_logs_response.rs | 3 +- .../src/models/describe_run_response.rs | 8 +- .../models/describe_secrets_key_response.rs | 3 +- .../src/models/describe_session_response.rs | 3 +- .../src/models/encrypted_catalog_property.rs | 3 +- crates/tower-api/src/models/environment.rs | 7 +- crates/tower-api/src/models/error_detail.rs | 10 +- crates/tower-api/src/models/error_model.rs | 3 +- crates/tower-api/src/models/event_error.rs | 8 +- crates/tower-api/src/models/event_log.rs | 8 +- .../src/models/event_run_failure_alert.rs | 3 +- crates/tower-api/src/models/event_warning.rs | 8 +- .../src/models/export_catalogs_params.rs | 11 +- .../src/models/export_catalogs_response.rs | 8 +- .../src/models/export_secrets_params.rs | 11 +- .../src/models/export_secrets_response.rs | 8 +- .../tower-api/src/models/exported_catalog.rs | 11 +- .../src/models/exported_catalog_property.rs | 3 +- .../tower-api/src/models/exported_secret.rs | 10 +- .../src/models/featurebase_identity.rs | 3 +- crates/tower-api/src/models/features.rs | 8 +- .../generate_app_statistics_response.rs | 3 +- .../models/generate_authenticator_response.rs | 3 +- .../generate_run_statistics_response.rs | 9 +- .../generate_runner_credentials_response.rs | 3 +- .../models/get_feature_flag_response_body.rs | 10 +- .../src/models/invite_team_member_params.rs | 3 +- .../src/models/invite_team_member_response.rs | 3 +- .../src/models/leave_team_response.rs | 8 +- .../src/models/list_account_plans_response.rs | 3 +- .../src/models/list_alerts_200_response.rs | 9 +- .../src/models/list_alerts_response.rs | 3 +- .../src/models/list_api_keys_response.rs | 3 +- .../models/list_app_environments_response.rs | 3 +- .../src/models/list_app_versions_response.rs | 3 +- .../src/models/list_apps_response.rs | 3 +- .../models/list_authenticators_response.rs | 3 +- .../src/models/list_catalogs_response.rs | 3 +- .../src/models/list_environments_response.rs | 3 +- .../list_my_team_invitations_response.rs | 3 +- .../src/models/list_runs_response.rs | 3 +- .../src/models/list_schedules_response.rs | 8 +- .../list_secret_environments_response.rs | 3 +- .../src/models/list_secrets_response.rs | 3 +- .../models/list_team_invitations_response.rs | 3 +- .../src/models/list_team_members_response.rs | 3 +- .../src/models/list_teams_response.rs | 3 +- crates/tower-api/src/models/pagination.rs | 3 +- crates/tower-api/src/models/parameter.rs | 3 +- crates/tower-api/src/models/plan.rs | 13 +- .../src/models/refresh_session_params.rs | 7 +- .../src/models/refresh_session_response.rs | 3 +- .../src/models/remove_team_member_params.rs | 3 +- .../src/models/remove_team_member_response.rs | 3 +- .../models/resend_team_invitation_params.rs | 3 +- .../models/resend_team_invitation_response.rs | 3 +- crates/tower-api/src/models/run.rs | 35 +- crates/tower-api/src/models/run_app_params.rs | 15 +- .../tower-api/src/models/run_app_response.rs | 8 +- .../tower-api/src/models/run_failure_alert.rs | 8 +- crates/tower-api/src/models/run_log_line.rs | 16 +- crates/tower-api/src/models/run_parameter.rs | 8 +- crates/tower-api/src/models/run_results.rs | 12 +- crates/tower-api/src/models/run_statistics.rs | 12 +- .../src/models/run_timeseries_point.rs | 14 +- .../src/models/runner_credentials.rs | 10 +- crates/tower-api/src/models/schedule.rs | 12 +- .../src/models/search_runs_response.rs | 3 +- crates/tower-api/src/models/secret.rs | 3 +- crates/tower-api/src/models/session.rs | 10 +- crates/tower-api/src/models/sse_warning.rs | 3 +- .../src/models/statistics_settings.rs | 16 +- .../stream_alerts_200_response_inner.rs | 3 +- .../stream_run_logs_200_response_inner.rs | 8 +- crates/tower-api/src/models/team.rs | 3 +- .../tower-api/src/models/team_invitation.rs | 3 +- crates/tower-api/src/models/token.rs | 7 +- .../src/models/unverified_authenticator.rs | 3 +- .../src/models/update_account_name_params.rs | 8 +- .../models/update_account_name_response.rs | 3 +- .../tower-api/src/models/update_app_params.rs | 10 +- .../src/models/update_app_response.rs | 8 +- .../src/models/update_catalog_params.rs | 8 +- .../src/models/update_catalog_response.rs | 3 +- .../src/models/update_environment_params.rs | 3 +- .../src/models/update_environment_response.rs | 3 +- .../update_my_team_invitation_params.rs | 3 +- .../update_my_team_invitation_response.rs | 7 +- .../models/update_password_reset_params.rs | 3 +- .../models/update_password_reset_response.rs | 8 +- .../src/models/update_plan_params.rs | 3 +- .../src/models/update_plan_response.rs | 8 +- .../src/models/update_schedule_params.rs | 10 +- .../src/models/update_schedule_response.rs | 3 +- .../src/models/update_secret_params.rs | 9 +- .../src/models/update_secret_response.rs | 3 +- .../src/models/update_team_params.rs | 8 +- .../src/models/update_team_response.rs | 8 +- .../src/models/update_user_params.rs | 52 +- .../src/models/update_user_response.rs | 8 +- crates/tower-api/src/models/user.rs | 21 +- .../src/models/verified_authenticator.rs | 10 +- .../src/models/verify_email_params.rs | 8 +- .../src/models/verify_email_response.rs | 8 +- crates/tower-cmd/src/api.rs | 399 +++- crates/tower-cmd/src/apps.rs | 36 +- crates/tower-cmd/src/deploy.rs | 13 +- crates/tower-cmd/src/environments.rs | 58 + crates/tower-cmd/src/error.rs | 2 +- crates/tower-cmd/src/lib.rs | 22 +- crates/tower-cmd/src/output.rs | 29 +- crates/tower-cmd/src/run.rs | 142 +- crates/tower-cmd/src/secrets.rs | 95 +- crates/tower-cmd/src/session.rs | 9 +- crates/tower-cmd/src/teams.rs | 14 +- crates/tower-cmd/src/util/dates.rs | 2 +- crates/tower-cmd/src/util/deploy.rs | 13 +- crates/tower-cmd/src/util/mod.rs | 4 +- crates/tower-cmd/src/version.rs | 5 +- crates/tower-package/src/lib.rs | 467 ++-- crates/tower-package/tests/package_test.rs | 272 ++- crates/tower-runtime/src/errors.rs | 14 +- crates/tower-runtime/src/lib.rs | 22 +- crates/tower-runtime/src/local.rs | 178 +- crates/tower-runtime/tests/local_test.rs | 38 +- crates/tower-telemetry/src/lib.rs | 9 +- crates/tower-telemetry/src/logging.rs | 41 +- crates/tower-uv/src/install.rs | 135 +- crates/tower-uv/src/lib.rs | 37 +- crates/tower-uv/tests/install_test.rs | 5 +- crates/tower-version/src/lib.rs | 23 +- 199 files changed, 3530 insertions(+), 1864 deletions(-) create mode 100644 crates/tower-cmd/src/environments.rs diff --git a/crates/config/src/error.rs b/crates/config/src/error.rs index fd276531..45169c63 100644 --- a/crates/config/src/error.rs +++ b/crates/config/src/error.rs @@ -27,7 +27,9 @@ pub enum Error { #[snafu(display("Unknown describe session value: {}", value))] UnknownDescribeSessionValue { value: serde_json::Value }, - DescribeSessionError { err: tower_api::apis::Error }, + DescribeSessionError { + err: tower_api::apis::Error, + }, } impl From for Error { diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index 29848012..e77be7a1 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -10,10 +10,7 @@ pub use error::Error; pub use session::{default_tower_url, Session, Team, Token, User}; pub use towerfile::Towerfile; -pub use session::{ - get_last_version_check_timestamp, - set_last_version_check_timestamp, -}; +pub use session::{get_last_version_check_timestamp, set_last_version_check_timestamp}; #[derive(Clone, Serialize, Deserialize)] pub struct Config { diff --git a/crates/config/src/session.rs b/crates/config/src/session.rs index 2fddd910..9148bb22 100644 --- a/crates/config/src/session.rs +++ b/crates/config/src/session.rs @@ -1,7 +1,7 @@ -use std::future::Future; +use chrono::{DateTime, TimeZone, Utc}; use serde::{Deserialize, Serialize}; -use chrono::{DateTime, Utc, TimeZone}; use std::fs; +use std::future::Future; use std::path::PathBuf; use url::Url; @@ -77,18 +77,22 @@ pub fn get_last_version_check_timestamp() -> DateTime { // called last_version_check.txt and contains a chrono::DateTime timestamp in ISO 8601 format. match find_or_create_config_dir() { Ok(path) => { - if let Ok(last_version_check) = fs::read_to_string(path.join("last_version_check.txt")) { + if let Ok(last_version_check) = fs::read_to_string(path.join("last_version_check.txt")) + { if let Ok(dt) = DateTime::parse_from_rfc3339(&last_version_check) { dt.into() } else { - debug!("Error parsing last version check timestamp: {}", last_version_check); + debug!( + "Error parsing last version check timestamp: {}", + last_version_check + ); default } } else { debug!("Error reading last version check timestamp"); default } - }, + } Err(err) => { debug!("Error finding config dir: {}", err); default @@ -104,7 +108,7 @@ pub fn set_last_version_check_timestamp(dt: DateTime) { if let Err(err) = fs::write(path.join("last_version_check.txt"), dt_str) { debug!("Error writing last version check timestamp: {}", err); } - }, + } Err(err) => { debug!("Error finding config dir: {}", err); } @@ -307,11 +311,9 @@ impl Session { // This hairy little function is a workaround for the fact that we can't use async/await in the // context of some of the functions in this file. -fn run_future_sync(future: F) -> T +fn run_future_sync(future: F) -> T where F: Future, { - tokio::task::block_in_place(|| { - tokio::runtime::Handle::current().block_on(future) - }) + tokio::task::block_in_place(|| tokio::runtime::Handle::current().block_on(future)) } diff --git a/crates/config/src/towerfile.rs b/crates/config/src/towerfile.rs index 0b228d50..60e627e8 100644 --- a/crates/config/src/towerfile.rs +++ b/crates/config/src/towerfile.rs @@ -3,7 +3,7 @@ use serde::Deserialize; use std::path::PathBuf; #[derive(Deserialize, Debug)] -pub struct Parameter{ +pub struct Parameter { #[serde(default)] pub name: String, @@ -70,7 +70,9 @@ impl Towerfile { let towerfile: Towerfile = toml::from_str(toml)?; if towerfile.app.name.is_empty() { - return Err(Error::MissingRequiredAppField{ field: "name".to_string() }); + return Err(Error::MissingRequiredAppField { + field: "name".to_string(), + }); } else { Ok(towerfile) } @@ -156,7 +158,10 @@ mod test { "#; let err = crate::Towerfile::from_toml(toml).err().unwrap(); - assert_eq!(err.to_string(), "Missing required app field `name` in Towerfile"); + assert_eq!( + err.to_string(), + "Missing required app field `name` in Towerfile" + ); } #[ignore] @@ -212,7 +217,7 @@ mod test { "#; let temp_dir = std::env::temp_dir(); - let towerfile_path= temp_dir.join("Towerfile"); + let towerfile_path = temp_dir.join("Towerfile"); let mut tempfile = TestFile::new(towerfile_path.clone()).unwrap(); let file = tempfile.file(); file.write_all(toml.as_bytes()).unwrap(); diff --git a/crates/crypto/src/lib.rs b/crates/crypto/src/lib.rs index 92bc1fac..f18b958a 100644 --- a/crates/crypto/src/lib.rs +++ b/crates/crypto/src/lib.rs @@ -1,14 +1,10 @@ -use sha2::Sha256; +use aes_gcm::aead::Aead; +use aes_gcm::{Aes256Gcm, Key, KeyInit, Nonce}; // Or Aes256GcmSiv, Aes256GcmHs use base64::prelude::*; use rand::rngs::OsRng; use rand::RngCore; -use aes_gcm::{Aes256Gcm, Key, KeyInit, Nonce}; // Or Aes256GcmSiv, Aes256GcmHs -use aes_gcm::aead::Aead; -use rsa::{ - Oaep, RsaPrivateKey, RsaPublicKey, - traits::PublicKeyParts, - pkcs8::EncodePublicKey, -}; +use rsa::{pkcs8::EncodePublicKey, traits::PublicKeyParts, Oaep, RsaPrivateKey, RsaPublicKey}; +use sha2::Sha256; mod errors; pub use errors::Error; @@ -16,10 +12,7 @@ pub use errors::Error; /// encrypt encryptes plaintext with a randomly-generated AES-256 key and IV, then encrypts the AES /// key with RSA-OAEP using the provided public key. The result is a non-URL-safe base64-encoded /// string. -pub fn encrypt( - key: RsaPublicKey, - plaintext: String -) -> Result { +pub fn encrypt(key: RsaPublicKey, plaintext: String) -> Result { // Generate a random 32-byte AES key let mut aes_key = [0u8; 32]; OsRng.fill_bytes(&mut aes_key); @@ -58,12 +51,9 @@ pub fn decrypt(key: RsaPrivateKey, ciphertext: String) -> Result let n = key.size(); let (ciphered_key, suffix) = decoded.split_at(n); - let key = key.decrypt( - Oaep::new::(), - ciphered_key, - )?; + let key = key.decrypt(Oaep::new::(), ciphered_key)?; - let aes_key =Key::::from_slice(&key); + let aes_key = Key::::from_slice(&key); let cipher = Aes256Gcm::new(aes_key); // Check if the suffix is at least 12 bytes (96 bits) for the IV @@ -100,7 +90,7 @@ mod test { #[test] fn test_encrypt_decrypt() { - let (private_key, public_key) = testutils::crypto::get_test_keys(); + let (private_key, public_key) = testutils::crypto::get_test_keys(); let plaintext = "Hello, World!".to_string(); let ciphertext = encrypt(public_key, plaintext.clone()).unwrap(); @@ -111,7 +101,7 @@ mod test { #[test] fn test_encrypt_decrypt_long_messages() { - let (private_key, public_key) = testutils::crypto::get_test_keys(); + let (private_key, public_key) = testutils::crypto::get_test_keys(); let plaintext: String = rand::thread_rng() .sample_iter(&Alphanumeric) @@ -127,7 +117,7 @@ mod test { #[test] fn test_serialize_public_key() { - let (_private_key, public_key) = testutils::crypto::get_test_keys(); + let (_private_key, public_key) = testutils::crypto::get_test_keys(); let serialized = serialize_public_key(public_key.clone()); let deserialized = RsaPublicKey::from_public_key_pem(&serialized).unwrap(); diff --git a/crates/testutils/src/crypto.rs b/crates/testutils/src/crypto.rs index 8dc9b584..508146d5 100644 --- a/crates/testutils/src/crypto.rs +++ b/crates/testutils/src/crypto.rs @@ -1,9 +1,4 @@ -use rsa::{ - RsaPublicKey, - RsaPrivateKey, - pkcs1::DecodeRsaPublicKey, - pkcs1::DecodeRsaPrivateKey, -}; +use rsa::{pkcs1::DecodeRsaPrivateKey, pkcs1::DecodeRsaPublicKey, RsaPrivateKey, RsaPublicKey}; const PUBLIC_KEY_PEM: &str = "-----BEGIN RSA PUBLIC KEY----- MIIBCgKCAQEAxModqC5QNOKPZRDkaEnY8AL6gFsasyFXveqJAEnCK75Adodj4MD0 diff --git a/crates/testutils/src/fs.rs b/crates/testutils/src/fs.rs index b9c40551..26533ce3 100644 --- a/crates/testutils/src/fs.rs +++ b/crates/testutils/src/fs.rs @@ -1,6 +1,6 @@ -use std::fs::{File, remove_file}; -use std::path::{Path, PathBuf}; +use std::fs::{remove_file, File}; use std::io; +use std::path::{Path, PathBuf}; pub struct TestFile { path: PathBuf, diff --git a/crates/testutils/src/lib.rs b/crates/testutils/src/lib.rs index 6af3ab6c..3020392b 100644 --- a/crates/testutils/src/lib.rs +++ b/crates/testutils/src/lib.rs @@ -1,2 +1,2 @@ -pub mod fs; pub mod crypto; +pub mod fs; diff --git a/crates/tower-api/src/apis/configuration.rs b/crates/tower-api/src/apis/configuration.rs index 8d7f593d..9ae99dba 100644 --- a/crates/tower-api/src/apis/configuration.rs +++ b/crates/tower-api/src/apis/configuration.rs @@ -8,8 +8,6 @@ * Generated by: https://openapi-generator.tech */ - - #[derive(Debug, Clone)] pub struct Configuration { pub base_path: String, @@ -29,7 +27,6 @@ pub struct ApiKey { pub key: String, } - impl Configuration { pub fn new() -> Configuration { Configuration::default() diff --git a/crates/tower-api/src/apis/default_api.rs b/crates/tower-api/src/apis/default_api.rs index a53798ee..d3280a6d 100644 --- a/crates/tower-api/src/apis/default_api.rs +++ b/crates/tower-api/src/apis/default_api.rs @@ -8,11 +8,10 @@ * Generated by: https://openapi-generator.tech */ - -use reqwest; -use serde::{Deserialize, Serialize, de::Error as _}; +use super::{configuration, ContentType, Error}; use crate::{apis::ResponseContent, models}; -use super::{Error, configuration, ContentType}; +use reqwest; +use serde::{de::Error as _, Deserialize, Serialize}; const DEFAULT_TOWER_TRACE_ID: &str = "(none)"; @@ -20,7 +19,7 @@ const DEFAULT_TOWER_TRACE_ID: &str = "(none)"; #[derive(Clone, Debug)] pub struct AcknowledgeAlertParams { /// Seq of the alert to acknowledge - pub alert_seq: i64 + pub alert_seq: i64, } /// struct for passing parameters to the method [`cancel_run`] @@ -29,105 +28,105 @@ pub struct CancelRunParams { /// The name of the app to fetch runs for. pub name: String, /// The number of the run to fetch. - pub seq: i64 + pub seq: i64, } /// struct for passing parameters to the method [`claim_device_login_ticket`] #[derive(Clone, Debug)] pub struct ClaimDeviceLoginTicketParams { - pub claim_device_login_ticket_params: models::ClaimDeviceLoginTicketParams + pub claim_device_login_ticket_params: models::ClaimDeviceLoginTicketParams, } /// struct for passing parameters to the method [`create_account`] #[derive(Clone, Debug)] pub struct CreateAccountParams { - pub create_account_params: models::CreateAccountParams + pub create_account_params: models::CreateAccountParams, } /// struct for passing parameters to the method [`create_api_key`] #[derive(Clone, Debug)] pub struct CreateApiKeyParams { - pub create_api_key_params: models::CreateApiKeyParams + pub create_api_key_params: models::CreateApiKeyParams, } /// struct for passing parameters to the method [`create_app`] #[derive(Clone, Debug)] pub struct CreateAppParams { - pub create_app_params: models::CreateAppParams + pub create_app_params: models::CreateAppParams, } /// struct for passing parameters to the method [`create_authenticator`] #[derive(Clone, Debug)] pub struct CreateAuthenticatorParams { - pub create_authenticator_params: models::CreateAuthenticatorParams + pub create_authenticator_params: models::CreateAuthenticatorParams, } /// struct for passing parameters to the method [`create_catalog`] #[derive(Clone, Debug)] pub struct CreateCatalogParams { - pub create_catalog_params: models::CreateCatalogParams + pub create_catalog_params: models::CreateCatalogParams, } /// struct for passing parameters to the method [`create_environment`] #[derive(Clone, Debug)] pub struct CreateEnvironmentParams { - pub create_environment_params: models::CreateEnvironmentParams + pub create_environment_params: models::CreateEnvironmentParams, } /// struct for passing parameters to the method [`create_password_reset`] #[derive(Clone, Debug)] pub struct CreatePasswordResetParams { - pub create_password_reset_params: models::CreatePasswordResetParams + pub create_password_reset_params: models::CreatePasswordResetParams, } /// struct for passing parameters to the method [`create_schedule`] #[derive(Clone, Debug)] pub struct CreateScheduleParams { - pub create_schedule_params: models::CreateScheduleParams + pub create_schedule_params: models::CreateScheduleParams, } /// struct for passing parameters to the method [`create_secret`] #[derive(Clone, Debug)] pub struct CreateSecretParams { - pub create_secret_params: models::CreateSecretParams + pub create_secret_params: models::CreateSecretParams, } /// struct for passing parameters to the method [`create_session`] #[derive(Clone, Debug)] pub struct CreateSessionParams { - pub create_session_params: models::CreateSessionParams + pub create_session_params: models::CreateSessionParams, } /// struct for passing parameters to the method [`create_team`] #[derive(Clone, Debug)] pub struct CreateTeamParams { - pub create_team_params: models::CreateTeamParams + pub create_team_params: models::CreateTeamParams, } /// struct for passing parameters to the method [`delete_alert`] #[derive(Clone, Debug)] pub struct DeleteAlertParams { /// ID of the alert to delete - pub alert_id: String + pub alert_id: String, } /// struct for passing parameters to the method [`delete_api_key`] #[derive(Clone, Debug)] pub struct DeleteApiKeyParams { - pub delete_api_key_params: models::DeleteApiKeyParams + pub delete_api_key_params: models::DeleteApiKeyParams, } /// struct for passing parameters to the method [`delete_app`] #[derive(Clone, Debug)] pub struct DeleteAppParams { /// The name of the app to delete. - pub name: String + pub name: String, } /// struct for passing parameters to the method [`delete_authenticator`] #[derive(Clone, Debug)] pub struct DeleteAuthenticatorParams { - pub delete_authenticator_params: models::DeleteAuthenticatorParams + pub delete_authenticator_params: models::DeleteAuthenticatorParams, } /// struct for passing parameters to the method [`delete_catalog`] @@ -136,13 +135,13 @@ pub struct DeleteCatalogParams { /// The name of the catalog to update. pub name: String, /// The environment of the catalog to delete. - pub environment: Option + pub environment: Option, } /// struct for passing parameters to the method [`delete_schedule`] #[derive(Clone, Debug)] pub struct DeleteScheduleParams { - pub delete_schedule_params: models::DeleteScheduleParams + pub delete_schedule_params: models::DeleteScheduleParams, } /// struct for passing parameters to the method [`delete_secret`] @@ -151,13 +150,13 @@ pub struct DeleteSecretParams { /// The name of the secret to delete. pub name: String, /// The environment of the secret to delete. - pub environment: Option + pub environment: Option, } /// struct for passing parameters to the method [`delete_team`] #[derive(Clone, Debug)] pub struct DeleteTeamParams { - pub delete_team_params: models::DeleteTeamParams + pub delete_team_params: models::DeleteTeamParams, } /// struct for passing parameters to the method [`delete_team_invitation`] @@ -165,7 +164,7 @@ pub struct DeleteTeamParams { pub struct DeleteTeamInvitationParams { /// The name of the team to remove someone from pub name: String, - pub delete_team_invitation_params: models::DeleteTeamInvitationParams + pub delete_team_invitation_params: models::DeleteTeamInvitationParams, } /// struct for passing parameters to the method [`deploy_app`] @@ -176,7 +175,7 @@ pub struct DeployAppParams { /// The encoding of the content. pub content_encoding: Option, /// The SHA256 hash of the content, used to verify integrity. - pub x_tower_checksum_sha256: Option + pub x_tower_checksum_sha256: Option, } /// struct for passing parameters to the method [`describe_app`] @@ -191,7 +190,7 @@ pub struct DescribeAppParams { /// Filter runs scheduled before or at this datetime (inclusive). Provide timestamps in ISO-8601 format. pub end_at: Option, /// Timezone for the statistics (e.g., 'Europe/Berlin'). Defaults to UTC. - pub timezone: Option + pub timezone: Option, } /// struct for passing parameters to the method [`describe_app_version`] @@ -200,14 +199,14 @@ pub struct DescribeAppVersionParams { /// The name of the app to get the version for. pub name: String, /// The version string to get the version for. - pub num: String + pub num: String, } /// struct for passing parameters to the method [`describe_device_login_session`] #[derive(Clone, Debug)] pub struct DescribeDeviceLoginSessionParams { /// The device code to check. - pub device_code: String + pub device_code: String, } /// struct for passing parameters to the method [`describe_run`] @@ -216,7 +215,7 @@ pub struct DescribeRunParams { /// The name of the app to fetch runs for. pub name: String, /// The number of the run to fetch. - pub seq: i64 + pub seq: i64, } /// struct for passing parameters to the method [`describe_run_logs`] @@ -225,33 +224,33 @@ pub struct DescribeRunLogsParams { /// The name of the app to get logs for. pub name: String, /// The sequence number of the run to get logs for. - pub seq: i64 + pub seq: i64, } /// struct for passing parameters to the method [`describe_secrets_key`] #[derive(Clone, Debug)] pub struct DescribeSecretsKeyParams { /// The format to return the key in. Options are 'pkcs1' and 'spki'. - pub format: Option + pub format: Option, } /// struct for passing parameters to the method [`export_catalogs`] #[derive(Clone, Debug)] pub struct ExportCatalogsParams { - pub export_catalogs_params: models::ExportCatalogsParams + pub export_catalogs_params: models::ExportCatalogsParams, } /// struct for passing parameters to the method [`export_secrets`] #[derive(Clone, Debug)] pub struct ExportSecretsParams { - pub export_secrets_params: models::ExportSecretsParams + pub export_secrets_params: models::ExportSecretsParams, } /// struct for passing parameters to the method [`generate_app_statistics`] #[derive(Clone, Debug)] pub struct GenerateAppStatisticsParams { /// The environment to filter the statistics by. If not provided, statistics for all environments will be returned. - pub environment: Option + pub environment: Option, } /// struct for passing parameters to the method [`generate_run_statistics`] @@ -266,7 +265,7 @@ pub struct GenerateRunStatisticsParams { /// Timezone for the statistics (e.g., 'Europe/Berlin'). Defaults to UTC. pub timezone: Option, /// Filter runs by environment. If not provided, all environments will be included. - pub environment: Option + pub environment: Option, } /// struct for passing parameters to the method [`invite_team_member`] @@ -274,14 +273,14 @@ pub struct GenerateRunStatisticsParams { pub struct InviteTeamMemberParams { /// The name of the team to invite someone to pub name: String, - pub invite_team_member_params: models::InviteTeamMemberParams + pub invite_team_member_params: models::InviteTeamMemberParams, } /// struct for passing parameters to the method [`leave_team`] #[derive(Clone, Debug)] pub struct LeaveTeamParams { /// The name of the team to leave - pub name: String + pub name: String, } /// struct for passing parameters to the method [`list_alerts`] @@ -300,21 +299,21 @@ pub struct ListAlertsParams { /// Filter alerts by acknowledged status. pub acked: Option, /// Filter alerts by environment (e.g., production, staging) - pub environment: Option + pub environment: Option, } /// struct for passing parameters to the method [`list_app_environments`] #[derive(Clone, Debug)] pub struct ListAppEnvironmentsParams { /// The name of the app to get the version for. - pub name: String + pub name: String, } /// struct for passing parameters to the method [`list_app_versions`] #[derive(Clone, Debug)] pub struct ListAppVersionsParams { /// The name of the app to list versions for. - pub name: String + pub name: String, } /// struct for passing parameters to the method [`list_apps`] @@ -333,7 +332,7 @@ pub struct ListAppsParams { /// Filter to see apps with certain statuses. pub filter: Option, /// The environment to filter the apps by. If not provided, apps for all environments will be returned. - pub environment: Option + pub environment: Option, } /// struct for passing parameters to the method [`list_catalogs`] @@ -346,7 +345,7 @@ pub struct ListCatalogsParams { /// The page number to fetch. pub page: Option, /// The number of records to fetch on each page. - pub page_size: Option + pub page_size: Option, } /// struct for passing parameters to the method [`list_plans`] @@ -355,7 +354,7 @@ pub struct ListPlansParams { /// The page number to fetch. pub page: Option, /// The number of records to fetch on each page. - pub page_size: Option + pub page_size: Option, } /// struct for passing parameters to the method [`list_runs`] @@ -374,7 +373,7 @@ pub struct ListRunsParams { /// Filter runs scheduled before or at this datetime (inclusive) pub end_at: Option, /// Filter runs by environment. If not provided, all environments will be included. - pub environment: Option + pub environment: Option, } /// struct for passing parameters to the method [`list_schedules`] @@ -383,7 +382,7 @@ pub struct ListSchedulesParams { /// The page number to fetch. pub page: Option, /// The number of records to fetch on each page. - pub page_size: Option + pub page_size: Option, } /// struct for passing parameters to the method [`list_secrets`] @@ -396,27 +395,27 @@ pub struct ListSecretsParams { /// The page number to fetch. pub page: Option, /// The number of records to fetch on each page. - pub page_size: Option + pub page_size: Option, } /// struct for passing parameters to the method [`list_team_invitations`] #[derive(Clone, Debug)] pub struct ListTeamInvitationsParams { /// The name of the team to list members for - pub name: String + pub name: String, } /// struct for passing parameters to the method [`list_team_members`] #[derive(Clone, Debug)] pub struct ListTeamMembersParams { /// The name of the team to list members for - pub name: String + pub name: String, } /// struct for passing parameters to the method [`refresh_session`] #[derive(Clone, Debug)] pub struct RefreshSessionParams { - pub refresh_session_params: models::RefreshSessionParams + pub refresh_session_params: models::RefreshSessionParams, } /// struct for passing parameters to the method [`remove_team_member`] @@ -424,7 +423,7 @@ pub struct RefreshSessionParams { pub struct RemoveTeamMemberParams { /// The name of the team to remove someone from pub name: String, - pub remove_team_member_params: models::RemoveTeamMemberParams + pub remove_team_member_params: models::RemoveTeamMemberParams, } /// struct for passing parameters to the method [`resend_team_invitation`] @@ -432,7 +431,7 @@ pub struct RemoveTeamMemberParams { pub struct ResendTeamInvitationParams { /// The name of the team to invite someone to pub name: String, - pub resend_team_invitation_params: models::ResendTeamInvitationParams + pub resend_team_invitation_params: models::ResendTeamInvitationParams, } /// struct for passing parameters to the method [`run_app`] @@ -440,7 +439,7 @@ pub struct ResendTeamInvitationParams { pub struct RunAppParams { /// The name of the app to fetch runs for. pub name: String, - pub run_app_params: models::RunAppParams + pub run_app_params: models::RunAppParams, } /// struct for passing parameters to the method [`search_runs`] @@ -457,7 +456,7 @@ pub struct SearchRunsParams { /// Filter runs scheduled before or at this datetime (inclusive). Provide timestamps in ISO-8601 format. pub end_at: Option, /// Filter runs by environment. If not provided, all environments will be included. - pub environment: Option + pub environment: Option, } /// struct for passing parameters to the method [`stream_run_logs`] @@ -466,7 +465,7 @@ pub struct StreamRunLogsParams { /// The name of the app to get logs for. pub name: String, /// The sequence number of the run to get logs for. - pub seq: i64 + pub seq: i64, } /// struct for passing parameters to the method [`update_account_name`] @@ -474,7 +473,7 @@ pub struct StreamRunLogsParams { pub struct UpdateAccountNameParams { /// The name of the account to update pub name: String, - pub update_account_name_params: models::UpdateAccountNameParams + pub update_account_name_params: models::UpdateAccountNameParams, } /// struct for passing parameters to the method [`update_app`] @@ -482,7 +481,7 @@ pub struct UpdateAccountNameParams { pub struct UpdateAppParams { /// The name of the App to update. pub name: String, - pub update_app_params: models::UpdateAppParams + pub update_app_params: models::UpdateAppParams, } /// struct for passing parameters to the method [`update_catalog`] @@ -490,7 +489,7 @@ pub struct UpdateAppParams { pub struct UpdateCatalogParams { /// The name of the catalog to update. pub name: String, - pub update_catalog_params: models::UpdateCatalogParams + pub update_catalog_params: models::UpdateCatalogParams, } /// struct for passing parameters to the method [`update_environment`] @@ -498,13 +497,13 @@ pub struct UpdateCatalogParams { pub struct UpdateEnvironmentParams { /// The current name of the environment to update. pub name: String, - pub update_environment_params: models::UpdateEnvironmentParams + pub update_environment_params: models::UpdateEnvironmentParams, } /// struct for passing parameters to the method [`update_my_team_invitation`] #[derive(Clone, Debug)] pub struct UpdateMyTeamInvitationParams { - pub update_my_team_invitation_params: models::UpdateMyTeamInvitationParams + pub update_my_team_invitation_params: models::UpdateMyTeamInvitationParams, } /// struct for passing parameters to the method [`update_password_reset`] @@ -512,13 +511,13 @@ pub struct UpdateMyTeamInvitationParams { pub struct UpdatePasswordResetParams { /// The password reset code that was sent to you pub code: String, - pub update_password_reset_params: models::UpdatePasswordResetParams + pub update_password_reset_params: models::UpdatePasswordResetParams, } /// struct for passing parameters to the method [`update_plan`] #[derive(Clone, Debug)] pub struct UpdatePlanParams { - pub update_plan_params: models::UpdatePlanParams + pub update_plan_params: models::UpdatePlanParams, } /// struct for passing parameters to the method [`update_schedule`] @@ -526,14 +525,14 @@ pub struct UpdatePlanParams { pub struct UpdateScheduleParams { /// The ID of the schedule to update. pub id: String, - pub update_schedule_params: models::UpdateScheduleParams + pub update_schedule_params: models::UpdateScheduleParams, } /// struct for passing parameters to the method [`update_secret`] #[derive(Clone, Debug)] pub struct UpdateSecretParams { pub name: String, - pub update_secret_params: models::UpdateSecretParams + pub update_secret_params: models::UpdateSecretParams, } /// struct for passing parameters to the method [`update_team`] @@ -541,22 +540,21 @@ pub struct UpdateSecretParams { pub struct UpdateTeamParams { /// The name of the team to update pub name: String, - pub update_team_params: models::UpdateTeamParams + pub update_team_params: models::UpdateTeamParams, } /// struct for passing parameters to the method [`update_user`] #[derive(Clone, Debug)] pub struct UpdateUserParams { - pub update_user_params: models::UpdateUserParams + pub update_user_params: models::UpdateUserParams, } /// struct for passing parameters to the method [`verify_email`] #[derive(Clone, Debug)] pub struct VerifyEmailParams { - pub verify_email_params: models::VerifyEmailParams + pub verify_email_params: models::VerifyEmailParams, } - /// struct for typed successes of method [`acknowledge_alert`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] @@ -1808,12 +1806,19 @@ pub enum VerifyEmailError { UnknownValue(serde_json::Value), } - /// Mark an alert as acknowledged -pub async fn acknowledge_alert(configuration: &configuration::Configuration, params: AcknowledgeAlertParams) -> Result, Error> { - - let uri_str = format!("{}/alerts/{alert_seq}/acknowledge", configuration.base_path, alert_seq=params.alert_seq); - let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str); +pub async fn acknowledge_alert( + configuration: &configuration::Configuration, + params: AcknowledgeAlertParams, +) -> Result, Error> { + let uri_str = format!( + "{}/alerts/{alert_seq}/acknowledge", + configuration.base_path, + alert_seq = params.alert_seq + ); + let mut req_builder = configuration + .client + .request(reqwest::Method::POST, &uri_str); if let Some(ref user_agent) = configuration.user_agent { req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); @@ -1836,19 +1841,32 @@ pub async fn acknowledge_alert(configuration: &configuration::Configuration, par if !status.is_client_error() && !status.is_server_error() { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Ok(ResponseContent { tower_trace_id, status, content, entity }) + Ok(ResponseContent { + tower_trace_id, + status, + content, + entity, + }) } else { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { tower_trace_id, status, content, entity })) + Err(Error::ResponseError(ResponseContent { + tower_trace_id, + status, + content, + entity, + })) } } /// Mark all unacknowledged alerts as acknowledged for the current user in the current account -pub async fn acknowledge_all_alerts(configuration: &configuration::Configuration) -> Result, Error> { - +pub async fn acknowledge_all_alerts( + configuration: &configuration::Configuration, +) -> Result, Error> { let uri_str = format!("{}/alerts/acknowledge-all", configuration.base_path); - let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str); + let mut req_builder = configuration + .client + .request(reqwest::Method::POST, &uri_str); if let Some(ref user_agent) = configuration.user_agent { req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); @@ -1871,19 +1889,38 @@ pub async fn acknowledge_all_alerts(configuration: &configuration::Configuration if !status.is_client_error() && !status.is_server_error() { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Ok(ResponseContent { tower_trace_id, status, content, entity }) + Ok(ResponseContent { + tower_trace_id, + status, + content, + entity, + }) } else { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { tower_trace_id, status, content, entity })) + Err(Error::ResponseError(ResponseContent { + tower_trace_id, + status, + content, + entity, + })) } } /// Cancel a run -pub async fn cancel_run(configuration: &configuration::Configuration, params: CancelRunParams) -> Result, Error> { - - let uri_str = format!("{}/apps/{name}/runs/{seq}", configuration.base_path, name=crate::apis::urlencode(params.name), seq=params.seq); - let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str); +pub async fn cancel_run( + configuration: &configuration::Configuration, + params: CancelRunParams, +) -> Result, Error> { + let uri_str = format!( + "{}/apps/{name}/runs/{seq}", + configuration.base_path, + name = crate::apis::urlencode(params.name), + seq = params.seq + ); + let mut req_builder = configuration + .client + .request(reqwest::Method::POST, &uri_str); if let Some(ref user_agent) = configuration.user_agent { req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); @@ -1906,19 +1943,33 @@ pub async fn cancel_run(configuration: &configuration::Configuration, params: Ca if !status.is_client_error() && !status.is_server_error() { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Ok(ResponseContent { tower_trace_id, status, content, entity }) + Ok(ResponseContent { + tower_trace_id, + status, + content, + entity, + }) } else { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { tower_trace_id, status, content, entity })) + Err(Error::ResponseError(ResponseContent { + tower_trace_id, + status, + content, + entity, + })) } } /// Claims a device login ticket code for the authenticated user. -pub async fn claim_device_login_ticket(configuration: &configuration::Configuration, params: ClaimDeviceLoginTicketParams) -> Result, Error> { - +pub async fn claim_device_login_ticket( + configuration: &configuration::Configuration, + params: ClaimDeviceLoginTicketParams, +) -> Result, Error> { let uri_str = format!("{}/login/device/claim", configuration.base_path); - let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str); + let mut req_builder = configuration + .client + .request(reqwest::Method::POST, &uri_str); if let Some(ref user_agent) = configuration.user_agent { req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); @@ -1942,19 +1993,33 @@ pub async fn claim_device_login_ticket(configuration: &configuration::Configurat if !status.is_client_error() && !status.is_server_error() { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Ok(ResponseContent { tower_trace_id, status, content, entity }) + Ok(ResponseContent { + tower_trace_id, + status, + content, + entity, + }) } else { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { tower_trace_id, status, content, entity })) + Err(Error::ResponseError(ResponseContent { + tower_trace_id, + status, + content, + entity, + })) } } /// This is the primary way that users register new accounts with Tower. -pub async fn create_account(configuration: &configuration::Configuration, params: CreateAccountParams) -> Result, Error> { - +pub async fn create_account( + configuration: &configuration::Configuration, + params: CreateAccountParams, +) -> Result, Error> { let uri_str = format!("{}/accounts", configuration.base_path); - let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str); + let mut req_builder = configuration + .client + .request(reqwest::Method::POST, &uri_str); if let Some(ref user_agent) = configuration.user_agent { req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); @@ -1975,18 +2040,32 @@ pub async fn create_account(configuration: &configuration::Configuration, params if !status.is_client_error() && !status.is_server_error() { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Ok(ResponseContent { tower_trace_id, status, content, entity }) + Ok(ResponseContent { + tower_trace_id, + status, + content, + entity, + }) } else { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { tower_trace_id, status, content, entity })) + Err(Error::ResponseError(ResponseContent { + tower_trace_id, + status, + content, + entity, + })) } } -pub async fn create_api_key(configuration: &configuration::Configuration, params: CreateApiKeyParams) -> Result, Error> { - +pub async fn create_api_key( + configuration: &configuration::Configuration, + params: CreateApiKeyParams, +) -> Result, Error> { let uri_str = format!("{}/api-keys", configuration.base_path); - let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str); + let mut req_builder = configuration + .client + .request(reqwest::Method::POST, &uri_str); if let Some(ref user_agent) = configuration.user_agent { req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); @@ -2010,19 +2089,33 @@ pub async fn create_api_key(configuration: &configuration::Configuration, params if !status.is_client_error() && !status.is_server_error() { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Ok(ResponseContent { tower_trace_id, status, content, entity }) + Ok(ResponseContent { + tower_trace_id, + status, + content, + entity, + }) } else { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { tower_trace_id, status, content, entity })) + Err(Error::ResponseError(ResponseContent { + tower_trace_id, + status, + content, + entity, + })) } } /// Create a new app in the current account. -pub async fn create_app(configuration: &configuration::Configuration, params: CreateAppParams) -> Result, Error> { - +pub async fn create_app( + configuration: &configuration::Configuration, + params: CreateAppParams, +) -> Result, Error> { let uri_str = format!("{}/apps", configuration.base_path); - let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str); + let mut req_builder = configuration + .client + .request(reqwest::Method::POST, &uri_str); if let Some(ref user_agent) = configuration.user_agent { req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); @@ -2046,19 +2139,33 @@ pub async fn create_app(configuration: &configuration::Configuration, params: Cr if !status.is_client_error() && !status.is_server_error() { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Ok(ResponseContent { tower_trace_id, status, content, entity }) + Ok(ResponseContent { + tower_trace_id, + status, + content, + entity, + }) } else { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { tower_trace_id, status, content, entity })) + Err(Error::ResponseError(ResponseContent { + tower_trace_id, + status, + content, + entity, + })) } } /// Associates an authenticator with your account, where the authenticator is identified by the URL with an otpauth URI scheme. -pub async fn create_authenticator(configuration: &configuration::Configuration, params: CreateAuthenticatorParams) -> Result, Error> { - +pub async fn create_authenticator( + configuration: &configuration::Configuration, + params: CreateAuthenticatorParams, +) -> Result, Error> { let uri_str = format!("{}/accounts/authenticator", configuration.base_path); - let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str); + let mut req_builder = configuration + .client + .request(reqwest::Method::POST, &uri_str); if let Some(ref user_agent) = configuration.user_agent { req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); @@ -2082,19 +2189,33 @@ pub async fn create_authenticator(configuration: &configuration::Configuration, if !status.is_client_error() && !status.is_server_error() { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Ok(ResponseContent { tower_trace_id, status, content, entity }) + Ok(ResponseContent { + tower_trace_id, + status, + content, + entity, + }) } else { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { tower_trace_id, status, content, entity })) + Err(Error::ResponseError(ResponseContent { + tower_trace_id, + status, + content, + entity, + })) } } /// Create a new catalog object in the currently authenticated account. -pub async fn create_catalog(configuration: &configuration::Configuration, params: CreateCatalogParams) -> Result, Error> { - +pub async fn create_catalog( + configuration: &configuration::Configuration, + params: CreateCatalogParams, +) -> Result, Error> { let uri_str = format!("{}/catalogs", configuration.base_path); - let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str); + let mut req_builder = configuration + .client + .request(reqwest::Method::POST, &uri_str); if let Some(ref user_agent) = configuration.user_agent { req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); @@ -2118,17 +2239,28 @@ pub async fn create_catalog(configuration: &configuration::Configuration, params if !status.is_client_error() && !status.is_server_error() { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Ok(ResponseContent { tower_trace_id, status, content, entity }) + Ok(ResponseContent { + tower_trace_id, + status, + content, + entity, + }) } else { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { tower_trace_id, status, content, entity })) + Err(Error::ResponseError(ResponseContent { + tower_trace_id, + status, + content, + entity, + })) } } /// Creates a new device login ticket and returns the codes and urls needed for authentication. -pub async fn create_device_login_ticket(configuration: &configuration::Configuration) -> Result, Error> { - +pub async fn create_device_login_ticket( + configuration: &configuration::Configuration, +) -> Result, Error> { let uri_str = format!("{}/login/device", configuration.base_path); let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); @@ -2150,19 +2282,33 @@ pub async fn create_device_login_ticket(configuration: &configuration::Configura if !status.is_client_error() && !status.is_server_error() { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Ok(ResponseContent { tower_trace_id, status, content, entity }) + Ok(ResponseContent { + tower_trace_id, + status, + content, + entity, + }) } else { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { tower_trace_id, status, content, entity })) + Err(Error::ResponseError(ResponseContent { + tower_trace_id, + status, + content, + entity, + })) } } /// Create a new environment for an app. -pub async fn create_environment(configuration: &configuration::Configuration, params: CreateEnvironmentParams) -> Result, Error> { - +pub async fn create_environment( + configuration: &configuration::Configuration, + params: CreateEnvironmentParams, +) -> Result, Error> { let uri_str = format!("{}/environments", configuration.base_path); - let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str); + let mut req_builder = configuration + .client + .request(reqwest::Method::POST, &uri_str); if let Some(ref user_agent) = configuration.user_agent { req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); @@ -2186,19 +2332,33 @@ pub async fn create_environment(configuration: &configuration::Configuration, pa if !status.is_client_error() && !status.is_server_error() { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Ok(ResponseContent { tower_trace_id, status, content, entity }) + Ok(ResponseContent { + tower_trace_id, + status, + content, + entity, + }) } else { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { tower_trace_id, status, content, entity })) + Err(Error::ResponseError(ResponseContent { + tower_trace_id, + status, + content, + entity, + })) } } /// Starts the password reset process for an account. If an email address exists for the account supplied, you will get a reset password email. -pub async fn create_password_reset(configuration: &configuration::Configuration, params: CreatePasswordResetParams) -> Result, Error> { - +pub async fn create_password_reset( + configuration: &configuration::Configuration, + params: CreatePasswordResetParams, +) -> Result, Error> { let uri_str = format!("{}/accounts/password-reset", configuration.base_path); - let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str); + let mut req_builder = configuration + .client + .request(reqwest::Method::POST, &uri_str); if let Some(ref user_agent) = configuration.user_agent { req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); @@ -2219,19 +2379,33 @@ pub async fn create_password_reset(configuration: &configuration::Configuration, if !status.is_client_error() && !status.is_server_error() { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Ok(ResponseContent { tower_trace_id, status, content, entity }) + Ok(ResponseContent { + tower_trace_id, + status, + content, + entity, + }) } else { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { tower_trace_id, status, content, entity })) + Err(Error::ResponseError(ResponseContent { + tower_trace_id, + status, + content, + entity, + })) } } /// Create a new schedule for an app. -pub async fn create_schedule(configuration: &configuration::Configuration, params: CreateScheduleParams) -> Result, Error> { - +pub async fn create_schedule( + configuration: &configuration::Configuration, + params: CreateScheduleParams, +) -> Result, Error> { let uri_str = format!("{}/schedules", configuration.base_path); - let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str); + let mut req_builder = configuration + .client + .request(reqwest::Method::POST, &uri_str); if let Some(ref user_agent) = configuration.user_agent { req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); @@ -2255,19 +2429,33 @@ pub async fn create_schedule(configuration: &configuration::Configuration, param if !status.is_client_error() && !status.is_server_error() { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Ok(ResponseContent { tower_trace_id, status, content, entity }) + Ok(ResponseContent { + tower_trace_id, + status, + content, + entity, + }) } else { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { tower_trace_id, status, content, entity })) + Err(Error::ResponseError(ResponseContent { + tower_trace_id, + status, + content, + entity, + })) } } /// Creates a new secret and associates it with the current account. -pub async fn create_secret(configuration: &configuration::Configuration, params: CreateSecretParams) -> Result, Error> { - +pub async fn create_secret( + configuration: &configuration::Configuration, + params: CreateSecretParams, +) -> Result, Error> { let uri_str = format!("{}/secrets", configuration.base_path); - let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str); + let mut req_builder = configuration + .client + .request(reqwest::Method::POST, &uri_str); if let Some(ref user_agent) = configuration.user_agent { req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); @@ -2291,19 +2479,33 @@ pub async fn create_secret(configuration: &configuration::Configuration, params: if !status.is_client_error() && !status.is_server_error() { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Ok(ResponseContent { tower_trace_id, status, content, entity }) + Ok(ResponseContent { + tower_trace_id, + status, + content, + entity, + }) } else { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { tower_trace_id, status, content, entity })) + Err(Error::ResponseError(ResponseContent { + tower_trace_id, + status, + content, + entity, + })) } } /// Create a new session and return it. -pub async fn create_session(configuration: &configuration::Configuration, params: CreateSessionParams) -> Result, Error> { - +pub async fn create_session( + configuration: &configuration::Configuration, + params: CreateSessionParams, +) -> Result, Error> { let uri_str = format!("{}/session", configuration.base_path); - let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str); + let mut req_builder = configuration + .client + .request(reqwest::Method::POST, &uri_str); if let Some(ref user_agent) = configuration.user_agent { req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); @@ -2324,19 +2526,33 @@ pub async fn create_session(configuration: &configuration::Configuration, params if !status.is_client_error() && !status.is_server_error() { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Ok(ResponseContent { tower_trace_id, status, content, entity }) + Ok(ResponseContent { + tower_trace_id, + status, + content, + entity, + }) } else { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { tower_trace_id, status, content, entity })) + Err(Error::ResponseError(ResponseContent { + tower_trace_id, + status, + content, + entity, + })) } } /// Create a new team -pub async fn create_team(configuration: &configuration::Configuration, params: CreateTeamParams) -> Result, Error> { - +pub async fn create_team( + configuration: &configuration::Configuration, + params: CreateTeamParams, +) -> Result, Error> { let uri_str = format!("{}/teams", configuration.base_path); - let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str); + let mut req_builder = configuration + .client + .request(reqwest::Method::POST, &uri_str); if let Some(ref user_agent) = configuration.user_agent { req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); @@ -2360,19 +2576,37 @@ pub async fn create_team(configuration: &configuration::Configuration, params: C if !status.is_client_error() && !status.is_server_error() { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Ok(ResponseContent { tower_trace_id, status, content, entity }) + Ok(ResponseContent { + tower_trace_id, + status, + content, + entity, + }) } else { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { tower_trace_id, status, content, entity })) + Err(Error::ResponseError(ResponseContent { + tower_trace_id, + status, + content, + entity, + })) } } /// Permanently delete an alert -pub async fn delete_alert(configuration: &configuration::Configuration, params: DeleteAlertParams) -> Result, Error> { - - let uri_str = format!("{}/alerts/{alert_id}", configuration.base_path, alert_id=crate::apis::urlencode(params.alert_id)); - let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str); +pub async fn delete_alert( + configuration: &configuration::Configuration, + params: DeleteAlertParams, +) -> Result, Error> { + let uri_str = format!( + "{}/alerts/{alert_id}", + configuration.base_path, + alert_id = crate::apis::urlencode(params.alert_id) + ); + let mut req_builder = configuration + .client + .request(reqwest::Method::DELETE, &uri_str); if let Some(ref user_agent) = configuration.user_agent { req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); @@ -2395,18 +2629,32 @@ pub async fn delete_alert(configuration: &configuration::Configuration, params: if !status.is_client_error() && !status.is_server_error() { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Ok(ResponseContent { tower_trace_id, status, content, entity }) + Ok(ResponseContent { + tower_trace_id, + status, + content, + entity, + }) } else { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { tower_trace_id, status, content, entity })) + Err(Error::ResponseError(ResponseContent { + tower_trace_id, + status, + content, + entity, + })) } } -pub async fn delete_api_key(configuration: &configuration::Configuration, params: DeleteApiKeyParams) -> Result, Error> { - +pub async fn delete_api_key( + configuration: &configuration::Configuration, + params: DeleteApiKeyParams, +) -> Result, Error> { let uri_str = format!("{}/api-keys", configuration.base_path); - let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str); + let mut req_builder = configuration + .client + .request(reqwest::Method::DELETE, &uri_str); if let Some(ref user_agent) = configuration.user_agent { req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); @@ -2430,19 +2678,37 @@ pub async fn delete_api_key(configuration: &configuration::Configuration, params if !status.is_client_error() && !status.is_server_error() { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Ok(ResponseContent { tower_trace_id, status, content, entity }) + Ok(ResponseContent { + tower_trace_id, + status, + content, + entity, + }) } else { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { tower_trace_id, status, content, entity })) + Err(Error::ResponseError(ResponseContent { + tower_trace_id, + status, + content, + entity, + })) } } /// Delete one of your apps, the associated code, and all the runs as well. -pub async fn delete_app(configuration: &configuration::Configuration, params: DeleteAppParams) -> Result, Error> { - - let uri_str = format!("{}/apps/{name}", configuration.base_path, name=crate::apis::urlencode(params.name)); - let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str); +pub async fn delete_app( + configuration: &configuration::Configuration, + params: DeleteAppParams, +) -> Result, Error> { + let uri_str = format!( + "{}/apps/{name}", + configuration.base_path, + name = crate::apis::urlencode(params.name) + ); + let mut req_builder = configuration + .client + .request(reqwest::Method::DELETE, &uri_str); if let Some(ref user_agent) = configuration.user_agent { req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); @@ -2465,19 +2731,33 @@ pub async fn delete_app(configuration: &configuration::Configuration, params: De if !status.is_client_error() && !status.is_server_error() { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Ok(ResponseContent { tower_trace_id, status, content, entity }) + Ok(ResponseContent { + tower_trace_id, + status, + content, + entity, + }) } else { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { tower_trace_id, status, content, entity })) + Err(Error::ResponseError(ResponseContent { + tower_trace_id, + status, + content, + entity, + })) } } /// Removes an authenticator from your account so you're no longer required to provide it at login. -pub async fn delete_authenticator(configuration: &configuration::Configuration, params: DeleteAuthenticatorParams) -> Result, Error> { - +pub async fn delete_authenticator( + configuration: &configuration::Configuration, + params: DeleteAuthenticatorParams, +) -> Result, Error> { let uri_str = format!("{}/accounts/authenticator", configuration.base_path); - let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str); + let mut req_builder = configuration + .client + .request(reqwest::Method::DELETE, &uri_str); if let Some(ref user_agent) = configuration.user_agent { req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); @@ -2501,19 +2781,37 @@ pub async fn delete_authenticator(configuration: &configuration::Configuration, if !status.is_client_error() && !status.is_server_error() { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Ok(ResponseContent { tower_trace_id, status, content, entity }) + Ok(ResponseContent { + tower_trace_id, + status, + content, + entity, + }) } else { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { tower_trace_id, status, content, entity })) + Err(Error::ResponseError(ResponseContent { + tower_trace_id, + status, + content, + entity, + })) } } /// Delete a new catalog object in the currently authenticated account. -pub async fn delete_catalog(configuration: &configuration::Configuration, params: DeleteCatalogParams) -> Result, Error> { - - let uri_str = format!("{}/catalogs/{name}", configuration.base_path, name=crate::apis::urlencode(params.name)); - let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str); +pub async fn delete_catalog( + configuration: &configuration::Configuration, + params: DeleteCatalogParams, +) -> Result, Error> { + let uri_str = format!( + "{}/catalogs/{name}", + configuration.base_path, + name = crate::apis::urlencode(params.name) + ); + let mut req_builder = configuration + .client + .request(reqwest::Method::DELETE, &uri_str); if let Some(ref param_value) = params.environment { req_builder = req_builder.query(&[("environment", ¶m_value.to_string())]); @@ -2539,19 +2837,33 @@ pub async fn delete_catalog(configuration: &configuration::Configuration, params if !status.is_client_error() && !status.is_server_error() { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Ok(ResponseContent { tower_trace_id, status, content, entity }) + Ok(ResponseContent { + tower_trace_id, + status, + content, + entity, + }) } else { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { tower_trace_id, status, content, entity })) + Err(Error::ResponseError(ResponseContent { + tower_trace_id, + status, + content, + entity, + })) } } /// Delete an existing schedule for an app. -pub async fn delete_schedule(configuration: &configuration::Configuration, params: DeleteScheduleParams) -> Result, Error> { - +pub async fn delete_schedule( + configuration: &configuration::Configuration, + params: DeleteScheduleParams, +) -> Result, Error> { let uri_str = format!("{}/schedules", configuration.base_path); - let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str); + let mut req_builder = configuration + .client + .request(reqwest::Method::DELETE, &uri_str); if let Some(ref user_agent) = configuration.user_agent { req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); @@ -2575,19 +2887,37 @@ pub async fn delete_schedule(configuration: &configuration::Configuration, param if !status.is_client_error() && !status.is_server_error() { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Ok(ResponseContent { tower_trace_id, status, content, entity }) + Ok(ResponseContent { + tower_trace_id, + status, + content, + entity, + }) } else { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { tower_trace_id, status, content, entity })) + Err(Error::ResponseError(ResponseContent { + tower_trace_id, + status, + content, + entity, + })) } } /// Delete a secret by name. -pub async fn delete_secret(configuration: &configuration::Configuration, params: DeleteSecretParams) -> Result, Error> { - - let uri_str = format!("{}/secrets/{name}", configuration.base_path, name=crate::apis::urlencode(params.name)); - let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str); +pub async fn delete_secret( + configuration: &configuration::Configuration, + params: DeleteSecretParams, +) -> Result, Error> { + let uri_str = format!( + "{}/secrets/{name}", + configuration.base_path, + name = crate::apis::urlencode(params.name) + ); + let mut req_builder = configuration + .client + .request(reqwest::Method::DELETE, &uri_str); if let Some(ref param_value) = params.environment { req_builder = req_builder.query(&[("environment", ¶m_value.to_string())]); @@ -2613,19 +2943,33 @@ pub async fn delete_secret(configuration: &configuration::Configuration, params: if !status.is_client_error() && !status.is_server_error() { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Ok(ResponseContent { tower_trace_id, status, content, entity }) + Ok(ResponseContent { + tower_trace_id, + status, + content, + entity, + }) } else { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { tower_trace_id, status, content, entity })) + Err(Error::ResponseError(ResponseContent { + tower_trace_id, + status, + content, + entity, + })) } } /// Delete a new team -pub async fn delete_team(configuration: &configuration::Configuration, params: DeleteTeamParams) -> Result, Error> { - +pub async fn delete_team( + configuration: &configuration::Configuration, + params: DeleteTeamParams, +) -> Result, Error> { let uri_str = format!("{}/teams", configuration.base_path); - let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str); + let mut req_builder = configuration + .client + .request(reqwest::Method::DELETE, &uri_str); if let Some(ref user_agent) = configuration.user_agent { req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); @@ -2649,19 +2993,37 @@ pub async fn delete_team(configuration: &configuration::Configuration, params: D if !status.is_client_error() && !status.is_server_error() { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Ok(ResponseContent { tower_trace_id, status, content, entity }) + Ok(ResponseContent { + tower_trace_id, + status, + content, + entity, + }) } else { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { tower_trace_id, status, content, entity })) + Err(Error::ResponseError(ResponseContent { + tower_trace_id, + status, + content, + entity, + })) } } /// Delete a pending team invitation that you have previously sent -pub async fn delete_team_invitation(configuration: &configuration::Configuration, params: DeleteTeamInvitationParams) -> Result, Error> { - - let uri_str = format!("{}/teams/{name}/invites", configuration.base_path, name=crate::apis::urlencode(params.name)); - let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str); +pub async fn delete_team_invitation( + configuration: &configuration::Configuration, + params: DeleteTeamInvitationParams, +) -> Result, Error> { + let uri_str = format!( + "{}/teams/{name}/invites", + configuration.base_path, + name = crate::apis::urlencode(params.name) + ); + let mut req_builder = configuration + .client + .request(reqwest::Method::DELETE, &uri_str); if let Some(ref user_agent) = configuration.user_agent { req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); @@ -2685,19 +3047,37 @@ pub async fn delete_team_invitation(configuration: &configuration::Configuration if !status.is_client_error() && !status.is_server_error() { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Ok(ResponseContent { tower_trace_id, status, content, entity }) + Ok(ResponseContent { + tower_trace_id, + status, + content, + entity, + }) } else { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { tower_trace_id, status, content, entity })) + Err(Error::ResponseError(ResponseContent { + tower_trace_id, + status, + content, + entity, + })) } } /// Deploy a new version of an app. Reads the request body, which is a TAR file (or a GZipped TAR file) and creates a new deployment for an app based on that file. -pub async fn deploy_app(configuration: &configuration::Configuration, params: DeployAppParams) -> Result, Error> { - - let uri_str = format!("{}/apps/{name}/deploy", configuration.base_path, name=crate::apis::urlencode(params.name)); - let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str); +pub async fn deploy_app( + configuration: &configuration::Configuration, + params: DeployAppParams, +) -> Result, Error> { + let uri_str = format!( + "{}/apps/{name}/deploy", + configuration.base_path, + name = crate::apis::urlencode(params.name) + ); + let mut req_builder = configuration + .client + .request(reqwest::Method::POST, &uri_str); if let Some(ref user_agent) = configuration.user_agent { req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); @@ -2726,18 +3106,34 @@ pub async fn deploy_app(configuration: &configuration::Configuration, params: De if !status.is_client_error() && !status.is_server_error() { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Ok(ResponseContent { tower_trace_id, status, content, entity }) + Ok(ResponseContent { + tower_trace_id, + status, + content, + entity, + }) } else { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { tower_trace_id, status, content, entity })) + Err(Error::ResponseError(ResponseContent { + tower_trace_id, + status, + content, + entity, + })) } } /// Get all the runs for the current account. -pub async fn describe_app(configuration: &configuration::Configuration, params: DescribeAppParams) -> Result, Error> { - - let uri_str = format!("{}/apps/{name}", configuration.base_path, name=crate::apis::urlencode(params.name)); +pub async fn describe_app( + configuration: &configuration::Configuration, + params: DescribeAppParams, +) -> Result, Error> { + let uri_str = format!( + "{}/apps/{name}", + configuration.base_path, + name = crate::apis::urlencode(params.name) + ); let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); if let Some(ref param_value) = params.runs { @@ -2773,18 +3169,35 @@ pub async fn describe_app(configuration: &configuration::Configuration, params: if !status.is_client_error() && !status.is_server_error() { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Ok(ResponseContent { tower_trace_id, status, content, entity }) + Ok(ResponseContent { + tower_trace_id, + status, + content, + entity, + }) } else { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { tower_trace_id, status, content, entity })) + Err(Error::ResponseError(ResponseContent { + tower_trace_id, + status, + content, + entity, + })) } } /// Describe an app version for an app in the current account. -pub async fn describe_app_version(configuration: &configuration::Configuration, params: DescribeAppVersionParams) -> Result, Error> { - - let uri_str = format!("{}/apps/{name}/versions/{num}", configuration.base_path, name=crate::apis::urlencode(params.name), num=crate::apis::urlencode(params.num)); +pub async fn describe_app_version( + configuration: &configuration::Configuration, + params: DescribeAppVersionParams, +) -> Result, Error> { + let uri_str = format!( + "{}/apps/{name}/versions/{num}", + configuration.base_path, + name = crate::apis::urlencode(params.name), + num = crate::apis::urlencode(params.num) + ); let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); if let Some(ref user_agent) = configuration.user_agent { @@ -2808,18 +3221,37 @@ pub async fn describe_app_version(configuration: &configuration::Configuration, if !status.is_client_error() && !status.is_server_error() { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Ok(ResponseContent { tower_trace_id, status, content, entity }) + Ok(ResponseContent { + tower_trace_id, + status, + content, + entity, + }) } else { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { tower_trace_id, status, content, entity })) + Err(Error::ResponseError(ResponseContent { + tower_trace_id, + status, + content, + entity, + })) } } /// Checks if a device login code has been claimed and returns the user session if so. -pub async fn describe_device_login_session(configuration: &configuration::Configuration, params: DescribeDeviceLoginSessionParams) -> Result, Error> { - - let uri_str = format!("{}/login/device/{device_code}", configuration.base_path, device_code=crate::apis::urlencode(params.device_code)); +pub async fn describe_device_login_session( + configuration: &configuration::Configuration, + params: DescribeDeviceLoginSessionParams, +) -> Result< + ResponseContent, + Error, +> { + let uri_str = format!( + "{}/login/device/{device_code}", + configuration.base_path, + device_code = crate::apis::urlencode(params.device_code) + ); let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); if let Some(ref user_agent) = configuration.user_agent { @@ -2840,18 +3272,35 @@ pub async fn describe_device_login_session(configuration: &configuration::Config if !status.is_client_error() && !status.is_server_error() { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Ok(ResponseContent { tower_trace_id, status, content, entity }) + Ok(ResponseContent { + tower_trace_id, + status, + content, + entity, + }) } else { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { tower_trace_id, status, content, entity })) + Err(Error::ResponseError(ResponseContent { + tower_trace_id, + status, + content, + entity, + })) } } /// Describe a run of an app. -pub async fn describe_run(configuration: &configuration::Configuration, params: DescribeRunParams) -> Result, Error> { - - let uri_str = format!("{}/apps/{name}/runs/{seq}", configuration.base_path, name=crate::apis::urlencode(params.name), seq=params.seq); +pub async fn describe_run( + configuration: &configuration::Configuration, + params: DescribeRunParams, +) -> Result, Error> { + let uri_str = format!( + "{}/apps/{name}/runs/{seq}", + configuration.base_path, + name = crate::apis::urlencode(params.name), + seq = params.seq + ); let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); if let Some(ref user_agent) = configuration.user_agent { @@ -2883,18 +3332,35 @@ pub async fn describe_run(configuration: &configuration::Configuration, params: if !status.is_client_error() && !status.is_server_error() { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Ok(ResponseContent { tower_trace_id, status, content, entity }) + Ok(ResponseContent { + tower_trace_id, + status, + content, + entity, + }) } else { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { tower_trace_id, status, content, entity })) + Err(Error::ResponseError(ResponseContent { + tower_trace_id, + status, + content, + entity, + })) } } /// Retrieves the logs associated with a particular run of an app. -pub async fn describe_run_logs(configuration: &configuration::Configuration, params: DescribeRunLogsParams) -> Result, Error> { - - let uri_str = format!("{}/apps/{name}/runs/{seq}/logs", configuration.base_path, name=crate::apis::urlencode(params.name), seq=params.seq); +pub async fn describe_run_logs( + configuration: &configuration::Configuration, + params: DescribeRunLogsParams, +) -> Result, Error> { + let uri_str = format!( + "{}/apps/{name}/runs/{seq}/logs", + configuration.base_path, + name = crate::apis::urlencode(params.name), + seq = params.seq + ); let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); if let Some(ref user_agent) = configuration.user_agent { @@ -2918,17 +3384,29 @@ pub async fn describe_run_logs(configuration: &configuration::Configuration, par if !status.is_client_error() && !status.is_server_error() { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Ok(ResponseContent { tower_trace_id, status, content, entity }) + Ok(ResponseContent { + tower_trace_id, + status, + content, + entity, + }) } else { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { tower_trace_id, status, content, entity })) + Err(Error::ResponseError(ResponseContent { + tower_trace_id, + status, + content, + entity, + })) } } /// Gets the encryption key used for encrypting secrets that you want to create in Tower. -pub async fn describe_secrets_key(configuration: &configuration::Configuration, params: DescribeSecretsKeyParams) -> Result, Error> { - +pub async fn describe_secrets_key( + configuration: &configuration::Configuration, + params: DescribeSecretsKeyParams, +) -> Result, Error> { let uri_str = format!("{}/secrets/key", configuration.base_path); let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); @@ -2956,17 +3434,28 @@ pub async fn describe_secrets_key(configuration: &configuration::Configuration, if !status.is_client_error() && !status.is_server_error() { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Ok(ResponseContent { tower_trace_id, status, content, entity }) + Ok(ResponseContent { + tower_trace_id, + status, + content, + entity, + }) } else { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { tower_trace_id, status, content, entity })) + Err(Error::ResponseError(ResponseContent { + tower_trace_id, + status, + content, + entity, + })) } } /// Validate your current session and return the user information associated with the session. -pub async fn describe_session(configuration: &configuration::Configuration) -> Result, Error> { - +pub async fn describe_session( + configuration: &configuration::Configuration, +) -> Result, Error> { let uri_str = format!("{}/session", configuration.base_path); let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); @@ -2991,19 +3480,33 @@ pub async fn describe_session(configuration: &configuration::Configuration) -> R if !status.is_client_error() && !status.is_server_error() { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Ok(ResponseContent { tower_trace_id, status, content, entity }) + Ok(ResponseContent { + tower_trace_id, + status, + content, + entity, + }) } else { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { tower_trace_id, status, content, entity })) + Err(Error::ResponseError(ResponseContent { + tower_trace_id, + status, + content, + entity, + })) } } /// Lists all the catalogs in your current account and re-encrypt them with the public key you supplied. -pub async fn export_catalogs(configuration: &configuration::Configuration, params: ExportCatalogsParams) -> Result, Error> { - +pub async fn export_catalogs( + configuration: &configuration::Configuration, + params: ExportCatalogsParams, +) -> Result, Error> { let uri_str = format!("{}/catalogs/export", configuration.base_path); - let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str); + let mut req_builder = configuration + .client + .request(reqwest::Method::POST, &uri_str); if let Some(ref user_agent) = configuration.user_agent { req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); @@ -3027,19 +3530,33 @@ pub async fn export_catalogs(configuration: &configuration::Configuration, param if !status.is_client_error() && !status.is_server_error() { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Ok(ResponseContent { tower_trace_id, status, content, entity }) + Ok(ResponseContent { + tower_trace_id, + status, + content, + entity, + }) } else { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { tower_trace_id, status, content, entity })) + Err(Error::ResponseError(ResponseContent { + tower_trace_id, + status, + content, + entity, + })) } } /// Lists all the secrets in your current account and re-encrypt them with the public key you supplied. -pub async fn export_secrets(configuration: &configuration::Configuration, params: ExportSecretsParams) -> Result, Error> { - +pub async fn export_secrets( + configuration: &configuration::Configuration, + params: ExportSecretsParams, +) -> Result, Error> { let uri_str = format!("{}/secrets/export", configuration.base_path); - let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str); + let mut req_builder = configuration + .client + .request(reqwest::Method::POST, &uri_str); if let Some(ref user_agent) = configuration.user_agent { req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); @@ -3063,17 +3580,29 @@ pub async fn export_secrets(configuration: &configuration::Configuration, params if !status.is_client_error() && !status.is_server_error() { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Ok(ResponseContent { tower_trace_id, status, content, entity }) + Ok(ResponseContent { + tower_trace_id, + status, + content, + entity, + }) } else { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { tower_trace_id, status, content, entity })) + Err(Error::ResponseError(ResponseContent { + tower_trace_id, + status, + content, + entity, + })) } } /// Generates current statistics about apps -pub async fn generate_app_statistics(configuration: &configuration::Configuration, params: GenerateAppStatisticsParams) -> Result, Error> { - +pub async fn generate_app_statistics( + configuration: &configuration::Configuration, + params: GenerateAppStatisticsParams, +) -> Result, Error> { let uri_str = format!("{}/stats/apps", configuration.base_path); let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); @@ -3101,19 +3630,35 @@ pub async fn generate_app_statistics(configuration: &configuration::Configuratio if !status.is_client_error() && !status.is_server_error() { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Ok(ResponseContent { tower_trace_id, status, content, entity }) + Ok(ResponseContent { + tower_trace_id, + status, + content, + entity, + }) } else { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { tower_trace_id, status, content, entity })) + Err(Error::ResponseError(ResponseContent { + tower_trace_id, + status, + content, + entity, + })) } } /// Generates a new authenticator for the user. This is used to set up two-factor authentication. -pub async fn generate_authenticator(configuration: &configuration::Configuration) -> Result, Error> { - - let uri_str = format!("{}/accounts/authenticator/generate", configuration.base_path); - let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str); +pub async fn generate_authenticator( + configuration: &configuration::Configuration, +) -> Result, Error> { + let uri_str = format!( + "{}/accounts/authenticator/generate", + configuration.base_path + ); + let mut req_builder = configuration + .client + .request(reqwest::Method::POST, &uri_str); if let Some(ref user_agent) = configuration.user_agent { req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); @@ -3136,24 +3681,49 @@ pub async fn generate_authenticator(configuration: &configuration::Configuration if !status.is_client_error() && !status.is_server_error() { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Ok(ResponseContent { tower_trace_id, status, content, entity }) + Ok(ResponseContent { + tower_trace_id, + status, + content, + entity, + }) } else { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { tower_trace_id, status, content, entity })) + Err(Error::ResponseError(ResponseContent { + tower_trace_id, + status, + content, + entity, + })) } } /// Generates statistics about runs over a specified time period. -pub async fn generate_run_statistics(configuration: &configuration::Configuration, params: GenerateRunStatisticsParams) -> Result, Error> { - +pub async fn generate_run_statistics( + configuration: &configuration::Configuration, + params: GenerateRunStatisticsParams, +) -> Result, Error> { let uri_str = format!("{}/stats/runs", configuration.base_path); let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); if let Some(ref param_value) = params.status { req_builder = match "csv" { - "multi" => req_builder.query(¶m_value.into_iter().map(|p| ("status".to_owned(), p.to_string())).collect::>()), - _ => req_builder.query(&[("status", ¶m_value.into_iter().map(|p| p.to_string()).collect::>().join(",").to_string())]), + "multi" => req_builder.query( + ¶m_value + .into_iter() + .map(|p| ("status".to_owned(), p.to_string())) + .collect::>(), + ), + _ => req_builder.query(&[( + "status", + ¶m_value + .into_iter() + .map(|p| p.to_string()) + .collect::>() + .join(",") + .to_string(), + )]), }; } req_builder = req_builder.query(&[("start_at", ¶ms.start_at.to_string())]); @@ -3185,19 +3755,33 @@ pub async fn generate_run_statistics(configuration: &configuration::Configuratio if !status.is_client_error() && !status.is_server_error() { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Ok(ResponseContent { tower_trace_id, status, content, entity }) + Ok(ResponseContent { + tower_trace_id, + status, + content, + entity, + }) } else { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { tower_trace_id, status, content, entity })) + Err(Error::ResponseError(ResponseContent { + tower_trace_id, + status, + content, + entity, + })) } } /// Uses your current authentication context to generate runner credentials that are used for authenticating runner requests -pub async fn generate_runner_credentials(configuration: &configuration::Configuration) -> Result, Error> { - +pub async fn generate_runner_credentials( + configuration: &configuration::Configuration, +) -> Result, Error> +{ let uri_str = format!("{}/runners/credentials", configuration.base_path); - let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str); + let mut req_builder = configuration + .client + .request(reqwest::Method::POST, &uri_str); if let Some(ref user_agent) = configuration.user_agent { req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); @@ -3228,19 +3812,37 @@ pub async fn generate_runner_credentials(configuration: &configuration::Configur if !status.is_client_error() && !status.is_server_error() { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Ok(ResponseContent { tower_trace_id, status, content, entity }) + Ok(ResponseContent { + tower_trace_id, + status, + content, + entity, + }) } else { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { tower_trace_id, status, content, entity })) + Err(Error::ResponseError(ResponseContent { + tower_trace_id, + status, + content, + entity, + })) } } /// Invite a new team -pub async fn invite_team_member(configuration: &configuration::Configuration, params: InviteTeamMemberParams) -> Result, Error> { - - let uri_str = format!("{}/teams/{name}/invites", configuration.base_path, name=crate::apis::urlencode(params.name)); - let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str); +pub async fn invite_team_member( + configuration: &configuration::Configuration, + params: InviteTeamMemberParams, +) -> Result, Error> { + let uri_str = format!( + "{}/teams/{name}/invites", + configuration.base_path, + name = crate::apis::urlencode(params.name) + ); + let mut req_builder = configuration + .client + .request(reqwest::Method::POST, &uri_str); if let Some(ref user_agent) = configuration.user_agent { req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); @@ -3264,19 +3866,37 @@ pub async fn invite_team_member(configuration: &configuration::Configuration, pa if !status.is_client_error() && !status.is_server_error() { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Ok(ResponseContent { tower_trace_id, status, content, entity }) + Ok(ResponseContent { + tower_trace_id, + status, + content, + entity, + }) } else { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { tower_trace_id, status, content, entity })) + Err(Error::ResponseError(ResponseContent { + tower_trace_id, + status, + content, + entity, + })) } } /// Remove yourself from a team, if that's something you'd like to do for whatever reason. If you're the last member of a team, you cannot remove yourself. You should delete the team instead. -pub async fn leave_team(configuration: &configuration::Configuration, params: LeaveTeamParams) -> Result, Error> { - - let uri_str = format!("{}/teams/{name}/leave", configuration.base_path, name=crate::apis::urlencode(params.name)); - let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str); +pub async fn leave_team( + configuration: &configuration::Configuration, + params: LeaveTeamParams, +) -> Result, Error> { + let uri_str = format!( + "{}/teams/{name}/leave", + configuration.base_path, + name = crate::apis::urlencode(params.name) + ); + let mut req_builder = configuration + .client + .request(reqwest::Method::POST, &uri_str); if let Some(ref user_agent) = configuration.user_agent { req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); @@ -3299,17 +3919,29 @@ pub async fn leave_team(configuration: &configuration::Configuration, params: Le if !status.is_client_error() && !status.is_server_error() { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Ok(ResponseContent { tower_trace_id, status, content, entity }) + Ok(ResponseContent { + tower_trace_id, + status, + content, + entity, + }) } else { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { tower_trace_id, status, content, entity })) + Err(Error::ResponseError(ResponseContent { + tower_trace_id, + status, + content, + entity, + })) } } /// List alerts for the current account with optional filtering -pub async fn list_alerts(configuration: &configuration::Configuration, params: ListAlertsParams) -> Result, Error> { - +pub async fn list_alerts( + configuration: &configuration::Configuration, + params: ListAlertsParams, +) -> Result, Error> { let uri_str = format!("{}/alerts", configuration.base_path); let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); @@ -3355,17 +3987,28 @@ pub async fn list_alerts(configuration: &configuration::Configuration, params: L if !status.is_client_error() && !status.is_server_error() { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Ok(ResponseContent { tower_trace_id, status, content, entity }) + Ok(ResponseContent { + tower_trace_id, + status, + content, + entity, + }) } else { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { tower_trace_id, status, content, entity })) + Err(Error::ResponseError(ResponseContent { + tower_trace_id, + status, + content, + entity, + })) } } /// List all the API keys associated with your current account. -pub async fn list_api_keys(configuration: &configuration::Configuration) -> Result, Error> { - +pub async fn list_api_keys( + configuration: &configuration::Configuration, +) -> Result, Error> { let uri_str = format!("{}/api-keys", configuration.base_path); let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); @@ -3390,18 +4033,34 @@ pub async fn list_api_keys(configuration: &configuration::Configuration) -> Resu if !status.is_client_error() && !status.is_server_error() { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Ok(ResponseContent { tower_trace_id, status, content, entity }) + Ok(ResponseContent { + tower_trace_id, + status, + content, + entity, + }) } else { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { tower_trace_id, status, content, entity })) + Err(Error::ResponseError(ResponseContent { + tower_trace_id, + status, + content, + entity, + })) } } /// Generates a list of all the known environments for a given app in the current account. -pub async fn list_app_environments(configuration: &configuration::Configuration, params: ListAppEnvironmentsParams) -> Result, Error> { - - let uri_str = format!("{}/apps/{name}/environments", configuration.base_path, name=crate::apis::urlencode(params.name)); +pub async fn list_app_environments( + configuration: &configuration::Configuration, + params: ListAppEnvironmentsParams, +) -> Result, Error> { + let uri_str = format!( + "{}/apps/{name}/environments", + configuration.base_path, + name = crate::apis::urlencode(params.name) + ); let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); if let Some(ref user_agent) = configuration.user_agent { @@ -3425,18 +4084,34 @@ pub async fn list_app_environments(configuration: &configuration::Configuration, if !status.is_client_error() && !status.is_server_error() { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Ok(ResponseContent { tower_trace_id, status, content, entity }) + Ok(ResponseContent { + tower_trace_id, + status, + content, + entity, + }) } else { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { tower_trace_id, status, content, entity })) + Err(Error::ResponseError(ResponseContent { + tower_trace_id, + status, + content, + entity, + })) } } /// List all versions of an app in the current account, sorted with the most recent first. -pub async fn list_app_versions(configuration: &configuration::Configuration, params: ListAppVersionsParams) -> Result, Error> { - - let uri_str = format!("{}/apps/{name}/versions", configuration.base_path, name=crate::apis::urlencode(params.name)); +pub async fn list_app_versions( + configuration: &configuration::Configuration, + params: ListAppVersionsParams, +) -> Result, Error> { + let uri_str = format!( + "{}/apps/{name}/versions", + configuration.base_path, + name = crate::apis::urlencode(params.name) + ); let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); if let Some(ref user_agent) = configuration.user_agent { @@ -3460,17 +4135,29 @@ pub async fn list_app_versions(configuration: &configuration::Configuration, par if !status.is_client_error() && !status.is_server_error() { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Ok(ResponseContent { tower_trace_id, status, content, entity }) + Ok(ResponseContent { + tower_trace_id, + status, + content, + entity, + }) } else { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { tower_trace_id, status, content, entity })) + Err(Error::ResponseError(ResponseContent { + tower_trace_id, + status, + content, + entity, + })) } } /// Get all the apps for the current account. -pub async fn list_apps(configuration: &configuration::Configuration, params: ListAppsParams) -> Result, Error> { - +pub async fn list_apps( + configuration: &configuration::Configuration, + params: ListAppsParams, +) -> Result, Error> { let uri_str = format!("{}/apps", configuration.base_path); let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); @@ -3524,17 +4211,28 @@ pub async fn list_apps(configuration: &configuration::Configuration, params: Lis if !status.is_client_error() && !status.is_server_error() { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Ok(ResponseContent { tower_trace_id, status, content, entity }) + Ok(ResponseContent { + tower_trace_id, + status, + content, + entity, + }) } else { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { tower_trace_id, status, content, entity })) + Err(Error::ResponseError(ResponseContent { + tower_trace_id, + status, + content, + entity, + })) } } /// Enumerates the authenticators associated with the current users' account -pub async fn list_authenticators(configuration: &configuration::Configuration) -> Result, Error> { - +pub async fn list_authenticators( + configuration: &configuration::Configuration, +) -> Result, Error> { let uri_str = format!("{}/accounts/authenticator", configuration.base_path); let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); @@ -3559,17 +4257,29 @@ pub async fn list_authenticators(configuration: &configuration::Configuration) - if !status.is_client_error() && !status.is_server_error() { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Ok(ResponseContent { tower_trace_id, status, content, entity }) + Ok(ResponseContent { + tower_trace_id, + status, + content, + entity, + }) } else { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { tower_trace_id, status, content, entity })) + Err(Error::ResponseError(ResponseContent { + tower_trace_id, + status, + content, + entity, + })) } } /// Lists all the catalogs associated with your current account. -pub async fn list_catalogs(configuration: &configuration::Configuration, params: ListCatalogsParams) -> Result, Error> { - +pub async fn list_catalogs( + configuration: &configuration::Configuration, + params: ListCatalogsParams, +) -> Result, Error> { let uri_str = format!("{}/catalogs", configuration.base_path); let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); @@ -3606,17 +4316,28 @@ pub async fn list_catalogs(configuration: &configuration::Configuration, params: if !status.is_client_error() && !status.is_server_error() { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Ok(ResponseContent { tower_trace_id, status, content, entity }) + Ok(ResponseContent { + tower_trace_id, + status, + content, + entity, + }) } else { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { tower_trace_id, status, content, entity })) + Err(Error::ResponseError(ResponseContent { + tower_trace_id, + status, + content, + entity, + })) } } /// List all environments in your account. -pub async fn list_environments(configuration: &configuration::Configuration) -> Result, Error> { - +pub async fn list_environments( + configuration: &configuration::Configuration, +) -> Result, Error> { let uri_str = format!("{}/environments", configuration.base_path); let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); @@ -3641,17 +4362,28 @@ pub async fn list_environments(configuration: &configuration::Configuration) -> if !status.is_client_error() && !status.is_server_error() { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Ok(ResponseContent { tower_trace_id, status, content, entity }) + Ok(ResponseContent { + tower_trace_id, + status, + content, + entity, + }) } else { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { tower_trace_id, status, content, entity })) + Err(Error::ResponseError(ResponseContent { + tower_trace_id, + status, + content, + entity, + })) } } /// List your pending invitations for teams -pub async fn list_my_team_invitations(configuration: &configuration::Configuration) -> Result, Error> { - +pub async fn list_my_team_invitations( + configuration: &configuration::Configuration, +) -> Result, Error> { let uri_str = format!("{}/team-invites", configuration.base_path); let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); @@ -3676,17 +4408,29 @@ pub async fn list_my_team_invitations(configuration: &configuration::Configurati if !status.is_client_error() && !status.is_server_error() { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Ok(ResponseContent { tower_trace_id, status, content, entity }) + Ok(ResponseContent { + tower_trace_id, + status, + content, + entity, + }) } else { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { tower_trace_id, status, content, entity })) + Err(Error::ResponseError(ResponseContent { + tower_trace_id, + status, + content, + entity, + })) } } /// List active and past account plans for the current account. -pub async fn list_plans(configuration: &configuration::Configuration, params: ListPlansParams) -> Result, Error> { - +pub async fn list_plans( + configuration: &configuration::Configuration, + params: ListPlansParams, +) -> Result, Error> { let uri_str = format!("{}/plans", configuration.base_path); let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); @@ -3717,18 +4461,34 @@ pub async fn list_plans(configuration: &configuration::Configuration, params: Li if !status.is_client_error() && !status.is_server_error() { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Ok(ResponseContent { tower_trace_id, status, content, entity }) + Ok(ResponseContent { + tower_trace_id, + status, + content, + entity, + }) } else { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { tower_trace_id, status, content, entity })) + Err(Error::ResponseError(ResponseContent { + tower_trace_id, + status, + content, + entity, + })) } } /// Generates a list of all the runs for a given app. The list is paginated based on the query string parameters passed in. -pub async fn list_runs(configuration: &configuration::Configuration, params: ListRunsParams) -> Result, Error> { - - let uri_str = format!("{}/apps/{name}/runs", configuration.base_path, name=crate::apis::urlencode(params.name)); +pub async fn list_runs( + configuration: &configuration::Configuration, + params: ListRunsParams, +) -> Result, Error> { + let uri_str = format!( + "{}/apps/{name}/runs", + configuration.base_path, + name = crate::apis::urlencode(params.name) + ); let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); if let Some(ref param_value) = params.page { @@ -3739,8 +4499,21 @@ pub async fn list_runs(configuration: &configuration::Configuration, params: Lis } if let Some(ref param_value) = params.status { req_builder = match "csv" { - "multi" => req_builder.query(¶m_value.into_iter().map(|p| ("status".to_owned(), p.to_string())).collect::>()), - _ => req_builder.query(&[("status", ¶m_value.into_iter().map(|p| p.to_string()).collect::>().join(",").to_string())]), + "multi" => req_builder.query( + ¶m_value + .into_iter() + .map(|p| ("status".to_owned(), p.to_string())) + .collect::>(), + ), + _ => req_builder.query(&[( + "status", + ¶m_value + .into_iter() + .map(|p| p.to_string()) + .collect::>() + .join(",") + .to_string(), + )]), }; } if let Some(ref param_value) = params.start_at { @@ -3773,17 +4546,29 @@ pub async fn list_runs(configuration: &configuration::Configuration, params: Lis if !status.is_client_error() && !status.is_server_error() { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Ok(ResponseContent { tower_trace_id, status, content, entity }) + Ok(ResponseContent { + tower_trace_id, + status, + content, + entity, + }) } else { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { tower_trace_id, status, content, entity })) + Err(Error::ResponseError(ResponseContent { + tower_trace_id, + status, + content, + entity, + })) } } /// List all schedules for an app. -pub async fn list_schedules(configuration: &configuration::Configuration, params: ListSchedulesParams) -> Result, Error> { - +pub async fn list_schedules( + configuration: &configuration::Configuration, + params: ListSchedulesParams, +) -> Result, Error> { let uri_str = format!("{}/schedules", configuration.base_path); let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); @@ -3814,17 +4599,28 @@ pub async fn list_schedules(configuration: &configuration::Configuration, params if !status.is_client_error() && !status.is_server_error() { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Ok(ResponseContent { tower_trace_id, status, content, entity }) + Ok(ResponseContent { + tower_trace_id, + status, + content, + entity, + }) } else { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { tower_trace_id, status, content, entity })) + Err(Error::ResponseError(ResponseContent { + tower_trace_id, + status, + content, + entity, + })) } } /// Lists all the environments associated with secrets. -pub async fn list_secret_environments(configuration: &configuration::Configuration) -> Result, Error> { - +pub async fn list_secret_environments( + configuration: &configuration::Configuration, +) -> Result, Error> { let uri_str = format!("{}/secrets/environments", configuration.base_path); let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); @@ -3849,17 +4645,29 @@ pub async fn list_secret_environments(configuration: &configuration::Configurati if !status.is_client_error() && !status.is_server_error() { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Ok(ResponseContent { tower_trace_id, status, content, entity }) + Ok(ResponseContent { + tower_trace_id, + status, + content, + entity, + }) } else { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { tower_trace_id, status, content, entity })) + Err(Error::ResponseError(ResponseContent { + tower_trace_id, + status, + content, + entity, + })) } } /// Lists all the secrets associated with your current account. -pub async fn list_secrets(configuration: &configuration::Configuration, params: ListSecretsParams) -> Result, Error> { - +pub async fn list_secrets( + configuration: &configuration::Configuration, + params: ListSecretsParams, +) -> Result, Error> { let uri_str = format!("{}/secrets", configuration.base_path); let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); @@ -3896,18 +4704,34 @@ pub async fn list_secrets(configuration: &configuration::Configuration, params: if !status.is_client_error() && !status.is_server_error() { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Ok(ResponseContent { tower_trace_id, status, content, entity }) + Ok(ResponseContent { + tower_trace_id, + status, + content, + entity, + }) } else { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { tower_trace_id, status, content, entity })) + Err(Error::ResponseError(ResponseContent { + tower_trace_id, + status, + content, + entity, + })) } } /// List the pending invitations for a team -pub async fn list_team_invitations(configuration: &configuration::Configuration, params: ListTeamInvitationsParams) -> Result, Error> { - - let uri_str = format!("{}/teams/{name}/invites", configuration.base_path, name=crate::apis::urlencode(params.name)); +pub async fn list_team_invitations( + configuration: &configuration::Configuration, + params: ListTeamInvitationsParams, +) -> Result, Error> { + let uri_str = format!( + "{}/teams/{name}/invites", + configuration.base_path, + name = crate::apis::urlencode(params.name) + ); let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); if let Some(ref user_agent) = configuration.user_agent { @@ -3931,18 +4755,34 @@ pub async fn list_team_invitations(configuration: &configuration::Configuration, if !status.is_client_error() && !status.is_server_error() { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Ok(ResponseContent { tower_trace_id, status, content, entity }) + Ok(ResponseContent { + tower_trace_id, + status, + content, + entity, + }) } else { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { tower_trace_id, status, content, entity })) + Err(Error::ResponseError(ResponseContent { + tower_trace_id, + status, + content, + entity, + })) } } /// List the members of a team -pub async fn list_team_members(configuration: &configuration::Configuration, params: ListTeamMembersParams) -> Result, Error> { - - let uri_str = format!("{}/teams/{name}/members", configuration.base_path, name=crate::apis::urlencode(params.name)); +pub async fn list_team_members( + configuration: &configuration::Configuration, + params: ListTeamMembersParams, +) -> Result, Error> { + let uri_str = format!( + "{}/teams/{name}/members", + configuration.base_path, + name = crate::apis::urlencode(params.name) + ); let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); if let Some(ref user_agent) = configuration.user_agent { @@ -3966,17 +4806,28 @@ pub async fn list_team_members(configuration: &configuration::Configuration, par if !status.is_client_error() && !status.is_server_error() { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Ok(ResponseContent { tower_trace_id, status, content, entity }) + Ok(ResponseContent { + tower_trace_id, + status, + content, + entity, + }) } else { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { tower_trace_id, status, content, entity })) + Err(Error::ResponseError(ResponseContent { + tower_trace_id, + status, + content, + entity, + })) } } /// List all the teams that the user is a member of. -pub async fn list_teams(configuration: &configuration::Configuration) -> Result, Error> { - +pub async fn list_teams( + configuration: &configuration::Configuration, +) -> Result, Error> { let uri_str = format!("{}/teams", configuration.base_path); let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); @@ -4001,19 +4852,33 @@ pub async fn list_teams(configuration: &configuration::Configuration) -> Result< if !status.is_client_error() && !status.is_server_error() { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Ok(ResponseContent { tower_trace_id, status, content, entity }) + Ok(ResponseContent { + tower_trace_id, + status, + content, + entity, + }) } else { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { tower_trace_id, status, content, entity })) + Err(Error::ResponseError(ResponseContent { + tower_trace_id, + status, + content, + entity, + })) } } /// Returns a new session based on the supplied authentication context. This is helpful when clients want to use POST instead of GET to check session information. -pub async fn refresh_session(configuration: &configuration::Configuration, params: RefreshSessionParams) -> Result, Error> { - +pub async fn refresh_session( + configuration: &configuration::Configuration, + params: RefreshSessionParams, +) -> Result, Error> { let uri_str = format!("{}/session/refresh", configuration.base_path); - let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str); + let mut req_builder = configuration + .client + .request(reqwest::Method::POST, &uri_str); if let Some(ref user_agent) = configuration.user_agent { req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); @@ -4037,19 +4902,37 @@ pub async fn refresh_session(configuration: &configuration::Configuration, param if !status.is_client_error() && !status.is_server_error() { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Ok(ResponseContent { tower_trace_id, status, content, entity }) + Ok(ResponseContent { + tower_trace_id, + status, + content, + entity, + }) } else { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { tower_trace_id, status, content, entity })) + Err(Error::ResponseError(ResponseContent { + tower_trace_id, + status, + content, + entity, + })) } } /// Remove a new team -pub async fn remove_team_member(configuration: &configuration::Configuration, params: RemoveTeamMemberParams) -> Result, Error> { - - let uri_str = format!("{}/teams/{name}/members", configuration.base_path, name=crate::apis::urlencode(params.name)); - let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str); +pub async fn remove_team_member( + configuration: &configuration::Configuration, + params: RemoveTeamMemberParams, +) -> Result, Error> { + let uri_str = format!( + "{}/teams/{name}/members", + configuration.base_path, + name = crate::apis::urlencode(params.name) + ); + let mut req_builder = configuration + .client + .request(reqwest::Method::DELETE, &uri_str); if let Some(ref user_agent) = configuration.user_agent { req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); @@ -4073,19 +4956,32 @@ pub async fn remove_team_member(configuration: &configuration::Configuration, pa if !status.is_client_error() && !status.is_server_error() { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Ok(ResponseContent { tower_trace_id, status, content, entity }) + Ok(ResponseContent { + tower_trace_id, + status, + content, + entity, + }) } else { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { tower_trace_id, status, content, entity })) + Err(Error::ResponseError(ResponseContent { + tower_trace_id, + status, + content, + entity, + })) } } /// If a user doesn't have a verified email address, this API endpoint will send a new confirmation email to them -pub async fn resend_email_verification(configuration: &configuration::Configuration) -> Result, Error> { - +pub async fn resend_email_verification( + configuration: &configuration::Configuration, +) -> Result, Error> { let uri_str = format!("{}/user/resend-verification", configuration.base_path); - let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str); + let mut req_builder = configuration + .client + .request(reqwest::Method::POST, &uri_str); if let Some(ref user_agent) = configuration.user_agent { req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); @@ -4108,19 +5004,37 @@ pub async fn resend_email_verification(configuration: &configuration::Configurat if !status.is_client_error() && !status.is_server_error() { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Ok(ResponseContent { tower_trace_id, status, content, entity }) + Ok(ResponseContent { + tower_trace_id, + status, + content, + entity, + }) } else { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { tower_trace_id, status, content, entity })) + Err(Error::ResponseError(ResponseContent { + tower_trace_id, + status, + content, + entity, + })) } } /// Resend a team invitation to a user if they need a reminder or if they lost it -pub async fn resend_team_invitation(configuration: &configuration::Configuration, params: ResendTeamInvitationParams) -> Result, Error> { - - let uri_str = format!("{}/teams/{name}/invites/resend", configuration.base_path, name=crate::apis::urlencode(params.name)); - let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str); +pub async fn resend_team_invitation( + configuration: &configuration::Configuration, + params: ResendTeamInvitationParams, +) -> Result, Error> { + let uri_str = format!( + "{}/teams/{name}/invites/resend", + configuration.base_path, + name = crate::apis::urlencode(params.name) + ); + let mut req_builder = configuration + .client + .request(reqwest::Method::POST, &uri_str); if let Some(ref user_agent) = configuration.user_agent { req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); @@ -4144,19 +5058,37 @@ pub async fn resend_team_invitation(configuration: &configuration::Configuration if !status.is_client_error() && !status.is_server_error() { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Ok(ResponseContent { tower_trace_id, status, content, entity }) + Ok(ResponseContent { + tower_trace_id, + status, + content, + entity, + }) } else { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { tower_trace_id, status, content, entity })) + Err(Error::ResponseError(ResponseContent { + tower_trace_id, + status, + content, + entity, + })) } } /// Runs an app with the supplied parameters. -pub async fn run_app(configuration: &configuration::Configuration, params: RunAppParams) -> Result, Error> { - - let uri_str = format!("{}/apps/{name}/runs", configuration.base_path, name=crate::apis::urlencode(params.name)); - let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str); +pub async fn run_app( + configuration: &configuration::Configuration, + params: RunAppParams, +) -> Result, Error> { + let uri_str = format!( + "{}/apps/{name}/runs", + configuration.base_path, + name = crate::apis::urlencode(params.name) + ); + let mut req_builder = configuration + .client + .request(reqwest::Method::POST, &uri_str); if let Some(ref user_agent) = configuration.user_agent { req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); @@ -4188,17 +5120,29 @@ pub async fn run_app(configuration: &configuration::Configuration, params: RunAp if !status.is_client_error() && !status.is_server_error() { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Ok(ResponseContent { tower_trace_id, status, content, entity }) + Ok(ResponseContent { + tower_trace_id, + status, + content, + entity, + }) } else { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { tower_trace_id, status, content, entity })) + Err(Error::ResponseError(ResponseContent { + tower_trace_id, + status, + content, + entity, + })) } } /// Search, filter, and list runs across all of the apps in your account. -pub async fn search_runs(configuration: &configuration::Configuration, params: SearchRunsParams) -> Result, Error> { - +pub async fn search_runs( + configuration: &configuration::Configuration, + params: SearchRunsParams, +) -> Result, Error> { let uri_str = format!("{}/runs", configuration.base_path); let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); @@ -4210,8 +5154,21 @@ pub async fn search_runs(configuration: &configuration::Configuration, params: S } if let Some(ref param_value) = params.status { req_builder = match "csv" { - "multi" => req_builder.query(¶m_value.into_iter().map(|p| ("status".to_owned(), p.to_string())).collect::>()), - _ => req_builder.query(&[("status", ¶m_value.into_iter().map(|p| p.to_string()).collect::>().join(",").to_string())]), + "multi" => req_builder.query( + ¶m_value + .into_iter() + .map(|p| ("status".to_owned(), p.to_string())) + .collect::>(), + ), + _ => req_builder.query(&[( + "status", + ¶m_value + .into_iter() + .map(|p| p.to_string()) + .collect::>() + .join(",") + .to_string(), + )]), }; } if let Some(ref param_value) = params.start_at { @@ -4244,17 +5201,28 @@ pub async fn search_runs(configuration: &configuration::Configuration, params: S if !status.is_client_error() && !status.is_server_error() { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Ok(ResponseContent { tower_trace_id, status, content, entity }) + Ok(ResponseContent { + tower_trace_id, + status, + content, + entity, + }) } else { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { tower_trace_id, status, content, entity })) + Err(Error::ResponseError(ResponseContent { + tower_trace_id, + status, + content, + entity, + })) } } /// Streams alert notifications in real-time -pub async fn stream_alerts(configuration: &configuration::Configuration) -> Result, Error> { - +pub async fn stream_alerts( + configuration: &configuration::Configuration, +) -> Result, Error> { let uri_str = format!("{}/alerts/stream", configuration.base_path); let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); @@ -4279,18 +5247,35 @@ pub async fn stream_alerts(configuration: &configuration::Configuration) -> Resu if !status.is_client_error() && !status.is_server_error() { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Ok(ResponseContent { tower_trace_id, status, content, entity }) + Ok(ResponseContent { + tower_trace_id, + status, + content, + entity, + }) } else { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { tower_trace_id, status, content, entity })) + Err(Error::ResponseError(ResponseContent { + tower_trace_id, + status, + content, + entity, + })) } } /// Streams the logs associated with a particular run of an app in real-time. -pub async fn stream_run_logs(configuration: &configuration::Configuration, params: StreamRunLogsParams) -> Result, Error> { - - let uri_str = format!("{}/apps/{name}/runs/{seq}/logs/stream", configuration.base_path, name=crate::apis::urlencode(params.name), seq=params.seq); +pub async fn stream_run_logs( + configuration: &configuration::Configuration, + params: StreamRunLogsParams, +) -> Result, Error> { + let uri_str = format!( + "{}/apps/{name}/runs/{seq}/logs/stream", + configuration.base_path, + name = crate::apis::urlencode(params.name), + seq = params.seq + ); let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); if let Some(ref user_agent) = configuration.user_agent { @@ -4314,18 +5299,34 @@ pub async fn stream_run_logs(configuration: &configuration::Configuration, param if !status.is_client_error() && !status.is_server_error() { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Ok(ResponseContent { tower_trace_id, status, content, entity }) + Ok(ResponseContent { + tower_trace_id, + status, + content, + entity, + }) } else { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { tower_trace_id, status, content, entity })) + Err(Error::ResponseError(ResponseContent { + tower_trace_id, + status, + content, + entity, + })) } } /// Update the name for an account -pub async fn update_account_name(configuration: &configuration::Configuration, params: UpdateAccountNameParams) -> Result, Error> { - - let uri_str = format!("{}/accounts/{name}", configuration.base_path, name=crate::apis::urlencode(params.name)); +pub async fn update_account_name( + configuration: &configuration::Configuration, + params: UpdateAccountNameParams, +) -> Result, Error> { + let uri_str = format!( + "{}/accounts/{name}", + configuration.base_path, + name = crate::apis::urlencode(params.name) + ); let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); if let Some(ref user_agent) = configuration.user_agent { @@ -4350,18 +5351,34 @@ pub async fn update_account_name(configuration: &configuration::Configuration, p if !status.is_client_error() && !status.is_server_error() { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Ok(ResponseContent { tower_trace_id, status, content, entity }) + Ok(ResponseContent { + tower_trace_id, + status, + content, + entity, + }) } else { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { tower_trace_id, status, content, entity })) + Err(Error::ResponseError(ResponseContent { + tower_trace_id, + status, + content, + entity, + })) } } /// Update an app in the currently authenticated account. -pub async fn update_app(configuration: &configuration::Configuration, params: UpdateAppParams) -> Result, Error> { - - let uri_str = format!("{}/apps/{name}", configuration.base_path, name=crate::apis::urlencode(params.name)); +pub async fn update_app( + configuration: &configuration::Configuration, + params: UpdateAppParams, +) -> Result, Error> { + let uri_str = format!( + "{}/apps/{name}", + configuration.base_path, + name = crate::apis::urlencode(params.name) + ); let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); if let Some(ref user_agent) = configuration.user_agent { @@ -4386,18 +5403,34 @@ pub async fn update_app(configuration: &configuration::Configuration, params: Up if !status.is_client_error() && !status.is_server_error() { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Ok(ResponseContent { tower_trace_id, status, content, entity }) + Ok(ResponseContent { + tower_trace_id, + status, + content, + entity, + }) } else { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { tower_trace_id, status, content, entity })) + Err(Error::ResponseError(ResponseContent { + tower_trace_id, + status, + content, + entity, + })) } } /// Update a new catalog object in the currently authenticated account. -pub async fn update_catalog(configuration: &configuration::Configuration, params: UpdateCatalogParams) -> Result, Error> { - - let uri_str = format!("{}/catalogs/{name}", configuration.base_path, name=crate::apis::urlencode(params.name)); +pub async fn update_catalog( + configuration: &configuration::Configuration, + params: UpdateCatalogParams, +) -> Result, Error> { + let uri_str = format!( + "{}/catalogs/{name}", + configuration.base_path, + name = crate::apis::urlencode(params.name) + ); let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); if let Some(ref user_agent) = configuration.user_agent { @@ -4422,18 +5455,34 @@ pub async fn update_catalog(configuration: &configuration::Configuration, params if !status.is_client_error() && !status.is_server_error() { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Ok(ResponseContent { tower_trace_id, status, content, entity }) + Ok(ResponseContent { + tower_trace_id, + status, + content, + entity, + }) } else { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { tower_trace_id, status, content, entity })) + Err(Error::ResponseError(ResponseContent { + tower_trace_id, + status, + content, + entity, + })) } } /// Rename your environment -pub async fn update_environment(configuration: &configuration::Configuration, params: UpdateEnvironmentParams) -> Result, Error> { - - let uri_str = format!("{}/environments/{name}", configuration.base_path, name=crate::apis::urlencode(params.name)); +pub async fn update_environment( + configuration: &configuration::Configuration, + params: UpdateEnvironmentParams, +) -> Result, Error> { + let uri_str = format!( + "{}/environments/{name}", + configuration.base_path, + name = crate::apis::urlencode(params.name) + ); let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); if let Some(ref user_agent) = configuration.user_agent { @@ -4458,17 +5507,29 @@ pub async fn update_environment(configuration: &configuration::Configuration, pa if !status.is_client_error() && !status.is_server_error() { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Ok(ResponseContent { tower_trace_id, status, content, entity }) + Ok(ResponseContent { + tower_trace_id, + status, + content, + entity, + }) } else { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { tower_trace_id, status, content, entity })) + Err(Error::ResponseError(ResponseContent { + tower_trace_id, + status, + content, + entity, + })) } } /// Update a team invitation that you have pending -pub async fn update_my_team_invitation(configuration: &configuration::Configuration, params: UpdateMyTeamInvitationParams) -> Result, Error> { - +pub async fn update_my_team_invitation( + configuration: &configuration::Configuration, + params: UpdateMyTeamInvitationParams, +) -> Result, Error> { let uri_str = format!("{}/team-invites", configuration.base_path); let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); @@ -4494,19 +5555,37 @@ pub async fn update_my_team_invitation(configuration: &configuration::Configurat if !status.is_client_error() && !status.is_server_error() { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Ok(ResponseContent { tower_trace_id, status, content, entity }) + Ok(ResponseContent { + tower_trace_id, + status, + content, + entity, + }) } else { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { tower_trace_id, status, content, entity })) + Err(Error::ResponseError(ResponseContent { + tower_trace_id, + status, + content, + entity, + })) } } /// Updates the password reset code with the new password -pub async fn update_password_reset(configuration: &configuration::Configuration, params: UpdatePasswordResetParams) -> Result, Error> { - - let uri_str = format!("{}/accounts/password-reset/{code}", configuration.base_path, code=crate::apis::urlencode(params.code)); - let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str); +pub async fn update_password_reset( + configuration: &configuration::Configuration, + params: UpdatePasswordResetParams, +) -> Result, Error> { + let uri_str = format!( + "{}/accounts/password-reset/{code}", + configuration.base_path, + code = crate::apis::urlencode(params.code) + ); + let mut req_builder = configuration + .client + .request(reqwest::Method::POST, &uri_str); if let Some(ref user_agent) = configuration.user_agent { req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); @@ -4527,16 +5606,28 @@ pub async fn update_password_reset(configuration: &configuration::Configuration, if !status.is_client_error() && !status.is_server_error() { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Ok(ResponseContent { tower_trace_id, status, content, entity }) + Ok(ResponseContent { + tower_trace_id, + status, + content, + entity, + }) } else { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { tower_trace_id, status, content, entity })) + Err(Error::ResponseError(ResponseContent { + tower_trace_id, + status, + content, + entity, + })) } } -pub async fn update_plan(configuration: &configuration::Configuration, params: UpdatePlanParams) -> Result, Error> { - +pub async fn update_plan( + configuration: &configuration::Configuration, + params: UpdatePlanParams, +) -> Result, Error> { let uri_str = format!("{}/plan", configuration.base_path); let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); @@ -4562,18 +5653,34 @@ pub async fn update_plan(configuration: &configuration::Configuration, params: U if !status.is_client_error() && !status.is_server_error() { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Ok(ResponseContent { tower_trace_id, status, content, entity }) + Ok(ResponseContent { + tower_trace_id, + status, + content, + entity, + }) } else { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { tower_trace_id, status, content, entity })) + Err(Error::ResponseError(ResponseContent { + tower_trace_id, + status, + content, + entity, + })) } } /// Update an existing schedule for an app. -pub async fn update_schedule(configuration: &configuration::Configuration, params: UpdateScheduleParams) -> Result, Error> { - - let uri_str = format!("{}/schedules/{id}", configuration.base_path, id=crate::apis::urlencode(params.id)); +pub async fn update_schedule( + configuration: &configuration::Configuration, + params: UpdateScheduleParams, +) -> Result, Error> { + let uri_str = format!( + "{}/schedules/{id}", + configuration.base_path, + id = crate::apis::urlencode(params.id) + ); let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); if let Some(ref user_agent) = configuration.user_agent { @@ -4598,18 +5705,34 @@ pub async fn update_schedule(configuration: &configuration::Configuration, param if !status.is_client_error() && !status.is_server_error() { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Ok(ResponseContent { tower_trace_id, status, content, entity }) + Ok(ResponseContent { + tower_trace_id, + status, + content, + entity, + }) } else { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { tower_trace_id, status, content, entity })) + Err(Error::ResponseError(ResponseContent { + tower_trace_id, + status, + content, + entity, + })) } } /// Updates a secret that has previously been created in your account -pub async fn update_secret(configuration: &configuration::Configuration, params: UpdateSecretParams) -> Result, Error> { - - let uri_str = format!("{}/secrets/{name}", configuration.base_path, name=crate::apis::urlencode(params.name)); +pub async fn update_secret( + configuration: &configuration::Configuration, + params: UpdateSecretParams, +) -> Result, Error> { + let uri_str = format!( + "{}/secrets/{name}", + configuration.base_path, + name = crate::apis::urlencode(params.name) + ); let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); if let Some(ref user_agent) = configuration.user_agent { @@ -4634,18 +5757,34 @@ pub async fn update_secret(configuration: &configuration::Configuration, params: if !status.is_client_error() && !status.is_server_error() { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Ok(ResponseContent { tower_trace_id, status, content, entity }) + Ok(ResponseContent { + tower_trace_id, + status, + content, + entity, + }) } else { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { tower_trace_id, status, content, entity })) + Err(Error::ResponseError(ResponseContent { + tower_trace_id, + status, + content, + entity, + })) } } /// Update a team with a new name or name. Note that updating the team with a new name will cause all your URLs to change! -pub async fn update_team(configuration: &configuration::Configuration, params: UpdateTeamParams) -> Result, Error> { - - let uri_str = format!("{}/teams/{name}", configuration.base_path, name=crate::apis::urlencode(params.name)); +pub async fn update_team( + configuration: &configuration::Configuration, + params: UpdateTeamParams, +) -> Result, Error> { + let uri_str = format!( + "{}/teams/{name}", + configuration.base_path, + name = crate::apis::urlencode(params.name) + ); let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); if let Some(ref user_agent) = configuration.user_agent { @@ -4670,17 +5809,29 @@ pub async fn update_team(configuration: &configuration::Configuration, params: U if !status.is_client_error() && !status.is_server_error() { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Ok(ResponseContent { tower_trace_id, status, content, entity }) + Ok(ResponseContent { + tower_trace_id, + status, + content, + entity, + }) } else { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { tower_trace_id, status, content, entity })) + Err(Error::ResponseError(ResponseContent { + tower_trace_id, + status, + content, + entity, + })) } } /// Updates your current user profile. -pub async fn update_user(configuration: &configuration::Configuration, params: UpdateUserParams) -> Result, Error> { - +pub async fn update_user( + configuration: &configuration::Configuration, + params: UpdateUserParams, +) -> Result, Error> { let uri_str = format!("{}/user", configuration.base_path); let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str); @@ -4706,19 +5857,33 @@ pub async fn update_user(configuration: &configuration::Configuration, params: U if !status.is_client_error() && !status.is_server_error() { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Ok(ResponseContent { tower_trace_id, status, content, entity }) + Ok(ResponseContent { + tower_trace_id, + status, + content, + entity, + }) } else { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { tower_trace_id, status, content, entity })) + Err(Error::ResponseError(ResponseContent { + tower_trace_id, + status, + content, + entity, + })) } } /// If the user hasn't verified their email address, this API endpoint allows them to send a confirmation token they received via email to indeed verify they can receive emails. -pub async fn verify_email(configuration: &configuration::Configuration, params: VerifyEmailParams) -> Result, Error> { - +pub async fn verify_email( + configuration: &configuration::Configuration, + params: VerifyEmailParams, +) -> Result, Error> { let uri_str = format!("{}/user/verify", configuration.base_path); - let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str); + let mut req_builder = configuration + .client + .request(reqwest::Method::POST, &uri_str); if let Some(ref user_agent) = configuration.user_agent { req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); @@ -4742,11 +5907,20 @@ pub async fn verify_email(configuration: &configuration::Configuration, params: if !status.is_client_error() && !status.is_server_error() { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Ok(ResponseContent { tower_trace_id, status, content, entity }) + Ok(ResponseContent { + tower_trace_id, + status, + content, + entity, + }) } else { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { tower_trace_id, status, content, entity })) + Err(Error::ResponseError(ResponseContent { + tower_trace_id, + status, + content, + entity, + })) } } - diff --git a/crates/tower-api/src/apis/feature_flags_api.rs b/crates/tower-api/src/apis/feature_flags_api.rs index 85bfd3d8..5591d5a8 100644 --- a/crates/tower-api/src/apis/feature_flags_api.rs +++ b/crates/tower-api/src/apis/feature_flags_api.rs @@ -8,11 +8,10 @@ * Generated by: https://openapi-generator.tech */ - -use reqwest; -use serde::{Deserialize, Serialize, de::Error as _}; +use super::{configuration, ContentType, Error}; use crate::{apis::ResponseContent, models}; -use super::{Error, configuration, ContentType}; +use reqwest; +use serde::{de::Error as _, Deserialize, Serialize}; const DEFAULT_TOWER_TRACE_ID: &str = "(none)"; @@ -20,10 +19,9 @@ const DEFAULT_TOWER_TRACE_ID: &str = "(none)"; #[derive(Clone, Debug)] pub struct GetFeatureFlagValueParams { /// The feature flag key - pub key: String + pub key: String, } - /// struct for typed successes of method [`get_feature_flag_value`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] @@ -40,11 +38,16 @@ pub enum GetFeatureFlagValueError { UnknownValue(serde_json::Value), } - /// Get the current value of a feature flag. Returns the flag value if enabled, or a default falsey value if disabled. -pub async fn get_feature_flag_value(configuration: &configuration::Configuration, params: GetFeatureFlagValueParams) -> Result, Error> { - - let uri_str = format!("{}/feature-flags/{key}", configuration.base_path, key=crate::apis::urlencode(params.key)); +pub async fn get_feature_flag_value( + configuration: &configuration::Configuration, + params: GetFeatureFlagValueParams, +) -> Result, Error> { + let uri_str = format!( + "{}/feature-flags/{key}", + configuration.base_path, + key = crate::apis::urlencode(params.key) + ); let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); if let Some(ref user_agent) = configuration.user_agent { @@ -65,11 +68,20 @@ pub async fn get_feature_flag_value(configuration: &configuration::Configuration if !status.is_client_error() && !status.is_server_error() { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Ok(ResponseContent { tower_trace_id, status, content, entity }) + Ok(ResponseContent { + tower_trace_id, + status, + content, + entity, + }) } else { let content = resp.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { tower_trace_id, status, content, entity })) + Err(Error::ResponseError(ResponseContent { + tower_trace_id, + status, + content, + entity, + })) } } - diff --git a/crates/tower-api/src/apis/mod.rs b/crates/tower-api/src/apis/mod.rs index 068ce002..cd45a3a4 100644 --- a/crates/tower-api/src/apis/mod.rs +++ b/crates/tower-api/src/apis/mod.rs @@ -17,7 +17,7 @@ pub enum Error { ResponseError(ResponseContent), } -impl fmt::Display for Error { +impl fmt::Display for Error { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let (module, e) = match self { Error::Reqwest(e) => ("reqwest", e.to_string()), @@ -29,7 +29,7 @@ impl fmt::Display for Error { } } -impl error::Error for Error { +impl error::Error for Error { fn source(&self) -> Option<&(dyn error::Error + 'static)> { Some(match self { Error::Reqwest(e) => e, @@ -40,19 +40,19 @@ impl error::Error for Error { } } -impl From for Error { +impl From for Error { fn from(e: reqwest::Error) -> Self { Error::Reqwest(e) } } -impl From for Error { +impl From for Error { fn from(e: serde_json::Error) -> Self { Error::Serde(e) } } -impl From for Error { +impl From for Error { fn from(e: std::io::Error) -> Self { Error::Io(e) } @@ -79,8 +79,10 @@ pub fn parse_deep_object(prefix: &str, value: &serde_json::Value) -> Vec<(String value, )); } - }, - serde_json::Value::String(s) => params.push((format!("{}[{}]", prefix, key), s.clone())), + } + serde_json::Value::String(s) => { + params.push((format!("{}[{}]", prefix, key), s.clone())) + } _ => params.push((format!("{}[{}]", prefix, key), value.to_string())), } } @@ -97,7 +99,7 @@ pub fn parse_deep_object(prefix: &str, value: &serde_json::Value) -> Vec<(String enum ContentType { Json, Text, - Unsupported(String) + Unsupported(String), } impl From<&str> for ContentType { diff --git a/crates/tower-api/src/lib.rs b/crates/tower-api/src/lib.rs index e1520628..9556a0a1 100644 --- a/crates/tower-api/src/lib.rs +++ b/crates/tower-api/src/lib.rs @@ -1,11 +1,11 @@ #![allow(unused_imports)] #![allow(clippy::too_many_arguments)] -extern crate serde_repr; +extern crate reqwest; extern crate serde; extern crate serde_json; +extern crate serde_repr; extern crate url; -extern crate reqwest; pub mod apis; pub mod models; diff --git a/crates/tower-api/src/models/account.rs b/crates/tower-api/src/models/account.rs index 29aaa97c..483fe0a2 100644 --- a/crates/tower-api/src/models/account.rs +++ b/crates/tower-api/src/models/account.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct Account { @@ -22,10 +22,6 @@ pub struct Account { impl Account { pub fn new(name: String) -> Account { - Account { - name, - slug: None, - } + Account { name, slug: None } } } - diff --git a/crates/tower-api/src/models/acknowledge_alert_response.rs b/crates/tower-api/src/models/acknowledge_alert_response.rs index 673efe22..f6c32326 100644 --- a/crates/tower-api/src/models/acknowledge_alert_response.rs +++ b/crates/tower-api/src/models/acknowledge_alert_response.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct AcknowledgeAlertResponse { @@ -28,4 +28,3 @@ impl AcknowledgeAlertResponse { } } } - diff --git a/crates/tower-api/src/models/acknowledge_all_alerts_response.rs b/crates/tower-api/src/models/acknowledge_all_alerts_response.rs index 157b0247..48cb991e 100644 --- a/crates/tower-api/src/models/acknowledge_all_alerts_response.rs +++ b/crates/tower-api/src/models/acknowledge_all_alerts_response.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct AcknowledgeAllAlertsResponse { @@ -32,4 +32,3 @@ impl AcknowledgeAllAlertsResponse { } } } - diff --git a/crates/tower-api/src/models/alert.rs b/crates/tower-api/src/models/alert.rs index 157d6ab4..54f4bf0f 100644 --- a/crates/tower-api/src/models/alert.rs +++ b/crates/tower-api/src/models/alert.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct Alert { @@ -30,7 +30,15 @@ pub struct Alert { } impl Alert { - pub fn new(acked: bool, alert_type: String, created_at: String, detail: models::RunFailureAlert, environment: String, seq: i64, status: String) -> Alert { + pub fn new( + acked: bool, + alert_type: String, + created_at: String, + detail: models::RunFailureAlert, + environment: String, + seq: i64, + status: String, + ) -> Alert { Alert { acked, alert_type, @@ -42,4 +50,3 @@ impl Alert { } } } - diff --git a/crates/tower-api/src/models/api_key.rs b/crates/tower-api/src/models/api_key.rs index e5d8ef58..358682cb 100644 --- a/crates/tower-api/src/models/api_key.rs +++ b/crates/tower-api/src/models/api_key.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct ApiKey { @@ -24,7 +24,12 @@ pub struct ApiKey { } impl ApiKey { - pub fn new(created_at: String, identifier: String, last_used_at: Option, name: String) -> ApiKey { + pub fn new( + created_at: String, + identifier: String, + last_used_at: Option, + name: String, + ) -> ApiKey { ApiKey { created_at, identifier, @@ -33,4 +38,3 @@ impl ApiKey { } } } - diff --git a/crates/tower-api/src/models/app.rs b/crates/tower-api/src/models/app.rs index 2a8d2902..820bf07f 100644 --- a/crates/tower-api/src/models/app.rs +++ b/crates/tower-api/src/models/app.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct App { @@ -52,7 +52,16 @@ pub struct App { } impl App { - pub fn new(created_at: String, health_status: HealthStatus, name: String, next_run_at: Option, owner: String, schedule: Option, short_description: String, version: Option) -> App { + pub fn new( + created_at: String, + health_status: HealthStatus, + name: String, + next_run_at: Option, + owner: String, + schedule: Option, + short_description: String, + version: Option, + ) -> App { App { created_at, health_status, @@ -131,4 +140,3 @@ impl<'de> Deserialize<'de> for Status { } } } - diff --git a/crates/tower-api/src/models/app_statistics.rs b/crates/tower-api/src/models/app_statistics.rs index 728d757d..c7ce6409 100644 --- a/crates/tower-api/src/models/app_statistics.rs +++ b/crates/tower-api/src/models/app_statistics.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct AppStatistics { @@ -24,7 +24,12 @@ pub struct AppStatistics { } impl AppStatistics { - pub fn new(all_apps: i64, disabled_apps: i64, healthy_apps: i64, running_apps: i64) -> AppStatistics { + pub fn new( + all_apps: i64, + disabled_apps: i64, + healthy_apps: i64, + running_apps: i64, + ) -> AppStatistics { AppStatistics { all_apps, disabled_apps, @@ -33,4 +38,3 @@ impl AppStatistics { } } } - diff --git a/crates/tower-api/src/models/app_summary.rs b/crates/tower-api/src/models/app_summary.rs index ae4babb2..ddcb4a5d 100644 --- a/crates/tower-api/src/models/app_summary.rs +++ b/crates/tower-api/src/models/app_summary.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct AppSummary { @@ -21,10 +21,6 @@ pub struct AppSummary { impl AppSummary { pub fn new(app: models::App, runs: Vec) -> AppSummary { - AppSummary { - app, - runs, - } + AppSummary { app, runs } } } - diff --git a/crates/tower-api/src/models/app_version.rs b/crates/tower-api/src/models/app_version.rs index c7a2197a..f0ac75a2 100644 --- a/crates/tower-api/src/models/app_version.rs +++ b/crates/tower-api/src/models/app_version.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct AppVersion { @@ -25,7 +25,12 @@ pub struct AppVersion { } impl AppVersion { - pub fn new(created_at: String, parameters: Vec, towerfile: String, version: String) -> AppVersion { + pub fn new( + created_at: String, + parameters: Vec, + towerfile: String, + version: String, + ) -> AppVersion { AppVersion { created_at, parameters, @@ -34,4 +39,3 @@ impl AppVersion { } } } - diff --git a/crates/tower-api/src/models/cancel_run_response.rs b/crates/tower-api/src/models/cancel_run_response.rs index 6d735d20..a3671774 100644 --- a/crates/tower-api/src/models/cancel_run_response.rs +++ b/crates/tower-api/src/models/cancel_run_response.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct CancelRunResponse { @@ -22,10 +22,6 @@ pub struct CancelRunResponse { impl CancelRunResponse { pub fn new(run: models::Run) -> CancelRunResponse { - CancelRunResponse { - schema: None, - run, - } + CancelRunResponse { schema: None, run } } } - diff --git a/crates/tower-api/src/models/catalog.rs b/crates/tower-api/src/models/catalog.rs index 36c13e3e..ffd7c3f3 100644 --- a/crates/tower-api/src/models/catalog.rs +++ b/crates/tower-api/src/models/catalog.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct Catalog { @@ -29,7 +29,13 @@ pub struct Catalog { } impl Catalog { - pub fn new(created_at: String, environment: String, name: String, properties: Vec, r#type: String) -> Catalog { + pub fn new( + created_at: String, + environment: String, + name: String, + properties: Vec, + r#type: String, + ) -> Catalog { Catalog { created_at, environment, @@ -40,4 +46,3 @@ impl Catalog { } } } - diff --git a/crates/tower-api/src/models/catalog_property.rs b/crates/tower-api/src/models/catalog_property.rs index 060628a9..94aac7eb 100644 --- a/crates/tower-api/src/models/catalog_property.rs +++ b/crates/tower-api/src/models/catalog_property.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct CatalogProperty { @@ -21,10 +21,6 @@ pub struct CatalogProperty { impl CatalogProperty { pub fn new(name: String, preview: String) -> CatalogProperty { - CatalogProperty { - name, - preview, - } + CatalogProperty { name, preview } } } - diff --git a/crates/tower-api/src/models/claim_device_login_ticket_params.rs b/crates/tower-api/src/models/claim_device_login_ticket_params.rs index 9fc3ae6b..bbe82fbe 100644 --- a/crates/tower-api/src/models/claim_device_login_ticket_params.rs +++ b/crates/tower-api/src/models/claim_device_login_ticket_params.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct ClaimDeviceLoginTicketParams { @@ -29,4 +29,3 @@ impl ClaimDeviceLoginTicketParams { } } } - diff --git a/crates/tower-api/src/models/claim_device_login_ticket_response.rs b/crates/tower-api/src/models/claim_device_login_ticket_response.rs index 6472c83a..9d3b02d0 100644 --- a/crates/tower-api/src/models/claim_device_login_ticket_response.rs +++ b/crates/tower-api/src/models/claim_device_login_ticket_response.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct ClaimDeviceLoginTicketResponse { @@ -29,4 +29,3 @@ impl ClaimDeviceLoginTicketResponse { } } } - diff --git a/crates/tower-api/src/models/create_account_params.rs b/crates/tower-api/src/models/create_account_params.rs index 3c3b76e5..23f1ea45 100644 --- a/crates/tower-api/src/models/create_account_params.rs +++ b/crates/tower-api/src/models/create_account_params.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct CreateAccountParams { @@ -31,4 +31,3 @@ impl CreateAccountParams { } } } - diff --git a/crates/tower-api/src/models/create_account_params_flags_struct.rs b/crates/tower-api/src/models/create_account_params_flags_struct.rs index 27fa015e..2c4da91e 100644 --- a/crates/tower-api/src/models/create_account_params_flags_struct.rs +++ b/crates/tower-api/src/models/create_account_params_flags_struct.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct CreateAccountParamsFlagsStruct { @@ -19,9 +19,6 @@ pub struct CreateAccountParamsFlagsStruct { impl CreateAccountParamsFlagsStruct { pub fn new(is_test_account: bool) -> CreateAccountParamsFlagsStruct { - CreateAccountParamsFlagsStruct { - is_test_account, - } + CreateAccountParamsFlagsStruct { is_test_account } } } - diff --git a/crates/tower-api/src/models/create_account_response.rs b/crates/tower-api/src/models/create_account_response.rs index 74338a91..7bcc05a9 100644 --- a/crates/tower-api/src/models/create_account_response.rs +++ b/crates/tower-api/src/models/create_account_response.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct CreateAccountResponse { @@ -28,4 +28,3 @@ impl CreateAccountResponse { } } } - diff --git a/crates/tower-api/src/models/create_api_key_params.rs b/crates/tower-api/src/models/create_api_key_params.rs index c90cb64b..c9557440 100644 --- a/crates/tower-api/src/models/create_api_key_params.rs +++ b/crates/tower-api/src/models/create_api_key_params.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct CreateApiKeyParams { @@ -22,10 +22,6 @@ pub struct CreateApiKeyParams { impl CreateApiKeyParams { pub fn new(name: String) -> CreateApiKeyParams { - CreateApiKeyParams { - schema: None, - name, - } + CreateApiKeyParams { schema: None, name } } } - diff --git a/crates/tower-api/src/models/create_api_key_response.rs b/crates/tower-api/src/models/create_api_key_response.rs index 28d901ae..c7c82741 100644 --- a/crates/tower-api/src/models/create_api_key_response.rs +++ b/crates/tower-api/src/models/create_api_key_response.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct CreateApiKeyResponse { @@ -29,4 +29,3 @@ impl CreateApiKeyResponse { } } } - diff --git a/crates/tower-api/src/models/create_app_params.rs b/crates/tower-api/src/models/create_app_params.rs index 2c00d377..a35be71e 100644 --- a/crates/tower-api/src/models/create_app_params.rs +++ b/crates/tower-api/src/models/create_app_params.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct CreateAppParams { @@ -17,7 +17,10 @@ pub struct CreateAppParams { #[serde(rename = "$schema", skip_serializing_if = "Option::is_none")] pub schema: Option, /// Indicates that web traffic should be routed to this app and that its runs should get a hostname assigned to it. - #[serde(rename = "is_externally_accessible", skip_serializing_if = "Option::is_none")] + #[serde( + rename = "is_externally_accessible", + skip_serializing_if = "Option::is_none" + )] pub is_externally_accessible: Option, /// The name of the app. #[serde(rename = "name")] @@ -41,4 +44,3 @@ impl CreateAppParams { } } } - diff --git a/crates/tower-api/src/models/create_app_response.rs b/crates/tower-api/src/models/create_app_response.rs index 3197127c..dcad44dd 100644 --- a/crates/tower-api/src/models/create_app_response.rs +++ b/crates/tower-api/src/models/create_app_response.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct CreateAppResponse { @@ -22,10 +22,6 @@ pub struct CreateAppResponse { impl CreateAppResponse { pub fn new(app: models::App) -> CreateAppResponse { - CreateAppResponse { - schema: None, - app, - } + CreateAppResponse { schema: None, app } } } - diff --git a/crates/tower-api/src/models/create_authenticator_params.rs b/crates/tower-api/src/models/create_authenticator_params.rs index 56ef643a..d97f4174 100644 --- a/crates/tower-api/src/models/create_authenticator_params.rs +++ b/crates/tower-api/src/models/create_authenticator_params.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct CreateAuthenticatorParams { @@ -33,4 +33,3 @@ impl CreateAuthenticatorParams { } } } - diff --git a/crates/tower-api/src/models/create_authenticator_response.rs b/crates/tower-api/src/models/create_authenticator_response.rs index cf3d2019..c0966521 100644 --- a/crates/tower-api/src/models/create_authenticator_response.rs +++ b/crates/tower-api/src/models/create_authenticator_response.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct CreateAuthenticatorResponse { @@ -28,4 +28,3 @@ impl CreateAuthenticatorResponse { } } } - diff --git a/crates/tower-api/src/models/create_catalog_params.rs b/crates/tower-api/src/models/create_catalog_params.rs index 5124a0fb..dc2b53f7 100644 --- a/crates/tower-api/src/models/create_catalog_params.rs +++ b/crates/tower-api/src/models/create_catalog_params.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct CreateCatalogParams { @@ -27,7 +27,12 @@ pub struct CreateCatalogParams { } impl CreateCatalogParams { - pub fn new(environment: String, name: String, properties: Vec, r#type: Type) -> CreateCatalogParams { + pub fn new( + environment: String, + name: String, + properties: Vec, + r#type: Type, + ) -> CreateCatalogParams { CreateCatalogParams { schema: None, environment, @@ -37,7 +42,7 @@ impl CreateCatalogParams { } } } -/// +/// #[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize)] pub enum Type { #[serde(rename = "snowflake-open-catalog")] @@ -69,9 +74,13 @@ impl<'de> Deserialize<'de> for Type { "lakekeeper" => Ok(Self::Lakekeeper), _ => Err(serde::de::Error::unknown_variant( &s, - &["snowflake-open-catalog", "apache-polaris", "cloudflare-r2-catalog", "lakekeeper"], + &[ + "snowflake-open-catalog", + "apache-polaris", + "cloudflare-r2-catalog", + "lakekeeper", + ], )), } } } - diff --git a/crates/tower-api/src/models/create_catalog_response.rs b/crates/tower-api/src/models/create_catalog_response.rs index c4cae940..00db23f7 100644 --- a/crates/tower-api/src/models/create_catalog_response.rs +++ b/crates/tower-api/src/models/create_catalog_response.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct CreateCatalogResponse { @@ -28,4 +28,3 @@ impl CreateCatalogResponse { } } } - diff --git a/crates/tower-api/src/models/create_device_login_ticket_response.rs b/crates/tower-api/src/models/create_device_login_ticket_response.rs index 901060b8..fa734138 100644 --- a/crates/tower-api/src/models/create_device_login_ticket_response.rs +++ b/crates/tower-api/src/models/create_device_login_ticket_response.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct CreateDeviceLoginTicketResponse { @@ -40,7 +40,15 @@ pub struct CreateDeviceLoginTicketResponse { } impl CreateDeviceLoginTicketResponse { - pub fn new(device_code: String, expires_in: i64, generated_at: String, interval: i64, login_url: String, user_code: String, verification_url: String) -> CreateDeviceLoginTicketResponse { + pub fn new( + device_code: String, + expires_in: i64, + generated_at: String, + interval: i64, + login_url: String, + user_code: String, + verification_url: String, + ) -> CreateDeviceLoginTicketResponse { CreateDeviceLoginTicketResponse { schema: None, device_code, @@ -53,4 +61,3 @@ impl CreateDeviceLoginTicketResponse { } } } - diff --git a/crates/tower-api/src/models/create_environment_params.rs b/crates/tower-api/src/models/create_environment_params.rs index d02901cd..5ad34940 100644 --- a/crates/tower-api/src/models/create_environment_params.rs +++ b/crates/tower-api/src/models/create_environment_params.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct CreateEnvironmentParams { @@ -23,10 +23,6 @@ pub struct CreateEnvironmentParams { impl CreateEnvironmentParams { pub fn new(name: String) -> CreateEnvironmentParams { - CreateEnvironmentParams { - schema: None, - name, - } + CreateEnvironmentParams { schema: None, name } } } - diff --git a/crates/tower-api/src/models/create_environment_response.rs b/crates/tower-api/src/models/create_environment_response.rs index 07e55c34..71c1095a 100644 --- a/crates/tower-api/src/models/create_environment_response.rs +++ b/crates/tower-api/src/models/create_environment_response.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct CreateEnvironmentResponse { @@ -28,4 +28,3 @@ impl CreateEnvironmentResponse { } } } - diff --git a/crates/tower-api/src/models/create_password_reset_params.rs b/crates/tower-api/src/models/create_password_reset_params.rs index 5b519ab3..b8c65b1f 100644 --- a/crates/tower-api/src/models/create_password_reset_params.rs +++ b/crates/tower-api/src/models/create_password_reset_params.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct CreatePasswordResetParams { @@ -29,4 +29,3 @@ impl CreatePasswordResetParams { } } } - diff --git a/crates/tower-api/src/models/create_password_reset_response.rs b/crates/tower-api/src/models/create_password_reset_response.rs index 72742b65..843ee10f 100644 --- a/crates/tower-api/src/models/create_password_reset_response.rs +++ b/crates/tower-api/src/models/create_password_reset_response.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct CreatePasswordResetResponse { @@ -23,10 +23,6 @@ pub struct CreatePasswordResetResponse { impl CreatePasswordResetResponse { pub fn new(ok: bool) -> CreatePasswordResetResponse { - CreatePasswordResetResponse { - schema: None, - ok, - } + CreatePasswordResetResponse { schema: None, ok } } } - diff --git a/crates/tower-api/src/models/create_schedule_params.rs b/crates/tower-api/src/models/create_schedule_params.rs index 541f1fcb..d0bf7588 100644 --- a/crates/tower-api/src/models/create_schedule_params.rs +++ b/crates/tower-api/src/models/create_schedule_params.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct CreateScheduleParams { @@ -20,7 +20,12 @@ pub struct CreateScheduleParams { #[serde(rename = "app_name")] pub app_name: String, /// The specific app version to run (if omitted, will use the app's default version) - #[serde(rename = "app_version", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] + #[serde( + rename = "app_version", + default, + with = "::serde_with::rust::double_option", + skip_serializing_if = "Option::is_none" + )] pub app_version: Option>, /// The cron expression defining when the app should run #[serde(rename = "cron")] @@ -45,4 +50,3 @@ impl CreateScheduleParams { } } } - diff --git a/crates/tower-api/src/models/create_schedule_response.rs b/crates/tower-api/src/models/create_schedule_response.rs index 2d1e230a..6fb41e18 100644 --- a/crates/tower-api/src/models/create_schedule_response.rs +++ b/crates/tower-api/src/models/create_schedule_response.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct CreateScheduleResponse { @@ -28,4 +28,3 @@ impl CreateScheduleResponse { } } } - diff --git a/crates/tower-api/src/models/create_secret_params.rs b/crates/tower-api/src/models/create_secret_params.rs index 1602a465..bfefba96 100644 --- a/crates/tower-api/src/models/create_secret_params.rs +++ b/crates/tower-api/src/models/create_secret_params.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct CreateSecretParams { @@ -27,7 +27,12 @@ pub struct CreateSecretParams { } impl CreateSecretParams { - pub fn new(encrypted_value: String, environment: String, name: String, preview: String) -> CreateSecretParams { + pub fn new( + encrypted_value: String, + environment: String, + name: String, + preview: String, + ) -> CreateSecretParams { CreateSecretParams { schema: None, encrypted_value, @@ -37,4 +42,3 @@ impl CreateSecretParams { } } } - diff --git a/crates/tower-api/src/models/create_secret_response.rs b/crates/tower-api/src/models/create_secret_response.rs index b0be1822..3a60b46b 100644 --- a/crates/tower-api/src/models/create_secret_response.rs +++ b/crates/tower-api/src/models/create_secret_response.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct CreateSecretResponse { @@ -28,4 +28,3 @@ impl CreateSecretResponse { } } } - diff --git a/crates/tower-api/src/models/create_session_params.rs b/crates/tower-api/src/models/create_session_params.rs index a860b8ff..81e66940 100644 --- a/crates/tower-api/src/models/create_session_params.rs +++ b/crates/tower-api/src/models/create_session_params.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct CreateSessionParams { @@ -35,4 +35,3 @@ impl CreateSessionParams { } } } - diff --git a/crates/tower-api/src/models/create_session_response.rs b/crates/tower-api/src/models/create_session_response.rs index 3931cd71..e9ca7b45 100644 --- a/crates/tower-api/src/models/create_session_response.rs +++ b/crates/tower-api/src/models/create_session_response.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct CreateSessionResponse { @@ -29,4 +29,3 @@ impl CreateSessionResponse { } } } - diff --git a/crates/tower-api/src/models/create_team_params.rs b/crates/tower-api/src/models/create_team_params.rs index 7e4d2c8d..eaa6fd20 100644 --- a/crates/tower-api/src/models/create_team_params.rs +++ b/crates/tower-api/src/models/create_team_params.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct CreateTeamParams { @@ -23,10 +23,6 @@ pub struct CreateTeamParams { impl CreateTeamParams { pub fn new(name: String) -> CreateTeamParams { - CreateTeamParams { - schema: None, - name, - } + CreateTeamParams { schema: None, name } } } - diff --git a/crates/tower-api/src/models/create_team_response.rs b/crates/tower-api/src/models/create_team_response.rs index 01a7c3d2..4ef5490f 100644 --- a/crates/tower-api/src/models/create_team_response.rs +++ b/crates/tower-api/src/models/create_team_response.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct CreateTeamResponse { @@ -23,10 +23,6 @@ pub struct CreateTeamResponse { impl CreateTeamResponse { pub fn new(team: models::Team) -> CreateTeamResponse { - CreateTeamResponse { - schema: None, - team, - } + CreateTeamResponse { schema: None, team } } } - diff --git a/crates/tower-api/src/models/delete_api_key_params.rs b/crates/tower-api/src/models/delete_api_key_params.rs index 066edc27..9b5abe09 100644 --- a/crates/tower-api/src/models/delete_api_key_params.rs +++ b/crates/tower-api/src/models/delete_api_key_params.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct DeleteApiKeyParams { @@ -28,4 +28,3 @@ impl DeleteApiKeyParams { } } } - diff --git a/crates/tower-api/src/models/delete_api_key_response.rs b/crates/tower-api/src/models/delete_api_key_response.rs index e6c743b8..b8a927b7 100644 --- a/crates/tower-api/src/models/delete_api_key_response.rs +++ b/crates/tower-api/src/models/delete_api_key_response.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct DeleteApiKeyResponse { @@ -29,4 +29,3 @@ impl DeleteApiKeyResponse { } } } - diff --git a/crates/tower-api/src/models/delete_app_response.rs b/crates/tower-api/src/models/delete_app_response.rs index 2b73e560..ffcb5144 100644 --- a/crates/tower-api/src/models/delete_app_response.rs +++ b/crates/tower-api/src/models/delete_app_response.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct DeleteAppResponse { @@ -22,10 +22,6 @@ pub struct DeleteAppResponse { impl DeleteAppResponse { pub fn new(app: models::App) -> DeleteAppResponse { - DeleteAppResponse { - schema: None, - app, - } + DeleteAppResponse { schema: None, app } } } - diff --git a/crates/tower-api/src/models/delete_authenticator_params.rs b/crates/tower-api/src/models/delete_authenticator_params.rs index 237b9a5a..a1a6ef18 100644 --- a/crates/tower-api/src/models/delete_authenticator_params.rs +++ b/crates/tower-api/src/models/delete_authenticator_params.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct DeleteAuthenticatorParams { @@ -29,4 +29,3 @@ impl DeleteAuthenticatorParams { } } } - diff --git a/crates/tower-api/src/models/delete_authenticator_response.rs b/crates/tower-api/src/models/delete_authenticator_response.rs index 17ce8c51..f290878a 100644 --- a/crates/tower-api/src/models/delete_authenticator_response.rs +++ b/crates/tower-api/src/models/delete_authenticator_response.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct DeleteAuthenticatorResponse { @@ -28,4 +28,3 @@ impl DeleteAuthenticatorResponse { } } } - diff --git a/crates/tower-api/src/models/delete_catalog_response.rs b/crates/tower-api/src/models/delete_catalog_response.rs index 36c74033..4b668239 100644 --- a/crates/tower-api/src/models/delete_catalog_response.rs +++ b/crates/tower-api/src/models/delete_catalog_response.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct DeleteCatalogResponse { @@ -28,4 +28,3 @@ impl DeleteCatalogResponse { } } } - diff --git a/crates/tower-api/src/models/delete_schedule_params.rs b/crates/tower-api/src/models/delete_schedule_params.rs index 1dadc175..d24638d2 100644 --- a/crates/tower-api/src/models/delete_schedule_params.rs +++ b/crates/tower-api/src/models/delete_schedule_params.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct DeleteScheduleParams { @@ -23,10 +23,6 @@ pub struct DeleteScheduleParams { impl DeleteScheduleParams { pub fn new(ids: Vec) -> DeleteScheduleParams { - DeleteScheduleParams { - schema: None, - ids, - } + DeleteScheduleParams { schema: None, ids } } } - diff --git a/crates/tower-api/src/models/delete_schedule_response.rs b/crates/tower-api/src/models/delete_schedule_response.rs index 908f6bec..0ce1b6c5 100644 --- a/crates/tower-api/src/models/delete_schedule_response.rs +++ b/crates/tower-api/src/models/delete_schedule_response.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct DeleteScheduleResponse { @@ -21,11 +21,12 @@ pub struct DeleteScheduleResponse { } impl DeleteScheduleResponse { - pub fn new(the_schedules_successfully_deleted: Vec) -> DeleteScheduleResponse { + pub fn new( + the_schedules_successfully_deleted: Vec, + ) -> DeleteScheduleResponse { DeleteScheduleResponse { schema: None, the_schedules_successfully_deleted, } } } - diff --git a/crates/tower-api/src/models/delete_secret_response.rs b/crates/tower-api/src/models/delete_secret_response.rs index 901e2f0b..1e9db8a7 100644 --- a/crates/tower-api/src/models/delete_secret_response.rs +++ b/crates/tower-api/src/models/delete_secret_response.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct DeleteSecretResponse { @@ -28,4 +28,3 @@ impl DeleteSecretResponse { } } } - diff --git a/crates/tower-api/src/models/delete_team_invitation_params.rs b/crates/tower-api/src/models/delete_team_invitation_params.rs index 575d7a19..fab00b40 100644 --- a/crates/tower-api/src/models/delete_team_invitation_params.rs +++ b/crates/tower-api/src/models/delete_team_invitation_params.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct DeleteTeamInvitationParams { @@ -29,4 +29,3 @@ impl DeleteTeamInvitationParams { } } } - diff --git a/crates/tower-api/src/models/delete_team_invitation_response.rs b/crates/tower-api/src/models/delete_team_invitation_response.rs index b41156fb..7d9159e9 100644 --- a/crates/tower-api/src/models/delete_team_invitation_response.rs +++ b/crates/tower-api/src/models/delete_team_invitation_response.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct DeleteTeamInvitationResponse { @@ -29,4 +29,3 @@ impl DeleteTeamInvitationResponse { } } } - diff --git a/crates/tower-api/src/models/delete_team_params.rs b/crates/tower-api/src/models/delete_team_params.rs index 8273962e..80857003 100644 --- a/crates/tower-api/src/models/delete_team_params.rs +++ b/crates/tower-api/src/models/delete_team_params.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct DeleteTeamParams { @@ -23,10 +23,6 @@ pub struct DeleteTeamParams { impl DeleteTeamParams { pub fn new(name: String) -> DeleteTeamParams { - DeleteTeamParams { - schema: None, - name, - } + DeleteTeamParams { schema: None, name } } } - diff --git a/crates/tower-api/src/models/delete_team_response.rs b/crates/tower-api/src/models/delete_team_response.rs index f18e22a5..f14effe6 100644 --- a/crates/tower-api/src/models/delete_team_response.rs +++ b/crates/tower-api/src/models/delete_team_response.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct DeleteTeamResponse { @@ -23,10 +23,6 @@ pub struct DeleteTeamResponse { impl DeleteTeamResponse { pub fn new(team: models::Team) -> DeleteTeamResponse { - DeleteTeamResponse { - schema: None, - team, - } + DeleteTeamResponse { schema: None, team } } } - diff --git a/crates/tower-api/src/models/deploy_app_response.rs b/crates/tower-api/src/models/deploy_app_response.rs index 626a301c..c47729ce 100644 --- a/crates/tower-api/src/models/deploy_app_response.rs +++ b/crates/tower-api/src/models/deploy_app_response.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct DeployAppResponse { @@ -28,4 +28,3 @@ impl DeployAppResponse { } } } - diff --git a/crates/tower-api/src/models/describe_app_response.rs b/crates/tower-api/src/models/describe_app_response.rs index 3a67cb69..b883013c 100644 --- a/crates/tower-api/src/models/describe_app_response.rs +++ b/crates/tower-api/src/models/describe_app_response.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct DescribeAppResponse { @@ -31,4 +31,3 @@ impl DescribeAppResponse { } } } - diff --git a/crates/tower-api/src/models/describe_app_version_response.rs b/crates/tower-api/src/models/describe_app_version_response.rs index b14a533b..0ec427b1 100644 --- a/crates/tower-api/src/models/describe_app_version_response.rs +++ b/crates/tower-api/src/models/describe_app_version_response.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct DescribeAppVersionResponse { @@ -28,4 +28,3 @@ impl DescribeAppVersionResponse { } } } - diff --git a/crates/tower-api/src/models/describe_device_login_session_response.rs b/crates/tower-api/src/models/describe_device_login_session_response.rs index 6890401c..1ec4eb1c 100644 --- a/crates/tower-api/src/models/describe_device_login_session_response.rs +++ b/crates/tower-api/src/models/describe_device_login_session_response.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct DescribeDeviceLoginSessionResponse { @@ -29,4 +29,3 @@ impl DescribeDeviceLoginSessionResponse { } } } - diff --git a/crates/tower-api/src/models/describe_run_logs_response.rs b/crates/tower-api/src/models/describe_run_logs_response.rs index cf5990f0..06db6cf9 100644 --- a/crates/tower-api/src/models/describe_run_logs_response.rs +++ b/crates/tower-api/src/models/describe_run_logs_response.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct DescribeRunLogsResponse { @@ -28,4 +28,3 @@ impl DescribeRunLogsResponse { } } } - diff --git a/crates/tower-api/src/models/describe_run_response.rs b/crates/tower-api/src/models/describe_run_response.rs index 4a0a2c0d..32c64fe4 100644 --- a/crates/tower-api/src/models/describe_run_response.rs +++ b/crates/tower-api/src/models/describe_run_response.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct DescribeRunResponse { @@ -22,10 +22,6 @@ pub struct DescribeRunResponse { impl DescribeRunResponse { pub fn new(run: models::Run) -> DescribeRunResponse { - DescribeRunResponse { - schema: None, - run, - } + DescribeRunResponse { schema: None, run } } } - diff --git a/crates/tower-api/src/models/describe_secrets_key_response.rs b/crates/tower-api/src/models/describe_secrets_key_response.rs index f9d11b6f..d649dc29 100644 --- a/crates/tower-api/src/models/describe_secrets_key_response.rs +++ b/crates/tower-api/src/models/describe_secrets_key_response.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct DescribeSecretsKeyResponse { @@ -28,4 +28,3 @@ impl DescribeSecretsKeyResponse { } } } - diff --git a/crates/tower-api/src/models/describe_session_response.rs b/crates/tower-api/src/models/describe_session_response.rs index 48d9a1ac..487812cf 100644 --- a/crates/tower-api/src/models/describe_session_response.rs +++ b/crates/tower-api/src/models/describe_session_response.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct DescribeSessionResponse { @@ -29,4 +29,3 @@ impl DescribeSessionResponse { } } } - diff --git a/crates/tower-api/src/models/encrypted_catalog_property.rs b/crates/tower-api/src/models/encrypted_catalog_property.rs index 7e7efa99..971a36bc 100644 --- a/crates/tower-api/src/models/encrypted_catalog_property.rs +++ b/crates/tower-api/src/models/encrypted_catalog_property.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct EncryptedCatalogProperty { @@ -30,4 +30,3 @@ impl EncryptedCatalogProperty { } } } - diff --git a/crates/tower-api/src/models/environment.rs b/crates/tower-api/src/models/environment.rs index 1cecfbbc..9836c564 100644 --- a/crates/tower-api/src/models/environment.rs +++ b/crates/tower-api/src/models/environment.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct Environment { @@ -20,9 +20,6 @@ pub struct Environment { impl Environment { pub fn new(name: String) -> Environment { - Environment { - name, - } + Environment { name } } } - diff --git a/crates/tower-api/src/models/error_detail.rs b/crates/tower-api/src/models/error_detail.rs index 6a150076..94086998 100644 --- a/crates/tower-api/src/models/error_detail.rs +++ b/crates/tower-api/src/models/error_detail.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct ErrorDetail { @@ -19,7 +19,12 @@ pub struct ErrorDetail { /// Error message text #[serde(rename = "message", skip_serializing_if = "Option::is_none")] pub message: Option, - #[serde(rename = "value", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] + #[serde( + rename = "value", + default, + with = "::serde_with::rust::double_option", + skip_serializing_if = "Option::is_none" + )] pub value: Option>, } @@ -32,4 +37,3 @@ impl ErrorDetail { } } } - diff --git a/crates/tower-api/src/models/error_model.rs b/crates/tower-api/src/models/error_model.rs index 92049d6b..0c4b85c1 100644 --- a/crates/tower-api/src/models/error_model.rs +++ b/crates/tower-api/src/models/error_model.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct ErrorModel { @@ -49,4 +49,3 @@ impl ErrorModel { } } } - diff --git a/crates/tower-api/src/models/event_error.rs b/crates/tower-api/src/models/event_error.rs index 82adf867..b1fd084a 100644 --- a/crates/tower-api/src/models/event_error.rs +++ b/crates/tower-api/src/models/event_error.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct EventError { @@ -57,11 +57,7 @@ impl<'de> Deserialize<'de> for Event { let s = String::deserialize(deserializer)?; match s.to_lowercase().as_str() { "error" => Ok(Self::Error), - _ => Err(serde::de::Error::unknown_variant( - &s, - &["error"], - )), + _ => Err(serde::de::Error::unknown_variant(&s, &["error"])), } } } - diff --git a/crates/tower-api/src/models/event_log.rs b/crates/tower-api/src/models/event_log.rs index 9910c181..b6f41e16 100644 --- a/crates/tower-api/src/models/event_log.rs +++ b/crates/tower-api/src/models/event_log.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct EventLog { @@ -57,11 +57,7 @@ impl<'de> Deserialize<'de> for Event { let s = String::deserialize(deserializer)?; match s.to_lowercase().as_str() { "log" => Ok(Self::Log), - _ => Err(serde::de::Error::unknown_variant( - &s, - &["log"], - )), + _ => Err(serde::de::Error::unknown_variant(&s, &["log"])), } } } - diff --git a/crates/tower-api/src/models/event_run_failure_alert.rs b/crates/tower-api/src/models/event_run_failure_alert.rs index a2ce19e1..0f0cae1b 100644 --- a/crates/tower-api/src/models/event_run_failure_alert.rs +++ b/crates/tower-api/src/models/event_run_failure_alert.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct EventRunFailureAlert { @@ -64,4 +64,3 @@ impl<'de> Deserialize<'de> for Event { } } } - diff --git a/crates/tower-api/src/models/event_warning.rs b/crates/tower-api/src/models/event_warning.rs index 33a1fe0c..795d0381 100644 --- a/crates/tower-api/src/models/event_warning.rs +++ b/crates/tower-api/src/models/event_warning.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct EventWarning { @@ -57,11 +57,7 @@ impl<'de> Deserialize<'de> for Event { let s = String::deserialize(deserializer)?; match s.to_lowercase().as_str() { "warning" => Ok(Self::Warning), - _ => Err(serde::de::Error::unknown_variant( - &s, - &["warning"], - )), + _ => Err(serde::de::Error::unknown_variant(&s, &["warning"])), } } } - diff --git a/crates/tower-api/src/models/export_catalogs_params.rs b/crates/tower-api/src/models/export_catalogs_params.rs index 666a6a15..691b7996 100644 --- a/crates/tower-api/src/models/export_catalogs_params.rs +++ b/crates/tower-api/src/models/export_catalogs_params.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct ExportCatalogsParams { @@ -34,7 +34,13 @@ pub struct ExportCatalogsParams { } impl ExportCatalogsParams { - pub fn new(all: bool, environment: String, page: i64, page_size: i64, public_key: String) -> ExportCatalogsParams { + pub fn new( + all: bool, + environment: String, + page: i64, + page_size: i64, + public_key: String, + ) -> ExportCatalogsParams { ExportCatalogsParams { schema: None, all, @@ -45,4 +51,3 @@ impl ExportCatalogsParams { } } } - diff --git a/crates/tower-api/src/models/export_catalogs_response.rs b/crates/tower-api/src/models/export_catalogs_response.rs index c5229fc3..2e0b021d 100644 --- a/crates/tower-api/src/models/export_catalogs_response.rs +++ b/crates/tower-api/src/models/export_catalogs_response.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct ExportCatalogsResponse { @@ -23,7 +23,10 @@ pub struct ExportCatalogsResponse { } impl ExportCatalogsResponse { - pub fn new(catalogs: Vec, pages: models::Pagination) -> ExportCatalogsResponse { + pub fn new( + catalogs: Vec, + pages: models::Pagination, + ) -> ExportCatalogsResponse { ExportCatalogsResponse { schema: None, catalogs, @@ -31,4 +34,3 @@ impl ExportCatalogsResponse { } } } - diff --git a/crates/tower-api/src/models/export_secrets_params.rs b/crates/tower-api/src/models/export_secrets_params.rs index 93344a90..d3fd2094 100644 --- a/crates/tower-api/src/models/export_secrets_params.rs +++ b/crates/tower-api/src/models/export_secrets_params.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct ExportSecretsParams { @@ -34,7 +34,13 @@ pub struct ExportSecretsParams { } impl ExportSecretsParams { - pub fn new(all: bool, environment: String, page: i64, page_size: i64, public_key: String) -> ExportSecretsParams { + pub fn new( + all: bool, + environment: String, + page: i64, + page_size: i64, + public_key: String, + ) -> ExportSecretsParams { ExportSecretsParams { schema: None, all, @@ -45,4 +51,3 @@ impl ExportSecretsParams { } } } - diff --git a/crates/tower-api/src/models/export_secrets_response.rs b/crates/tower-api/src/models/export_secrets_response.rs index bcda8474..c47abb5a 100644 --- a/crates/tower-api/src/models/export_secrets_response.rs +++ b/crates/tower-api/src/models/export_secrets_response.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct ExportSecretsResponse { @@ -23,7 +23,10 @@ pub struct ExportSecretsResponse { } impl ExportSecretsResponse { - pub fn new(pages: models::Pagination, secrets: Vec) -> ExportSecretsResponse { + pub fn new( + pages: models::Pagination, + secrets: Vec, + ) -> ExportSecretsResponse { ExportSecretsResponse { schema: None, pages, @@ -31,4 +34,3 @@ impl ExportSecretsResponse { } } } - diff --git a/crates/tower-api/src/models/exported_catalog.rs b/crates/tower-api/src/models/exported_catalog.rs index 492d9b7c..6dd2fc1b 100644 --- a/crates/tower-api/src/models/exported_catalog.rs +++ b/crates/tower-api/src/models/exported_catalog.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct ExportedCatalog { @@ -29,7 +29,13 @@ pub struct ExportedCatalog { } impl ExportedCatalog { - pub fn new(created_at: String, environment: String, name: String, properties: Vec, r#type: String) -> ExportedCatalog { + pub fn new( + created_at: String, + environment: String, + name: String, + properties: Vec, + r#type: String, + ) -> ExportedCatalog { ExportedCatalog { created_at, environment, @@ -40,4 +46,3 @@ impl ExportedCatalog { } } } - diff --git a/crates/tower-api/src/models/exported_catalog_property.rs b/crates/tower-api/src/models/exported_catalog_property.rs index 2771216a..cce0ad6c 100644 --- a/crates/tower-api/src/models/exported_catalog_property.rs +++ b/crates/tower-api/src/models/exported_catalog_property.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct ExportedCatalogProperty { @@ -30,4 +30,3 @@ impl ExportedCatalogProperty { } } } - diff --git a/crates/tower-api/src/models/exported_secret.rs b/crates/tower-api/src/models/exported_secret.rs index bcd6a6b9..a866ce1b 100644 --- a/crates/tower-api/src/models/exported_secret.rs +++ b/crates/tower-api/src/models/exported_secret.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct ExportedSecret { @@ -24,7 +24,12 @@ pub struct ExportedSecret { } impl ExportedSecret { - pub fn new(created_at: String, encrypted_value: String, environment: String, name: String) -> ExportedSecret { + pub fn new( + created_at: String, + encrypted_value: String, + environment: String, + name: String, + ) -> ExportedSecret { ExportedSecret { created_at, encrypted_value, @@ -33,4 +38,3 @@ impl ExportedSecret { } } } - diff --git a/crates/tower-api/src/models/featurebase_identity.rs b/crates/tower-api/src/models/featurebase_identity.rs index c35e901b..d2ac6355 100644 --- a/crates/tower-api/src/models/featurebase_identity.rs +++ b/crates/tower-api/src/models/featurebase_identity.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct FeaturebaseIdentity { @@ -27,4 +27,3 @@ impl FeaturebaseIdentity { } } } - diff --git a/crates/tower-api/src/models/features.rs b/crates/tower-api/src/models/features.rs index 88a51a29..f2d2b54c 100644 --- a/crates/tower-api/src/models/features.rs +++ b/crates/tower-api/src/models/features.rs @@ -9,12 +9,15 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct Features { /// Whether self-hosted runners are enabled - #[serde(rename = "has_self_hosted_runners", skip_serializing_if = "Option::is_none")] + #[serde( + rename = "has_self_hosted_runners", + skip_serializing_if = "Option::is_none" + )] pub has_self_hosted_runners: Option, /// The number of apps that can be created #[serde(rename = "num_apps", skip_serializing_if = "Option::is_none")] @@ -41,4 +44,3 @@ impl Features { } } } - diff --git a/crates/tower-api/src/models/generate_app_statistics_response.rs b/crates/tower-api/src/models/generate_app_statistics_response.rs index d6022344..82bc6f33 100644 --- a/crates/tower-api/src/models/generate_app_statistics_response.rs +++ b/crates/tower-api/src/models/generate_app_statistics_response.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct GenerateAppStatisticsResponse { @@ -28,4 +28,3 @@ impl GenerateAppStatisticsResponse { } } } - diff --git a/crates/tower-api/src/models/generate_authenticator_response.rs b/crates/tower-api/src/models/generate_authenticator_response.rs index 9b2ec9d4..ef8ce857 100644 --- a/crates/tower-api/src/models/generate_authenticator_response.rs +++ b/crates/tower-api/src/models/generate_authenticator_response.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct GenerateAuthenticatorResponse { @@ -28,4 +28,3 @@ impl GenerateAuthenticatorResponse { } } } - diff --git a/crates/tower-api/src/models/generate_run_statistics_response.rs b/crates/tower-api/src/models/generate_run_statistics_response.rs index 723c0911..c80cd3c4 100644 --- a/crates/tower-api/src/models/generate_run_statistics_response.rs +++ b/crates/tower-api/src/models/generate_run_statistics_response.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct GenerateRunStatisticsResponse { @@ -25,7 +25,11 @@ pub struct GenerateRunStatisticsResponse { } impl GenerateRunStatisticsResponse { - pub fn new(series: Vec, settings: models::StatisticsSettings, stats: models::RunStatistics) -> GenerateRunStatisticsResponse { + pub fn new( + series: Vec, + settings: models::StatisticsSettings, + stats: models::RunStatistics, + ) -> GenerateRunStatisticsResponse { GenerateRunStatisticsResponse { schema: None, series, @@ -34,4 +38,3 @@ impl GenerateRunStatisticsResponse { } } } - diff --git a/crates/tower-api/src/models/generate_runner_credentials_response.rs b/crates/tower-api/src/models/generate_runner_credentials_response.rs index 13f13780..b8b07aef 100644 --- a/crates/tower-api/src/models/generate_runner_credentials_response.rs +++ b/crates/tower-api/src/models/generate_runner_credentials_response.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct GenerateRunnerCredentialsResponse { @@ -28,4 +28,3 @@ impl GenerateRunnerCredentialsResponse { } } } - diff --git a/crates/tower-api/src/models/get_feature_flag_response_body.rs b/crates/tower-api/src/models/get_feature_flag_response_body.rs index 8dd48cfc..b97f9f2d 100644 --- a/crates/tower-api/src/models/get_feature_flag_response_body.rs +++ b/crates/tower-api/src/models/get_feature_flag_response_body.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct GetFeatureFlagResponseBody { @@ -30,7 +30,12 @@ pub struct GetFeatureFlagResponseBody { } impl GetFeatureFlagResponseBody { - pub fn new(enabled: bool, key: String, value: Option, value_type: ValueType) -> GetFeatureFlagResponseBody { + pub fn new( + enabled: bool, + key: String, + value: Option, + value_type: ValueType, + ) -> GetFeatureFlagResponseBody { GetFeatureFlagResponseBody { schema: None, enabled, @@ -77,4 +82,3 @@ impl<'de> Deserialize<'de> for ValueType { } } } - diff --git a/crates/tower-api/src/models/invite_team_member_params.rs b/crates/tower-api/src/models/invite_team_member_params.rs index b9104567..9b2d8ad6 100644 --- a/crates/tower-api/src/models/invite_team_member_params.rs +++ b/crates/tower-api/src/models/invite_team_member_params.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct InviteTeamMemberParams { @@ -33,4 +33,3 @@ impl InviteTeamMemberParams { } } } - diff --git a/crates/tower-api/src/models/invite_team_member_response.rs b/crates/tower-api/src/models/invite_team_member_response.rs index 9299a746..7c0daa5e 100644 --- a/crates/tower-api/src/models/invite_team_member_response.rs +++ b/crates/tower-api/src/models/invite_team_member_response.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct InviteTeamMemberResponse { @@ -29,4 +29,3 @@ impl InviteTeamMemberResponse { } } } - diff --git a/crates/tower-api/src/models/leave_team_response.rs b/crates/tower-api/src/models/leave_team_response.rs index 289873cd..16fa2b16 100644 --- a/crates/tower-api/src/models/leave_team_response.rs +++ b/crates/tower-api/src/models/leave_team_response.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct LeaveTeamResponse { @@ -23,10 +23,6 @@ pub struct LeaveTeamResponse { impl LeaveTeamResponse { pub fn new(team: models::Team) -> LeaveTeamResponse { - LeaveTeamResponse { - schema: None, - team, - } + LeaveTeamResponse { schema: None, team } } } - diff --git a/crates/tower-api/src/models/list_account_plans_response.rs b/crates/tower-api/src/models/list_account_plans_response.rs index 11b7c256..0079592f 100644 --- a/crates/tower-api/src/models/list_account_plans_response.rs +++ b/crates/tower-api/src/models/list_account_plans_response.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct ListAccountPlansResponse { @@ -31,4 +31,3 @@ impl ListAccountPlansResponse { } } } - diff --git a/crates/tower-api/src/models/list_alerts_200_response.rs b/crates/tower-api/src/models/list_alerts_200_response.rs index 4947ff23..4c820556 100644 --- a/crates/tower-api/src/models/list_alerts_200_response.rs +++ b/crates/tower-api/src/models/list_alerts_200_response.rs @@ -9,16 +9,13 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct ListAlerts200Response { -} +pub struct ListAlerts200Response {} impl ListAlerts200Response { pub fn new() -> ListAlerts200Response { - ListAlerts200Response { - } + ListAlerts200Response {} } } - diff --git a/crates/tower-api/src/models/list_alerts_response.rs b/crates/tower-api/src/models/list_alerts_response.rs index f1318949..2b400b69 100644 --- a/crates/tower-api/src/models/list_alerts_response.rs +++ b/crates/tower-api/src/models/list_alerts_response.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct ListAlertsResponse { @@ -33,4 +33,3 @@ impl ListAlertsResponse { } } } - diff --git a/crates/tower-api/src/models/list_api_keys_response.rs b/crates/tower-api/src/models/list_api_keys_response.rs index d17b19b7..74a79062 100644 --- a/crates/tower-api/src/models/list_api_keys_response.rs +++ b/crates/tower-api/src/models/list_api_keys_response.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct ListApiKeysResponse { @@ -29,4 +29,3 @@ impl ListApiKeysResponse { } } } - diff --git a/crates/tower-api/src/models/list_app_environments_response.rs b/crates/tower-api/src/models/list_app_environments_response.rs index dd7c3e5a..23efed72 100644 --- a/crates/tower-api/src/models/list_app_environments_response.rs +++ b/crates/tower-api/src/models/list_app_environments_response.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct ListAppEnvironmentsResponse { @@ -28,4 +28,3 @@ impl ListAppEnvironmentsResponse { } } } - diff --git a/crates/tower-api/src/models/list_app_versions_response.rs b/crates/tower-api/src/models/list_app_versions_response.rs index 2bfd533a..88de94c0 100644 --- a/crates/tower-api/src/models/list_app_versions_response.rs +++ b/crates/tower-api/src/models/list_app_versions_response.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct ListAppVersionsResponse { @@ -28,4 +28,3 @@ impl ListAppVersionsResponse { } } } - diff --git a/crates/tower-api/src/models/list_apps_response.rs b/crates/tower-api/src/models/list_apps_response.rs index c5984671..b166340e 100644 --- a/crates/tower-api/src/models/list_apps_response.rs +++ b/crates/tower-api/src/models/list_apps_response.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct ListAppsResponse { @@ -31,4 +31,3 @@ impl ListAppsResponse { } } } - diff --git a/crates/tower-api/src/models/list_authenticators_response.rs b/crates/tower-api/src/models/list_authenticators_response.rs index 164b0be4..9de94309 100644 --- a/crates/tower-api/src/models/list_authenticators_response.rs +++ b/crates/tower-api/src/models/list_authenticators_response.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct ListAuthenticatorsResponse { @@ -28,4 +28,3 @@ impl ListAuthenticatorsResponse { } } } - diff --git a/crates/tower-api/src/models/list_catalogs_response.rs b/crates/tower-api/src/models/list_catalogs_response.rs index 38e61d82..678fe07f 100644 --- a/crates/tower-api/src/models/list_catalogs_response.rs +++ b/crates/tower-api/src/models/list_catalogs_response.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct ListCatalogsResponse { @@ -31,4 +31,3 @@ impl ListCatalogsResponse { } } } - diff --git a/crates/tower-api/src/models/list_environments_response.rs b/crates/tower-api/src/models/list_environments_response.rs index c493c590..ed40b5ae 100644 --- a/crates/tower-api/src/models/list_environments_response.rs +++ b/crates/tower-api/src/models/list_environments_response.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct ListEnvironmentsResponse { @@ -28,4 +28,3 @@ impl ListEnvironmentsResponse { } } } - diff --git a/crates/tower-api/src/models/list_my_team_invitations_response.rs b/crates/tower-api/src/models/list_my_team_invitations_response.rs index 31fc2ed8..77be881b 100644 --- a/crates/tower-api/src/models/list_my_team_invitations_response.rs +++ b/crates/tower-api/src/models/list_my_team_invitations_response.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct ListMyTeamInvitationsResponse { @@ -29,4 +29,3 @@ impl ListMyTeamInvitationsResponse { } } } - diff --git a/crates/tower-api/src/models/list_runs_response.rs b/crates/tower-api/src/models/list_runs_response.rs index b83b2fde..0a684f6c 100644 --- a/crates/tower-api/src/models/list_runs_response.rs +++ b/crates/tower-api/src/models/list_runs_response.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct ListRunsResponse { @@ -31,4 +31,3 @@ impl ListRunsResponse { } } } - diff --git a/crates/tower-api/src/models/list_schedules_response.rs b/crates/tower-api/src/models/list_schedules_response.rs index e33cb4aa..42b168d0 100644 --- a/crates/tower-api/src/models/list_schedules_response.rs +++ b/crates/tower-api/src/models/list_schedules_response.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct ListSchedulesResponse { @@ -23,7 +23,10 @@ pub struct ListSchedulesResponse { } impl ListSchedulesResponse { - pub fn new(pages: models::Pagination, schedules: Vec) -> ListSchedulesResponse { + pub fn new( + pages: models::Pagination, + schedules: Vec, + ) -> ListSchedulesResponse { ListSchedulesResponse { schema: None, pages, @@ -31,4 +34,3 @@ impl ListSchedulesResponse { } } } - diff --git a/crates/tower-api/src/models/list_secret_environments_response.rs b/crates/tower-api/src/models/list_secret_environments_response.rs index 301ad17f..5fc2c704 100644 --- a/crates/tower-api/src/models/list_secret_environments_response.rs +++ b/crates/tower-api/src/models/list_secret_environments_response.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct ListSecretEnvironmentsResponse { @@ -28,4 +28,3 @@ impl ListSecretEnvironmentsResponse { } } } - diff --git a/crates/tower-api/src/models/list_secrets_response.rs b/crates/tower-api/src/models/list_secrets_response.rs index 10b68717..fca75c09 100644 --- a/crates/tower-api/src/models/list_secrets_response.rs +++ b/crates/tower-api/src/models/list_secrets_response.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct ListSecretsResponse { @@ -31,4 +31,3 @@ impl ListSecretsResponse { } } } - diff --git a/crates/tower-api/src/models/list_team_invitations_response.rs b/crates/tower-api/src/models/list_team_invitations_response.rs index a24b3597..04c2740c 100644 --- a/crates/tower-api/src/models/list_team_invitations_response.rs +++ b/crates/tower-api/src/models/list_team_invitations_response.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct ListTeamInvitationsResponse { @@ -29,4 +29,3 @@ impl ListTeamInvitationsResponse { } } } - diff --git a/crates/tower-api/src/models/list_team_members_response.rs b/crates/tower-api/src/models/list_team_members_response.rs index 1ce31d96..ec484e58 100644 --- a/crates/tower-api/src/models/list_team_members_response.rs +++ b/crates/tower-api/src/models/list_team_members_response.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct ListTeamMembersResponse { @@ -29,4 +29,3 @@ impl ListTeamMembersResponse { } } } - diff --git a/crates/tower-api/src/models/list_teams_response.rs b/crates/tower-api/src/models/list_teams_response.rs index 4e22edae..84e09218 100644 --- a/crates/tower-api/src/models/list_teams_response.rs +++ b/crates/tower-api/src/models/list_teams_response.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct ListTeamsResponse { @@ -29,4 +29,3 @@ impl ListTeamsResponse { } } } - diff --git a/crates/tower-api/src/models/pagination.rs b/crates/tower-api/src/models/pagination.rs index a8ab57e2..9edb2d75 100644 --- a/crates/tower-api/src/models/pagination.rs +++ b/crates/tower-api/src/models/pagination.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct Pagination { @@ -33,4 +33,3 @@ impl Pagination { } } } - diff --git a/crates/tower-api/src/models/parameter.rs b/crates/tower-api/src/models/parameter.rs index 85b4a85c..295af4dd 100644 --- a/crates/tower-api/src/models/parameter.rs +++ b/crates/tower-api/src/models/parameter.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct Parameter { @@ -30,4 +30,3 @@ impl Parameter { } } } - diff --git a/crates/tower-api/src/models/plan.rs b/crates/tower-api/src/models/plan.rs index e1ac8e01..89d5cab9 100644 --- a/crates/tower-api/src/models/plan.rs +++ b/crates/tower-api/src/models/plan.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct Plan { @@ -34,7 +34,15 @@ pub struct Plan { } impl Plan { - pub fn new(account_id: String, base_plan_name: String, created_at: String, features: models::Features, id: String, start_at: String, status: String) -> Plan { + pub fn new( + account_id: String, + base_plan_name: String, + created_at: String, + features: models::Features, + id: String, + start_at: String, + status: String, + ) -> Plan { Plan { account_id, base_plan_name, @@ -48,4 +56,3 @@ impl Plan { } } } - diff --git a/crates/tower-api/src/models/refresh_session_params.rs b/crates/tower-api/src/models/refresh_session_params.rs index 95af5b6c..ce4d36bd 100644 --- a/crates/tower-api/src/models/refresh_session_params.rs +++ b/crates/tower-api/src/models/refresh_session_params.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct RefreshSessionParams { @@ -20,9 +20,6 @@ pub struct RefreshSessionParams { impl RefreshSessionParams { pub fn new() -> RefreshSessionParams { - RefreshSessionParams { - schema: None, - } + RefreshSessionParams { schema: None } } } - diff --git a/crates/tower-api/src/models/refresh_session_response.rs b/crates/tower-api/src/models/refresh_session_response.rs index c01ec2c0..7ca6b6ac 100644 --- a/crates/tower-api/src/models/refresh_session_response.rs +++ b/crates/tower-api/src/models/refresh_session_response.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct RefreshSessionResponse { @@ -33,4 +33,3 @@ impl RefreshSessionResponse { } } } - diff --git a/crates/tower-api/src/models/remove_team_member_params.rs b/crates/tower-api/src/models/remove_team_member_params.rs index f51d4f52..ad57c149 100644 --- a/crates/tower-api/src/models/remove_team_member_params.rs +++ b/crates/tower-api/src/models/remove_team_member_params.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct RemoveTeamMemberParams { @@ -29,4 +29,3 @@ impl RemoveTeamMemberParams { } } } - diff --git a/crates/tower-api/src/models/remove_team_member_response.rs b/crates/tower-api/src/models/remove_team_member_response.rs index d6c0dcb4..ad15d587 100644 --- a/crates/tower-api/src/models/remove_team_member_response.rs +++ b/crates/tower-api/src/models/remove_team_member_response.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct RemoveTeamMemberResponse { @@ -29,4 +29,3 @@ impl RemoveTeamMemberResponse { } } } - diff --git a/crates/tower-api/src/models/resend_team_invitation_params.rs b/crates/tower-api/src/models/resend_team_invitation_params.rs index 278e78c2..d5666667 100644 --- a/crates/tower-api/src/models/resend_team_invitation_params.rs +++ b/crates/tower-api/src/models/resend_team_invitation_params.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct ResendTeamInvitationParams { @@ -33,4 +33,3 @@ impl ResendTeamInvitationParams { } } } - diff --git a/crates/tower-api/src/models/resend_team_invitation_response.rs b/crates/tower-api/src/models/resend_team_invitation_response.rs index 1185a4b7..0a71cf81 100644 --- a/crates/tower-api/src/models/resend_team_invitation_response.rs +++ b/crates/tower-api/src/models/resend_team_invitation_response.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct ResendTeamInvitationResponse { @@ -29,4 +29,3 @@ impl ResendTeamInvitationResponse { } } } - diff --git a/crates/tower-api/src/models/run.rs b/crates/tower-api/src/models/run.rs index b733bae6..fd1388fb 100644 --- a/crates/tower-api/src/models/run.rs +++ b/crates/tower-api/src/models/run.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct Run { @@ -52,7 +52,23 @@ pub struct Run { } impl Run { - pub fn new(dollar_link: String, app_name: String, app_version: String, cancelled_at: Option, created_at: String, ended_at: Option, environment: String, exit_code: Option, number: i64, parameters: Vec, run_id: String, scheduled_at: String, started_at: Option, status: Status, status_group: StatusGroup) -> Run { + pub fn new( + dollar_link: String, + app_name: String, + app_version: String, + cancelled_at: Option, + created_at: String, + ended_at: Option, + environment: String, + exit_code: Option, + number: i64, + parameters: Vec, + run_id: String, + scheduled_at: String, + started_at: Option, + status: Status, + status_group: StatusGroup, + ) -> Run { Run { dollar_link, app_name, @@ -73,7 +89,7 @@ impl Run { } } } -/// +/// #[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize)] pub enum Status { #[serde(rename = "scheduled")] @@ -114,12 +130,20 @@ impl<'de> Deserialize<'de> for Status { "cancelled" => Ok(Self::Cancelled), _ => Err(serde::de::Error::unknown_variant( &s, - &["scheduled", "pending", "running", "crashed", "errored", "exited", "cancelled"], + &[ + "scheduled", + "pending", + "running", + "crashed", + "errored", + "exited", + "cancelled", + ], )), } } } -/// +/// #[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize)] pub enum StatusGroup { #[serde(rename = "successful")] @@ -153,4 +177,3 @@ impl<'de> Deserialize<'de> for StatusGroup { } } } - diff --git a/crates/tower-api/src/models/run_app_params.rs b/crates/tower-api/src/models/run_app_params.rs index cafe3384..867d7295 100644 --- a/crates/tower-api/src/models/run_app_params.rs +++ b/crates/tower-api/src/models/run_app_params.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct RunAppParams { @@ -23,12 +23,20 @@ pub struct RunAppParams { #[serde(rename = "parameters")] pub parameters: std::collections::HashMap, /// The ID of the run that invoked this run, if relevant. Should be null, if none. - #[serde(rename = "parent_run_id", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] + #[serde( + rename = "parent_run_id", + default, + with = "::serde_with::rust::double_option", + skip_serializing_if = "Option::is_none" + )] pub parent_run_id: Option>, } impl RunAppParams { - pub fn new(environment: String, parameters: std::collections::HashMap) -> RunAppParams { + pub fn new( + environment: String, + parameters: std::collections::HashMap, + ) -> RunAppParams { RunAppParams { schema: None, environment, @@ -37,4 +45,3 @@ impl RunAppParams { } } } - diff --git a/crates/tower-api/src/models/run_app_response.rs b/crates/tower-api/src/models/run_app_response.rs index 486c2506..af5a7571 100644 --- a/crates/tower-api/src/models/run_app_response.rs +++ b/crates/tower-api/src/models/run_app_response.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct RunAppResponse { @@ -22,10 +22,6 @@ pub struct RunAppResponse { impl RunAppResponse { pub fn new(run: models::Run) -> RunAppResponse { - RunAppResponse { - schema: None, - run, - } + RunAppResponse { schema: None, run } } } - diff --git a/crates/tower-api/src/models/run_failure_alert.rs b/crates/tower-api/src/models/run_failure_alert.rs index 97edeee8..803a99ff 100644 --- a/crates/tower-api/src/models/run_failure_alert.rs +++ b/crates/tower-api/src/models/run_failure_alert.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct RunFailureAlert { @@ -23,10 +23,6 @@ pub struct RunFailureAlert { impl RunFailureAlert { pub fn new(app: models::App, run: models::Run) -> RunFailureAlert { - RunFailureAlert { - app, - run, - } + RunFailureAlert { app, run } } } - diff --git a/crates/tower-api/src/models/run_log_line.rs b/crates/tower-api/src/models/run_log_line.rs index 9ea5666f..4e7b483a 100644 --- a/crates/tower-api/src/models/run_log_line.rs +++ b/crates/tower-api/src/models/run_log_line.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct RunLogLine { @@ -37,7 +37,13 @@ pub struct RunLogLine { } impl RunLogLine { - pub fn new(channel: Channel, content: String, line_num: i64, reported_at: String, run_id: String) -> RunLogLine { + pub fn new( + channel: Channel, + content: String, + line_num: i64, + reported_at: String, + run_id: String, + ) -> RunLogLine { RunLogLine { channel, content, @@ -73,11 +79,7 @@ impl<'de> Deserialize<'de> for Channel { match s.to_lowercase().as_str() { "program" => Ok(Self::Program), "setup" => Ok(Self::Setup), - _ => Err(serde::de::Error::unknown_variant( - &s, - &["program", "setup"], - )), + _ => Err(serde::de::Error::unknown_variant(&s, &["program", "setup"])), } } } - diff --git a/crates/tower-api/src/models/run_parameter.rs b/crates/tower-api/src/models/run_parameter.rs index 5d562d38..013d4bb0 100644 --- a/crates/tower-api/src/models/run_parameter.rs +++ b/crates/tower-api/src/models/run_parameter.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct RunParameter { @@ -21,10 +21,6 @@ pub struct RunParameter { impl RunParameter { pub fn new(name: String, value: String) -> RunParameter { - RunParameter { - name, - value, - } + RunParameter { name, value } } } - diff --git a/crates/tower-api/src/models/run_results.rs b/crates/tower-api/src/models/run_results.rs index 73c14bd2..a1aeab7c 100644 --- a/crates/tower-api/src/models/run_results.rs +++ b/crates/tower-api/src/models/run_results.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct RunResults { @@ -28,7 +28,14 @@ pub struct RunResults { } impl RunResults { - pub fn new(cancelled: i64, crashed: i64, errored: i64, exited: i64, pending: i64, running: i64) -> RunResults { + pub fn new( + cancelled: i64, + crashed: i64, + errored: i64, + exited: i64, + pending: i64, + running: i64, + ) -> RunResults { RunResults { cancelled, crashed, @@ -39,4 +46,3 @@ impl RunResults { } } } - diff --git a/crates/tower-api/src/models/run_statistics.rs b/crates/tower-api/src/models/run_statistics.rs index 7de078c8..19afcc16 100644 --- a/crates/tower-api/src/models/run_statistics.rs +++ b/crates/tower-api/src/models/run_statistics.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct RunStatistics { @@ -28,7 +28,14 @@ pub struct RunStatistics { } impl RunStatistics { - pub fn new(cancelled_runs: i64, crashed_runs: i64, errored_runs: i64, exited_runs: i64, running_runs: i64, total_runs: i64) -> RunStatistics { + pub fn new( + cancelled_runs: i64, + crashed_runs: i64, + errored_runs: i64, + exited_runs: i64, + running_runs: i64, + total_runs: i64, + ) -> RunStatistics { RunStatistics { cancelled_runs, crashed_runs, @@ -39,4 +46,3 @@ impl RunStatistics { } } } - diff --git a/crates/tower-api/src/models/run_timeseries_point.rs b/crates/tower-api/src/models/run_timeseries_point.rs index 05da0286..99fbc5ea 100644 --- a/crates/tower-api/src/models/run_timeseries_point.rs +++ b/crates/tower-api/src/models/run_timeseries_point.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct RunTimeseriesPoint { @@ -33,7 +33,16 @@ pub struct RunTimeseriesPoint { } impl RunTimeseriesPoint { - pub fn new(cancelled: i64, crashed: i64, errored: i64, exited: i64, pending: i64, period: String, running: i64, scheduled: i64) -> RunTimeseriesPoint { + pub fn new( + cancelled: i64, + crashed: i64, + errored: i64, + exited: i64, + pending: i64, + period: String, + running: i64, + scheduled: i64, + ) -> RunTimeseriesPoint { RunTimeseriesPoint { cancelled, crashed, @@ -46,4 +55,3 @@ impl RunTimeseriesPoint { } } } - diff --git a/crates/tower-api/src/models/runner_credentials.rs b/crates/tower-api/src/models/runner_credentials.rs index 9b37d155..e7442cc2 100644 --- a/crates/tower-api/src/models/runner_credentials.rs +++ b/crates/tower-api/src/models/runner_credentials.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct RunnerCredentials { @@ -28,7 +28,12 @@ pub struct RunnerCredentials { } impl RunnerCredentials { - pub fn new(certificate: String, private_key: String, root_ca: Option, runner_service_url: String) -> RunnerCredentials { + pub fn new( + certificate: String, + private_key: String, + root_ca: Option, + runner_service_url: String, + ) -> RunnerCredentials { RunnerCredentials { certificate, private_key, @@ -37,4 +42,3 @@ impl RunnerCredentials { } } } - diff --git a/crates/tower-api/src/models/schedule.rs b/crates/tower-api/src/models/schedule.rs index 7b493d98..d37b0e78 100644 --- a/crates/tower-api/src/models/schedule.rs +++ b/crates/tower-api/src/models/schedule.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct Schedule { @@ -40,7 +40,14 @@ pub struct Schedule { } impl Schedule { - pub fn new(app_name: String, created_at: String, cron: String, environment: String, id: String, updated_at: String) -> Schedule { + pub fn new( + app_name: String, + created_at: String, + cron: String, + environment: String, + id: String, + updated_at: String, + ) -> Schedule { Schedule { app_name, app_version: None, @@ -53,4 +60,3 @@ impl Schedule { } } } - diff --git a/crates/tower-api/src/models/search_runs_response.rs b/crates/tower-api/src/models/search_runs_response.rs index d05150c5..31fd7402 100644 --- a/crates/tower-api/src/models/search_runs_response.rs +++ b/crates/tower-api/src/models/search_runs_response.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct SearchRunsResponse { @@ -31,4 +31,3 @@ impl SearchRunsResponse { } } } - diff --git a/crates/tower-api/src/models/secret.rs b/crates/tower-api/src/models/secret.rs index 6e3c6865..297197a7 100644 --- a/crates/tower-api/src/models/secret.rs +++ b/crates/tower-api/src/models/secret.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct Secret { @@ -33,4 +33,3 @@ impl Secret { } } } - diff --git a/crates/tower-api/src/models/session.rs b/crates/tower-api/src/models/session.rs index c8e45ef9..d8db6c52 100644 --- a/crates/tower-api/src/models/session.rs +++ b/crates/tower-api/src/models/session.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct Session { @@ -24,7 +24,12 @@ pub struct Session { } impl Session { - pub fn new(featurebase_identity: models::FeaturebaseIdentity, teams: Vec, token: models::Token, user: models::User) -> Session { + pub fn new( + featurebase_identity: models::FeaturebaseIdentity, + teams: Vec, + token: models::Token, + user: models::User, + ) -> Session { Session { featurebase_identity, teams, @@ -33,4 +38,3 @@ impl Session { } } } - diff --git a/crates/tower-api/src/models/sse_warning.rs b/crates/tower-api/src/models/sse_warning.rs index fe40b2d9..3fcba8c1 100644 --- a/crates/tower-api/src/models/sse_warning.rs +++ b/crates/tower-api/src/models/sse_warning.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct SseWarning { @@ -29,4 +29,3 @@ impl SseWarning { } } } - diff --git a/crates/tower-api/src/models/statistics_settings.rs b/crates/tower-api/src/models/statistics_settings.rs index fa7b4e72..55077032 100644 --- a/crates/tower-api/src/models/statistics_settings.rs +++ b/crates/tower-api/src/models/statistics_settings.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct StatisticsSettings { @@ -31,7 +31,13 @@ pub struct StatisticsSettings { } impl StatisticsSettings { - pub fn new(end_at: String, environment: String, interval: Interval, start_at: String, timezone: String) -> StatisticsSettings { + pub fn new( + end_at: String, + environment: String, + interval: Interval, + start_at: String, + timezone: String, + ) -> StatisticsSettings { StatisticsSettings { end_at, environment, @@ -65,11 +71,7 @@ impl<'de> Deserialize<'de> for Interval { match s.to_lowercase().as_str() { "daily" => Ok(Self::Daily), "hourly" => Ok(Self::Hourly), - _ => Err(serde::de::Error::unknown_variant( - &s, - &["daily", "hourly"], - )), + _ => Err(serde::de::Error::unknown_variant(&s, &["daily", "hourly"])), } } } - diff --git a/crates/tower-api/src/models/stream_alerts_200_response_inner.rs b/crates/tower-api/src/models/stream_alerts_200_response_inner.rs index cab6d9ac..1e4accef 100644 --- a/crates/tower-api/src/models/stream_alerts_200_response_inner.rs +++ b/crates/tower-api/src/models/stream_alerts_200_response_inner.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] #[serde(untagged)] @@ -51,4 +51,3 @@ impl<'de> Deserialize<'de> for Event { } } } - diff --git a/crates/tower-api/src/models/stream_run_logs_200_response_inner.rs b/crates/tower-api/src/models/stream_run_logs_200_response_inner.rs index db6797ae..8aee12b5 100644 --- a/crates/tower-api/src/models/stream_run_logs_200_response_inner.rs +++ b/crates/tower-api/src/models/stream_run_logs_200_response_inner.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] #[serde(untagged)] @@ -44,11 +44,7 @@ impl<'de> Deserialize<'de> for Event { let s = String::deserialize(deserializer)?; match s.to_lowercase().as_str() { "warning" => Ok(Self::Warning), - _ => Err(serde::de::Error::unknown_variant( - &s, - &["warning"], - )), + _ => Err(serde::de::Error::unknown_variant(&s, &["warning"])), } } } - diff --git a/crates/tower-api/src/models/team.rs b/crates/tower-api/src/models/team.rs index 29d23d8f..6d3d6032 100644 --- a/crates/tower-api/src/models/team.rs +++ b/crates/tower-api/src/models/team.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct Team { @@ -35,4 +35,3 @@ impl Team { } } } - diff --git a/crates/tower-api/src/models/team_invitation.rs b/crates/tower-api/src/models/team_invitation.rs index 2fbe1e9b..98080c1d 100644 --- a/crates/tower-api/src/models/team_invitation.rs +++ b/crates/tower-api/src/models/team_invitation.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct TeamInvitation { @@ -30,4 +30,3 @@ impl TeamInvitation { } } } - diff --git a/crates/tower-api/src/models/token.rs b/crates/tower-api/src/models/token.rs index 3d15106e..21c69e30 100644 --- a/crates/tower-api/src/models/token.rs +++ b/crates/tower-api/src/models/token.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct Token { @@ -19,9 +19,6 @@ pub struct Token { impl Token { pub fn new(jwt: String) -> Token { - Token { - jwt, - } + Token { jwt } } } - diff --git a/crates/tower-api/src/models/unverified_authenticator.rs b/crates/tower-api/src/models/unverified_authenticator.rs index 6362ffca..cc269357 100644 --- a/crates/tower-api/src/models/unverified_authenticator.rs +++ b/crates/tower-api/src/models/unverified_authenticator.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct UnverifiedAuthenticator { @@ -37,4 +37,3 @@ impl UnverifiedAuthenticator { } } } - diff --git a/crates/tower-api/src/models/update_account_name_params.rs b/crates/tower-api/src/models/update_account_name_params.rs index 72e1b243..be553511 100644 --- a/crates/tower-api/src/models/update_account_name_params.rs +++ b/crates/tower-api/src/models/update_account_name_params.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct UpdateAccountNameParams { @@ -23,10 +23,6 @@ pub struct UpdateAccountNameParams { impl UpdateAccountNameParams { pub fn new(name: String) -> UpdateAccountNameParams { - UpdateAccountNameParams { - schema: None, - name, - } + UpdateAccountNameParams { schema: None, name } } } - diff --git a/crates/tower-api/src/models/update_account_name_response.rs b/crates/tower-api/src/models/update_account_name_response.rs index 4f49e3b9..b9ce5025 100644 --- a/crates/tower-api/src/models/update_account_name_response.rs +++ b/crates/tower-api/src/models/update_account_name_response.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct UpdateAccountNameResponse { @@ -28,4 +28,3 @@ impl UpdateAccountNameResponse { } } } - diff --git a/crates/tower-api/src/models/update_app_params.rs b/crates/tower-api/src/models/update_app_params.rs index 78c6c3e4..d3724529 100644 --- a/crates/tower-api/src/models/update_app_params.rs +++ b/crates/tower-api/src/models/update_app_params.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct UpdateAppParams { @@ -20,7 +20,12 @@ pub struct UpdateAppParams { #[serde(rename = "description")] pub description: String, /// Indicates that web traffic should be routed to this app and that its runs should get a hostname assigned to it. - #[serde(rename = "is_externally_accessible", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] + #[serde( + rename = "is_externally_accessible", + default, + with = "::serde_with::rust::double_option", + skip_serializing_if = "Option::is_none" + )] pub is_externally_accessible: Option>, /// New status for the App #[serde(rename = "status")] @@ -37,4 +42,3 @@ impl UpdateAppParams { } } } - diff --git a/crates/tower-api/src/models/update_app_response.rs b/crates/tower-api/src/models/update_app_response.rs index 4fcd7db4..697b308d 100644 --- a/crates/tower-api/src/models/update_app_response.rs +++ b/crates/tower-api/src/models/update_app_response.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct UpdateAppResponse { @@ -22,10 +22,6 @@ pub struct UpdateAppResponse { impl UpdateAppResponse { pub fn new(app: models::App) -> UpdateAppResponse { - UpdateAppResponse { - schema: None, - app, - } + UpdateAppResponse { schema: None, app } } } - diff --git a/crates/tower-api/src/models/update_catalog_params.rs b/crates/tower-api/src/models/update_catalog_params.rs index 59a3d330..b9a04c8c 100644 --- a/crates/tower-api/src/models/update_catalog_params.rs +++ b/crates/tower-api/src/models/update_catalog_params.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct UpdateCatalogParams { @@ -24,7 +24,10 @@ pub struct UpdateCatalogParams { } impl UpdateCatalogParams { - pub fn new(environment: String, properties: Vec) -> UpdateCatalogParams { + pub fn new( + environment: String, + properties: Vec, + ) -> UpdateCatalogParams { UpdateCatalogParams { schema: None, environment, @@ -32,4 +35,3 @@ impl UpdateCatalogParams { } } } - diff --git a/crates/tower-api/src/models/update_catalog_response.rs b/crates/tower-api/src/models/update_catalog_response.rs index ae4b25f5..7d958ea0 100644 --- a/crates/tower-api/src/models/update_catalog_response.rs +++ b/crates/tower-api/src/models/update_catalog_response.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct UpdateCatalogResponse { @@ -28,4 +28,3 @@ impl UpdateCatalogResponse { } } } - diff --git a/crates/tower-api/src/models/update_environment_params.rs b/crates/tower-api/src/models/update_environment_params.rs index 59170edc..d5c1d7b6 100644 --- a/crates/tower-api/src/models/update_environment_params.rs +++ b/crates/tower-api/src/models/update_environment_params.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct UpdateEnvironmentParams { @@ -29,4 +29,3 @@ impl UpdateEnvironmentParams { } } } - diff --git a/crates/tower-api/src/models/update_environment_response.rs b/crates/tower-api/src/models/update_environment_response.rs index dee175cd..c315dcce 100644 --- a/crates/tower-api/src/models/update_environment_response.rs +++ b/crates/tower-api/src/models/update_environment_response.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct UpdateEnvironmentResponse { @@ -28,4 +28,3 @@ impl UpdateEnvironmentResponse { } } } - diff --git a/crates/tower-api/src/models/update_my_team_invitation_params.rs b/crates/tower-api/src/models/update_my_team_invitation_params.rs index a08b89fc..7d5204c4 100644 --- a/crates/tower-api/src/models/update_my_team_invitation_params.rs +++ b/crates/tower-api/src/models/update_my_team_invitation_params.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct UpdateMyTeamInvitationParams { @@ -33,4 +33,3 @@ impl UpdateMyTeamInvitationParams { } } } - diff --git a/crates/tower-api/src/models/update_my_team_invitation_response.rs b/crates/tower-api/src/models/update_my_team_invitation_response.rs index eb709b02..7bf058c4 100644 --- a/crates/tower-api/src/models/update_my_team_invitation_response.rs +++ b/crates/tower-api/src/models/update_my_team_invitation_response.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct UpdateMyTeamInvitationResponse { @@ -20,9 +20,6 @@ pub struct UpdateMyTeamInvitationResponse { impl UpdateMyTeamInvitationResponse { pub fn new() -> UpdateMyTeamInvitationResponse { - UpdateMyTeamInvitationResponse { - schema: None, - } + UpdateMyTeamInvitationResponse { schema: None } } } - diff --git a/crates/tower-api/src/models/update_password_reset_params.rs b/crates/tower-api/src/models/update_password_reset_params.rs index 8a7d519c..b47e775a 100644 --- a/crates/tower-api/src/models/update_password_reset_params.rs +++ b/crates/tower-api/src/models/update_password_reset_params.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct UpdatePasswordResetParams { @@ -29,4 +29,3 @@ impl UpdatePasswordResetParams { } } } - diff --git a/crates/tower-api/src/models/update_password_reset_response.rs b/crates/tower-api/src/models/update_password_reset_response.rs index 45ef7355..199330e4 100644 --- a/crates/tower-api/src/models/update_password_reset_response.rs +++ b/crates/tower-api/src/models/update_password_reset_response.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct UpdatePasswordResetResponse { @@ -23,10 +23,6 @@ pub struct UpdatePasswordResetResponse { impl UpdatePasswordResetResponse { pub fn new(ok: bool) -> UpdatePasswordResetResponse { - UpdatePasswordResetResponse { - schema: None, - ok, - } + UpdatePasswordResetResponse { schema: None, ok } } } - diff --git a/crates/tower-api/src/models/update_plan_params.rs b/crates/tower-api/src/models/update_plan_params.rs index 2a50883d..9e4d068b 100644 --- a/crates/tower-api/src/models/update_plan_params.rs +++ b/crates/tower-api/src/models/update_plan_params.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct UpdatePlanParams { @@ -33,4 +33,3 @@ impl UpdatePlanParams { } } } - diff --git a/crates/tower-api/src/models/update_plan_response.rs b/crates/tower-api/src/models/update_plan_response.rs index bb16c5e1..5aded84b 100644 --- a/crates/tower-api/src/models/update_plan_response.rs +++ b/crates/tower-api/src/models/update_plan_response.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct UpdatePlanResponse { @@ -22,10 +22,6 @@ pub struct UpdatePlanResponse { impl UpdatePlanResponse { pub fn new(plan: models::Plan) -> UpdatePlanResponse { - UpdatePlanResponse { - schema: None, - plan, - } + UpdatePlanResponse { schema: None, plan } } } - diff --git a/crates/tower-api/src/models/update_schedule_params.rs b/crates/tower-api/src/models/update_schedule_params.rs index 30072fd5..7290bae0 100644 --- a/crates/tower-api/src/models/update_schedule_params.rs +++ b/crates/tower-api/src/models/update_schedule_params.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct UpdateScheduleParams { @@ -17,7 +17,12 @@ pub struct UpdateScheduleParams { #[serde(rename = "$schema", skip_serializing_if = "Option::is_none")] pub schema: Option, /// The specific app version to run (if omitted, will use the app's default version) - #[serde(rename = "app_version", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] + #[serde( + rename = "app_version", + default, + with = "::serde_with::rust::double_option", + skip_serializing_if = "Option::is_none" + )] pub app_version: Option>, /// The cron expression defining when the app should run #[serde(rename = "cron", skip_serializing_if = "Option::is_none")] @@ -41,4 +46,3 @@ impl UpdateScheduleParams { } } } - diff --git a/crates/tower-api/src/models/update_schedule_response.rs b/crates/tower-api/src/models/update_schedule_response.rs index 72cb6e41..a6b22159 100644 --- a/crates/tower-api/src/models/update_schedule_response.rs +++ b/crates/tower-api/src/models/update_schedule_response.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct UpdateScheduleResponse { @@ -28,4 +28,3 @@ impl UpdateScheduleResponse { } } } - diff --git a/crates/tower-api/src/models/update_secret_params.rs b/crates/tower-api/src/models/update_secret_params.rs index a187d9ed..ed9c7d96 100644 --- a/crates/tower-api/src/models/update_secret_params.rs +++ b/crates/tower-api/src/models/update_secret_params.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct UpdateSecretParams { @@ -25,7 +25,11 @@ pub struct UpdateSecretParams { } impl UpdateSecretParams { - pub fn new(encrypted_value: String, environment: String, preview: String) -> UpdateSecretParams { + pub fn new( + encrypted_value: String, + environment: String, + preview: String, + ) -> UpdateSecretParams { UpdateSecretParams { schema: None, encrypted_value, @@ -34,4 +38,3 @@ impl UpdateSecretParams { } } } - diff --git a/crates/tower-api/src/models/update_secret_response.rs b/crates/tower-api/src/models/update_secret_response.rs index 550734c6..7f6398b0 100644 --- a/crates/tower-api/src/models/update_secret_response.rs +++ b/crates/tower-api/src/models/update_secret_response.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct UpdateSecretResponse { @@ -28,4 +28,3 @@ impl UpdateSecretResponse { } } } - diff --git a/crates/tower-api/src/models/update_team_params.rs b/crates/tower-api/src/models/update_team_params.rs index 4402d2c6..bb6b3687 100644 --- a/crates/tower-api/src/models/update_team_params.rs +++ b/crates/tower-api/src/models/update_team_params.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct UpdateTeamParams { @@ -23,10 +23,6 @@ pub struct UpdateTeamParams { impl UpdateTeamParams { pub fn new(name: Option) -> UpdateTeamParams { - UpdateTeamParams { - schema: None, - name, - } + UpdateTeamParams { schema: None, name } } } - diff --git a/crates/tower-api/src/models/update_team_response.rs b/crates/tower-api/src/models/update_team_response.rs index 18d0899c..940fb239 100644 --- a/crates/tower-api/src/models/update_team_response.rs +++ b/crates/tower-api/src/models/update_team_response.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct UpdateTeamResponse { @@ -23,10 +23,6 @@ pub struct UpdateTeamResponse { impl UpdateTeamResponse { pub fn new(team: models::Team) -> UpdateTeamResponse { - UpdateTeamResponse { - schema: None, - team, - } + UpdateTeamResponse { schema: None, team } } } - diff --git a/crates/tower-api/src/models/update_user_params.rs b/crates/tower-api/src/models/update_user_params.rs index 10e2abc2..a7764cd3 100644 --- a/crates/tower-api/src/models/update_user_params.rs +++ b/crates/tower-api/src/models/update_user_params.rs @@ -9,27 +9,62 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct UpdateUserParams { /// A URL to the JSON Schema for this object. #[serde(rename = "$schema", skip_serializing_if = "Option::is_none")] pub schema: Option, - #[serde(rename = "company", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] + #[serde( + rename = "company", + default, + with = "::serde_with::rust::double_option", + skip_serializing_if = "Option::is_none" + )] pub company: Option>, - #[serde(rename = "country", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] + #[serde( + rename = "country", + default, + with = "::serde_with::rust::double_option", + skip_serializing_if = "Option::is_none" + )] pub country: Option>, - #[serde(rename = "first_name", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] + #[serde( + rename = "first_name", + default, + with = "::serde_with::rust::double_option", + skip_serializing_if = "Option::is_none" + )] pub first_name: Option>, - #[serde(rename = "is_alerts_enabled", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] + #[serde( + rename = "is_alerts_enabled", + default, + with = "::serde_with::rust::double_option", + skip_serializing_if = "Option::is_none" + )] pub is_alerts_enabled: Option>, /// If true, the user will receive changelog updates via email. - #[serde(rename = "is_subscribed_to_changelog", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] + #[serde( + rename = "is_subscribed_to_changelog", + default, + with = "::serde_with::rust::double_option", + skip_serializing_if = "Option::is_none" + )] pub is_subscribed_to_changelog: Option>, - #[serde(rename = "last_name", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] + #[serde( + rename = "last_name", + default, + with = "::serde_with::rust::double_option", + skip_serializing_if = "Option::is_none" + )] pub last_name: Option>, - #[serde(rename = "password", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] + #[serde( + rename = "password", + default, + with = "::serde_with::rust::double_option", + skip_serializing_if = "Option::is_none" + )] pub password: Option>, } @@ -47,4 +82,3 @@ impl UpdateUserParams { } } } - diff --git a/crates/tower-api/src/models/update_user_response.rs b/crates/tower-api/src/models/update_user_response.rs index 54bff270..7589573c 100644 --- a/crates/tower-api/src/models/update_user_response.rs +++ b/crates/tower-api/src/models/update_user_response.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct UpdateUserResponse { @@ -22,10 +22,6 @@ pub struct UpdateUserResponse { impl UpdateUserResponse { pub fn new(user: models::User) -> UpdateUserResponse { - UpdateUserResponse { - schema: None, - user, - } + UpdateUserResponse { schema: None, user } } } - diff --git a/crates/tower-api/src/models/user.rs b/crates/tower-api/src/models/user.rs index b596d3f3..61675b3b 100644 --- a/crates/tower-api/src/models/user.rs +++ b/crates/tower-api/src/models/user.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct User { @@ -28,7 +28,10 @@ pub struct User { #[serde(rename = "is_confirmed")] pub is_confirmed: bool, /// This property is deprecated. It will be removed in a future version. - #[serde(rename = "is_invitation_claimed", skip_serializing_if = "Option::is_none")] + #[serde( + rename = "is_invitation_claimed", + skip_serializing_if = "Option::is_none" + )] pub is_invitation_claimed: Option, #[serde(rename = "is_subscribed_to_changelog")] pub is_subscribed_to_changelog: bool, @@ -39,7 +42,18 @@ pub struct User { } impl User { - pub fn new(company: String, country: String, created_at: String, email: String, first_name: String, is_alerts_enabled: bool, is_confirmed: bool, is_subscribed_to_changelog: bool, last_name: String, profile_photo_url: String) -> User { + pub fn new( + company: String, + country: String, + created_at: String, + email: String, + first_name: String, + is_alerts_enabled: bool, + is_confirmed: bool, + is_subscribed_to_changelog: bool, + last_name: String, + profile_photo_url: String, + ) -> User { User { company, country, @@ -55,4 +69,3 @@ impl User { } } } - diff --git a/crates/tower-api/src/models/verified_authenticator.rs b/crates/tower-api/src/models/verified_authenticator.rs index 233b69fb..de0cb4e7 100644 --- a/crates/tower-api/src/models/verified_authenticator.rs +++ b/crates/tower-api/src/models/verified_authenticator.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct VerifiedAuthenticator { @@ -28,7 +28,12 @@ pub struct VerifiedAuthenticator { } impl VerifiedAuthenticator { - pub fn new(created_at: String, id: String, issuer: String, label: String) -> VerifiedAuthenticator { + pub fn new( + created_at: String, + id: String, + issuer: String, + label: String, + ) -> VerifiedAuthenticator { VerifiedAuthenticator { created_at, id, @@ -37,4 +42,3 @@ impl VerifiedAuthenticator { } } } - diff --git a/crates/tower-api/src/models/verify_email_params.rs b/crates/tower-api/src/models/verify_email_params.rs index 78d0949c..def3264e 100644 --- a/crates/tower-api/src/models/verify_email_params.rs +++ b/crates/tower-api/src/models/verify_email_params.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct VerifyEmailParams { @@ -22,10 +22,6 @@ pub struct VerifyEmailParams { impl VerifyEmailParams { pub fn new(code: String) -> VerifyEmailParams { - VerifyEmailParams { - schema: None, - code, - } + VerifyEmailParams { schema: None, code } } } - diff --git a/crates/tower-api/src/models/verify_email_response.rs b/crates/tower-api/src/models/verify_email_response.rs index df9dfc6c..c9de27f2 100644 --- a/crates/tower-api/src/models/verify_email_response.rs +++ b/crates/tower-api/src/models/verify_email_response.rs @@ -9,7 +9,7 @@ */ use crate::models; -use serde::{Deserialize, Serialize, Deserializer}; +use serde::{Deserialize, Deserializer, Serialize}; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct VerifyEmailResponse { @@ -23,10 +23,6 @@ pub struct VerifyEmailResponse { impl VerifyEmailResponse { pub fn new(user: models::User) -> VerifyEmailResponse { - VerifyEmailResponse { - schema: None, - user, - } + VerifyEmailResponse { schema: None, user } } } - diff --git a/crates/tower-cmd/src/api.rs b/crates/tower-cmd/src/api.rs index b47a63bb..2e6ad76f 100644 --- a/crates/tower-cmd/src/api.rs +++ b/crates/tower-cmd/src/api.rs @@ -1,24 +1,30 @@ -use tower_api::apis::Error; use config::Config; +use futures_util::StreamExt; use http::StatusCode; +use reqwest_eventsource::{Event, EventSource}; use std::collections::HashMap; -use tower_api::apis::ResponseContent; -use tower_telemetry::debug; use tokio::sync::mpsc; -use reqwest_eventsource::{Event, EventSource}; use tower_api::apis::configuration; -use futures_util::StreamExt; +use tower_api::apis::Error; +use tower_api::apis::ResponseContent; +use tower_telemetry::debug; /// Helper trait to extract the successful response data from API responses pub trait ResponseEntity { /// The type of data contained in the successful response type Data; - + /// Extract the data from the response, returning None if it's not the expected type fn extract_data(self) -> Option; } -pub async fn describe_app(config: &Config, name: &str) -> Result> { +pub async fn describe_app( + config: &Config, + name: &str, +) -> Result< + tower_api::models::DescribeAppResponse, + Error, +> { let api_config = &config.into(); let params = tower_api::apis::default_api::DescribeAppParams { @@ -29,10 +35,16 @@ pub async fn describe_app(config: &Config, name: &str) -> Result Result> { +pub async fn list_apps( + config: &Config, +) -> Result> +{ let api_config = &config.into(); let params = tower_api::apis::default_api::ListAppsParams { @@ -48,11 +60,16 @@ pub async fn list_apps(config: &Config) -> Result Result> { +pub async fn create_app( + config: &Config, + name: &str, + description: &str, +) -> Result> +{ let api_config = &config.into(); let params = tower_api::apis::default_api::CreateAppParams { - create_app_params: tower_api::models::CreateAppParams{ + create_app_params: tower_api::models::CreateAppParams { schema: None, name: name.to_string(), short_description: Some(description.to_string()), @@ -61,10 +78,14 @@ pub async fn create_app(config: &Config, name: &str, description: &str) -> Resul }, }; - unwrap_api_response(tower_api::apis::default_api::create_app(api_config, params)).await + unwrap_api_response(tower_api::apis::default_api::create_app(api_config, params)).await } -pub async fn delete_app(config: &Config, name: &str) -> Result> { +pub async fn delete_app( + config: &Config, + name: &str, +) -> Result> +{ let api_config = &config.into(); let params = tower_api::apis::default_api::DeleteAppParams { @@ -74,7 +95,14 @@ pub async fn delete_app(config: &Config, name: &str) -> Result Result> { +pub async fn describe_run( + config: &Config, + app_name: &str, + seq: i64, +) -> Result< + tower_api::models::DescribeRunResponse, + Error, +> { let api_config = &config.into(); let params = tower_api::apis::default_api::DescribeRunParams { @@ -82,10 +110,20 @@ pub async fn describe_run(config: &Config, app_name: &str, seq: i64) -> Result Result> { +pub async fn describe_run_logs( + config: &Config, + name: &str, + seq: i64, +) -> Result< + tower_api::models::DescribeRunLogsResponse, + Error, +> { let api_config = &config.into(); let params = tower_api::apis::default_api::DescribeRunLogsParams { @@ -93,10 +131,18 @@ pub async fn describe_run_logs(config: &Config, name: &str, seq: i64) -> Result< seq, }; - unwrap_api_response(tower_api::apis::default_api::describe_run_logs(api_config, params)).await + unwrap_api_response(tower_api::apis::default_api::describe_run_logs( + api_config, params, + )) + .await } -pub async fn run_app(config: &Config, name: &str, env: &str, params: HashMap) -> Result> { +pub async fn run_app( + config: &Config, + name: &str, + env: &str, + params: HashMap, +) -> Result> { let api_config = &config.into(); let params = tower_api::apis::default_api::RunAppParams { @@ -112,7 +158,15 @@ pub async fn run_app(config: &Config, name: &str, env: &str, params: HashMap Result> { +pub async fn export_secrets( + config: &Config, + env: &str, + all: bool, + public_key: rsa::RsaPublicKey, +) -> Result< + tower_api::models::ExportSecretsResponse, + Error, +> { let api_config = &config.into(); let params = tower_api::apis::default_api::ExportSecretsParams { @@ -126,10 +180,21 @@ pub async fn export_secrets(config: &Config, env: &str, all: bool, public_key: r }, }; - unwrap_api_response(tower_api::apis::default_api::export_secrets(api_config, params)).await -} - -pub async fn export_catalogs(config: &Config, env: &str, all: bool, public_key: rsa::RsaPublicKey) -> Result> { + unwrap_api_response(tower_api::apis::default_api::export_secrets( + api_config, params, + )) + .await +} + +pub async fn export_catalogs( + config: &Config, + env: &str, + all: bool, + public_key: rsa::RsaPublicKey, +) -> Result< + tower_api::models::ExportCatalogsResponse, + Error, +> { let api_config = &config.into(); let params = tower_api::apis::default_api::ExportCatalogsParams { @@ -143,11 +208,20 @@ pub async fn export_catalogs(config: &Config, env: &str, all: bool, public_key: }, }; - unwrap_api_response(tower_api::apis::default_api::export_catalogs(api_config, params)).await -} - + unwrap_api_response(tower_api::apis::default_api::export_catalogs( + api_config, params, + )) + .await +} -pub async fn list_secrets(config: &Config, env: &str, all: bool) -> Result> { +pub async fn list_secrets( + config: &Config, + env: &str, + all: bool, +) -> Result< + tower_api::models::ListSecretsResponse, + Error, +> { let api_config = &config.into(); let params = tower_api::apis::default_api::ListSecretsParams { @@ -157,10 +231,22 @@ pub async fn list_secrets(config: &Config, env: &str, all: bool) -> Result Result> { + unwrap_api_response(tower_api::apis::default_api::list_secrets( + api_config, params, + )) + .await +} + +pub async fn create_secret( + config: &Config, + name: &str, + env: &str, + encrypted_value: &str, + preview: &str, +) -> Result< + tower_api::models::CreateSecretResponse, + Error, +> { let api_config = &config.into(); let params = tower_api::apis::default_api::CreateSecretParams { @@ -173,20 +259,36 @@ pub async fn create_secret(config: &Config, name: &str, env: &str, encrypted_val }, }; - unwrap_api_response(tower_api::apis::default_api::create_secret(api_config, params)).await + unwrap_api_response(tower_api::apis::default_api::create_secret( + api_config, params, + )) + .await } -pub async fn describe_secrets_key(config: &Config) -> Result> { +pub async fn describe_secrets_key( + config: &Config, +) -> Result< + tower_api::models::DescribeSecretsKeyResponse, + Error, +> { let api_config = &config.into(); - let params = tower_api::apis::default_api::DescribeSecretsKeyParams { - format: None, - }; + let params = tower_api::apis::default_api::DescribeSecretsKeyParams { format: None }; - unwrap_api_response(tower_api::apis::default_api::describe_secrets_key(api_config, params)).await + unwrap_api_response(tower_api::apis::default_api::describe_secrets_key( + api_config, params, + )) + .await } -pub async fn delete_secret(config: &Config, name: &str, env: &str) -> Result> { +pub async fn delete_secret( + config: &Config, + name: &str, + env: &str, +) -> Result< + tower_api::models::DeleteSecretResponse, + Error, +> { let api_config = &config.into(); let params = tower_api::apis::default_api::DeleteSecretParams { @@ -194,32 +296,60 @@ pub async fn delete_secret(config: &Config, name: &str, env: &str) -> Result Result> { +pub async fn create_device_login_ticket( + config: &Config, +) -> Result< + tower_api::models::CreateDeviceLoginTicketResponse, + Error, +> { let api_config = &config.into(); - unwrap_api_response(tower_api::apis::default_api::create_device_login_ticket(api_config)).await -} - -pub async fn describe_device_login_session(config: &Config, device_code: &str) -> Result> { + unwrap_api_response(tower_api::apis::default_api::create_device_login_ticket( + api_config, + )) + .await +} + +pub async fn describe_device_login_session( + config: &Config, + device_code: &str, +) -> Result< + tower_api::models::DescribeDeviceLoginSessionResponse, + Error, +> { let api_config = &config.into(); let params = tower_api::apis::default_api::DescribeDeviceLoginSessionParams { device_code: device_code.to_string(), }; - unwrap_api_response(tower_api::apis::default_api::describe_device_login_session(api_config, params)).await + unwrap_api_response(tower_api::apis::default_api::describe_device_login_session( + api_config, params, + )) + .await } -pub async fn refresh_session(config: &Config) -> Result> { +pub async fn refresh_session( + config: &Config, +) -> Result< + tower_api::models::RefreshSessionResponse, + Error, +> { let api_config = &config.into(); let params = tower_api::apis::default_api::RefreshSessionParams { refresh_session_params: tower_api::models::RefreshSessionParams::new(), }; - unwrap_api_response(tower_api::apis::default_api::refresh_session(api_config, params)).await + unwrap_api_response(tower_api::apis::default_api::refresh_session( + api_config, params, + )) + .await } pub enum LogStreamEvent { @@ -248,40 +378,47 @@ async fn drain_run_logs_stream(mut source: EventSource, tx: mpsc::Sender { match message.event.as_str() { - "log" => { - let event_log = serde_json::from_str(&message.data); - - match event_log { - Ok(event) => { - tx.send(LogStreamEvent::EventLog(event)).await.ok(); - }, - Err(err) => { - debug!("Failed to parse log message: {}. Error: {}", message.data, err); + "log" => { + let event_log = serde_json::from_str(&message.data); + + match event_log { + Ok(event) => { + tx.send(LogStreamEvent::EventLog(event)).await.ok(); + } + Err(err) => { + debug!( + "Failed to parse log message: {}. Error: {}", + message.data, err + ); + } + }; + } + "warning" => { + let event_warning = serde_json::from_str(&message.data); + if let Ok(event) = event_warning { + tx.send(LogStreamEvent::EventWarning(event)).await.ok(); + } else { + debug!("Failed to parse warning message: {:?}", message.data); } - }; - }, - "warning" => { - let event_warning = serde_json::from_str(&message.data); - if let Ok(event) = event_warning { - tx.send(LogStreamEvent::EventWarning(event)).await.ok(); - } else { - debug!("Failed to parse warning message: {:?}", message.data); - } - } - _ => { - debug!("Unknown or unsupported log message: {:?}", message); - } + } + _ => { + debug!("Unknown or unsupported log message: {:?}", message); + } }; - }, + } Err(err) => { debug!("Error in log stream: {}", err); break; // Exit on error } - } + } } } -pub async fn stream_run_logs(config: &Config, app_name: &str, seq: i64) -> Result, LogStreamError> { +pub async fn stream_run_logs( + config: &Config, + app_name: &str, + seq: i64, +) -> Result, LogStreamError> { let api_config: configuration::Configuration = config.into(); // These represent the messages that we'll stream to the client. @@ -290,7 +427,12 @@ pub async fn stream_run_logs(config: &Config, app_name: &str, seq: i64) -> Resul // This code is copied from tower-api. Since that code is generated, there's not really a good // way to share this code between here and the rest of the app. let name = tower_api::apis::urlencode(app_name); - let uri = format!("{}/apps/{name}/runs/{seq}/logs/stream", api_config.base_path, name=name, seq=seq); + let uri = format!( + "{}/apps/{name}/runs/{seq}/logs/stream", + api_config.base_path, + name = name, + seq = seq + ); let mut builder = api_config.client.request(reqwest::Method::GET, &uri); if let Some(ref user_agent) = api_config.user_agent { @@ -309,25 +451,22 @@ pub async fn stream_run_logs(config: &Config, app_name: &str, seq: i64) -> Resul Ok(Event::Open) => { tokio::spawn(drain_run_logs_stream(source, tx)); Ok(rx) - }, + } Ok(Event::Message(message)) => { // This is a bug in the program and should never happen. - panic!("Received message when expected an open event. Message: {:?}", message); - }, - Err(err) => { - match err { - reqwest_eventsource::Error::Transport(e) => { - Err(LogStreamError::Reqwest(e)) - }, - reqwest_eventsource::Error::StreamEnded => { - drop(tx); - Ok(rx) - }, - _ => { - Err(LogStreamError::Unknown) - } - } + panic!( + "Received message when expected an open event. Message: {:?}", + message + ); } + Err(err) => match err { + reqwest_eventsource::Error::Transport(e) => Err(LogStreamError::Reqwest(e)), + reqwest_eventsource::Error::StreamEnded => { + drop(tx); + Ok(rx) + } + _ => Err(LogStreamError::Unknown), + }, } } else { // If we didn't get an event, we can't stream logs. @@ -361,14 +500,12 @@ where Err(err) } } else { - let err = Error::ResponseError( - tower_api::apis::ResponseContent { - tower_trace_id: "".to_string(), - status: StatusCode::NO_CONTENT, - content: "Empty response from server".to_string(), - entity: None, - }, - ); + let err = Error::ResponseError(tower_api::apis::ResponseContent { + tower_trace_id: "".to_string(), + status: StatusCode::NO_CONTENT, + content: "Empty response from server".to_string(), + entity: None, + }); Err(err) } } @@ -438,15 +575,13 @@ impl ResponseEntity for tower_api::apis::default_api::ListAppsSuccess { fn extract_data(self) -> Option { match self { Self::Status200(data) => Some(data), - Self::UnknownValue(data) => { - match serde_json::from_value(data) { - Ok(obj) => Some(obj), - Err(err) => { - debug!("Failed to deserialize ListAppsResponse from value: {}", err); - None - }, + Self::UnknownValue(data) => match serde_json::from_value(data) { + Ok(obj) => Some(obj), + Err(err) => { + debug!("Failed to deserialize ListAppsResponse from value: {}", err); + None } - } + }, } } } @@ -571,3 +706,57 @@ impl ResponseEntity for tower_api::apis::default_api::DescribeRunSuccess { } } } + +pub async fn list_environments( + config: &Config, +) -> Result< + tower_api::models::ListEnvironmentsResponse, + Error, +> { + let api_config = &config.into(); + unwrap_api_response(tower_api::apis::default_api::list_environments(api_config)).await +} + +pub async fn create_environment( + config: &Config, + name: &str, +) -> Result< + tower_api::models::CreateEnvironmentResponse, + Error, +> { + let api_config = &config.into(); + + let params = tower_api::apis::default_api::CreateEnvironmentParams { + create_environment_params: tower_api::models::CreateEnvironmentParams { + schema: None, + name: name.to_string(), + }, + }; + + unwrap_api_response(tower_api::apis::default_api::create_environment( + api_config, params, + )) + .await +} + +impl ResponseEntity for tower_api::apis::default_api::ListEnvironmentsSuccess { + type Data = tower_api::models::ListEnvironmentsResponse; + + fn extract_data(self) -> Option { + match self { + Self::Status200(data) => Some(data), + Self::UnknownValue(_) => None, + } + } +} + +impl ResponseEntity for tower_api::apis::default_api::CreateEnvironmentSuccess { + type Data = tower_api::models::CreateEnvironmentResponse; + + fn extract_data(self) -> Option { + match self { + Self::Status201(data) => Some(data), + Self::UnknownValue(_) => None, + } + } +} diff --git a/crates/tower-cmd/src/apps.rs b/crates/tower-cmd/src/apps.rs index 83f62a10..54ad8907 100644 --- a/crates/tower-cmd/src/apps.rs +++ b/crates/tower-cmd/src/apps.rs @@ -4,11 +4,7 @@ use config::Config; use tower_api::models::Run; -use crate::{ - util::dates, - output, - api, -}; +use crate::{api, output, util::dates}; pub fn apps_cmd() -> Command { Command::new("apps") @@ -65,7 +61,7 @@ pub async fn do_logs(config: Config, cmd: &ArgMatches) { pub async fn do_show(config: Config, cmd: &ArgMatches) { let name = extract_app_name("show", cmd.subcommand()); - match api::describe_app(&config, &name).await { + match api::describe_app(&config, &name).await { Ok(app_response) => { let app = app_response.app; let runs = app_response.runs; @@ -115,8 +111,7 @@ pub async fn do_show(config: Config, cmd: &ArgMatches) { { let start = started_at.parse::>().ok(); - let end = - ended_at.parse::>().ok(); + let end = ended_at.parse::>().ok(); if let (Some(start), Some(end)) = (start, end) { format!("{:.1}s", (end - start).num_seconds()) } else { @@ -136,12 +131,7 @@ pub async fn do_show(config: Config, cmd: &ArgMatches) { "Pending".into() }; - vec![ - run.number.to_string(), - status_str, - start_time, - elapsed_time, - ] + vec![run.number.to_string(), status_str, start_time, elapsed_time] }) .collect(); @@ -172,7 +162,7 @@ pub async fn do_list_apps(config: Config) { }) .collect(); output::list(items); - }, + } Err(err) => { output::tower_error(err); } @@ -194,7 +184,6 @@ pub async fn do_create(config: Config, args: &ArgMatches) { spinner.success(); output::success(&format!("App '{}' created", name)); } - } pub async fn do_delete(config: Config, cmd: &ArgMatches) { @@ -221,10 +210,16 @@ fn extract_app_name_and_run(subcmd: &str, cmd: Option<(&str, &ArgMatches)>) -> ( ); } - let line = format!("Run number is required. Example: tower apps {} #", subcmd); + let line = format!( + "Run number is required. Example: tower apps {} #", + subcmd + ); output::die(&line); } - let line = format!("App name is required. Example: tower apps {} #", subcmd); + let line = format!( + "App name is required. Example: tower apps {} #", + subcmd + ); output::die(&line) } @@ -233,6 +228,9 @@ fn extract_app_name(subcmd: &str, cmd: Option<(&str, &ArgMatches)>) -> String { return name.to_string(); } - let line = format!("App name is required. Example: tower apps {} ", subcmd); + let line = format!( + "App name is required. Example: tower apps {} ", + subcmd + ); output::die(&line); } diff --git a/crates/tower-cmd/src/deploy.rs b/crates/tower-cmd/src/deploy.rs index 2f238be8..4e910de2 100644 --- a/crates/tower-cmd/src/deploy.rs +++ b/crates/tower-cmd/src/deploy.rs @@ -4,9 +4,9 @@ use std::convert::From; use std::path::PathBuf; use crate::{output, util}; +use tower_api::apis::configuration::Configuration; use tower_package::{Package, PackageSpec}; use tower_telemetry::debug; -use tower_api::apis::configuration::Configuration; pub fn deploy_cmd() -> Command { Command::new("deploy") @@ -72,20 +72,13 @@ pub async fn do_deploy(config: Config, args: &ArgMatches) { } async fn do_deploy_package(api_config: Configuration, package: Package, towerfile: &Towerfile) { - let res = util::deploy::deploy_app_package( - &api_config, - &towerfile.app.name, - package, - ).await; + let res = util::deploy::deploy_app_package(&api_config, &towerfile.app.name, package).await; match res { Ok(resp) => { let version = resp.version; - let line = format!( - "Version `{}` has been deployed to Tower!", - version.version - ); + let line = format!("Version `{}` has been deployed to Tower!", version.version); output::success(&line); } diff --git a/crates/tower-cmd/src/environments.rs b/crates/tower-cmd/src/environments.rs new file mode 100644 index 00000000..1516e9d6 --- /dev/null +++ b/crates/tower-cmd/src/environments.rs @@ -0,0 +1,58 @@ +use clap::{value_parser, Arg, ArgMatches, Command}; +use colored::Colorize; +use config::Config; + +use crate::{api, output}; + +pub fn environments_cmd() -> Command { + Command::new("environments") + .about("Manage the environments in your current Tower account") + .arg_required_else_help(true) + .subcommand(Command::new("list").about("List all of your environments")) + .subcommand( + Command::new("create") + .arg( + Arg::new("name") + .short('n') + .long("name") + .value_parser(value_parser!(String)) + .required(true) + .action(clap::ArgAction::Set), + ) + .about("Create a new environment in Tower"), + ) +} + +pub async fn do_list(config: Config) { + let resp = api::list_environments(&config).await; + + match resp { + Ok(resp) => { + let items = resp + .environments + .into_iter() + .map(|env| env.name.bold().green().to_string()) + .collect(); + output::list(items); + } + Err(err) => { + output::tower_error(err); + } + } +} + +pub async fn do_create(config: Config, args: &ArgMatches) { + let name = args.get_one::("name").unwrap_or_else(|| { + output::die("Environment name (--name) is required"); + }); + + let mut spinner = output::spinner("Creating environment"); + + if let Err(err) = api::create_environment(&config, name).await { + spinner.failure(); + output::tower_error(err); + } else { + spinner.success(); + output::success(&format!("Environment '{}' created", name)); + } +} diff --git a/crates/tower-cmd/src/error.rs b/crates/tower-cmd/src/error.rs index 1eb80c67..df208dc4 100644 --- a/crates/tower-cmd/src/error.rs +++ b/crates/tower-cmd/src/error.rs @@ -1,6 +1,6 @@ use snafu::prelude::*; -use tower_telemetry::debug; use tower_api::apis::default_api::DescribeRunError; +use tower_telemetry::debug; #[derive(Debug, Snafu)] pub enum Error { diff --git a/crates/tower-cmd/src/lib.rs b/crates/tower-cmd/src/lib.rs index b34cb323..22ae9a6c 100644 --- a/crates/tower-cmd/src/lib.rs +++ b/crates/tower-cmd/src/lib.rs @@ -1,11 +1,12 @@ use clap::{value_parser, Arg, Command}; use config::{Config, Session}; +pub mod api; mod apps; mod deploy; -pub mod output; -pub mod api; +mod environments; pub mod error; +pub mod output; mod run; mod secrets; mod session; @@ -31,7 +32,7 @@ impl App { Session::from_jwt(&token).ok() } else { Session::from_config_dir().ok() - }; + }; Self { cmd, session } } @@ -118,6 +119,20 @@ impl App { } } } + Some(("environments", sub_matches)) => { + let environments_command = sub_matches.subcommand(); + + match environments_command { + Some(("list", _)) => environments::do_list(sessionized_config).await, + Some(("create", args)) => { + environments::do_create(sessionized_config, args).await + } + _ => { + environments::environments_cmd().print_help().unwrap(); + std::process::exit(2); + } + } + } Some(("deploy", args)) => deploy::do_deploy(sessionized_config, args).await, Some(("run", args)) => run::do_run(sessionized_config, args, args.subcommand()).await, Some(("teams", sub_matches)) => { @@ -163,6 +178,7 @@ fn root_cmd() -> Command { .subcommand(session::login_cmd()) .subcommand(apps::apps_cmd()) .subcommand(secrets::secrets_cmd()) + .subcommand(environments::environments_cmd()) .subcommand(deploy::deploy_cmd()) .subcommand(run::run_cmd()) .subcommand(version::version_cmd()) diff --git a/crates/tower-cmd/src/output.rs b/crates/tower-cmd/src/output.rs index 294efd73..4087c46c 100644 --- a/crates/tower-cmd/src/output.rs +++ b/crates/tower-cmd/src/output.rs @@ -3,14 +3,11 @@ use cli_table::{ format::{Border, HorizontalLine, Separator}, print_stdout, Table, }; -use http::StatusCode; use colored::Colorize; +use http::StatusCode; use std::io::{self, Write}; use tower_api::{ - apis::{ - Error as ApiError, - ResponseContent, - }, + apis::{Error as ApiError, ResponseContent}, models::ErrorModel, }; use tower_telemetry::debug; @@ -55,7 +52,8 @@ pub fn package_error(err: tower_package::Error) { "Invalid manifest was found or created".to_string() } tower_package::Error::InvalidPath => { - "There was a problem determining exactly where your Towerfile was stored on disk".to_string() + "There was a problem determining exactly where your Towerfile was stored on disk" + .to_string() } }; @@ -123,7 +121,7 @@ pub fn output_full_error_details(model: &ErrorModel) { writeln!(io::stdout(), "\n{}", "Error details:".yellow()).unwrap(); writeln!(io::stdout(), "{}", detail.red()).unwrap(); } - + // Show any additional error details from the errors field if let Some(errors) = &model.errors { if !errors.is_empty() { @@ -147,7 +145,7 @@ fn output_response_content_error(err: ResponseContent) { Ok(model) => { debug!("Error model (status: {}): {:?}", err.status, model); model - }, + } Err(e) => { debug!("Failed to parse error content as JSON: {}", e); debug!("Raw error content: {}", err.content); @@ -162,26 +160,27 @@ fn output_response_content_error(err: ResponseContent) { StatusCode::CONFLICT => { error("There was a conflict while trying to do that!"); output_full_error_details(&error_model); - }, + } StatusCode::UNPROCESSABLE_ENTITY => { output_full_error_details(&error_model); - }, + } StatusCode::INTERNAL_SERVER_ERROR => { error("The Tower API encountered an internal error. Maybe try again later on."); - }, + } StatusCode::NOT_FOUND => { output_full_error_details(&error_model); - }, + } StatusCode::UNAUTHORIZED => { - error("You aren't authorized to do that! Are you logged in? Run `tower login` to login."); - }, + error( + "You aren't authorized to do that! Are you logged in? Run `tower login` to login.", + ); + } _ => { error("The Tower API returned an error that the Tower CLI doesn't know what to do with! Maybe try again in a bit."); } } } - pub fn tower_error(err: ApiError) { match err { ApiError::ResponseError(resp) => { diff --git a/crates/tower-cmd/src/run.rs b/crates/tower-cmd/src/run.rs index 12b5e3e0..d62933d9 100644 --- a/crates/tower-cmd/src/run.rs +++ b/crates/tower-cmd/src/run.rs @@ -2,22 +2,14 @@ use clap::{Arg, ArgMatches, Command}; use config::{Config, Towerfile}; use std::collections::HashMap; use std::path::PathBuf; +use tower_api::models::Run; use tower_package::{Package, PackageSpec}; use tower_runtime::{local::LocalApp, App, AppLauncher, OutputReceiver}; -use tower_telemetry::{Context, debug}; -use tower_api::models::Run; +use tower_telemetry::{debug, Context}; -use tokio::sync::{ - oneshot::self, - mpsc::unbounded_channel, -}; +use tokio::sync::{mpsc::unbounded_channel, oneshot}; -use crate::{ - util::dates, - output, - api, - Error, -}; +use crate::{api, output, util::dates, Error}; pub fn run_cmd() -> Command { Command::new("run") @@ -97,7 +89,12 @@ pub async fn do_run(config: Config, args: &ArgMatches, cmd: Option<(&str, &ArgMa /// do_run_local is the entrypoint for running an app locally. It will load the Towerfile, build /// the package, and launch the app. The relevant package is cleaned up after execution is /// complete. -async fn do_run_local(config: Config, path: PathBuf, env: &str, mut params: HashMap) { +async fn do_run_local( + config: Config, + path: PathBuf, + env: &str, + mut params: HashMap, +) { let mut spinner = output::spinner("Setting up runtime environment..."); // Load all the secrets and catalogs from the server @@ -154,7 +151,15 @@ async fn do_run_local(config: Config, path: PathBuf, env: &str, mut params: Hash let mut launcher: AppLauncher = AppLauncher::default(); if let Err(err) = launcher - .launch(Context::new(), sender, package, env.to_string(), secrets, params, env_vars) + .launch( + Context::new(), + sender, + package, + env.to_string(), + secrets, + params, + env_vars, + ) .await { output::runtime_error(err); @@ -197,7 +202,7 @@ async fn do_run_remote( spinner.failure(); debug!("Failed to schedule run: {}", err); output::tower_error(err); - }, + } Ok(res) => { spinner.success(); @@ -220,10 +225,7 @@ async fn do_run_remote( } } -async fn do_follow_run( - config: Config, - run: &Run, -) { +async fn do_follow_run(config: Config, run: &Run) { let mut spinner = output::spinner("Waiting for run to start..."); match wait_for_run_start(&config, &run).await { @@ -232,7 +234,7 @@ async fn do_follow_run( debug!("Failed to wait for run to start: {}", err); let msg = format!("An error occurred while waiting for the run to start. This shouldn't happen! You can get more details at {:?} or by contacting support.", run.dollar_link); output::failure(&msg); - }, + } Ok(()) => { spinner.success(); @@ -254,39 +256,35 @@ async fn do_follow_run( output::write(&msg); output::newline(); - let msg = format!( - "You can follow it at {}", - run_copy.dollar_link - ); + let msg = format!("You can follow it at {}", run_copy.dollar_link); output::write(&msg); output::newline(); // According to // https://www.agileconnection.com/article/overview-linux-exit-codes... std::process::exit(130); - }).expect("Failed to set Ctrl+C handler"); + }) + .expect("Failed to set Ctrl+C handler"); // Now we follow the logs from the run. We can stream them from the cloud to here using // the stream_logs API endpoint. match api::stream_run_logs(&config, &run.app_name, run.number).await { - Ok(mut output) => { - loop { - tokio::select! { - Some(event) = output.recv() => print_log_stream_event(event), - res = &mut run_complete => { - match res { - Ok(run) => print_run_completion(&run), - Err(err) => { - debug!("Failed to monitor run completion: {:?}", err); - let msg = format!("An error occurred while waiting for the run to complete. This shouldn't happen! You can get more details at {:?} or by contacting support.", run.dollar_link); - output::failure(&msg); - } + Ok(mut output) => loop { + tokio::select! { + Some(event) = output.recv() => print_log_stream_event(event), + res = &mut run_complete => { + match res { + Ok(run) => print_run_completion(&run), + Err(err) => { + debug!("Failed to monitor run completion: {:?}", err); + let msg = format!("An error occurred while waiting for the run to complete. This shouldn't happen! You can get more details at {:?} or by contacting support.", run.dollar_link); + output::failure(&msg); } + } - break; - }, - }; - } + break; + }, + }; }, Err(err) => { debug!("Failed to stream run logs: {:?}", err); @@ -314,9 +312,7 @@ fn get_run_parameters( Ok((local, path, params, app_name)) } -fn should_follow_run( - args: &ArgMatches, -) -> bool { +fn should_follow_run(args: &ArgMatches) -> bool { let local = *args.get_one::("detached").unwrap(); !local } @@ -380,12 +376,13 @@ async fn get_secrets(config: &Config, env: &str) -> Result { output::tower_error(err); Err(Error::FetchingSecretsFailed) @@ -405,14 +402,16 @@ async fn get_catalogs(config: &Config, env: &str) -> Result { output::tower_error(err); Err(Error::FetchingCatalogsFailed) @@ -485,8 +484,14 @@ async fn monitor_status(app: LocalApp) { } fn create_pyiceberg_catalog_property_name(catalog_name: &str, property_name: &str) -> String { - let catalog_name = catalog_name.replace('.', "_").replace(':', "_").to_uppercase(); - let property_name = property_name.replace('.', "_").replace(':', "_").to_uppercase(); + let catalog_name = catalog_name + .replace('.', "_") + .replace(':', "_") + .to_uppercase(); + let property_name = property_name + .replace('.', "_") + .replace(':', "_") + .to_uppercase(); format!("PYICEBERG_CATALOG__{}__{}", catalog_name, property_name) } @@ -498,12 +503,12 @@ async fn wait_for_run_start(config: &Config, run: &Run) -> Result<(), Error> { let res = api::describe_run(config, &run.app_name, run.number).await?; if is_run_started(&res.run)? { - break + break; } else { // Wait half a second to to try again. tokio::time::sleep(tokio::time::Duration::from_millis(500)).await; } - } + } Ok(()) } @@ -515,15 +520,15 @@ async fn wait_for_run_completion(config: &Config, run: &Run) -> Result Result { match run.status { tower_api::models::run::Status::Scheduled => Ok(false), @@ -553,11 +558,11 @@ fn monitor_run_completion(config: &Config, run: &Run) -> oneshot::Receiver let run_clone = run.clone(); tokio::spawn(async move { - let run = wait_for_run_completion(&config_clone, &run_clone). - await. - unwrap(); + let run = wait_for_run_completion(&config_clone, &run_clone) + .await + .unwrap(); - let _ = tx.send(run); + let _ = tx.send(run); }); rx @@ -568,11 +573,7 @@ fn print_log_stream_event(event: api::LogStreamEvent) { api::LogStreamEvent::EventLog(log) => { let ts = dates::format_str(&log.reported_at); - output::log_line( - &ts, - &log.content, - output::LogLineType::Remote, - ); + output::log_line(&ts, &log.content, output::LogLineType::Remote); } api::LogStreamEvent::EventWarning(warning) => { debug!("warning: {:?}", warning); @@ -590,21 +591,18 @@ fn print_run_completion(run: &Run) { run.number, run.app_name ); output::failure(&line); - }, + } tower_api::models::run::Status::Crashed => { - let line = format!( - "Run #{} for app `{}` crashed", - run.number, run.app_name - ); + let line = format!("Run #{} for app `{}` crashed", run.number, run.app_name); output::failure(&line); - }, + } tower_api::models::run::Status::Cancelled => { let line = format!( "Run #{} for app `{}` was cancelled", run.number, run.app_name ); output::failure(&line); - }, + } _ => { let line = format!( "Run #{} for app `{}` has exited successfully", diff --git a/crates/tower-cmd/src/secrets.rs b/crates/tower-cmd/src/secrets.rs index ef47a0ea..0d112060 100644 --- a/crates/tower-cmd/src/secrets.rs +++ b/crates/tower-cmd/src/secrets.rs @@ -5,19 +5,12 @@ use crypto::encrypt; use rsa::pkcs1::DecodeRsaPublicKey; use tower_api::{ - apis:: { - Error, - default_api::CreateSecretError, - }, + apis::{default_api::CreateSecretError, Error}, models::CreateSecretResponse, }; use tower_telemetry::debug; -use crate::{ - output, - api, - util::cmd, -}; +use crate::{api, output, util::cmd}; pub fn secrets_cmd() -> Command { Command::new("secrets") @@ -84,10 +77,13 @@ pub fn secrets_cmd() -> Command { pub async fn do_list(config: Config, args: &ArgMatches) { let all = cmd::get_bool_flag(args, "all"); - let show = cmd::get_bool_flag(args, "show"); + let show = cmd::get_bool_flag(args, "show"); let env = cmd::get_string_flag(args, "environment"); - debug!("listing secrets, environment={} all={} show={}", env, all, show); + debug!( + "listing secrets, environment={} all={} show={}", + env, all, show + ); if show { let (private_key, public_key) = crypto::generate_key_pair(); @@ -99,21 +95,24 @@ pub async fn do_list(config: Config, args: &ArgMatches) { "Environment".bold().yellow().to_string(), "Value".bold().yellow().to_string(), ]; - let data = list_response.secrets.iter().map(|secret| { - // now we decrypt the value and show it. - let decrypted_value = crypto::decrypt( - private_key.clone(), - secret.encrypted_value.clone(), - ).unwrap(); - - vec![ - secret.name.clone(), - secret.environment.clone(), - decrypted_value, - ] - }).collect(); + let data = list_response + .secrets + .iter() + .map(|secret| { + // now we decrypt the value and show it. + let decrypted_value = + crypto::decrypt(private_key.clone(), secret.encrypted_value.clone()) + .unwrap(); + + vec![ + secret.name.clone(), + secret.environment.clone(), + decrypted_value, + ] + }) + .collect(); output::table(headers, data); - }, + } Err(err) => output::tower_error(err), } } else { @@ -124,15 +123,19 @@ pub async fn do_list(config: Config, args: &ArgMatches) { "Environment".bold().yellow().to_string(), "Preview".bold().yellow().to_string(), ]; - let data = list_response.secrets.iter().map(|secret| { - vec![ - secret.name.clone(), - secret.environment.clone(), - secret.preview.dimmed().to_string(), - ] - }).collect(); + let data = list_response + .secrets + .iter() + .map(|secret| { + vec![ + secret.name.clone(), + secret.environment.clone(), + secret.preview.dimmed().to_string(), + ] + }) + .collect(); output::table(headers, data); - }, + } Err(err) => output::tower_error(err), } } @@ -145,18 +148,14 @@ pub async fn do_create(config: Config, args: &ArgMatches) { let mut spinner = output::spinner("Creating secret..."); - match encrypt_and_create_secret(&config, &name, &value, &environment).await { + match encrypt_and_create_secret(&config, &name, &value, &environment).await { Ok(_) => { spinner.success(); - let line = format!( - "Secret {} created in environment {}", - name, - environment, - ); + let line = format!("Secret {} created in environment {}", name, environment,); output::success(&line); - }, + } Err(err) => { debug!("Failed to create secrets: {}", err); spinner.failure(); @@ -199,8 +198,8 @@ async fn encrypt_and_create_secret( ) -> Result> { match api::describe_secrets_key(config).await { Ok(res) => { - let public_key = rsa::RsaPublicKey::from_pkcs1_pem(&res.public_key) - .unwrap_or_else(|_| { + let public_key = + rsa::RsaPublicKey::from_pkcs1_pem(&res.public_key).unwrap_or_else(|_| { output::die("Failed to parse public key"); }); @@ -208,7 +207,7 @@ async fn encrypt_and_create_secret( let preview = create_preview(value); api::create_secret(&config, name, environment, &encrypted_value, &preview).await - }, + } Err(err) => { debug!("failed to talk to tower api: {}", err); output::die("There was a problem with the Tower API! Please try again later."); @@ -216,13 +215,19 @@ async fn encrypt_and_create_secret( } } -fn extract_secret_environment_and_name(subcmd: &str, cmd: Option<(&str, &ArgMatches)>) -> (String, String) { +fn extract_secret_environment_and_name( + subcmd: &str, + cmd: Option<(&str, &ArgMatches)>, +) -> (String, String) { if let Some((slug, _)) = cmd { if let Some((env, name)) = slug.split_once('/') { return (env.to_string(), name.to_string()); } - let line = format!("Secret name is required. Example: tower secrets {} /", subcmd); + let line = format!( + "Secret name is required. Example: tower secrets {} /", + subcmd + ); output::die(&line); } diff --git a/crates/tower-cmd/src/session.rs b/crates/tower-cmd/src/session.rs index bb847f7a..ca4e8646 100644 --- a/crates/tower-cmd/src/session.rs +++ b/crates/tower-cmd/src/session.rs @@ -20,7 +20,7 @@ pub async fn do_login(config: Config) { Ok(resp) => { spinner.success(); handle_device_login(config, resp).await; - }, + } Err(err) => { spinner.failure(); output::failure(&format!("Failed to create device login ticket: {}", err)); @@ -28,10 +28,7 @@ pub async fn do_login(config: Config) { } } -async fn handle_device_login( - config: Config, - claim: CreateDeviceLoginTicketResponse, -) { +async fn handle_device_login(config: Config, claim: CreateDeviceLoginTicketResponse) { // Try to open the login URL in browser if let Err(err) = webbrowser::open(&claim.login_url) { debug!("failed to open web browser: {}", err); @@ -69,7 +66,7 @@ async fn poll_for_login( Ok(resp) => { finalize_session(config, &resp, spinner); return true; - }, + } Err(err) => { if let Some(api_err) = extract_api_error(&err) { if api_err.status != 404 && !api_err.is_incomplete_device_login { diff --git a/crates/tower-cmd/src/teams.rs b/crates/tower-cmd/src/teams.rs index 2d8064ed..755f42de 100644 --- a/crates/tower-cmd/src/teams.rs +++ b/crates/tower-cmd/src/teams.rs @@ -3,10 +3,7 @@ use colored::*; use config::Config; use tower_telemetry::debug; -use crate::{ - output, - api, -}; +use crate::{api, output}; pub fn teams_cmd() -> Command { Command::new("teams") @@ -16,7 +13,7 @@ pub fn teams_cmd() -> Command { .subcommand( Command::new("switch") .allow_external_subcommands(true) - .about("Switch context to a different team") + .about("Switch context to a different team"), ) } @@ -47,7 +44,7 @@ async fn refresh_session(config: &Config) -> config::Session { } session - }, + } Err(err) => { debug!("Failed to refresh session: {}", err); @@ -135,6 +132,9 @@ fn extract_team_name(subcmd: &str, cmd: Option<(&str, &ArgMatches)>) -> String { return name.to_string(); } - let line = format!("Team name is required. Example: tower teams {} ", subcmd); + let line = format!( + "Team name is required. Example: tower teams {} ", + subcmd + ); output::die(&line); } diff --git a/crates/tower-cmd/src/util/dates.rs b/crates/tower-cmd/src/util/dates.rs index a1984f16..96aa38b2 100644 --- a/crates/tower-cmd/src/util/dates.rs +++ b/crates/tower-cmd/src/util/dates.rs @@ -1,4 +1,4 @@ -use chrono::{DateTime, Utc}; +use chrono::{DateTime, Utc}; pub fn format_str(ts: &str) -> String { let dt: DateTime = DateTime::parse_from_rfc3339(ts) diff --git a/crates/tower-cmd/src/util/deploy.rs b/crates/tower-cmd/src/util/deploy.rs index c69eeebd..4488c39d 100644 --- a/crates/tower-cmd/src/util/deploy.rs +++ b/crates/tower-cmd/src/util/deploy.rs @@ -4,14 +4,14 @@ use std::path::PathBuf; use std::sync::{Arc, Mutex}; use tokio::fs::File; use tokio_util::io::ReaderStream; -use tower_package::{Package, compute_sha256_file}; +use tower_package::{compute_sha256_file, Package}; use tower_telemetry::debug; use tower_api::apis::configuration::Configuration; -use tower_api::apis::ResponseContent; -use tower_api::models::DeployAppResponse; use tower_api::apis::default_api::DeployAppError; use tower_api::apis::Error; +use tower_api::apis::ResponseContent; +use tower_api::models::DeployAppResponse; pub async fn upload_file_with_progress( api_config: &Configuration, @@ -74,7 +74,12 @@ pub async fn upload_file_with_progress( let content = response.text().await?; let entity: Option = serde_json::from_str(&content).ok(); - Err(Error::ResponseError(ResponseContent { tower_trace_id, status, content, entity })) + Err(Error::ResponseError(ResponseContent { + tower_trace_id, + status, + content, + entity, + })) } } diff --git a/crates/tower-cmd/src/util/mod.rs b/crates/tower-cmd/src/util/mod.rs index 4424a057..f086032f 100644 --- a/crates/tower-cmd/src/util/mod.rs +++ b/crates/tower-cmd/src/util/mod.rs @@ -1,5 +1,5 @@ pub mod apps; -pub mod deploy; -pub mod progress; pub mod cmd; pub mod dates; +pub mod deploy; +pub mod progress; diff --git a/crates/tower-cmd/src/version.rs b/crates/tower-cmd/src/version.rs index 4794ee99..53252088 100644 --- a/crates/tower-cmd/src/version.rs +++ b/crates/tower-cmd/src/version.rs @@ -1,9 +1,8 @@ -use clap::Command; use crate::output; +use clap::Command; pub fn version_cmd() -> Command { - Command::new("version") - .about("Print the current version of Tower") + Command::new("version").about("Print the current version of Tower") } pub async fn do_version() { diff --git a/crates/tower-package/src/lib.rs b/crates/tower-package/src/lib.rs index 9edf36fc..c863bf5d 100644 --- a/crates/tower-package/src/lib.rs +++ b/crates/tower-package/src/lib.rs @@ -1,19 +1,19 @@ +use config::Towerfile; +use glob::glob; use serde::{Deserialize, Serialize}; +use sha2::{Digest, Sha256}; +use std::collections::{HashMap, VecDeque}; use std::path::{Path, PathBuf}; use std::pin::Pin; -use std::collections::{VecDeque, HashMap}; +use tmpdir::TmpDir; use tokio::{ fs::File, - io::{AsyncRead, BufReader, AsyncReadExt, AsyncWriteExt}, + io::{AsyncRead, AsyncReadExt, AsyncWriteExt, BufReader}, }; -use config::Towerfile; use tokio_tar::{Archive, Builder}; -use glob::glob; -use tmpdir::TmpDir; -use sha2::{Sha256, Digest}; -use async_compression::tokio::write::GzipEncoder; use async_compression::tokio::bufread::GzipDecoder; +use async_compression::tokio::write::GzipEncoder; use tower_telemetry::debug; @@ -23,7 +23,7 @@ pub use error::Error; const CURRENT_PACKAGE_VERSION: i32 = 2; #[derive(Clone, Serialize, Deserialize, Debug)] -pub struct Parameter{ +pub struct Parameter { pub name: String, pub description: String, pub default: String, @@ -71,7 +71,7 @@ impl Manifest { pub async fn from_json(data: &str) -> Result { let manifest: Self = serde_json::from_str(data)?; - Ok(manifest) + Ok(manifest) } } @@ -115,9 +115,10 @@ impl PackageSpec { pub fn from_towerfile(towerfile: &Towerfile) -> Self { debug!("creating package spec from towerfile: {:?}", towerfile); let towerfile_path = towerfile.file_path.clone(); - let base_dir = towerfile_path.parent(). - unwrap_or_else(|| Path::new(".")). - to_path_buf(); + let base_dir = towerfile_path + .parent() + .unwrap_or_else(|| Path::new(".")) + .to_path_buf(); let schedule = if towerfile.app.schedule.is_empty() { None @@ -126,7 +127,10 @@ impl PackageSpec { }; // We need to turn these (validated) paths into something taht we can use at runtime. - let import_paths = towerfile.app.import_paths.iter() + let import_paths = towerfile + .app + .import_paths + .iter() .map(|p| p.to_string_lossy().to_string()) .collect(); @@ -138,12 +142,12 @@ impl PackageSpec { invoke: towerfile.app.script.clone(), file_globs: towerfile.app.source.clone(), parameters: get_parameters(towerfile), - } + } } } pub struct Package { - pub manifest: Manifest, + pub manifest: Manifest, // tmp_dir is used to keep the package directory around occasionally so the directory doesn't // get deleted out from under the application. @@ -157,186 +161,191 @@ pub struct Package { } impl Package { - pub fn default() -> Self { - Self { - tmp_dir: None, - package_file_path: None, - unpacked_path: None, - manifest: Manifest { - version: Some(CURRENT_PACKAGE_VERSION), - invoke: "".to_string(), - parameters: vec![], - schedule: None, - import_paths: vec![], - app_dir_name: "app".to_string(), - modules_dir_name: "modules".to_string(), - checksum: "".to_string(), - }, - } - } - - pub async fn from_unpacked_path(path: PathBuf) -> Self { - let manifest_path = path.join("MANIFEST"); - let manifest = Manifest::from_path(&manifest_path).await.unwrap(); - - Self { - tmp_dir: None, - package_file_path: None, - unpacked_path: Some(path), - manifest, - } - } - - // build creates a new package from a PackageSpec. PackageSpec is typically composed of fields - // copied from the Towerfile. The most important thing to know is that the collection of file - // globs to include in the package. - // - // The underlying package is just a TAR file with a special `MANIFEST` file that has also been - // GZip'd. - pub async fn build(spec: PackageSpec) -> Result { - debug!("building package from spec: {:?}", spec); - - // we canonicalize this because we want to treat all paths in the same keyspace more or - // less. - let base_dir = spec.base_dir.canonicalize()?; - - let tmp_dir = TmpDir::new("tower-package").await?; - let package_path = tmp_dir.to_path_buf().join("package.tar"); - debug!("building package at: {:?}", package_path); - - let file = File::create(package_path.clone()).await?; - let gzip = GzipEncoder::new(file); - let mut builder = Builder::new(gzip); - - // These help us compute the integrity of the package contents overall. For each path, we'll - // store a hash of the contents written to the file. Then we'll hash the final content to - // create a fingerprint of the data. - let mut path_hashes = HashMap::new(); - - // If the user didn't specify anything here we'll package everything under this directory - // and ship it to Tower. - let mut file_globs = spec.file_globs.clone(); - - // If there was no source specified, we'll pull in all the source code in the current - // directory. - if file_globs.is_empty() { - debug!("no source files specified. using default paths."); - file_globs.push("./**/*".to_string()); - } - - // We'll collect all the file paths in a collection here. - let mut file_paths = HashMap::new(); - - for file_glob in file_globs { - let path = base_dir.join(file_glob); - resolve_glob_path(path, &base_dir, &mut file_paths).await; - } - - // App code lives in the app dir - let app_dir = PathBuf::from("app"); - - // Now that we have all the paths, we'll append them to the builder. - for (physical_path, logical_path) in file_paths { - // All of the app code goes into the "app" directory. - let logical_path = app_dir.join(logical_path); - - let hash = compute_sha256_file(&physical_path).await?; - path_hashes.insert(logical_path.clone(), hash); - - builder.append_path_with_name(physical_path, logical_path).await?; - } - - // Module code lives in the modules dir. - let module_dir = PathBuf::from("modules"); - let mut import_paths = vec![]; - - // Now we need to package up all the modules to include in the code base too. - for import_path in &spec.import_paths { - // The import_path should always be relative to the base_path. - let import_path = base_dir.join(import_path).canonicalize()?; - let parent = import_path.parent().unwrap(); - - let mut file_paths = HashMap::new(); - resolve_path(&import_path, parent, &mut file_paths).await; - - // The file_name should constitute the logical path - let import_path = import_path.file_name().unwrap(); - let import_path = module_dir.join(import_path); - let import_path_str = import_path.into_os_string().into_string().unwrap(); - import_paths.push(import_path_str); - - // Now we write all of these paths to the modules directory. - for (physical_path, logical_path) in file_paths { - let logical_path = module_dir.join(logical_path); - - let hash = compute_sha256_file(&physical_path).await?; - path_hashes.insert(logical_path.clone(), hash); - - debug!("adding file {}", logical_path.display()); - builder.append_path_with_name(physical_path, logical_path).await?; - } - } - - let manifest = Manifest { - import_paths, - version: Some(CURRENT_PACKAGE_VERSION), - invoke: String::from(spec.invoke), - parameters: spec.parameters, - schedule: spec.schedule, - app_dir_name: app_dir.to_string_lossy().to_string(), - modules_dir_name: module_dir.to_string_lossy().to_string(), - checksum: compute_sha256_package(&path_hashes)?, - }; - - // the whole manifest needs to be written to a file as a convenient way to avoid having to - // manually populate the TAR file headers for this data. maybe in the future, someone will - // have the humption to do so here, thus avoiding an unnecessary file write (and the - // associated failure modes). - let manifest_path = tmp_dir.to_path_buf().join("MANIFEST"); - write_manifest_to_file(&manifest_path, &manifest).await?; - builder.append_path_with_name(manifest_path, "MANIFEST").await?; - - // Let's also package the Towerfile along with it. - builder.append_path_with_name( - spec.towerfile_path, - "Towerfile", - ).await?; - - let mut gzip = builder.into_inner().await?; - gzip.shutdown().await?; - - // probably not explicitly required; however, makes the test suite pass so... - let mut file = gzip.into_inner(); - file.shutdown().await?; - - Ok(Self { - manifest, - unpacked_path: None, - tmp_dir: Some(tmp_dir), - package_file_path: Some(package_path), - }) - } - - /// unpack is the primary interface in to unpacking a package. It will allocate a temporary - /// directory if one isn't already allocated and unpack the package contents into that location. - pub async fn unpack(&mut self) -> Result<(), Error> { - // If there's already a tmp_dir allocated to this package, then we'll use that. Otherwise, - // we allocate one and store it on this package for later use. - let path = if let Some(tmp_dir) = self.tmp_dir.as_ref() { - tmp_dir.to_path_buf() - } else { - let tmp_dir = TmpDir::new("tower-package").await?; - let path = tmp_dir.to_path_buf(); - self.tmp_dir = Some(tmp_dir); - path - }; - - // self.package_file_path should be set otherwise this is a bug. - let package_path = self.package_file_path.clone().unwrap(); - unpack_archive(&package_path, &path).await?; - self.unpacked_path = Some(path); - Ok(()) - } + pub fn default() -> Self { + Self { + tmp_dir: None, + package_file_path: None, + unpacked_path: None, + manifest: Manifest { + version: Some(CURRENT_PACKAGE_VERSION), + invoke: "".to_string(), + parameters: vec![], + schedule: None, + import_paths: vec![], + app_dir_name: "app".to_string(), + modules_dir_name: "modules".to_string(), + checksum: "".to_string(), + }, + } + } + + pub async fn from_unpacked_path(path: PathBuf) -> Self { + let manifest_path = path.join("MANIFEST"); + let manifest = Manifest::from_path(&manifest_path).await.unwrap(); + + Self { + tmp_dir: None, + package_file_path: None, + unpacked_path: Some(path), + manifest, + } + } + + // build creates a new package from a PackageSpec. PackageSpec is typically composed of fields + // copied from the Towerfile. The most important thing to know is that the collection of file + // globs to include in the package. + // + // The underlying package is just a TAR file with a special `MANIFEST` file that has also been + // GZip'd. + pub async fn build(spec: PackageSpec) -> Result { + debug!("building package from spec: {:?}", spec); + + // we canonicalize this because we want to treat all paths in the same keyspace more or + // less. + let base_dir = spec.base_dir.canonicalize()?; + + let tmp_dir = TmpDir::new("tower-package").await?; + let package_path = tmp_dir.to_path_buf().join("package.tar"); + debug!("building package at: {:?}", package_path); + + let file = File::create(package_path.clone()).await?; + let gzip = GzipEncoder::new(file); + let mut builder = Builder::new(gzip); + + // These help us compute the integrity of the package contents overall. For each path, we'll + // store a hash of the contents written to the file. Then we'll hash the final content to + // create a fingerprint of the data. + let mut path_hashes = HashMap::new(); + + // If the user didn't specify anything here we'll package everything under this directory + // and ship it to Tower. + let mut file_globs = spec.file_globs.clone(); + + // If there was no source specified, we'll pull in all the source code in the current + // directory. + if file_globs.is_empty() { + debug!("no source files specified. using default paths."); + file_globs.push("./**/*".to_string()); + } + + // We'll collect all the file paths in a collection here. + let mut file_paths = HashMap::new(); + + for file_glob in file_globs { + let path = base_dir.join(file_glob); + resolve_glob_path(path, &base_dir, &mut file_paths).await; + } + + // App code lives in the app dir + let app_dir = PathBuf::from("app"); + + // Now that we have all the paths, we'll append them to the builder. + for (physical_path, logical_path) in file_paths { + // All of the app code goes into the "app" directory. + let logical_path = app_dir.join(logical_path); + + let hash = compute_sha256_file(&physical_path).await?; + path_hashes.insert(logical_path.clone(), hash); + + builder + .append_path_with_name(physical_path, logical_path) + .await?; + } + + // Module code lives in the modules dir. + let module_dir = PathBuf::from("modules"); + let mut import_paths = vec![]; + + // Now we need to package up all the modules to include in the code base too. + for import_path in &spec.import_paths { + // The import_path should always be relative to the base_path. + let import_path = base_dir.join(import_path).canonicalize()?; + let parent = import_path.parent().unwrap(); + + let mut file_paths = HashMap::new(); + resolve_path(&import_path, parent, &mut file_paths).await; + + // The file_name should constitute the logical path + let import_path = import_path.file_name().unwrap(); + let import_path = module_dir.join(import_path); + let import_path_str = import_path.into_os_string().into_string().unwrap(); + import_paths.push(import_path_str); + + // Now we write all of these paths to the modules directory. + for (physical_path, logical_path) in file_paths { + let logical_path = module_dir.join(logical_path); + + let hash = compute_sha256_file(&physical_path).await?; + path_hashes.insert(logical_path.clone(), hash); + + debug!("adding file {}", logical_path.display()); + builder + .append_path_with_name(physical_path, logical_path) + .await?; + } + } + + let manifest = Manifest { + import_paths, + version: Some(CURRENT_PACKAGE_VERSION), + invoke: String::from(spec.invoke), + parameters: spec.parameters, + schedule: spec.schedule, + app_dir_name: app_dir.to_string_lossy().to_string(), + modules_dir_name: module_dir.to_string_lossy().to_string(), + checksum: compute_sha256_package(&path_hashes)?, + }; + + // the whole manifest needs to be written to a file as a convenient way to avoid having to + // manually populate the TAR file headers for this data. maybe in the future, someone will + // have the humption to do so here, thus avoiding an unnecessary file write (and the + // associated failure modes). + let manifest_path = tmp_dir.to_path_buf().join("MANIFEST"); + write_manifest_to_file(&manifest_path, &manifest).await?; + builder + .append_path_with_name(manifest_path, "MANIFEST") + .await?; + + // Let's also package the Towerfile along with it. + builder + .append_path_with_name(spec.towerfile_path, "Towerfile") + .await?; + + let mut gzip = builder.into_inner().await?; + gzip.shutdown().await?; + + // probably not explicitly required; however, makes the test suite pass so... + let mut file = gzip.into_inner(); + file.shutdown().await?; + + Ok(Self { + manifest, + unpacked_path: None, + tmp_dir: Some(tmp_dir), + package_file_path: Some(package_path), + }) + } + + /// unpack is the primary interface in to unpacking a package. It will allocate a temporary + /// directory if one isn't already allocated and unpack the package contents into that location. + pub async fn unpack(&mut self) -> Result<(), Error> { + // If there's already a tmp_dir allocated to this package, then we'll use that. Otherwise, + // we allocate one and store it on this package for later use. + let path = if let Some(tmp_dir) = self.tmp_dir.as_ref() { + tmp_dir.to_path_buf() + } else { + let tmp_dir = TmpDir::new("tower-package").await?; + let path = tmp_dir.to_path_buf(); + self.tmp_dir = Some(tmp_dir); + path + }; + + // self.package_file_path should be set otherwise this is a bug. + let package_path = self.package_file_path.clone().unwrap(); + unpack_archive(&package_path, &path).await?; + self.unpacked_path = Some(path); + Ok(()) + } } async fn write_manifest_to_file(path: &PathBuf, manifest: &Manifest) -> Result<(), Error> { @@ -375,10 +384,10 @@ async fn is_valid_gzip>(path: P) -> bool { Ok(file) => file, Err(_) => return false, }; - + let reader = BufReader::new(file); let mut decoder = GzipDecoder::new(reader); - + // Try to read a small amount of data. If we can, then we assume that it's a valid gzip file. // Othwewise, it's not gzipped I suppose? let mut buffer = [0u8; 1024]; @@ -388,7 +397,10 @@ async fn is_valid_gzip>(path: P) -> bool { } } -async fn unpack_archive>(package_path: P, output_path: P) -> Result<(), std::io::Error> { +async fn unpack_archive>( + package_path: P, + output_path: P, +) -> Result<(), std::io::Error> { let reader: Pin> = if is_valid_gzip(&package_path).await { // gor gzipped files let file = File::open(&package_path).await?; @@ -400,21 +412,25 @@ async fn unpack_archive>(package_path: P, output_path: P) -> Resu let file = File::open(&package_path).await?; Box::pin(file) }; - + // Create and unpack the archive let mut archive = Archive::new(reader); archive.unpack(output_path).await?; - + Ok(()) } -async fn resolve_glob_path(path: PathBuf, base_dir: &PathBuf, file_paths: &mut HashMap) { - let path_str = extract_glob_path(path); - debug!("resolving glob pattern: {}", path_str); +async fn resolve_glob_path( + path: PathBuf, + base_dir: &PathBuf, + file_paths: &mut HashMap, +) { + let path_str = extract_glob_path(path); + debug!("resolving glob pattern: {}", path_str); - for entry in glob(&path_str).unwrap() { - resolve_path(&entry.unwrap(), base_dir, file_paths).await; - } + for entry in glob(&path_str).unwrap() { + resolve_path(&entry.unwrap(), base_dir, file_paths).await; + } } async fn resolve_path(path: &PathBuf, base_dir: &Path, file_paths: &mut HashMap) { @@ -425,8 +441,12 @@ async fn resolve_path(path: &PathBuf, base_dir: &Path, file_paths: &mut HashMap< let canonical_path = current_path.canonicalize(); if canonical_path.is_err() { - debug!(" - skipping path {}: {}", current_path.display(), canonical_path.unwrap_err()); - continue; + debug!( + " - skipping path {}: {}", + current_path.display(), + canonical_path.unwrap_err() + ); + continue; } // We can safely unwrap this because we understand that it's not going to fail at this @@ -445,11 +465,20 @@ async fn resolve_path(path: &PathBuf, base_dir: &Path, file_paths: &mut HashMap< match cp.strip_prefix(base_dir) { Err(err) => { - debug!(" - skipping file {}: not in base directory {}: {:?}", physical_path.display(), base_dir.display(), err); + debug!( + " - skipping file {}: not in base directory {}: {:?}", + physical_path.display(), + base_dir.display(), + err + ); continue; } Ok(logical_path) => { - debug!(" - resolved path {} to logical path {}", physical_path.display(), logical_path.display()); + debug!( + " - resolved path {} to logical path {}", + physical_path.display(), + logical_path.display() + ); file_paths.insert(physical_path, logical_path.to_path_buf()); } } @@ -494,17 +523,17 @@ fn should_ignore_file(p: &PathBuf) -> bool { // Remove anything thats __pycache__ if is_in_dir(p, "__pycache__") { - return true + return true; } // Ignore anything that lives within a .git directory if is_in_dir(p, ".git") { - return true + return true; } // Ignore anything that's in a virtualenv, too if is_in_dir(p, ".venv") { - return true + return true; } return false; @@ -524,10 +553,10 @@ fn compute_sha256_package(path_hashes: &HashMap) -> Result Result { // Open the file let file = File::open(file_path).await?; let mut reader = BufReader::new(file); - + // Create a SHA256 hasher let mut hasher = Sha256::new(); - + // Read file in chunks to handle large files efficiently let mut buffer = [0; 8192]; // 8KB buffer loop { @@ -549,10 +578,10 @@ pub async fn compute_sha256_file(file_path: &PathBuf) -> Result { } hasher.update(&buffer[..bytes_read]); } - + // Finalize and get the hash result let result = hasher.finalize(); - + // Convert to hex string Ok(format!("{:x}", result)) } diff --git a/crates/tower-package/tests/package_test.rs b/crates/tower-package/tests/package_test.rs index c55e9f16..d7a6e437 100644 --- a/crates/tower-package/tests/package_test.rs +++ b/crates/tower-package/tests/package_test.rs @@ -1,19 +1,19 @@ use std::collections::HashMap; use std::path::PathBuf; +use async_compression::tokio::bufread::GzipDecoder; use tmpdir::TmpDir; use tokio::{ fs, fs::File, - io::{BufReader, AsyncReadExt, AsyncWriteExt}, + io::{AsyncReadExt, AsyncWriteExt, BufReader}, }; use tokio_stream::*; -use async_compression::tokio::bufread::GzipDecoder; +use config::Towerfile; use tokio_tar::Archive; -use tower_package::{Package, PackageSpec, Manifest}; +use tower_package::{Manifest, Package, PackageSpec}; use tower_telemetry::debug; -use config::Towerfile; macro_rules! make_path { ($($component:expr),+ $(,)?) => { @@ -29,10 +29,17 @@ macro_rules! make_path { #[tokio::test] async fn it_creates_package() { - let tmp_dir = TmpDir::new("example").await.expect("Failed to create temp dir"); + let tmp_dir = TmpDir::new("example") + .await + .expect("Failed to create temp dir"); create_test_file(tmp_dir.to_path_buf(), "Towerfile", "").await; create_test_file(tmp_dir.to_path_buf(), "main.py", "print('Hello, world!')").await; - create_test_file(tmp_dir.to_path_buf(), "requirements.txt", "requests==2.25.1").await; + create_test_file( + tmp_dir.to_path_buf(), + "requirements.txt", + "requests==2.25.1", + ) + .await; let spec = PackageSpec { invoke: "main.py".to_string(), @@ -54,13 +61,23 @@ async fn it_creates_package() { let files = read_package_files(package).await; - assert!(files.contains_key("app/main.py"), "files {:?} was missing key main.py", files); - assert!(files.contains_key("MANIFEST"), "files {:?} was missing MANIFEST", files); + assert!( + files.contains_key("app/main.py"), + "files {:?} was missing key main.py", + files + ); + assert!( + files.contains_key("MANIFEST"), + "files {:?} was missing MANIFEST", + files + ); } #[tokio::test] async fn it_respects_complex_file_globs() { - let tmp_dir = TmpDir::new("example").await.expect("Failed to create temp dir"); + let tmp_dir = TmpDir::new("example") + .await + .expect("Failed to create temp dir"); create_test_file(tmp_dir.to_path_buf(), "Towerfile", "").await; create_test_file(tmp_dir.to_path_buf(), "main.py", "print('Hello, world!')").await; create_test_file(tmp_dir.to_path_buf(), "pack/__init__.py", "").await; @@ -70,10 +87,7 @@ async fn it_respects_complex_file_globs() { invoke: "main.py".to_string(), base_dir: tmp_dir.to_path_buf(), towerfile_path: tmp_dir.to_path_buf().join("Towerfile").to_path_buf(), - file_globs: vec![ - "*.py".to_string(), - "**/*.py".to_string(), - ], + file_globs: vec!["*.py".to_string(), "**/*.py".to_string()], parameters: vec![], schedule: Some("every 1 minute".to_string()), import_paths: vec![], @@ -83,21 +97,38 @@ async fn it_respects_complex_file_globs() { assert_eq!(package.manifest.version, Some(2)); assert_eq!(package.manifest.invoke, "main.py"); - assert_eq!(package.manifest.schedule, Some("every 1 minute".to_string())); + assert_eq!( + package.manifest.schedule, + Some("every 1 minute".to_string()) + ); let package_file_path = package.package_file_path.clone().unwrap(); assert!(!package_file_path.as_os_str().is_empty()); let files = read_package_files(package).await; - assert!(files.contains_key("app/main.py"), "files {:?} was missing key main.py", files); - assert!(files.contains_key("MANIFEST"), "files {:?} was missing MANIFEST", files); - assert!(files.contains_key("app/pack/__init__.py"), "files {:?} was missing pack/__init__.py", files); + assert!( + files.contains_key("app/main.py"), + "files {:?} was missing key main.py", + files + ); + assert!( + files.contains_key("MANIFEST"), + "files {:?} was missing MANIFEST", + files + ); + assert!( + files.contains_key("app/pack/__init__.py"), + "files {:?} was missing pack/__init__.py", + files + ); } #[tokio::test] async fn it_packages_all_files_by_default() { - let tmp_dir = TmpDir::new("all-files-by-default").await.expect("Failed to create temp dir"); + let tmp_dir = TmpDir::new("all-files-by-default") + .await + .expect("Failed to create temp dir"); create_test_file(tmp_dir.to_path_buf(), "Towerfile", "").await; create_test_file(tmp_dir.to_path_buf(), "main.py", "print('Hello, world!')").await; create_test_file(tmp_dir.to_path_buf(), "pack/__init__.py", "").await; @@ -119,15 +150,33 @@ async fn it_packages_all_files_by_default() { assert!(!package_file_path.as_os_str().is_empty()); let files = read_package_files(package).await; - assert!(files.contains_key("MANIFEST"), "files {:?} was missing MANIFEST", files); - assert!(files.contains_key("app/main.py"), "files {:?} was missing key main.py", files); - assert!(files.contains_key("app/pack/__init__.py"), "files {:?} was missing pack/__init__.py", files); - assert!(files.contains_key("app/pack/pack.py"), "files {:?} was missing pack/__init__.py", files); + assert!( + files.contains_key("MANIFEST"), + "files {:?} was missing MANIFEST", + files + ); + assert!( + files.contains_key("app/main.py"), + "files {:?} was missing key main.py", + files + ); + assert!( + files.contains_key("app/pack/__init__.py"), + "files {:?} was missing pack/__init__.py", + files + ); + assert!( + files.contains_key("app/pack/pack.py"), + "files {:?} was missing pack/__init__.py", + files + ); } #[tokio::test] async fn it_packages_directory_contents() { - let tmp_dir = TmpDir::new("directory-contents").await.expect("Failed to create temp dir"); + let tmp_dir = TmpDir::new("directory-contents") + .await + .expect("Failed to create temp dir"); create_test_file(tmp_dir.to_path_buf(), "Towerfile", "").await; create_test_file(tmp_dir.to_path_buf(), "main.py", "print('Hello, world!')").await; create_test_file(tmp_dir.to_path_buf(), "pack/__init__.py", "").await; @@ -138,10 +187,7 @@ async fn it_packages_directory_contents() { invoke: "main.py".to_string(), base_dir: tmp_dir.to_path_buf(), towerfile_path: tmp_dir.to_path_buf().join("Towerfile").to_path_buf(), - file_globs: vec![ - "main.py".to_string(), - "pack".to_string(), - ], + file_globs: vec!["main.py".to_string(), "pack".to_string()], parameters: vec![], schedule: Some("every 1 minute".to_string()), import_paths: vec![], @@ -153,28 +199,57 @@ async fn it_packages_directory_contents() { assert!(!package_file_path.as_os_str().is_empty()); let files = read_package_files(package).await; - assert!(files.contains_key("MANIFEST"), "files {:?} was missing MANIFEST", files); - assert!(files.contains_key("app/main.py"), "files {:?} was missing key main.py", files); - assert!(files.contains_key("app/pack/__init__.py"), "files {:?} was missing pack/__init__.py", files); - assert!(files.contains_key("app/pack/pack.py"), "files {:?} was missing pack/__init__.py", files); - assert!(files.contains_key("app/pack/submodule/pack.py"), "files {:?} was missing pack/submodule/pack.py", files); + assert!( + files.contains_key("MANIFEST"), + "files {:?} was missing MANIFEST", + files + ); + assert!( + files.contains_key("app/main.py"), + "files {:?} was missing key main.py", + files + ); + assert!( + files.contains_key("app/pack/__init__.py"), + "files {:?} was missing pack/__init__.py", + files + ); + assert!( + files.contains_key("app/pack/pack.py"), + "files {:?} was missing pack/__init__.py", + files + ); + assert!( + files.contains_key("app/pack/submodule/pack.py"), + "files {:?} was missing pack/submodule/pack.py", + files + ); } #[tokio::test] async fn it_packages_import_paths() { - let tmp_dir = TmpDir::new("example").await.expect("Failed to create temp dir"); + let tmp_dir = TmpDir::new("example") + .await + .expect("Failed to create temp dir"); create_test_file(tmp_dir.to_path_buf(), "app/Towerfile", "").await; - create_test_file(tmp_dir.to_path_buf(), "app/main.py", "print('Hello, world!')").await; + create_test_file( + tmp_dir.to_path_buf(), + "app/main.py", + "print('Hello, world!')", + ) + .await; create_test_file(tmp_dir.to_path_buf(), "shared/module/__init__.py", "").await; create_test_file(tmp_dir.to_path_buf(), "shared/module/test.py", "").await; let spec = PackageSpec { invoke: "main.py".to_string(), base_dir: tmp_dir.to_path_buf().join("app"), - towerfile_path: tmp_dir.to_path_buf().join("app").join("Towerfile").to_path_buf(), - file_globs: vec![ - "**/*.py".to_string(), - ], + towerfile_path: tmp_dir + .to_path_buf() + .join("app") + .join("Towerfile") + .to_path_buf(), + file_globs: vec!["**/*.py".to_string()], parameters: vec![], schedule: None, import_paths: vec!["../shared".to_string()], @@ -188,30 +263,74 @@ async fn it_packages_import_paths() { let files = read_package_files(package).await; - assert!(files.contains_key("MANIFEST"), "files {:?} was missing MANIFEST", files); - assert!(files.contains_key("app/main.py"), "files {:?} was missing key app/main.py", files); - assert!(files.contains_key("modules/shared/module/__init__.py"), "files {:?} was missing shared/module/__init__.py", files); - assert!(files.contains_key("modules/shared/module/test.py"), "files {:?} was missing shared/module/test.py", files); + assert!( + files.contains_key("MANIFEST"), + "files {:?} was missing MANIFEST", + files + ); + assert!( + files.contains_key("app/main.py"), + "files {:?} was missing key app/main.py", + files + ); + assert!( + files.contains_key("modules/shared/module/__init__.py"), + "files {:?} was missing shared/module/__init__.py", + files + ); + assert!( + files.contains_key("modules/shared/module/test.py"), + "files {:?} was missing shared/module/test.py", + files + ); // Let's decode the manifest and make sure import paths are set correctly. - let manifest = Manifest::from_json(files.get("MANIFEST").unwrap()).await.expect("Manifest was not valid JSON"); + let manifest = Manifest::from_json(files.get("MANIFEST").unwrap()) + .await + .expect("Manifest was not valid JSON"); // NOTE: These paths are joined by the OS so we need to be more specific about the expected // path. - assert!(manifest.import_paths.contains(make_path!("modules", "shared")), "Import paths {:?} did not contain expected path", manifest.import_paths); + assert!( + manifest + .import_paths + .contains(make_path!("modules", "shared")), + "Import paths {:?} did not contain expected path", + manifest.import_paths + ); // We should have some integrity check here too. - assert!(!manifest.checksum.is_empty(), "Manifest integrity check was not set"); + assert!( + !manifest.checksum.is_empty(), + "Manifest integrity check was not set" + ); } #[tokio::test] async fn it_excludes_various_content_that_should_not_be_there() { - let tmp_dir = TmpDir::new("example").await.expect("Failed to create temp dir"); + let tmp_dir = TmpDir::new("example") + .await + .expect("Failed to create temp dir"); create_test_file(tmp_dir.to_path_buf(), "Towerfile", "").await; create_test_file(tmp_dir.to_path_buf(), "main.py", "print('Hello, world!')").await; - create_test_file(tmp_dir.to_path_buf(), "main.py.pyc", "print('Hello, world!')").await; - create_test_file(tmp_dir.to_path_buf(), "some-app/test.py", "print('Hello, world!')").await; - create_test_file(tmp_dir.to_path_buf(), "some-app/__pycache__/test.pyc", "print('Hello, world!')").await; + create_test_file( + tmp_dir.to_path_buf(), + "main.py.pyc", + "print('Hello, world!')", + ) + .await; + create_test_file( + tmp_dir.to_path_buf(), + "some-app/test.py", + "print('Hello, world!')", + ) + .await; + create_test_file( + tmp_dir.to_path_buf(), + "some-app/__pycache__/test.pyc", + "print('Hello, world!')", + ) + .await; create_test_file(tmp_dir.to_path_buf(), ".git/some-file", "").await; let spec = PackageSpec { @@ -227,9 +346,21 @@ async fn it_excludes_various_content_that_should_not_be_there() { let package = Package::build(spec).await.expect("Failed to build package"); let files = read_package_files(package).await; - assert!(!files.contains_key(".git/some-file"), "files {:?} had .git directory", files); - assert!(!files.contains_key("some-app/__pycache__/test.pyc"), "files {:?} contained a .pyc", files); - assert!(!files.contains_key("main.py.pyc"), "files {:?} contained a .pyc", files); + assert!( + !files.contains_key(".git/some-file"), + "files {:?} had .git directory", + files + ); + assert!( + !files.contains_key("some-app/__pycache__/test.pyc"), + "files {:?} contained a .pyc", + files + ); + assert!( + !files.contains_key("main.py.pyc"), + "files {:?} contained a .pyc", + files + ); } #[tokio::test] @@ -259,14 +390,20 @@ async fn building_package_spec_from_towerfile() { async fn read_package_files(package: Package) -> HashMap { // Now we should crack open the file to make sure that we can find the relevant contents within // it. - let package_file_path = package.package_file_path.expect("Failed to get package file path"); - let file = File::open(package_file_path).await.expect("Failed to open package file"); + let package_file_path = package + .package_file_path + .expect("Failed to get package file path"); + let file = File::open(package_file_path) + .await + .expect("Failed to open package file"); let buf = BufReader::new(file); // TODO: Re-enable this when we reintroduce gzip compression let gzip = GzipDecoder::new(buf); let mut archive = Archive::new(gzip); - let mut entries = archive.entries().expect("Failed to get entries from archive"); + let mut entries = archive + .entries() + .expect("Failed to get entries from archive"); let mut files = HashMap::new(); @@ -275,10 +412,13 @@ async fn read_package_files(package: Package) -> HashMap { let contents = read_async_to_string(&mut file).await; let path = file.path().expect("Failed to get path from file"); - let path = path.to_str().expect("Failed to convert path to string").to_string(); + let path = path + .to_str() + .expect("Failed to convert path to string") + .to_string(); files.insert(path, contents); } - + files } @@ -287,13 +427,20 @@ async fn create_test_file(tempdir: PathBuf, path: &str, contents: &str) { if let Some(parent) = path.parent() { if !parent.exists() { - fs::create_dir_all(&parent).await.expect("Failed to create file directory"); + fs::create_dir_all(&parent) + .await + .expect("Failed to create file directory"); } } - debug!("creating test file at: {:?} with content {:?}", path, contents); + debug!( + "creating test file at: {:?} with content {:?}", + path, contents + ); let mut file = File::create(&path).await.expect("Failed to create file"); - file.write_all(contents.as_bytes()).await.expect("Failed to write content to file") + file.write_all(contents.as_bytes()) + .await + .expect("Failed to write content to file") } async fn read_async_to_string(reader: &mut R) -> String @@ -301,6 +448,9 @@ where R: AsyncReadExt + Unpin, { let mut content = String::new(); - reader.read_to_string(&mut content).await.expect("Failed to read string from stream"); + reader + .read_to_string(&mut content) + .await + .expect("Failed to read string from stream"); content } diff --git a/crates/tower-runtime/src/errors.rs b/crates/tower-runtime/src/errors.rs index 73c1b7cc..19c8ed10 100644 --- a/crates/tower-runtime/src/errors.rs +++ b/crates/tower-runtime/src/errors.rs @@ -81,13 +81,13 @@ impl From for Error { impl From for Error { fn from(err: tower_uv::Error) -> Self { match err { - tower_uv::Error::IoError(_) => Error::SpawnFailed, - tower_uv::Error::NotFound(_) => Error::SpawnFailed, - tower_uv::Error::PermissionDenied(_) => Error::SpawnFailed, - tower_uv::Error::Other(_) => Error::SpawnFailed, - tower_uv::Error::MissingPyprojectToml => Error::SpawnFailed, - tower_uv::Error::InvalidUv => Error::SpawnFailed, - tower_uv::Error::UnsupportedPlatform => Error::UnsupportedPlatform, + tower_uv::Error::IoError(_) => Error::SpawnFailed, + tower_uv::Error::NotFound(_) => Error::SpawnFailed, + tower_uv::Error::PermissionDenied(_) => Error::SpawnFailed, + tower_uv::Error::Other(_) => Error::SpawnFailed, + tower_uv::Error::MissingPyprojectToml => Error::SpawnFailed, + tower_uv::Error::InvalidUv => Error::SpawnFailed, + tower_uv::Error::UnsupportedPlatform => Error::UnsupportedPlatform, } } } diff --git a/crates/tower-runtime/src/lib.rs b/crates/tower-runtime/src/lib.rs index bae6807a..c5b8b35b 100644 --- a/crates/tower-runtime/src/lib.rs +++ b/crates/tower-runtime/src/lib.rs @@ -1,17 +1,14 @@ -use std::path::PathBuf; -use std::future::Future; -use std::collections::HashMap; -use tokio::sync::mpsc::{ - UnboundedReceiver, - UnboundedSender, -}; use chrono::{DateTime, Utc}; +use std::collections::HashMap; +use std::future::Future; +use std::path::PathBuf; +use tokio::sync::mpsc::{UnboundedReceiver, UnboundedSender}; use tower_package::Package; use tower_telemetry::debug; -pub mod local; pub mod errors; +pub mod local; use errors::Error; @@ -53,12 +50,13 @@ pub type OutputSender = UnboundedSender; pub trait App { // start will start the process fn start(opts: StartOptions) -> impl Future> + Send - where Self: Sized; + where + Self: Sized; // terminate will terminate the subprocess fn terminate(&mut self) -> impl Future> + Send; - // status checks the status of an app + // status checks the status of an app fn status(&self) -> impl Future> + Send; } @@ -68,9 +66,7 @@ pub struct AppLauncher { impl std::default::Default for AppLauncher { fn default() -> Self { - Self { - app: None, - } + Self { app: None } } } diff --git a/crates/tower-runtime/src/local.rs b/crates/tower-runtime/src/local.rs index 5c207c69..b7a44ac3 100644 --- a/crates/tower-runtime/src/local.rs +++ b/crates/tower-runtime/src/local.rs @@ -1,29 +1,21 @@ -use std::path::PathBuf; +use std::collections::HashMap; use std::env; +use std::path::PathBuf; use std::process::Stdio; -use std::collections::HashMap; #[cfg(unix)] use std::os::unix::fs::PermissionsExt; -use crate::{ - Status, - StartOptions, - OutputSender, - errors::Error, -}; +use crate::{errors::Error, OutputSender, StartOptions, Status}; use tokio::{ fs, - io::{AsyncRead, BufReader, AsyncBufReadExt}, - process::{Child, Command}, + io::{AsyncBufReadExt, AsyncRead, BufReader}, + process::{Child, Command}, runtime::Handle, sync::{ + oneshot::{self, error::TryRecvError}, Mutex, - oneshot::{ - self, - error::TryRecvError, - }, }, task::JoinHandle, time::{timeout, Duration}, @@ -31,11 +23,8 @@ use tokio::{ #[cfg(unix)] use nix::{ + sys::signal::{killpg, Signal}, unistd::Pid, - sys::signal::{ - Signal, - killpg, - }, }; use tokio_util::sync::CancellationToken; @@ -44,12 +33,7 @@ use tower_package::{Manifest, Package}; use tower_telemetry::debug; use tower_uv::Uv; -use crate::{ - FD, - Channel, - App, - Output, -}; +use crate::{App, Channel, Output, FD}; pub struct LocalApp { status: Mutex>, @@ -115,14 +99,15 @@ async fn find_bash() -> Result { } } -async fn execute_local_app(opts: StartOptions, sx: oneshot::Sender, cancel_token: CancellationToken) -> Result<(), Error> { +async fn execute_local_app( + opts: StartOptions, + sx: oneshot::Sender, + cancel_token: CancellationToken, +) -> Result<(), Error> { let ctx = opts.ctx.clone(); let package = opts.package; let environment = opts.environment; - let package_path = package.unpacked_path - .clone() - .unwrap() - .to_path_buf(); + let package_path = package.unpacked_path.clone().unwrap().to_path_buf(); // set for later on. let working_dir = if package.manifest.version == Some(2) { @@ -141,7 +126,9 @@ async fn execute_local_app(opts: StartOptions, sx: oneshot::Sender, cancel_ if !package.manifest.import_paths.is_empty() { debug!(ctx: &ctx, "adding import paths to PYTHONPATH: {:?}", package.manifest.import_paths); - let import_paths = package.manifest.import_paths + let import_paths = package + .manifest + .import_paths .iter() .map(|p| package_path.join(p)) .collect::>(); @@ -186,12 +173,20 @@ async fn execute_local_app(opts: StartOptions, sx: oneshot::Sender, cancel_ secrets, params, other_env_vars, - ).await?; + ) + .await?; let _ = sx.send(wait_for_process(ctx.clone(), &cancel_token, child).await); - } else { + } else { let uv = Uv::new().await?; - let env_vars = make_env_vars(&ctx, &environment, &package_path, &secrets, ¶ms, &other_env_vars); + let env_vars = make_env_vars( + &ctx, + &environment, + &package_path, + &secrets, + ¶ms, + &other_env_vars, + ); // Now we also need to find the program to execute. let program_path = working_dir.join(&manifest.invoke); @@ -208,10 +203,20 @@ async fn execute_local_app(opts: StartOptions, sx: oneshot::Sender, cancel_ // Drain the logs to the output channel. let stdout = child.stdout.take().expect("no stdout"); - tokio::spawn(drain_output(FD::Stdout, Channel::Setup, opts.output_sender.clone(), BufReader::new(stdout))); + tokio::spawn(drain_output( + FD::Stdout, + Channel::Setup, + opts.output_sender.clone(), + BufReader::new(stdout), + )); let stderr = child.stderr.take().expect("no stderr"); - tokio::spawn(drain_output(FD::Stderr, Channel::Setup, opts.output_sender.clone(), BufReader::new(stderr))); + tokio::spawn(drain_output( + FD::Stderr, + Channel::Setup, + opts.output_sender.clone(), + BufReader::new(stderr), + )); // Wait for venv to finish up. wait_for_process(ctx.clone(), &cancel_token, child).await; @@ -227,7 +232,7 @@ async fn execute_local_app(opts: StartOptions, sx: oneshot::Sender, cancel_ match uv.sync(&working_dir, &env_vars).await { Err(e) => { // If we were missing a pyproject.toml, then that's fine for us--we'll just - // continue execution. + // continue execution. // // Note that we do a match here instead of an if. That's because of the way // tower_uv::Error is implemented. Namely, it doesn't implement PartialEq and can't @@ -235,20 +240,30 @@ async fn execute_local_app(opts: StartOptions, sx: oneshot::Sender, cancel_ match e { tower_uv::Error::MissingPyprojectToml => { debug!(ctx: &ctx, "no pyproject.toml found, continuing without sync"); - }, + } _ => { // If we got any other error, we want to return it. return Err(e.into()); } } - }, + } Ok(mut child) => { // Drain the logs to the output channel. let stdout = child.stdout.take().expect("no stdout"); - tokio::spawn(drain_output(FD::Stdout, Channel::Setup, opts.output_sender.clone(), BufReader::new(stdout))); + tokio::spawn(drain_output( + FD::Stdout, + Channel::Setup, + opts.output_sender.clone(), + BufReader::new(stdout), + )); let stderr = child.stderr.take().expect("no stderr"); - tokio::spawn(drain_output(FD::Stderr, Channel::Setup, opts.output_sender.clone(), BufReader::new(stderr))); + tokio::spawn(drain_output( + FD::Stderr, + Channel::Setup, + opts.output_sender.clone(), + BufReader::new(stderr), + )); // Let's wait for the setup to finish. We don't care about the results. wait_for_process(ctx.clone(), &cancel_token, child).await; @@ -267,23 +282,33 @@ async fn execute_local_app(opts: StartOptions, sx: oneshot::Sender, cancel_ // Drain the logs to the output channel. let stdout = child.stdout.take().expect("no stdout"); - tokio::spawn(drain_output(FD::Stdout, Channel::Program, opts.output_sender.clone(), BufReader::new(stdout))); + tokio::spawn(drain_output( + FD::Stdout, + Channel::Program, + opts.output_sender.clone(), + BufReader::new(stdout), + )); let stderr = child.stderr.take().expect("no stderr"); - tokio::spawn(drain_output(FD::Stderr, Channel::Program, opts.output_sender.clone(), BufReader::new(stderr))); + tokio::spawn(drain_output( + FD::Stderr, + Channel::Program, + opts.output_sender.clone(), + BufReader::new(stderr), + )); let _ = sx.send(wait_for_process(ctx.clone(), &cancel_token, child).await); } // Everything was properly executed I suppose. - return Ok(()) -} + return Ok(()); +} impl Drop for LocalApp { fn drop(&mut self) { // CancellationToken::cancel() is not async self.terminator.cancel(); - + // Optionally spawn a task to wait for the handle if let Some(execute_handle) = self.execute_handle.take() { if let Ok(handle) = Handle::try_current() { @@ -345,9 +370,9 @@ impl App for LocalApp { // Now we should wait for the join handle to finish. if let Some(execute_handle) = self.execute_handle.take() { - let _ = execute_handle.await; + let _ = execute_handle.await; self.execute_handle = None; - } + } Ok(()) } @@ -374,7 +399,14 @@ async fn execute_bash_program( .stdin(Stdio::null()) .stdout(Stdio::piped()) .stderr(Stdio::piped()) - .envs(make_env_vars(&ctx, env, &cwd, &secrets, ¶ms, &other_env_vars)) + .envs(make_env_vars( + &ctx, + env, + &cwd, + &secrets, + ¶ms, + &other_env_vars, + )) .kill_on_drop(true) .spawn()?; @@ -384,13 +416,23 @@ async fn execute_bash_program( fn make_env_var_key(src: &str) -> String { // TODO: We have this special case defined for dltHub, and I'm not sure that we want to... if src.starts_with("dlt.") { - src.strip_prefix("dlt.").unwrap().to_uppercase().replace(".", "__") + src.strip_prefix("dlt.") + .unwrap() + .to_uppercase() + .replace(".", "__") } else { src.to_string() } } -fn make_env_vars(ctx: &tower_telemetry::Context, env: &str, cwd: &PathBuf, secs: &HashMap, params: &HashMap, other_env_vars: &HashMap) -> HashMap { +fn make_env_vars( + ctx: &tower_telemetry::Context, + env: &str, + cwd: &PathBuf, + secs: &HashMap, + params: &HashMap, + other_env_vars: &HashMap, +) -> HashMap { let mut res = HashMap::new(); debug!(ctx: &ctx, "converting {} env variables", (params.len() + secs.len())); @@ -455,24 +497,15 @@ async fn kill_child_process(ctx: &tower_telemetry::Context, mut child: Child) { // We first send a SIGTERM to ensure that the child processes are terminated. Using SIGKILL // (default behavior in Child::kill) can leave orphaned processes behind. - killpg( - pid, - Signal::SIGTERM - ).ok(); - + killpg(pid, Signal::SIGTERM).ok(); + // If it doesn't die after 2 seconds then we'll forcefully kill it. This timeout should be less // than the overall timeout for the process (which should likely live on the context as a // deadline). - let timeout = timeout( - Duration::from_secs(2), - child.wait() - ).await; - + let timeout = timeout(Duration::from_secs(2), child.wait()).await; + if timeout.is_err() { - killpg( - pid, - Signal::SIGKILL - ).ok(); + killpg(pid, Signal::SIGKILL).ok(); } } @@ -484,7 +517,11 @@ async fn kill_child_process(ctx: &tower_telemetry::Context, mut child: Child) { }; } -async fn wait_for_process(ctx: tower_telemetry::Context, cancel_token: &CancellationToken, mut child: Child) -> i32 { +async fn wait_for_process( + ctx: tower_telemetry::Context, + cancel_token: &CancellationToken, + mut child: Child, +) -> i32 { let code = loop { if cancel_token.is_cancelled() { debug!(ctx: &ctx, "process cancelled, terminating child process"); @@ -511,11 +548,16 @@ async fn wait_for_process(ctx: tower_telemetry::Context, cancel_token: &Cancella code } -async fn drain_output(fd: FD, channel: Channel, output: OutputSender, input: BufReader) { +async fn drain_output( + fd: FD, + channel: Channel, + output: OutputSender, + input: BufReader, +) { let mut lines = input.lines(); while let Some(line) = lines.next_line().await.expect("line iteration fialed") { - let _ = output.send(Output{ + let _ = output.send(Output { channel, fd, line, @@ -525,5 +567,5 @@ async fn drain_output(fd: FD, channel: Channel, output: Ou } fn is_bash_package(package: &Package) -> bool { - return package.manifest.invoke.ends_with(".sh") + return package.manifest.invoke.ends_with(".sh"); } diff --git a/crates/tower-runtime/tests/local_test.rs b/crates/tower-runtime/tests/local_test.rs index 8457d4ad..87b34d95 100644 --- a/crates/tower-runtime/tests/local_test.rs +++ b/crates/tower-runtime/tests/local_test.rs @@ -1,12 +1,7 @@ use std::collections::HashMap; use std::path::PathBuf; -use tower_runtime::{ - App, - StartOptions, - Status, - local::LocalApp, -}; +use tower_runtime::{local::LocalApp, App, StartOptions, Status}; use config::Towerfile; use tower_package::{Package, PackageSpec}; @@ -29,9 +24,11 @@ fn get_example_app_dir(name: &str) -> PathBuf { } async fn build_package_from_dir(dir: &PathBuf) -> Package { - let towerfile = Towerfile::from_path(dir.join("Towerfile")).expect("Failed to load Towerfile"); + let towerfile = Towerfile::from_path(dir.join("Towerfile")).expect("Failed to load Towerfile"); let spec = PackageSpec::from_towerfile(&towerfile); - let mut package = Package::build(spec).await.expect("Failed to build package from directory"); + let mut package = Package::build(spec) + .await + .expect("Failed to build package from directory"); package.unpack().await.expect("Failed to unpack package"); package } @@ -50,7 +47,7 @@ async fn test_running_hello_world() { let (sender, mut receiver) = unbounded_channel(); // We need to create the package, which will load the app - let opts = StartOptions{ + let opts = StartOptions { ctx: tower_telemetry::Context::new(), package, output_sender: sender, @@ -69,12 +66,15 @@ async fn test_running_hello_world() { assert!(status == Status::Running, "App should be running"); while let Some(output) = receiver.recv().await { - let valid_line = output.line.contains("Hello, world!") || - output.line.contains("Using CPython") || - output.line.contains("Creating virtual environment") || - output.line.contains("Activate with"); - - assert!(valid_line, "Log should contain 'Hello, world!' or a setup line"); + let valid_line = output.line.contains("Hello, world!") + || output.line.contains("Using CPython") + || output.line.contains("Creating virtual environment") + || output.line.contains("Activate with"); + + assert!( + valid_line, + "Log should contain 'Hello, world!' or a setup line" + ); } // check the status once more, should be done. @@ -92,7 +92,7 @@ async fn test_running_use_faker() { let (sender, mut receiver) = unbounded_channel(); // We need to create the package, which will load the app - let opts = StartOptions{ + let opts = StartOptions { ctx: tower_telemetry::Context::new(), package, output_sender: sender, @@ -118,7 +118,7 @@ async fn test_running_use_faker() { match output.channel { tower_runtime::Channel::Setup => { count_setup += 1; - }, + } tower_runtime::Channel::Program => { count_stdout += 1; } @@ -143,7 +143,7 @@ async fn test_running_legacy_app() { let (sender, mut receiver) = unbounded_channel(); // We need to create the package, which will load the app - let opts = StartOptions{ + let opts = StartOptions { ctx: tower_telemetry::Context::new(), package, output_sender: sender, @@ -169,7 +169,7 @@ async fn test_running_legacy_app() { match output.channel { tower_runtime::Channel::Setup => { count_setup += 1; - }, + } tower_runtime::Channel::Program => { count_stdout += 1; } diff --git a/crates/tower-telemetry/src/lib.rs b/crates/tower-telemetry/src/lib.rs index 733049c2..fa361d57 100644 --- a/crates/tower-telemetry/src/lib.rs +++ b/crates/tower-telemetry/src/lib.rs @@ -1,13 +1,8 @@ -pub mod logging; pub mod context; +pub mod logging; /// reexport tracing to make sure that it gets included everywhere. pub use tracing; pub use context::Context; -pub use logging::{ - LogFormat, - LogDestination, - LogLevel, - enable_logging -}; +pub use logging::{enable_logging, LogDestination, LogFormat, LogLevel}; diff --git a/crates/tower-telemetry/src/logging.rs b/crates/tower-telemetry/src/logging.rs index 60e0e104..743fcc6f 100644 --- a/crates/tower-telemetry/src/logging.rs +++ b/crates/tower-telemetry/src/logging.rs @@ -1,10 +1,5 @@ use tracing_subscriber::prelude::*; -use tracing_subscriber::{ - registry::Registry, - layer::Layer, - filter::EnvFilter, - fmt, -}; +use tracing_subscriber::{filter::EnvFilter, fmt, layer::Layer, registry::Registry}; #[macro_export] macro_rules! event_with_level { @@ -171,29 +166,23 @@ type BoxedFmtLayer = Box + Send + Sync>; fn create_fmt_layer(format: LogFormat, destination: LogDestination) -> BoxedFmtLayer { match destination { - LogDestination::Stdout => { - match format { - LogFormat::Plain => Box::new(fmt::layer().event_format(fmt::format().pretty())), - LogFormat::Json => Box::new(fmt::layer().event_format(fmt::format().json())), - } - } + LogDestination::Stdout => match format { + LogFormat::Plain => Box::new(fmt::layer().event_format(fmt::format().pretty())), + LogFormat::Json => Box::new(fmt::layer().event_format(fmt::format().json())), + }, LogDestination::File(path) => { let file_appender = tracing_appender::rolling::daily(".", path); match format { - LogFormat::Plain => { - Box::new( - fmt::layer() - .event_format(fmt::format().pretty()) - .with_writer(file_appender) - ) - } - LogFormat::Json => { - Box::new( - fmt::layer() - .event_format(fmt::format().json()) - .with_writer(file_appender) - ) - } + LogFormat::Plain => Box::new( + fmt::layer() + .event_format(fmt::format().pretty()) + .with_writer(file_appender), + ), + LogFormat::Json => Box::new( + fmt::layer() + .event_format(fmt::format().json()) + .with_writer(file_appender), + ), } } } diff --git a/crates/tower-uv/src/install.rs b/crates/tower-uv/src/install.rs index d3c052c0..3f0c7147 100644 --- a/crates/tower-uv/src/install.rs +++ b/crates/tower-uv/src/install.rs @@ -2,14 +2,11 @@ use std::env; use std::path::PathBuf; use std::sync::OnceLock; -use tokio_tar::Archive; -use tokio::{ - sync::Mutex, - process::Command, -}; use async_compression::tokio::bufread::GzipDecoder; use async_zip::tokio::read::seek::ZipFileReader; use futures_lite::io::AsyncReadExt; +use tokio::{process::Command, sync::Mutex}; +use tokio_tar::Archive; use tower_telemetry::debug; @@ -55,17 +52,17 @@ impl ArchiveSelector { pub async fn get_archive_name() -> Result { let arch = env::consts::ARCH; let os = env::consts::OS; - + match (arch, os) { // macOS ("aarch64", "macos") => Ok("uv-aarch64-apple-darwin.tar.gz".to_string()), ("x86_64", "macos") => Ok("uv-x86_64-apple-darwin.tar.gz".to_string()), - + // Windows ("aarch64", "windows") => Ok("uv-aarch64-pc-windows-msvc.zip".to_string()), ("x86_64", "windows") => Ok("uv-x86_64-pc-windows-msvc.zip".to_string()), ("x86", "windows") => Ok("uv-i686-pc-windows-msvc.zip".to_string()), - + // Linux ("aarch64", "linux") => { if Self::is_musl_target() { @@ -135,68 +132,64 @@ impl ArchiveSelector { Err("s390x requires glibc 2.17 or newer".to_string()) } } - + _ => Err(format!("Unsupported platform: {} {}", arch, os)), } } - + /// Check if the current target uses musl libc fn is_musl_target() -> bool { // Check if we're compiled with musl cfg!(target_env = "musl") } - + /// Check if glibc version meets minimum requirements async fn check_glibc(major: u32, minor: u32) -> bool { // Only check glibc on Linux with gnu env if !cfg!(target_os = "linux") || cfg!(target_env = "musl") { return false; } - + // Try to get glibc version using ldd - if let Ok(output) = Command::new("ldd") - .arg("--version") - .output() - .await - { + if let Ok(output) = Command::new("ldd").arg("--version").output().await { if let Ok(version_str) = String::from_utf8(output.stdout) { return Self::parse_glibc_version(&version_str, major, minor); } } - + // Fallback: try to read from /lib/libc.so.6 - if let Ok(output) = Command::new("/lib/libc.so.6") - .output() - .await - { + if let Ok(output) = Command::new("/lib/libc.so.6").output().await { if let Ok(version_str) = String::from_utf8(output.stdout) { return Self::parse_glibc_version(&version_str, major, minor); } } - + // If we can't determine the version, assume it's old false } - + /// Parse glibc version string and compare with required version fn parse_glibc_version(version_str: &str, req_major: u32, req_minor: u32) -> bool { // Look for version pattern like "2.17" or "2.31" for line in version_str.lines() { - if let Some(version_part) = line.split_whitespace() - .find(|part| part.contains('.') && part.chars().next().unwrap_or('0').is_ascii_digit()) - { - let version_clean = version_part.trim_matches(|c: char| !c.is_ascii_digit() && c != '.'); + if let Some(version_part) = line.split_whitespace().find(|part| { + part.contains('.') && part.chars().next().unwrap_or('0').is_ascii_digit() + }) { + let version_clean = + version_part.trim_matches(|c: char| !c.is_ascii_digit() && c != '.'); let parts: Vec<&str> = version_clean.split('.').collect(); - + if parts.len() >= 2 { - if let (Ok(major), Ok(minor)) = (parts[0].parse::(), parts[1].parse::()) { + if let (Ok(major), Ok(minor)) = + (parts[0].parse::(), parts[1].parse::()) + { return major > req_major || (major == req_major && minor >= req_minor); } } } } false - } + } } fn extract_package_name(archive: String) -> String { @@ -210,8 +203,11 @@ fn extract_package_name(archive: String) -> String { async fn download_uv_archive(path: &PathBuf, archive: String) -> Result { debug!("Downloading UV archive: {}", archive); - let url = format!("https://github.com/astral-sh/uv/releases/download/{}/{}", UV_VERSION, archive); - + let url = format!( + "https://github.com/astral-sh/uv/releases/download/{}/{}", + UV_VERSION, archive + ); + // Create the directory if it doesn't exist std::fs::create_dir_all(&path).map_err(Error::IoError)?; @@ -219,8 +215,9 @@ async fn download_uv_archive(path: &PathBuf, archive: String) -> Result Result Result Result Result Result Option { if uv_path.exists() { return Some(uv_path); } - } + } } - + None -} +} pub async fn find_or_setup_uv() -> Result { // We only allow setup in the process space at a given time. @@ -342,7 +351,7 @@ pub async fn find_or_setup_uv() -> Result { // If we get here, uv wasn't found in PATH, so let's download it if let Some(path) = find_uv_binary().await { debug!("UV binary found at {:?}", path); - Ok(path) + Ok(path) } else { let path = get_default_uv_bin_dir()?; debug!("UV binary not found in PATH, setting up UV at {:?}", path); @@ -350,7 +359,8 @@ pub async fn find_or_setup_uv() -> Result { // Create the directory if it doesn't exist std::fs::create_dir_all(&path).map_err(Error::IoError)?; - let parent = path.parent() + let parent = path + .parent() .ok_or_else(|| Error::NotFound("Parent directory not found".to_string()))? .to_path_buf(); @@ -361,8 +371,7 @@ pub async fn find_or_setup_uv() -> Result { let target = path.join("uv"); // Copy the `uv` binary into the default directory - tokio::fs::copy(&exe, &target) - .await?; + tokio::fs::copy(&exe, &target).await?; #[cfg(unix)] { diff --git a/crates/tower-uv/src/lib.rs b/crates/tower-uv/src/lib.rs index e86cf65f..10674f6f 100644 --- a/crates/tower-uv/src/lib.rs +++ b/crates/tower-uv/src/lib.rs @@ -1,7 +1,7 @@ -use std::path::PathBuf; use std::collections::HashMap; +use std::path::PathBuf; use std::process::Stdio; -use tokio::process::{Command, Child}; +use tokio::process::{Child, Command}; use tower_telemetry::debug; pub mod install; @@ -66,7 +66,7 @@ impl Uv { Ok(uv_path) => { test_uv_path(&uv_path).await?; Ok(Uv { uv_path }) - }, + } Err(e) => { debug!("Error setting up UV: {:?}", e); Err(e.into()) @@ -74,7 +74,11 @@ impl Uv { } } - pub async fn venv(&self, cwd: &PathBuf, env_vars: &HashMap) -> Result { + pub async fn venv( + &self, + cwd: &PathBuf, + env_vars: &HashMap, + ) -> Result { debug!("Executing UV ({:?}) venv in {:?}", &self.uv_path, cwd); let child = Command::new(&self.uv_path) @@ -90,7 +94,11 @@ impl Uv { Ok(child) } - pub async fn sync(&self, cwd: &PathBuf, env_vars: &HashMap) -> Result { + pub async fn sync( + &self, + cwd: &PathBuf, + env_vars: &HashMap, + ) -> Result { // We need to figure out which sync strategy to apply. If there is a pyproject.toml, then // that's easy. if cwd.join("pyproject.toml").exists() { @@ -116,7 +124,10 @@ impl Uv { Ok(child) } else if cwd.join("requirements.txt").exists() { - debug!("Executing UV ({:?}) sync with requirements in {:?}", &self.uv_path, cwd); + debug!( + "Executing UV ({:?}) sync with requirements in {:?}", + &self.uv_path, cwd + ); // If there is a requirements.txt, then we can use that to sync. let mut cmd = Command::new(&self.uv_path); @@ -145,12 +156,18 @@ impl Uv { // If there is no pyproject.toml or requirements.txt, then we can't sync. Err(Error::MissingPyprojectToml) } - - } - pub async fn run(&self, cwd: &PathBuf, program: &PathBuf, env_vars: &HashMap) -> Result { - debug!("Executing UV ({:?}) run {:?} in {:?}", &self.uv_path, program, cwd); + pub async fn run( + &self, + cwd: &PathBuf, + program: &PathBuf, + env_vars: &HashMap, + ) -> Result { + debug!( + "Executing UV ({:?}) run {:?} in {:?}", + &self.uv_path, program, cwd + ); let mut cmd = Command::new(&self.uv_path); cmd.kill_on_drop(true) diff --git a/crates/tower-uv/tests/install_test.rs b/crates/tower-uv/tests/install_test.rs index 82fe493c..bfdb0393 100644 --- a/crates/tower-uv/tests/install_test.rs +++ b/crates/tower-uv/tests/install_test.rs @@ -1,7 +1,4 @@ -use tower_uv::{ - install::get_default_uv_bin_dir, - Uv, -}; +use tower_uv::{install::get_default_uv_bin_dir, Uv}; #[tokio::test] async fn test_installing_uv() { diff --git a/crates/tower-version/src/lib.rs b/crates/tower-version/src/lib.rs index 19813d41..3deb1449 100644 --- a/crates/tower-version/src/lib.rs +++ b/crates/tower-version/src/lib.rs @@ -1,7 +1,7 @@ use anyhow::Result; +use chrono::{Duration, Utc}; use reqwest; use serde_json::Value; -use chrono::{Utc, Duration}; use tower_telemetry::debug; pub fn current_version() -> &'static str { @@ -18,26 +18,25 @@ pub async fn should_check_latest_version() -> bool { pub async fn check_latest_version() -> Result> { let client = reqwest::Client::new(); - let pypi_url = std::env::var("TOWER_PYPI_URL") - .unwrap_or_else(|_| "https://pypi.org".to_string()); + let pypi_url = + std::env::var("TOWER_PYPI_URL").unwrap_or_else(|_| "https://pypi.org".to_string()); let url = format!("{}/pypi/tower/json", pypi_url); - - let resp = client - .get(url) - .send() - .await?; - + + let resp = client.get(url).send().await?; + let status = resp.status(); debug!("PyPI returned status code: {}", status); - + if status.is_success() { // Update the config so we don't check more often. config::set_last_version_check_timestamp(Utc::now()); let json: Value = resp.json().await?; - if let Some(version) = json.get("info") + if let Some(version) = json + .get("info") .and_then(|info| info.get("version")) - .and_then(|v| v.as_str()) { + .and_then(|v| v.as_str()) + { return Ok(Some(version.to_string())); } } From 521d85d7f169ede818d88735cf0c1ec2c492f5fb Mon Sep 17 00:00:00 2001 From: Brad Heller Date: Tue, 16 Sep 2025 14:59:22 +0200 Subject: [PATCH 2/3] chore: List environments as a table --- crates/tower-cmd/src/environments.rs | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/crates/tower-cmd/src/environments.rs b/crates/tower-cmd/src/environments.rs index 1516e9d6..5c6294e8 100644 --- a/crates/tower-cmd/src/environments.rs +++ b/crates/tower-cmd/src/environments.rs @@ -28,12 +28,24 @@ pub async fn do_list(config: Config) { match resp { Ok(resp) => { - let items = resp - .environments + let headers = vec!["Name"] .into_iter() - .map(|env| env.name.bold().green().to_string()) + .map(|h| h.yellow().to_string()) + .collect(); + + // Format the environments data for the table + let envs = resp + .environments + .into_iter(); + + let envs_data: Vec> = envs + .map(|env| { + vec![env.name.clone()] + }) .collect(); - output::list(items); + + // Display the table using the existing table function + output::table(headers, envs_data); } Err(err) => { output::tower_error(err); From 87206413075a322c83f6d759bba8ecae332a3cc7 Mon Sep 17 00:00:00 2001 From: Brad Heller Date: Wed, 17 Sep 2025 11:31:33 +0200 Subject: [PATCH 3/3] Integrate feedback from @copilot --- crates/tower-cmd/src/environments.rs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/crates/tower-cmd/src/environments.rs b/crates/tower-cmd/src/environments.rs index 5c6294e8..cbc0ed9e 100644 --- a/crates/tower-cmd/src/environments.rs +++ b/crates/tower-cmd/src/environments.rs @@ -33,14 +33,11 @@ pub async fn do_list(config: Config) { .map(|h| h.yellow().to_string()) .collect(); - // Format the environments data for the table - let envs = resp + let envs_data: Vec> = resp .environments - .into_iter(); - - let envs_data: Vec> = envs + .into_iter() .map(|env| { - vec![env.name.clone()] + vec![env.name] }) .collect();