Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
269 changes: 168 additions & 101 deletions Cargo.lock

Large diffs are not rendered by default.

11 changes: 4 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@ resolver = "2"

[workspace.package]
edition = "2021"
version = "0.3.15"



version = "0.3.16"
description = "Tower is the best way to host Python data apps in production"
rust-version = "1.77"
authors = ["Brad Heller <brad@tower.dev>"]
Expand All @@ -27,13 +24,11 @@ colored = "2"
config = { path = "crates/config" }
crypto = { path = "crates/crypto" }
dirs = "5"
env_logger = "*"
futures = "0.3"
futures-util = "0.3"
glob = "0.3"
http = "1.1"
indicatif = "0.17"
log = { version = "0.4", features = ["kv"] }
pem = "3"
promptly = "0.3"
rand = "0.8"
Expand All @@ -47,7 +42,6 @@ rsa = "0.9"
serde = "1"
serde_json = "1.0"
sha2 = "0.10"
simple_logger = "5"
snafu = "0.7"
spinners = "4"
testutils = { path = "crates/testutils" }
Expand All @@ -63,6 +57,9 @@ tower-cmd = { path = "crates/tower-cmd" }
tower-package = { path = "crates/tower-package" }
tower-runtime = { path = "crates/tower-runtime" }
tower-telemetry = { path = "crates/tower-telemetry" }
tracing = { version = "0.1" }
tracing-appender = "0.2"
tracing-subscriber = { version = "0.3", features = ["json", "env-filter"] }
url = { version = "2", features = ["serde"] }
webbrowser = "1"

Expand Down
2 changes: 1 addition & 1 deletion crates/config/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ chrono = { workspace = true }
clap = { workspace = true }
dirs = { workspace = true }
futures = { workspace = true }
log = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }
snafu = { workspace = true }
Expand All @@ -20,3 +19,4 @@ toml = { workspace = true }
testutils = { workspace = true }
url = { workspace = true }
tower-api = { workspace = true }
tower-telemetry = { workspace = true }
4 changes: 2 additions & 2 deletions crates/config/src/error.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use snafu::prelude::*;
use tower_telemetry::debug;

#[derive(Debug, Snafu)]
pub enum Error {
Expand Down Expand Up @@ -43,8 +44,7 @@ impl From<serde_json::Error> for Error {

impl From<toml::de::Error> for Error {
fn from(err: toml::de::Error) -> Self {
log::debug!("error parsing Towerfile TOMl: {}", err);
println!("error parsing Towerfile TOML: {}", err);
debug!("error parsing Towerfile TOMl: {}", err);
Error::InvalidTowerfile
}
}
15 changes: 8 additions & 7 deletions crates/config/src/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use url::Url;

use crate::error::Error;
use tower_api::apis::default_api::describe_session;
use tower_telemetry::debug;

const DEFAULT_TOWER_URL: &str = "https://api.tower.dev";

Expand Down Expand Up @@ -81,16 +82,16 @@ pub fn get_last_version_check_timestamp() -> DateTime<Utc> {
if let Ok(dt) = DateTime::parse_from_rfc3339(&last_version_check) {
dt.into()
} else {
log::debug!("Error parsing last version check timestamp: {}", last_version_check);
debug!("Error parsing last version check timestamp: {}", last_version_check);
default
}
} else {
log::debug!("Error reading last version check timestamp");
debug!("Error reading last version check timestamp");
default
}
},
Err(err) => {
log::debug!("Error finding config dir: {}", err);
debug!("Error finding config dir: {}", err);
default
}
}
Expand All @@ -102,11 +103,11 @@ pub fn set_last_version_check_timestamp(dt: DateTime<Utc>) {
let dt_str = dt.to_rfc3339();

if let Err(err) = fs::write(path.join("last_version_check.txt"), dt_str) {
log::debug!("Error writing last version check timestamp: {}", err);
debug!("Error writing last version check timestamp: {}", err);
}
},
Err(err) => {
log::debug!("Error finding config dir: {}", err);
debug!("Error finding config dir: {}", err);
}
}
}
Expand Down Expand Up @@ -294,13 +295,13 @@ impl Session {
Ok(session)
}
tower_api::apis::default_api::DescribeSessionSuccess::UnknownValue(val) => {
log::error!("Unknown value while describing session: {}", val);
debug!("Unknown value while describing session: {}", val);
Err(Error::UnknownDescribeSessionValue { value: val })
}
}
}
Err(err) => {
log::error!("Error describing session: {}", err);
debug!("Error describing session: {}", err);
Err(Error::DescribeSessionError { err })
}
}
Expand Down
3 changes: 2 additions & 1 deletion crates/config/src/towerfile.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::Error;
use serde::Deserialize;
use std::path::PathBuf;
use tower_telemetry::debug;

#[derive(Deserialize, Debug)]
pub struct Parameter{
Expand Down Expand Up @@ -88,7 +89,7 @@ impl Towerfile {
// We set the workspace to the directory of the Towerfile if it's not set because that's
// the implicit behavior overall for legacy Towerfiles.
if towerfile.app.workspace.as_os_str().is_empty() {
log::debug!("Setting workspace to the directory of the Towerfile");
debug!("Setting workspace to the directory of the Towerfile");
towerfile.app.workspace = towerfile.file_path
.parent()
.map(|p| p.to_path_buf())
Expand Down
1 change: 0 additions & 1 deletion crates/tower-api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ rust-version = { workspace = true }
license = { workspace = true }

[dependencies]
log = { workspace = true }
serde = { version = "^1.0", features = ["derive"] }
serde_with = { version = "^3.8", default-features = false, features = ["base64", "std", "macros"] }
serde_json = "^1.0"
Expand Down
4 changes: 3 additions & 1 deletion crates/tower-api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ For more information, please visit [https://tower.dev](https://tower.dev)

This API client was generated by the [OpenAPI Generator](https://openapi-generator.tech) project. By using the [openapi-spec](https://openapis.org) from a remote server, you can easily generate an API client.

- API version: v0.5.23
- API version: v0.6.3
- Package version: 1.0.0
- Generator version: 7.13.0
- Build package: `org.openapitools.codegen.languages.RustClientCodegen`
Expand Down Expand Up @@ -78,6 +78,7 @@ Class | Method | HTTP request | Description
*DefaultApi* | [**remove_team_member**](docs/DefaultApi.md#remove_team_member) | **DELETE** /teams/{slug}/members | Remove team member
*DefaultApi* | [**resend_team_invitation**](docs/DefaultApi.md#resend_team_invitation) | **POST** /teams/{slug}/invites/resend | Resend team invitation
*DefaultApi* | [**run_app**](docs/DefaultApi.md#run_app) | **POST** /apps/{slug}/runs | Run app
*DefaultApi* | [**search_runs**](docs/DefaultApi.md#search_runs) | **GET** /runs | Search runs
*DefaultApi* | [**stream_alerts**](docs/DefaultApi.md#stream_alerts) | **GET** /alerts/stream | Stream alert notifications
*DefaultApi* | [**stream_run_logs**](docs/DefaultApi.md#stream_run_logs) | **GET** /apps/{slug}/runs/{seq}/logs/stream | Stream run logs
*DefaultApi* | [**update_account_slug**](docs/DefaultApi.md#update_account_slug) | **PUT** /accounts/{slug} | Update account slug
Expand Down Expand Up @@ -188,6 +189,7 @@ Class | Method | HTTP request | Description
- [RunParameter](docs/RunParameter.md)
- [RunResults](docs/RunResults.md)
- [RunStatistics](docs/RunStatistics.md)
- [SearchRunsResponse](docs/SearchRunsResponse.md)
- [Secret](docs/Secret.md)
- [SeriesPoint](docs/SeriesPoint.md)
- [Session](docs/Session.md)
Expand Down
2 changes: 1 addition & 1 deletion crates/tower-api/src/apis/configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
* REST API to interact with Tower Services.
*
* The version of the OpenAPI document: v0.5.23
* The version of the OpenAPI document: v0.6.3
* Contact: hello@tower.dev
* Generated by: https://openapi-generator.tech
*/
Expand Down
86 changes: 85 additions & 1 deletion crates/tower-api/src/apis/default_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
* REST API to interact with Tower Services.
*
* The version of the OpenAPI document: v0.5.23
* The version of the OpenAPI document: v0.6.3
* Contact: hello@tower.dev
* Generated by: https://openapi-generator.tech
*/
Expand Down Expand Up @@ -370,6 +370,21 @@ pub struct RunAppParams {
pub run_app_params: models::RunAppParams
}

/// struct for passing parameters to the method [`search_runs`]
#[derive(Clone, Debug)]
pub struct SearchRunsParams {
/// The page number to fetch.
pub page: Option<i64>,
/// The number of records to fetch on each page.
pub page_size: Option<i64>,
/// Filter runs by status(es). Define multiple with a comma-separated list. Supplying none will return all statuses.
pub status: Option<Vec<String>>,
/// Filter runs scheduled after this datetime (inclusive). Provide timestamps in ISO-8601 format.
pub start_at: Option<String>,
/// Filter runs scheduled before or at this datetime (inclusive). Provide timestamps in ISO-8601 format.
pub end_at: Option<String>
}

/// struct for passing parameters to the method [`stream_run_logs`]
#[derive(Clone, Debug)]
pub struct StreamRunLogsParams {
Expand Down Expand Up @@ -848,6 +863,14 @@ pub enum RunAppSuccess {
UnknownValue(serde_json::Value),
}

/// struct for typed successes of method [`search_runs`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum SearchRunsSuccess {
Status200(models::SearchRunsResponse),
UnknownValue(serde_json::Value),
}

/// struct for typed successes of method [`stream_alerts`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
Expand Down Expand Up @@ -1339,6 +1362,14 @@ pub enum RunAppError {
UnknownValue(serde_json::Value),
}

/// struct for typed errors of method [`search_runs`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum SearchRunsError {
DefaultResponse(models::ErrorModel),
UnknownValue(serde_json::Value),
}

/// struct for typed errors of method [`stream_alerts`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
Expand Down Expand Up @@ -3328,6 +3359,59 @@ pub async fn run_app(configuration: &configuration::Configuration, params: RunAp
}
}

/// Search, filter, and list runs across all of the apps in your account.
pub async fn search_runs(configuration: &configuration::Configuration, params: SearchRunsParams) -> Result<ResponseContent<SearchRunsSuccess>, Error<SearchRunsError>> {

let uri_str = format!("{}/runs", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);

if let Some(ref param_value) = params.page {
req_builder = req_builder.query(&[("page", &param_value.to_string())]);
}
if let Some(ref param_value) = params.page_size {
req_builder = req_builder.query(&[("page_size", &param_value.to_string())]);
}
if let Some(ref param_value) = params.status {
req_builder = match "csv" {
"multi" => req_builder.query(&param_value.into_iter().map(|p| ("status".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
_ => req_builder.query(&[("status", &param_value.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
};
}
if let Some(ref param_value) = params.start_at {
req_builder = req_builder.query(&[("start_at", &param_value.to_string())]);
}
if let Some(ref param_value) = params.end_at {
req_builder = req_builder.query(&[("end_at", &param_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};

let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;

let status = resp.status();

let tower_trace_id = resp
.headers()
.get("x-tower-trace-id")
.and_then(|v| v.to_str().ok())
.map_or(String::from(DEFAULT_TOWER_TRACE_ID), String::from);

if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
let entity: Option<SearchRunsSuccess> = serde_json::from_str(&content).ok();
Ok(ResponseContent { tower_trace_id, status, content, entity })
} else {
let content = resp.text().await?;
let entity: Option<SearchRunsError> = serde_json::from_str(&content).ok();
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<ResponseContent<StreamAlertsSuccess>, Error<StreamAlertsError>> {

Expand Down
2 changes: 1 addition & 1 deletion crates/tower-api/src/models/accept_invitation_params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
* REST API to interact with Tower Services.
*
* The version of the OpenAPI document: v0.5.23
* The version of the OpenAPI document: v0.6.3
* Contact: hello@tower.dev
* Generated by: https://openapi-generator.tech
*/
Expand Down
2 changes: 1 addition & 1 deletion crates/tower-api/src/models/accept_invitation_response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
* REST API to interact with Tower Services.
*
* The version of the OpenAPI document: v0.5.23
* The version of the OpenAPI document: v0.6.3
* Contact: hello@tower.dev
* Generated by: https://openapi-generator.tech
*/
Expand Down
2 changes: 1 addition & 1 deletion crates/tower-api/src/models/account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
* REST API to interact with Tower Services.
*
* The version of the OpenAPI document: v0.5.23
* The version of the OpenAPI document: v0.6.3
* Contact: hello@tower.dev
* Generated by: https://openapi-generator.tech
*/
Expand Down
2 changes: 1 addition & 1 deletion crates/tower-api/src/models/acknowledge_alert_response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
* REST API to interact with Tower Services.
*
* The version of the OpenAPI document: v0.5.23
* The version of the OpenAPI document: v0.6.3
* Contact: hello@tower.dev
* Generated by: https://openapi-generator.tech
*/
Expand Down
2 changes: 1 addition & 1 deletion crates/tower-api/src/models/alert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
* REST API to interact with Tower Services.
*
* The version of the OpenAPI document: v0.5.23
* The version of the OpenAPI document: v0.6.3
* Contact: hello@tower.dev
* Generated by: https://openapi-generator.tech
*/
Expand Down
2 changes: 1 addition & 1 deletion crates/tower-api/src/models/api_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
* REST API to interact with Tower Services.
*
* The version of the OpenAPI document: v0.5.23
* The version of the OpenAPI document: v0.6.3
* Contact: hello@tower.dev
* Generated by: https://openapi-generator.tech
*/
Expand Down
2 changes: 1 addition & 1 deletion crates/tower-api/src/models/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
* REST API to interact with Tower Services.
*
* The version of the OpenAPI document: v0.5.23
* The version of the OpenAPI document: v0.6.3
* Contact: hello@tower.dev
* Generated by: https://openapi-generator.tech
*/
Expand Down
2 changes: 1 addition & 1 deletion crates/tower-api/src/models/app_statistics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
* REST API to interact with Tower Services.
*
* The version of the OpenAPI document: v0.5.23
* The version of the OpenAPI document: v0.6.3
* Contact: hello@tower.dev
* Generated by: https://openapi-generator.tech
*/
Expand Down
2 changes: 1 addition & 1 deletion crates/tower-api/src/models/app_summary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
* REST API to interact with Tower Services.
*
* The version of the OpenAPI document: v0.5.23
* The version of the OpenAPI document: v0.6.3
* Contact: hello@tower.dev
* Generated by: https://openapi-generator.tech
*/
Expand Down
Loading