#![allow(deprecated)]
use std::future::Future;
use std::time::Duration;
use base64::Engine as _;
use base64::engine::general_purpose::{GeneralPurpose, STANDARD, STANDARD_NO_PAD};
use buffa::Message as _;
use pethost::{Client, Error, ErrorCode, ErrorDetail, Timestamp, types};
use tokio::io::{AsyncReadExt, AsyncWriteExt};
use tokio::net::{TcpListener, TcpStream};
#[path = "../src/wire/buffa/mod.rs"]
#[rustfmt::skip]
#[allow(clippy::all, dead_code, unreachable_pub)]
mod proto;
use proto::pethost::panel::v1 as wire;
const TOKEN: &str = "pth_checks";
const HEADERS: [&str; 4] = [
"authorization: bearer pth_checks",
"content-type: application/proto",
"connect-protocol-version: 1",
"user-agent: pethost-rust/0.1.0",
];
const MESSAGE: &str = "the fake's sentence";
struct Answer {
status: u16,
content_type: &'static str,
body: Vec<u8>,
}
fn ok(response: &impl buffa::Message) -> Answer {
Answer {
status: 200,
content_type: "application/proto",
body: response.encode_to_vec(),
}
}
fn failure(code: &str, status: u16, details: &[(&str, &[u8])], encode: &GeneralPurpose) -> Answer {
let details: Vec<serde_json::Value> = details
.iter()
.map(|(name, bytes)| serde_json::json!({ "type": name, "value": encode.encode(bytes) }))
.collect();
let body = serde_json::json!({ "code": code, "message": MESSAGE, "details": details });
Answer {
status,
content_type: "application/json",
body: body.to_string().into_bytes(),
}
}
async fn exchange<Request, Response, Call>(
rpc: &str,
answer: Answer,
call: impl FnOnce(Client) -> Call,
) -> (Request, Result<Response, Error>)
where
Request: buffa::Message,
Call: Future<Output = Result<Response, Error>>,
{
let listener = TcpListener::bind("127.0.0.1:0").await.unwrap();
let address = listener.local_addr().unwrap();
let client = Client::with_base_url(&format!("{TOKEN}\n"), &format!("http://{address}")).unwrap();
let fake = tokio::spawn(async move {
let (mut socket, _) = listener.accept().await.unwrap();
let request = read_request(&mut socket).await;
let head = format!(
"HTTP/1.1 {} Fake\r\ncontent-type: {}\r\ncontent-length: {}\r\nconnection: close\r\n\r\n",
answer.status,
answer.content_type,
answer.body.len()
);
socket.write_all(head.as_bytes()).await.unwrap();
socket.write_all(&answer.body).await.unwrap();
request
});
let response = call(client).await;
let (head, body) = tokio::time::timeout(Duration::from_secs(10), fake)
.await
.expect("the client made no call")
.unwrap();
let line = format!("post /pethost.panel.v1.PanelService/{rpc} http/1.1").to_lowercase();
assert!(head.starts_with(&line), "{line} does not start:\n{head}");
for header in HEADERS {
assert!(head.contains(header), "{header} is not in:\n{head}");
}
(Request::decode_from_slice(&body).unwrap(), response)
}
async fn read_request(socket: &mut TcpStream) -> (String, Vec<u8>) {
let mut bytes = Vec::new();
let mut chunk = [0u8; 4096];
loop {
let read = socket.read(&mut chunk).await.unwrap();
assert!(read > 0, "the client closed the connection inside a request");
bytes.extend_from_slice(&chunk[..read]);
let Some(end) = bytes.windows(4).position(|window| window == b"\r\n\r\n") else {
continue;
};
let head = String::from_utf8_lossy(&bytes[..end]).to_lowercase();
let length: usize = head
.lines()
.find_map(|line| line.strip_prefix("content-length: "))
.map_or(0, |value| value.parse().unwrap());
if bytes.len() >= end + 4 + length {
return (head, bytes[end + 4..].to_vec());
}
}
}
#[allow(dead_code)]
mod states {
use pethost::Timestamp;
const FLAG_BITS: usize = 2;
pub fn text(name: &str, k: usize) -> String {
format!("{name} {k}")
}
pub fn number(field: u32, k: usize) -> u32 {
field * 1000 + k as u32 + 1
}
pub fn flag(ordinal: usize, k: usize) -> bool {
(ordinal >> (k % FLAG_BITS)) & 1 == 1
}
pub fn plain<T: Default>(k: usize, value: T) -> T {
if k % 2 == 1 { value } else { T::default() }
}
pub fn marked<T: Default>(k: usize, value: T) -> Option<T> {
match k % 3 {
0 => None,
1 => Some(T::default()),
_ => Some(value),
}
}
pub fn maybe<T>(k: usize, value: T) -> Option<T> {
(k % 2 == 1).then_some(value)
}
pub fn many<T>(k: usize, items: [T; 2]) -> Vec<T> {
if k % 2 == 1 { items.into() } else { Vec::new() }
}
pub fn time(number: u32) -> Timestamp {
Timestamp {
seconds: 1_700_000_000 + i64::from(number),
nanos: number,
}
}
pub fn time_on_wire(number: u32) -> buffa_types::google::protobuf::Timestamp {
buffa_types::google::protobuf::Timestamp {
seconds: 1_700_000_000 + i64::from(number),
nanos: number as i32,
..Default::default()
}
}
pub fn present<T: Default + PartialEq>(value: T) -> Option<T> {
(value != T::default()).then_some(value)
}
pub fn set<E: buffa::Enumeration>(value: buffa::EnumValue<E>) -> Option<buffa::EnumValue<E>> {
(value.to_i32() != 0).then_some(value)
}
pub fn make<T: Default>(fill: impl FnOnce(&mut T)) -> T {
let mut message = T::default();
fill(&mut message);
message
}
pub fn later_field() -> buffa::UnknownField {
buffa::UnknownField {
number: 29,
data: buffa::UnknownFieldData::LengthDelimited(b"later".to_vec()),
}
}
}
mod samples {
use super::*;
pub fn machine_session_kind(k: usize) -> types::MachineSessionKind {
match k % 7 {
0 => types::MachineSessionKind::Unspecified,
1 => types::MachineSessionKind::WebTerminal,
2 => types::MachineSessionKind::SshTerminal,
3 => types::MachineSessionKind::SshCommand,
4 => types::MachineSessionKind::Sftp,
5 => types::MachineSessionKind::Tunnel,
_ => types::MachineSessionKind::Unrecognized(6),
}
}
pub fn project_problem_kind(k: usize) -> types::ProjectProblemKind {
match k % 12 {
0 => types::ProjectProblemKind::Unspecified,
1 => types::ProjectProblemKind::DeployFailed,
2 => types::ProjectProblemKind::ServiceUnhealthy,
3 => types::ProjectProblemKind::ServiceRestarting,
4 => types::ProjectProblemKind::ServiceOutOfMemory,
5 => types::ProjectProblemKind::BackupFailed,
6 => types::ProjectProblemKind::DeployCancelled,
7 => types::ProjectProblemKind::ServiceExited,
8 => types::ProjectProblemKind::RestoreFailed,
9 => types::ProjectProblemKind::AutoDeployRefused,
10 => types::ProjectProblemKind::ServicePortClosed,
_ => types::ProjectProblemKind::Unrecognized(11),
}
}
pub fn services_action_kind(k: usize) -> types::ServicesActionKind {
match k % 5 {
0 => types::ServicesActionKind::Unspecified,
1 => types::ServicesActionKind::Start,
2 => types::ServicesActionKind::Stop,
3 => types::ServicesActionKind::Restart,
_ => types::ServicesActionKind::Unrecognized(4),
}
}
pub fn service_state(k: usize) -> types::ServiceState {
match k % 10 {
0 => types::ServiceState::Unspecified,
1 => types::ServiceState::NotCreated,
2 => types::ServiceState::Starting,
3 => types::ServiceState::Running,
4 => types::ServiceState::Healthy,
5 => types::ServiceState::Unhealthy,
6 => types::ServiceState::Restarting,
7 => types::ServiceState::Stopped,
8 => types::ServiceState::Exited,
_ => types::ServiceState::Unrecognized(9),
}
}
pub fn restart_policy(k: usize) -> types::RestartPolicy {
match k % 6 {
0 => types::RestartPolicy::Unspecified,
1 => types::RestartPolicy::No,
2 => types::RestartPolicy::OnFailure,
3 => types::RestartPolicy::UnlessStopped,
4 => types::RestartPolicy::Always,
_ => types::RestartPolicy::Unrecognized(5),
}
}
pub fn health_status(k: usize) -> types::HealthStatus {
match k % 5 {
0 => types::HealthStatus::Unspecified,
1 => types::HealthStatus::Starting,
2 => types::HealthStatus::Healthy,
3 => types::HealthStatus::Unhealthy,
_ => types::HealthStatus::Unrecognized(4),
}
}
pub fn certificate_source(k: usize) -> types::CertificateSource {
match k % 5 {
0 => types::CertificateSource::Unspecified,
1 => types::CertificateSource::None,
2 => types::CertificateSource::Installed,
3 => types::CertificateSource::Automatic,
_ => types::CertificateSource::Unrecognized(4),
}
}
pub fn operation_kind(k: usize) -> types::OperationKind {
match k % 7 {
0 => types::OperationKind::Unspecified,
1 => types::OperationKind::Deploy,
2 => types::OperationKind::RecreateService,
3 => types::OperationKind::Backup,
4 => types::OperationKind::Restore,
5 => types::OperationKind::Delete,
_ => types::OperationKind::Unrecognized(6),
}
}
pub fn operation_status(k: usize) -> types::OperationStatus {
match k % 6 {
0 => types::OperationStatus::Unspecified,
1 => types::OperationStatus::InProgress,
2 => types::OperationStatus::Succeeded,
3 => types::OperationStatus::Failed,
4 => types::OperationStatus::Cancelled,
_ => types::OperationStatus::Unrecognized(5),
}
}
pub fn deploy_failure_reason(k: usize) -> types::DeployFailureReason {
match k % 13 {
0 => types::DeployFailureReason::Unspecified,
1 => types::DeployFailureReason::ImagePullFailed,
2 => types::DeployFailureReason::ImageBuildFailed,
3 => types::DeployFailureReason::ContainerStartFailed,
4 => types::DeployFailureReason::DiskFull,
5 => types::DeployFailureReason::Internal,
6 => types::DeployFailureReason::PortUnavailable,
7 => types::DeployFailureReason::ContainerExited,
8 => types::DeployFailureReason::ContainerUnhealthy,
9 => types::DeployFailureReason::TimedOut,
10 => types::DeployFailureReason::UncoveredImageVolume,
11 => types::DeployFailureReason::BuildMemoryUnavailable,
_ => types::DeployFailureReason::Unrecognized(12),
}
}
pub fn output_stream(k: usize) -> types::OutputStream {
match k % 4 {
0 => types::OutputStream::Unspecified,
1 => types::OutputStream::Stdout,
2 => types::OutputStream::Stderr,
_ => types::OutputStream::Unrecognized(3),
}
}
pub fn file_type(k: usize) -> types::FileType {
match k % 6 {
0 => types::FileType::Unspecified,
1 => types::FileType::File,
2 => types::FileType::Directory,
3 => types::FileType::Symlink,
4 => types::FileType::Other,
_ => types::FileType::Unrecognized(5),
}
}
pub fn file_location(k: usize) -> types::FileLocation {
match k % 5 {
0 => types::FileLocation::Unspecified,
1 => types::FileLocation::Container,
2 => types::FileLocation::Volume,
3 => types::FileLocation::ProjectFiles,
_ => types::FileLocation::Unrecognized(4),
}
}
pub fn no_machine_reason(k: usize) -> types::NoMachineReason {
match k % 4 {
0 => types::NoMachineReason::Unspecified,
1 => types::NoMachineReason::NoPlan,
2 => types::NoMachineReason::BeingPrepared,
_ => types::NoMachineReason::Unrecognized(3),
}
}
pub fn get_machine_request(_k: usize) -> types::GetMachineRequest {
types::GetMachineRequest {}
}
pub fn get_machine_response(k: usize) -> types::GetMachineResponse {
states::make(|message: &mut types::GetMachineResponse| {
message.machine = states::maybe(k, samples::machine(k));
message.projects = states::many(k, [samples::project_summary(k + 1), samples::project_summary(k + 2)]);
message.deleted_projects =
states::many(k, [samples::deleted_project(k + 2), samples::deleted_project(k + 3)]);
message.github = states::maybe(k, samples::github_connection(k + 3));
})
}
pub fn machine(k: usize) -> types::Machine {
states::make(|message: &mut types::Machine| {
message.name = states::plain(k, states::text("name", k));
message.location = states::plain(k, states::text("location", k));
message.sample_time = states::maybe(k, states::time(states::number(3, k + 2)));
message.cpu_used_cores = states::plain(k, f64::from(states::number(5, k)) + 0.5);
message.cpu_total_cores = states::plain(k, f64::from(states::number(6, k)) + 0.5);
message.memory_used_bytes = states::plain(k, u64::from(states::number(7, k)) << 32);
message.memory_total_bytes = states::plain(k, u64::from(states::number(8, k)) << 32);
message.disk_used_bytes = states::plain(k, u64::from(states::number(9, k)) << 32);
message.disk_total_bytes = states::plain(k, u64::from(states::number(10, k)) << 32);
message.disk_usage = states::maybe(k, samples::disk_usage(k + 9));
message.hostname = states::plain(k, states::text("hostname", k));
message.ssh_host_key_fingerprint = states::plain(k, states::text("ssh_host_key_fingerprint", k));
message.ssh_keys = states::many(k, [samples::ssh_key(k + 12), samples::ssh_key(k + 13)]);
message.backups_enabled = states::flag(1, k);
message.snapshot_list_time = states::maybe(k, states::time(states::number(22, k + 14)));
message.snapshot_list_failure_message = states::plain(k, states::text("snapshot_list_failure_message", k));
message.backup_retention_hours = states::plain(k, states::number(4, k));
message.acme_enabled = states::flag(2, k);
message.apps_domain = states::plain(k, states::text("apps_domain", k));
message.daemon_version = states::plain(k, states::text("daemon_version", k));
message.docker_version = states::plain(k, states::text("docker_version", k));
message.boot_time = states::maybe(k, states::time(states::number(18, k + 21)));
message.restart_required_time = states::maybe(k, states::time(states::number(19, k + 22)));
message.scheduled_restart_time = states::maybe(k, states::time(states::number(20, k + 23)));
message.sessions = states::many(k, [samples::machine_session(k + 24), samples::machine_session(k + 25)]);
})
}
pub fn machine_session(k: usize) -> types::MachineSession {
states::make(|message: &mut types::MachineSession| {
message.session_id = states::plain(k, states::text("session_id", k));
message.kind = samples::machine_session_kind(k + 1);
message.project_id = states::plain(k, states::text("project_id", k));
message.service = states::plain(k, states::text("service", k));
message.port = states::plain(k, states::number(5, k));
message.start_time = states::maybe(k, states::time(states::number(6, k + 5)));
message.client_address = states::plain(k, states::text("client_address", k));
message.ssh_key_label = states::plain(k, states::text("ssh_key_label", k));
message.ssh_key_fingerprint = states::plain(k, states::text("ssh_key_fingerprint", k));
})
}
pub fn disk_usage(k: usize) -> types::DiskUsage {
states::make(|message: &mut types::DiskUsage| {
message.images_bytes = states::plain(k, u64::from(states::number(1, k)) << 32);
message.build_cache_bytes = states::marked(k, u64::from(states::number(2, k)) << 32);
message.volumes_bytes = states::plain(k, u64::from(states::number(3, k)) << 32);
message.container_layers_bytes = states::plain(k, u64::from(states::number(4, k)) << 32);
message.project_files_bytes = states::plain(k, u64::from(states::number(5, k)) << 32);
message.container_logs_bytes = states::plain(k, u64::from(states::number(6, k)) << 32);
message.http_traffic_bytes = states::plain(k, u64::from(states::number(7, k)) << 32);
})
}
pub fn ssh_key(k: usize) -> types::SshKey {
types::SshKey {
public_key: states::plain(k, states::text("public_key", k)),
label: states::plain(k, states::text("label", k)),
fingerprint: states::plain(k, states::text("fingerprint", k)),
}
}
pub fn github_connection(k: usize) -> types::GithubConnection {
states::make(|message: &mut types::GithubConnection| {
message.app_name = states::plain(k, states::text("app_name", k));
message.install_url = states::plain(k, states::text("install_url", k));
message.repositories = states::many(
k,
[samples::github_repository(k + 2), samples::github_repository(k + 3)],
);
message.repository_count = states::plain(k, states::number(4, k));
message.webhooks_enabled = states::flag(1, k);
})
}
pub fn github_repository(k: usize) -> types::GithubRepository {
states::make(|message: &mut types::GithubRepository| {
message.repository = states::plain(k, states::text("repository", k));
message.default_branch = states::plain(k, states::text("default_branch", k));
message.private = states::flag(1, k);
message.push_time = states::maybe(k, states::time(states::number(4, k + 3)));
})
}
pub fn deleted_project(k: usize) -> types::DeletedProject {
states::make(|message: &mut types::DeletedProject| {
message.project_id = states::plain(k, states::text("project_id", k));
message.newest_snapshot = states::maybe(k, samples::snapshot(k + 1));
message.snapshot_count = states::plain(k, states::number(3, k));
})
}
pub fn run_machine_action_request(k: usize) -> types::RunMachineActionRequest {
types::RunMachineActionRequest {
action: match k % 12 {
0 => None,
1 => None,
2 => Some(types::RunMachineActionRequestAction::AddSshKey(samples::ssh_key(k))),
3 => Some(types::RunMachineActionRequestAction::RemoveSshKeyFingerprint(
states::text("remove_ssh_key_fingerprint", k),
)),
4 => Some(types::RunMachineActionRequestAction::RestartMachine(
samples::restart_machine_action(k),
)),
5 => Some(types::RunMachineActionRequestAction::CancelRestart(true)),
6 => Some(types::RunMachineActionRequestAction::EndSessionId(states::text(
"end_session_id",
k,
))),
7 => Some(types::RunMachineActionRequestAction::AddSshKey(Default::default())),
8 => Some(types::RunMachineActionRequestAction::RemoveSshKeyFingerprint(
Default::default(),
)),
9 => Some(types::RunMachineActionRequestAction::RestartMachine(Default::default())),
10 => Some(types::RunMachineActionRequestAction::CancelRestart(Default::default())),
_ => Some(types::RunMachineActionRequestAction::EndSessionId(Default::default())),
},
}
}
pub fn restart_machine_action(k: usize) -> types::RestartMachineAction {
types::RestartMachineAction {
restart_time: states::maybe(k, states::time(states::number(1, k))),
at_maintenance_window: states::flag(1, k),
interrupt_operations: states::flag(2, k),
}
}
pub fn run_machine_action_response(k: usize) -> types::RunMachineActionResponse {
states::make(|message: &mut types::RunMachineActionResponse| {
message.machine = states::maybe(k, samples::machine(k));
})
}
pub fn project_metadata(k: usize) -> types::ProjectMetadata {
types::ProjectMetadata {
name: states::marked(k, states::text("name", k)),
emoji: states::marked(k, states::text("emoji", k)),
description: states::marked(k, states::text("description", k)),
notes: states::marked(k, states::text("notes", k)),
}
}
pub fn project_summary(k: usize) -> types::ProjectSummary {
states::make(|message: &mut types::ProjectSummary| {
message.project_id = states::plain(k, states::text("project_id", k));
message.metadata = states::maybe(k, samples::project_metadata(k + 1));
message.problems = states::many(k, [samples::project_problem(k + 2), samples::project_problem(k + 3)]);
message.services = states::many(k, [samples::service_summary(k + 3), samples::service_summary(k + 4)]);
message.url = states::plain(k, states::text("url", k));
message.hosts = states::many(k, [states::text("hosts", k), states::text("hosts", k + 1)]);
message.http_traffic_last_day = states::maybe(k, samples::http_traffic_summary(k + 6));
message.cpu_used_cores = states::plain(k, f64::from(states::number(8, k)) + 0.5);
message.memory_used_bytes = states::plain(k, u64::from(states::number(9, k)) << 32);
message.deploy_time = states::maybe(k, states::time(states::number(10, k + 9)));
message.running_operations = states::many(k, [samples::operation(k + 10), samples::operation(k + 11)]);
message.pinned = states::flag(1, k);
message.disk_used_bytes = states::plain(k, u64::from(states::number(13, k)) << 32);
})
}
pub fn service_summary(k: usize) -> types::ServiceSummary {
states::make(|message: &mut types::ServiceSummary| {
message.service = states::plain(k, states::text("service", k));
message.state = samples::service_state(k + 1);
})
}
pub fn project_problem(k: usize) -> types::ProjectProblem {
states::make(|message: &mut types::ProjectProblem| {
message.kind = samples::project_problem_kind(k);
message.service = states::plain(k, states::text("service", k));
message.operation_id = states::plain(k, states::text("operation_id", k));
message.since_time = states::maybe(k, states::time(states::number(4, k + 3)));
message.problem_message = states::plain(k, states::text("problem_message", k));
})
}
pub fn get_project_request(k: usize) -> types::GetProjectRequest {
types::GetProjectRequest {
project_id: states::plain(k, states::text("project_id", k)),
include_secret_values: states::flag(1, k),
snapshots_before: states::maybe(k, states::time(states::number(3, k + 2))),
snapshots_volume: states::plain(k, states::text("snapshots_volume", k)),
}
}
pub fn get_project_response(k: usize) -> types::GetProjectResponse {
states::make(|message: &mut types::GetProjectResponse| {
message.project = states::maybe(k, samples::project(k));
})
}
pub fn project(k: usize) -> types::Project {
states::make(|message: &mut types::Project| {
message.project_id = states::plain(k, states::text("project_id", k));
message.metadata = states::maybe(k, samples::project_metadata(k + 1));
message.problems = states::many(k, [samples::project_problem(k + 2), samples::project_problem(k + 3)]);
message.url = states::plain(k, states::text("url", k));
message.cpu_used_cores = states::plain(k, f64::from(states::number(5, k)) + 0.5);
message.memory_used_bytes = states::plain(k, u64::from(states::number(6, k)) << 32);
message.deploy_id = states::plain(k, states::text("deploy_id", k));
message.deploy_status = samples::operation_status(k + 7);
message.deploy_time = states::maybe(k, states::time(states::number(8, k + 8)));
message.x_pethost_applies_at_once = states::flag(1, k);
message.services = states::many(k, [samples::service(k + 10), samples::service(k + 11)]);
message.volumes = states::many(k, [samples::volume(k + 11), samples::volume(k + 12)]);
message.routes = states::many(k, [samples::route(k + 12), samples::route(k + 13)]);
message.hosts = states::many(k, [samples::host(k + 13), samples::host(k + 14)]);
message.password_protected = states::flag(2, k);
message.operations = states::many(k, [samples::operation(k + 15), samples::operation(k + 16)]);
message.snapshots = states::many(k, [samples::snapshot(k + 16), samples::snapshot(k + 17)]);
message.snapshot_count = states::plain(k, states::number(15, k));
message.snapshot_list_time = states::maybe(k, states::time(states::number(20, k + 18)));
message.http_traffic_last_day = states::maybe(k, samples::http_traffic_summary(k + 19));
message.source = states::maybe(k, samples::project_source(k + 20));
message.running_services_action = states::maybe(k, samples::running_services_action(k + 21));
})
}
pub fn running_services_action(k: usize) -> types::RunningServicesAction {
states::make(|message: &mut types::RunningServicesAction| {
message.kind = samples::services_action_kind(k);
message.services = states::many(k, [states::text("services", k), states::text("services", k + 1)]);
message.start_time = states::maybe(k, states::time(states::number(3, k + 2)));
})
}
pub fn project_source(k: usize) -> types::ProjectSource {
types::ProjectSource {
kind: match k % 6 {
0 => None,
1 => Some(types::ProjectSourceKind::Unrecognized),
2 => Some(types::ProjectSourceKind::Files(true)),
3 => Some(types::ProjectSourceKind::Github(samples::github_source(k))),
4 => Some(types::ProjectSourceKind::Files(Default::default())),
_ => Some(types::ProjectSourceKind::Github(Default::default())),
},
}
}
pub fn github_source(k: usize) -> types::GithubSource {
types::GithubSource {
repository: states::marked(k, states::text("repository", k)),
branch: states::marked(k, states::text("branch", k)),
directory: states::marked(k, states::text("directory", k)),
auto_deploy: states::marked(k, true),
newest_commit: states::maybe(k, samples::github_commit(k + 4)),
deployed_commit: states::maybe(k, samples::github_commit(k + 5)),
pinned: states::flag(1, k),
auto_deploy_pending: states::flag(2, k),
}
}
pub fn github_commit(k: usize) -> types::GithubCommit {
types::GithubCommit {
sha: states::plain(k, states::text("sha", k)),
title: states::plain(k, states::text("title", k)),
url: states::plain(k, states::text("url", k)),
}
}
pub fn service(k: usize) -> types::Service {
states::make(|message: &mut types::Service| {
message.service = states::plain(k, states::text("service", k));
message.state = samples::service_state(k + 1);
message.container_running = states::flag(1, k);
message.image = states::plain(k, states::text("image", k));
message.builds_image = states::flag(2, k);
message.image_digest = states::plain(k, states::text("image_digest", k));
message.image_size_bytes = states::plain(k, u64::from(states::number(6, k)) << 32);
message.command = states::many(k, [states::text("command", k), states::text("command", k + 1)]);
message.run_as_user = states::plain(k, states::text("run_as_user", k));
message.start_time = states::maybe(k, states::time(states::number(9, k + 9)));
message.finish_time = states::maybe(k, states::time(states::number(10, k + 10)));
message.exit_code = states::marked(k, -(states::number(11, k) as i32));
message.out_of_memory = states::flag(3, k);
message.restart_count = states::plain(k, states::number(13, k));
message.cpu_used_cores = states::plain(k, f64::from(states::number(14, k)) + 0.5);
message.memory_used_bytes = states::plain(k, u64::from(states::number(15, k)) << 32);
message.memory_limit_bytes = states::plain(k, u64::from(states::number(16, k)) << 32);
message.cpu_limit_cores = states::plain(k, f64::from(states::number(17, k)) + 0.5);
message.writable_layer_bytes = states::plain(k, u64::from(states::number(18, k)) << 32);
message.ports = states::many(k, [states::number(19, k), states::number(19, k + 1)]);
message.listening_ports = states::many(k, [states::number(28, k), states::number(28, k + 1)]);
message.published_ports =
states::many(k, [samples::published_port(k + 21), samples::published_port(k + 22)]);
message.volume_mounts = states::many(k, [samples::volume_mount(k + 22), samples::volume_mount(k + 23)]);
message.restart_policy = samples::restart_policy(k + 23);
message.health_check = states::maybe(k, samples::health_check(k + 24));
message.environment = states::many(
k,
[
samples::environment_variable(k + 25),
samples::environment_variable(k + 26),
],
);
message.env_files = states::many(k, [states::text("env_files", k), states::text("env_files", k + 1)]);
message.ssh_command = states::plain(k, states::text("ssh_command", k));
})
}
pub fn published_port(k: usize) -> types::PublishedPort {
states::make(|message: &mut types::PublishedPort| {
message.machine_port = states::plain(k, states::number(1, k));
message.container_port = states::plain(k, states::number(2, k));
message.protocol = states::plain(k, states::text("protocol", k));
message.machine_only = states::flag(1, k);
})
}
pub fn volume_mount(k: usize) -> types::VolumeMount {
states::make(|message: &mut types::VolumeMount| {
message.volume = states::plain(k, states::text("volume", k));
message.container_path = states::plain(k, states::text("container_path", k));
})
}
pub fn health_check(k: usize) -> types::HealthCheck {
states::make(|message: &mut types::HealthCheck| {
message.command = states::many(k, [states::text("command", k), states::text("command", k + 1)]);
message.interval_seconds = states::plain(k, states::number(2, k));
message.status = samples::health_status(k + 2);
message.consecutive_failure_count = states::plain(k, states::number(4, k));
message.recent_results_passed = states::many(k, [true, true]);
message.last_failure_output = states::plain(k, states::text("last_failure_output", k));
})
}
pub fn environment_variable(k: usize) -> types::EnvironmentVariable {
states::make(|message: &mut types::EnvironmentVariable| {
message.name = states::plain(k, states::text("name", k));
message.value = states::plain(k, states::text("value", k));
message.secret = states::flag(1, k);
message.source_file = states::plain(k, states::text("source_file", k));
message.from_env_file_variables = states::many(
k,
[
states::text("from_env_file_variables", k),
states::text("from_env_file_variables", k + 1),
],
);
message.value_left_out = states::flag(2, k);
})
}
pub fn volume(k: usize) -> types::Volume {
states::make(|message: &mut types::Volume| {
message.volume = states::plain(k, states::text("volume", k));
message.size_bytes = states::plain(k, u64::from(states::number(2, k)) << 32);
message.mounted_by = states::many(
k,
[samples::volume_mounted_by(k + 2), samples::volume_mounted_by(k + 3)],
);
message.last_backup_time = states::maybe(k, states::time(states::number(4, k + 3)));
message.snapshot_count = states::plain(k, states::number(6, k));
message.declared = states::flag(1, k);
})
}
pub fn volume_mounted_by(k: usize) -> types::VolumeMountedBy {
states::make(|message: &mut types::VolumeMountedBy| {
message.service = states::plain(k, states::text("service", k));
message.container_path = states::plain(k, states::text("container_path", k));
})
}
pub fn host(k: usize) -> types::Host {
states::make(|message: &mut types::Host| {
message.host = states::plain(k, states::text("host", k));
message.url = states::plain(k, states::text("url", k));
message.certificate_source = samples::certificate_source(k + 2);
message.certificate_expire_time = states::maybe(k, states::time(states::number(4, k + 3)));
message.unavailable_message = states::plain(k, states::text("unavailable_message", k));
})
}
pub fn route(k: usize) -> types::Route {
types::Route {
host: states::plain(k, states::text("host", k)),
path: states::plain(k, states::text("path", k)),
service: states::plain(k, states::text("service", k)),
port: states::plain(k, states::number(4, k)),
strip_path: states::flag(1, k),
}
}
pub fn operation(k: usize) -> types::Operation {
states::make(|message: &mut types::Operation| {
message.operation_id = states::plain(k, states::text("operation_id", k));
message.kind = samples::operation_kind(k + 1);
message.status = samples::operation_status(k + 2);
message.start_time = states::maybe(k, states::time(states::number(4, k + 3)));
message.finish_time = states::maybe(k, states::time(states::number(5, k + 4)));
message.failure_message = states::plain(k, states::text("failure_message", k));
message.deploy_failure_reason = samples::deploy_failure_reason(k + 6);
message.made_current = states::flag(1, k);
message.service = states::plain(k, states::text("service", k));
message.failed_exit_code = states::plain(k, -(states::number(10, k) as i32));
message.snapshot_id = states::plain(k, states::text("snapshot_id", k));
message.restored_volumes = states::many(
k,
[
states::text("restored_volumes", k),
states::text("restored_volumes", k + 1),
],
);
message.undo_snapshot_id = states::plain(k, states::text("undo_snapshot_id", k));
message.github_commit = states::maybe(k, samples::github_commit(k + 13));
message.archive_name = states::plain(k, states::text("archive_name", k));
message.adjustments = states::many(k, [states::text("adjustments", k), states::text("adjustments", k + 1)]);
message.changed_paths = states::many(
k,
[states::text("changed_paths", k), states::text("changed_paths", k + 1)],
);
message.changed_path_count = states::plain(k, states::number(18, k));
message.files_kept = states::flag(2, k);
})
}
pub fn snapshot(k: usize) -> types::Snapshot {
states::make(|message: &mut types::Snapshot| {
message.snapshot_id = states::plain(k, states::text("snapshot_id", k));
message.create_time = states::maybe(k, states::time(states::number(2, k + 1)));
message.size_bytes = states::plain(k, u64::from(states::number(3, k)) << 32);
message.volumes = states::many(k, [states::text("volumes", k), states::text("volumes", k + 1)]);
})
}
pub fn http_traffic_summary(k: usize) -> types::HttpTrafficSummary {
states::make(|message: &mut types::HttpTrafficSummary| {
message.request_count = states::plain(k, u64::from(states::number(1, k)) << 32);
message.server_error_count = states::plain(k, u64::from(states::number(2, k)) << 32);
message.latency_p50_ms = states::plain(k, states::number(3, k));
message.latency_p95_ms = states::plain(k, states::number(4, k));
})
}
pub fn create_project_request(k: usize) -> types::CreateProjectRequest {
types::CreateProjectRequest {
project_id: states::plain(k, states::text("project_id", k)),
source: states::maybe(k, samples::project_source(k + 1)),
upload_id: states::plain(k, states::text("upload_id", k)),
files: states::many(k, [samples::file_change(k + 3), samples::file_change(k + 4)]),
x_pethost: states::maybe(k, samples::project_extension(k + 4)),
timeout_seconds: states::plain(k, states::number(6, k)),
operation_id: states::plain(k, states::text("operation_id", k)),
wait_seconds: states::marked(k, states::number(9, k)),
}
}
pub fn create_project_response(k: usize) -> types::CreateProjectResponse {
states::make(|message: &mut types::CreateProjectResponse| {
message.operation = states::maybe(k, samples::operation(k));
message.violations = states::many(k, [samples::spec_violation(k + 1), samples::spec_violation(k + 2)]);
message.adjustments = states::many(k, [states::text("adjustments", k), states::text("adjustments", k + 1)]);
message.project = states::maybe(k, samples::project(k + 3));
message.log = states::many(
k,
[samples::operation_log_line(k + 4), samples::operation_log_line(k + 5)],
);
})
}
pub fn deploy_project_request(k: usize) -> types::DeployProjectRequest {
types::DeployProjectRequest {
project_id: states::plain(k, states::text("project_id", k)),
base_deploy_id: states::plain(k, states::text("base_deploy_id", k)),
files: states::many(k, [samples::file_change(k + 2), samples::file_change(k + 3)]),
x_pethost: states::maybe(k, samples::project_extension(k + 3)),
mount_volume: states::maybe(k, samples::mount_volume(k + 4)),
timeout_seconds: states::plain(k, states::number(4, k)),
operation_id: states::plain(k, states::text("operation_id", k)),
version: match k % 10 {
0 => None,
1 => None,
2 => Some(types::DeployProjectRequestVersion::UploadId(states::text(
"upload_id",
k,
))),
3 => Some(types::DeployProjectRequestVersion::Commit(states::text("commit", k))),
4 => Some(types::DeployProjectRequestVersion::NewestCommit(true)),
5 => Some(types::DeployProjectRequestVersion::RollbackDeployId(states::text(
"rollback_deploy_id",
k,
))),
6 => Some(types::DeployProjectRequestVersion::UploadId(Default::default())),
7 => Some(types::DeployProjectRequestVersion::Commit(Default::default())),
8 => Some(types::DeployProjectRequestVersion::NewestCommit(Default::default())),
_ => Some(types::DeployProjectRequestVersion::RollbackDeployId(Default::default())),
},
wait_seconds: states::marked(k, states::number(13, k)),
}
}
pub fn mount_volume(k: usize) -> types::MountVolume {
types::MountVolume {
service: states::plain(k, states::text("service", k)),
volume: states::plain(k, states::text("volume", k)),
container_path: states::plain(k, states::text("container_path", k)),
}
}
pub fn project_extension(k: usize) -> types::ProjectExtension {
types::ProjectExtension {
metadata: states::maybe(k, samples::project_metadata(k)),
routes: states::many(k, [samples::route(k + 1), samples::route(k + 2)]),
remove_routes: states::flag(1, k),
password: states::plain(k, states::text("password", k)),
remove_password: states::flag(2, k),
}
}
pub fn file_change(k: usize) -> types::FileChange {
types::FileChange {
path: states::plain(k, states::text("path", k)),
change: match k % 14 {
0 => None,
1 => None,
2 => Some(types::FileChangeChange::Text(states::text("text", k))),
3 => Some(types::FileChangeChange::Data(states::text("data", k).into_bytes())),
4 => Some(types::FileChangeChange::MakeDirectory(true)),
5 => Some(types::FileChangeChange::Delete(true)),
6 => Some(types::FileChangeChange::DeleteTree(true)),
7 => Some(types::FileChangeChange::RenameTo(states::text("rename_to", k))),
8 => Some(types::FileChangeChange::Text(Default::default())),
9 => Some(types::FileChangeChange::Data(Default::default())),
10 => Some(types::FileChangeChange::MakeDirectory(Default::default())),
11 => Some(types::FileChangeChange::Delete(Default::default())),
12 => Some(types::FileChangeChange::DeleteTree(Default::default())),
_ => Some(types::FileChangeChange::RenameTo(Default::default())),
},
executable: states::flag(1, k),
}
}
pub fn deploy_project_response(k: usize) -> types::DeployProjectResponse {
states::make(|message: &mut types::DeployProjectResponse| {
message.operation = states::maybe(k, samples::operation(k));
message.violations = states::many(k, [samples::spec_violation(k + 1), samples::spec_violation(k + 2)]);
message.adjustments = states::many(k, [states::text("adjustments", k), states::text("adjustments", k + 1)]);
message.project = states::maybe(k, samples::project(k + 3));
message.log = states::many(
k,
[samples::operation_log_line(k + 4), samples::operation_log_line(k + 5)],
);
})
}
pub fn spec_violation(k: usize) -> types::SpecViolation {
states::make(|message: &mut types::SpecViolation| {
message.service = states::plain(k, states::text("service", k));
message.location = states::plain(k, states::text("location", k));
message.violation_message = states::plain(k, states::text("violation_message", k));
})
}
pub fn list_commits_request(k: usize) -> types::ListCommitsRequest {
types::ListCommitsRequest {
project_id: states::plain(k, states::text("project_id", k)),
before_commit: states::plain(k, states::text("before_commit", k)),
}
}
pub fn list_commits_response(k: usize) -> types::ListCommitsResponse {
states::make(|message: &mut types::ListCommitsResponse| {
message.commits = states::many(k, [samples::branch_commit(k), samples::branch_commit(k + 1)]);
message.more = states::flag(1, k);
})
}
pub fn branch_commit(k: usize) -> types::BranchCommit {
states::make(|message: &mut types::BranchCommit| {
message.commit = states::maybe(k, samples::github_commit(k));
message.author = states::plain(k, states::text("author", k));
message.commit_time = states::maybe(k, states::time(states::number(3, k + 2)));
message.deployed = states::flag(1, k);
message.last_deploy = states::maybe(k, samples::operation(k + 4));
message.newest = states::flag(2, k);
})
}
pub fn run_project_action_request(k: usize) -> types::RunProjectActionRequest {
types::RunProjectActionRequest {
project_id: states::plain(k, states::text("project_id", k)),
action: match k % 22 {
0 => None,
1 => None,
2 => Some(types::RunProjectActionRequestAction::StartServices(
samples::services_action(k),
)),
3 => Some(types::RunProjectActionRequestAction::StopServices(
samples::services_action(k),
)),
4 => Some(types::RunProjectActionRequestAction::RestartServices(
samples::services_action(k),
)),
5 => Some(types::RunProjectActionRequestAction::RecreateService(
samples::recreate_service_action(k),
)),
6 => Some(types::RunProjectActionRequestAction::BackUp(samples::back_up_action(k))),
7 => Some(types::RunProjectActionRequestAction::RestoreSnapshot(
samples::restore_snapshot_action(k),
)),
8 => Some(types::RunProjectActionRequestAction::CancelOperation(
samples::cancel_operation_action(k),
)),
9 => Some(types::RunProjectActionRequestAction::DeleteProject(
samples::delete_project_action(k),
)),
10 => Some(types::RunProjectActionRequestAction::SetSource(
samples::project_source(k),
)),
11 => Some(types::RunProjectActionRequestAction::DeleteVolume(states::text(
"delete_volume",
k,
))),
12 => Some(types::RunProjectActionRequestAction::StartServices(Default::default())),
13 => Some(types::RunProjectActionRequestAction::StopServices(Default::default())),
14 => Some(types::RunProjectActionRequestAction::RestartServices(Default::default())),
15 => Some(types::RunProjectActionRequestAction::RecreateService(Default::default())),
16 => Some(types::RunProjectActionRequestAction::BackUp(Default::default())),
17 => Some(types::RunProjectActionRequestAction::RestoreSnapshot(Default::default())),
18 => Some(types::RunProjectActionRequestAction::CancelOperation(Default::default())),
19 => Some(types::RunProjectActionRequestAction::DeleteProject(Default::default())),
20 => Some(types::RunProjectActionRequestAction::SetSource(Default::default())),
_ => Some(types::RunProjectActionRequestAction::DeleteVolume(Default::default())),
},
operation_id: states::plain(k, states::text("operation_id", k)),
wait_seconds: states::marked(k, states::number(13, k)),
}
}
pub fn services_action(k: usize) -> types::ServicesAction {
types::ServicesAction {
services: states::many(k, [states::text("services", k), states::text("services", k + 1)]),
}
}
pub fn recreate_service_action(k: usize) -> types::RecreateServiceAction {
types::RecreateServiceAction {
service: states::plain(k, states::text("service", k)),
pull_latest_image: states::flag(1, k),
}
}
pub fn back_up_action(_k: usize) -> types::BackUpAction {
types::BackUpAction {}
}
pub fn restore_snapshot_action(k: usize) -> types::RestoreSnapshotAction {
types::RestoreSnapshotAction {
snapshot_id: states::plain(k, states::text("snapshot_id", k)),
volumes: states::many(k, [states::text("volumes", k), states::text("volumes", k + 1)]),
}
}
pub fn cancel_operation_action(k: usize) -> types::CancelOperationAction {
types::CancelOperationAction {
operation_id: states::plain(k, states::text("operation_id", k)),
}
}
pub fn delete_project_action(k: usize) -> types::DeleteProjectAction {
types::DeleteProjectAction {
skip_final_backup: states::flag(1, k),
}
}
pub fn run_project_action_response(k: usize) -> types::RunProjectActionResponse {
states::make(|message: &mut types::RunProjectActionResponse| {
message.operation = states::maybe(k, samples::operation(k));
message.project = states::maybe(k, samples::project(k + 1));
message.log = states::many(
k,
[samples::operation_log_line(k + 2), samples::operation_log_line(k + 3)],
);
})
}
pub fn get_operation_request(k: usize) -> types::GetOperationRequest {
types::GetOperationRequest {
project_id: states::plain(k, states::text("project_id", k)),
operation_id: states::plain(k, states::text("operation_id", k)),
wait_seconds: states::marked(k, states::number(3, k)),
after_log_line: states::marked(k, states::number(4, k)),
log_line_limit: states::marked(k, states::number(5, k)),
}
}
pub fn get_operation_response(k: usize) -> types::GetOperationResponse {
states::make(|message: &mut types::GetOperationResponse| {
message.operation = states::maybe(k, samples::operation(k));
message.project = states::maybe(k, samples::project(k + 1));
message.log = states::many(
k,
[samples::operation_log_line(k + 2), samples::operation_log_line(k + 3)],
);
message.log_line_count = states::plain(k, states::number(3, k));
message.next_after_log_line = states::plain(k, states::number(4, k));
})
}
pub fn operation_log_line(k: usize) -> types::OperationLogLine {
states::make(|message: &mut types::OperationLogLine| {
message.time = states::maybe(k, states::time(states::number(1, k)));
message.text = states::plain(k, states::text("text", k));
})
}
pub fn http_traffic_filter(k: usize) -> types::HttpTrafficFilter {
types::HttpTrafficFilter {
host: states::plain(k, states::text("host", k)),
method: states::plain(k, states::text("method", k)),
path_contains: states::plain(k, states::text("path_contains", k)),
path_pattern: states::plain(k, states::text("path_pattern", k)),
status_class: states::plain(k, states::number(5, k)),
}
}
pub fn query_http_traffic_request(k: usize) -> types::QueryHttpTrafficRequest {
types::QueryHttpTrafficRequest {
project_id: states::plain(k, states::text("project_id", k)),
filter: states::maybe(k, samples::http_traffic_filter(k + 1)),
start_time: states::maybe(k, states::time(states::number(3, k + 2))),
end_time: states::maybe(k, states::time(states::number(4, k + 3))),
last_seconds: states::plain(k, states::number(8, k)),
bucket_width_seconds: states::plain(k, states::number(5, k)),
request_limit: states::plain(k, states::number(6, k)),
page_token: states::plain(k, states::text("page_token", k)),
}
}
pub fn query_http_traffic_response(k: usize) -> types::QueryHttpTrafficResponse {
states::make(|message: &mut types::QueryHttpTrafficResponse| {
message.start_time = states::maybe(k, states::time(states::number(1, k)));
message.end_time = states::maybe(k, states::time(states::number(2, k + 1)));
message.oldest_kept_time = states::maybe(k, states::time(states::number(8, k + 2)));
message.summary = states::maybe(k, samples::http_traffic_summary(k + 3));
message.buckets = states::many(
k,
[samples::http_traffic_bucket(k + 4), samples::http_traffic_bucket(k + 5)],
);
message.top_paths = states::many(
k,
[samples::http_path_traffic(k + 5), samples::http_path_traffic(k + 6)],
);
message.newest_sequence = states::plain(k, u64::from(states::number(9, k)) << 32);
message.requests = states::many(k, [samples::http_request(k + 7), samples::http_request(k + 8)]);
message.next_page_token = states::plain(k, states::text("next_page_token", k));
message.tail_sequence = states::plain(k, u64::from(states::number(10, k)) << 32);
})
}
pub fn http_traffic_bucket(k: usize) -> types::HttpTrafficBucket {
states::make(|message: &mut types::HttpTrafficBucket| {
message.start_time = states::maybe(k, states::time(states::number(1, k)));
message.summary = states::maybe(k, samples::http_traffic_summary(k + 1));
})
}
pub fn http_path_traffic(k: usize) -> types::HttpPathTraffic {
states::make(|message: &mut types::HttpPathTraffic| {
message.method = states::plain(k, states::text("method", k));
message.path_pattern = states::plain(k, states::text("path_pattern", k));
message.summary = states::maybe(k, samples::http_traffic_summary(k + 2));
})
}
pub fn http_request(k: usize) -> types::HttpRequest {
states::make(|message: &mut types::HttpRequest| {
message.sequence = states::plain(k, u64::from(states::number(1, k)) << 32);
message.finish_time = states::maybe(k, states::time(states::number(2, k + 1)));
message.host = states::plain(k, states::text("host", k));
message.method = states::plain(k, states::text("method", k));
message.path = states::plain(k, states::text("path", k));
message.path_pattern = states::plain(k, states::text("path_pattern", k));
message.route_path = states::plain(k, states::text("route_path", k));
message.service = states::plain(k, states::text("service", k));
message.port = states::plain(k, states::number(9, k));
message.status_code = states::plain(k, states::number(10, k));
message.response_size_bytes = states::plain(k, u64::from(states::number(11, k)) << 32);
message.duration_ms = states::plain(k, states::number(12, k));
message.service_duration_ms = states::plain(k, states::number(13, k));
message.client_ip_address = states::plain(k, states::text("client_ip_address", k));
message.user_agent = states::plain(k, states::text("user_agent", k));
})
}
pub fn container_log_filter(k: usize) -> types::ContainerLogFilter {
types::ContainerLogFilter {
service: states::plain(k, states::text("service", k)),
stream: samples::output_stream(k + 1),
text_contains: states::plain(k, states::text("text_contains", k)),
}
}
pub fn query_container_logs_request(k: usize) -> types::QueryContainerLogsRequest {
types::QueryContainerLogsRequest {
project_id: states::plain(k, states::text("project_id", k)),
filter: states::maybe(k, samples::container_log_filter(k + 1)),
start_time: states::maybe(k, states::time(states::number(3, k + 2))),
end_time: states::maybe(k, states::time(states::number(4, k + 3))),
last_seconds: states::plain(k, states::number(8, k)),
limit: states::plain(k, states::number(5, k)),
from_start: states::flag(1, k),
page_token: states::plain(k, states::text("page_token", k)),
}
}
pub fn query_container_logs_response(k: usize) -> types::QueryContainerLogsResponse {
states::make(|message: &mut types::QueryContainerLogsResponse| {
message.start_time = states::maybe(k, states::time(states::number(4, k)));
message.end_time = states::maybe(k, states::time(states::number(5, k + 1)));
message.oldest_kept_time = states::maybe(k, states::time(states::number(6, k + 2)));
message.lines = states::many(k, [samples::log_line(k + 3), samples::log_line(k + 4)]);
message.next_page_token = states::plain(k, states::text("next_page_token", k));
message.tail_cursor = states::plain(k, states::text("tail_cursor", k));
})
}
pub fn log_line(k: usize) -> types::LogLine {
states::make(|message: &mut types::LogLine| {
message.time = states::maybe(k, states::time(states::number(1, k)));
message.service = states::plain(k, states::text("service", k));
message.stream = samples::output_stream(k + 2);
message.text = states::plain(k, states::text("text", k));
})
}
pub fn run_service_command_request(k: usize) -> types::RunServiceCommandRequest {
types::RunServiceCommandRequest {
project_id: states::plain(k, states::text("project_id", k)),
service: states::plain(k, states::text("service", k)),
command: states::many(k, [states::text("command", k), states::text("command", k + 1)]),
stdin: states::plain(k, states::text("stdin", k)),
run_as_user: states::plain(k, states::text("run_as_user", k)),
working_directory: states::plain(k, states::text("working_directory", k)),
timeout_seconds: states::plain(k, states::number(7, k)),
}
}
pub fn run_service_command_response(k: usize) -> types::RunServiceCommandResponse {
states::make(|message: &mut types::RunServiceCommandResponse| {
message.exit_code = states::plain(k, -(states::number(1, k) as i32));
message.timed_out = states::flag(1, k);
message.stdout = states::plain(k, states::text("stdout", k));
message.stderr = states::plain(k, states::text("stderr", k));
message.output_truncated = states::flag(2, k);
})
}
pub fn file_entry(k: usize) -> types::FileEntry {
states::make(|message: &mut types::FileEntry| {
message.name = states::plain(k, states::text("name", k));
message.r#type = samples::file_type(k + 1);
message.size_bytes = states::plain(k, u64::from(states::number(3, k)) << 32);
message.modify_time = states::maybe(k, states::time(states::number(4, k + 3)));
message.mode = states::plain(k, states::text("mode", k));
message.owner_uid = states::plain(k, states::number(6, k));
message.owner_gid = states::plain(k, states::number(7, k));
message.symlink_target = states::plain(k, states::text("symlink_target", k));
})
}
pub fn read_path_request(k: usize) -> types::ReadPathRequest {
types::ReadPathRequest {
project_id: states::plain(k, states::text("project_id", k)),
root: match k % 6 {
0 => None,
1 => None,
2 => Some(types::ReadPathRequestRoot::Service(states::text("service", k))),
3 => Some(types::ReadPathRequestRoot::Volume(states::text("volume", k))),
4 => Some(types::ReadPathRequestRoot::Service(Default::default())),
_ => Some(types::ReadPathRequestRoot::Volume(Default::default())),
},
path: states::plain(k, states::text("path", k)),
entry_limit: states::plain(k, states::number(6, k)),
offset_bytes: states::plain(k, u64::from(states::number(7, k)) << 32),
length_bytes: states::plain(k, states::number(8, k)),
entry_page_token: states::plain(k, states::text("entry_page_token", k)),
}
}
pub fn read_path_response(k: usize) -> types::ReadPathResponse {
states::make(|message: &mut types::ReadPathResponse| {
message.entry = states::maybe(k, samples::file_entry(k));
message.location = samples::file_location(k + 1);
message.volume = states::plain(k, states::text("volume", k));
message.entries = states::many(k, [samples::file_entry(k + 3), samples::file_entry(k + 4)]);
message.entry_count = states::plain(k, states::number(4, k));
message.next_entry_page_token = states::plain(k, states::text("next_entry_page_token", k));
message.text = states::plain(k, states::text("text", k));
message.binary = states::flag(1, k);
message.next_offset_bytes = states::plain(k, u64::from(states::number(7, k)) << 32);
message.deploy_id = states::plain(k, states::text("deploy_id", k));
})
}
pub fn create_transfer_request(k: usize) -> types::CreateTransferRequest {
types::CreateTransferRequest {
transfer: match k % 8 {
0 => None,
1 => None,
2 => Some(types::CreateTransferRequestTransfer::UploadArchive(
samples::archive_upload(k),
)),
3 => Some(types::CreateTransferRequestTransfer::UploadFile(samples::file_upload(
k,
))),
4 => Some(types::CreateTransferRequestTransfer::Download(samples::path_download(
k,
))),
5 => Some(types::CreateTransferRequestTransfer::UploadArchive(Default::default())),
6 => Some(types::CreateTransferRequestTransfer::UploadFile(Default::default())),
_ => Some(types::CreateTransferRequestTransfer::Download(Default::default())),
},
}
}
pub fn archive_upload(k: usize) -> types::ArchiveUpload {
types::ArchiveUpload {
file_name: states::plain(k, states::text("file_name", k)),
}
}
pub fn file_upload(k: usize) -> types::FileUpload {
types::FileUpload {
project_id: states::plain(k, states::text("project_id", k)),
root: match k % 6 {
0 => None,
1 => None,
2 => Some(types::FileUploadRoot::Service(states::text("service", k))),
3 => Some(types::FileUploadRoot::Volume(states::text("volume", k))),
4 => Some(types::FileUploadRoot::Service(Default::default())),
_ => Some(types::FileUploadRoot::Volume(Default::default())),
},
path: states::plain(k, states::text("path", k)),
}
}
pub fn path_download(k: usize) -> types::PathDownload {
types::PathDownload {
project_id: states::plain(k, states::text("project_id", k)),
root: match k % 6 {
0 => None,
1 => None,
2 => Some(types::PathDownloadRoot::Service(states::text("service", k))),
3 => Some(types::PathDownloadRoot::Volume(states::text("volume", k))),
4 => Some(types::PathDownloadRoot::Service(Default::default())),
_ => Some(types::PathDownloadRoot::Volume(Default::default())),
},
path: states::plain(k, states::text("path", k)),
}
}
pub fn create_transfer_response(k: usize) -> types::CreateTransferResponse {
states::make(|message: &mut types::CreateTransferResponse| {
message.url = states::plain(k, states::text("url", k));
message.http_method = states::plain(k, states::text("http_method", k));
message.expire_time = states::maybe(k, states::time(states::number(3, k + 2)));
message.command = states::plain(k, states::text("command", k));
message.upload_id = states::plain(k, states::text("upload_id", k));
message.replaces = states::flag(1, k);
message.file_name = states::plain(k, states::text("file_name", k));
})
}
pub fn project_busy(k: usize) -> types::ProjectBusy {
states::make(|message: &mut types::ProjectBusy| {
message.operation_id = states::plain(k, states::text("operation_id", k));
message.kind = samples::operation_kind(k + 1);
message.start_time = states::maybe(k, states::time(states::number(3, k + 2)));
})
}
pub fn project_changed(_k: usize) -> types::ProjectChanged {
types::ProjectChanged::default()
}
pub fn machine_unreachable(_k: usize) -> types::MachineUnreachable {
types::MachineUnreachable::default()
}
pub fn no_machine(k: usize) -> types::NoMachine {
states::make(|message: &mut types::NoMachine| {
message.reason = samples::no_machine_reason(k);
message.url = states::plain(k, states::text("url", k));
})
}
}
mod on_wire {
use super::*;
pub fn machine_session_kind(k: usize) -> buffa::EnumValue<wire::MachineSessionKind> {
let number = match k % 7 {
0 => 0,
1 => 1,
2 => 2,
3 => 3,
4 => 4,
5 => 5,
_ => 6,
};
buffa::EnumValue::from(number)
}
pub fn project_problem_kind(k: usize) -> buffa::EnumValue<wire::ProjectProblemKind> {
let number = match k % 12 {
0 => 0,
1 => 1,
2 => 2,
3 => 3,
4 => 4,
5 => 5,
6 => 6,
7 => 7,
8 => 8,
9 => 9,
10 => 10,
_ => 11,
};
buffa::EnumValue::from(number)
}
pub fn services_action_kind(k: usize) -> buffa::EnumValue<wire::ServicesActionKind> {
let number = match k % 5 {
0 => 0,
1 => 1,
2 => 2,
3 => 3,
_ => 4,
};
buffa::EnumValue::from(number)
}
pub fn service_state(k: usize) -> buffa::EnumValue<wire::ServiceState> {
let number = match k % 10 {
0 => 0,
1 => 1,
2 => 2,
3 => 3,
4 => 4,
5 => 5,
6 => 6,
7 => 7,
8 => 8,
_ => 9,
};
buffa::EnumValue::from(number)
}
pub fn restart_policy(k: usize) -> buffa::EnumValue<wire::RestartPolicy> {
let number = match k % 6 {
0 => 0,
1 => 1,
2 => 2,
3 => 3,
4 => 4,
_ => 5,
};
buffa::EnumValue::from(number)
}
pub fn health_status(k: usize) -> buffa::EnumValue<wire::HealthStatus> {
let number = match k % 5 {
0 => 0,
1 => 1,
2 => 2,
3 => 3,
_ => 4,
};
buffa::EnumValue::from(number)
}
pub fn certificate_source(k: usize) -> buffa::EnumValue<wire::CertificateSource> {
let number = match k % 5 {
0 => 0,
1 => 1,
2 => 2,
3 => 3,
_ => 4,
};
buffa::EnumValue::from(number)
}
pub fn operation_kind(k: usize) -> buffa::EnumValue<wire::OperationKind> {
let number = match k % 7 {
0 => 0,
1 => 1,
2 => 2,
3 => 3,
4 => 4,
5 => 5,
_ => 6,
};
buffa::EnumValue::from(number)
}
pub fn operation_status(k: usize) -> buffa::EnumValue<wire::OperationStatus> {
let number = match k % 6 {
0 => 0,
1 => 1,
2 => 2,
3 => 3,
4 => 4,
_ => 5,
};
buffa::EnumValue::from(number)
}
pub fn deploy_failure_reason(k: usize) -> buffa::EnumValue<wire::DeployFailureReason> {
let number = match k % 13 {
0 => 0,
1 => 1,
2 => 2,
3 => 3,
4 => 4,
5 => 5,
6 => 6,
7 => 7,
8 => 8,
9 => 9,
10 => 10,
11 => 11,
_ => 12,
};
buffa::EnumValue::from(number)
}
pub fn output_stream(k: usize) -> buffa::EnumValue<wire::OutputStream> {
let number = match k % 4 {
0 => 0,
1 => 1,
2 => 2,
_ => 3,
};
buffa::EnumValue::from(number)
}
pub fn file_type(k: usize) -> buffa::EnumValue<wire::FileType> {
let number = match k % 6 {
0 => 0,
1 => 1,
2 => 2,
3 => 3,
4 => 4,
_ => 5,
};
buffa::EnumValue::from(number)
}
pub fn file_location(k: usize) -> buffa::EnumValue<wire::FileLocation> {
let number = match k % 5 {
0 => 0,
1 => 1,
2 => 2,
3 => 3,
_ => 4,
};
buffa::EnumValue::from(number)
}
pub fn no_machine_reason(k: usize) -> buffa::EnumValue<wire::NoMachineReason> {
let number = match k % 4 {
0 => 0,
1 => 1,
2 => 2,
_ => 3,
};
buffa::EnumValue::from(number)
}
pub fn get_machine_request(k: usize, received: bool) -> wire::GetMachineRequest {
let mut message = wire::GetMachineRequest { ..Default::default() };
if received && k % 2 == 1 {
message.__buffa_unknown_fields.push(states::later_field());
}
message
}
pub fn get_machine_response(k: usize, received: bool) -> wire::GetMachineResponse {
let mut message = wire::GetMachineResponse {
machine: states::maybe(k, on_wire::machine(k, received)).into(),
projects: states::many(
k,
[
on_wire::project_summary(k + 1, received),
on_wire::project_summary(k + 2, received),
],
),
deleted_projects: states::many(
k,
[
on_wire::deleted_project(k + 2, received),
on_wire::deleted_project(k + 3, received),
],
),
github: states::maybe(k, on_wire::github_connection(k + 3, received)).into(),
..Default::default()
};
if received && k % 2 == 1 {
message.__buffa_unknown_fields.push(states::later_field());
}
message
}
pub fn machine(k: usize, received: bool) -> wire::Machine {
let mut message = wire::Machine {
name: states::present(states::plain(k, states::text("name", k))),
location: states::present(states::plain(k, states::text("location", k))),
sample_time: states::maybe(k, states::time_on_wire(states::number(3, k + 2))).into(),
cpu_used_cores: states::present(states::plain(k, f64::from(states::number(5, k)) + 0.5)),
cpu_total_cores: states::present(states::plain(k, f64::from(states::number(6, k)) + 0.5)),
memory_used_bytes: states::present(states::plain(k, u64::from(states::number(7, k)) << 32)),
memory_total_bytes: states::present(states::plain(k, u64::from(states::number(8, k)) << 32)),
disk_used_bytes: states::present(states::plain(k, u64::from(states::number(9, k)) << 32)),
disk_total_bytes: states::present(states::plain(k, u64::from(states::number(10, k)) << 32)),
disk_usage: states::maybe(k, on_wire::disk_usage(k + 9, received)).into(),
hostname: states::present(states::plain(k, states::text("hostname", k))),
ssh_host_key_fingerprint: states::present(states::plain(k, states::text("ssh_host_key_fingerprint", k))),
ssh_keys: states::many(
k,
[on_wire::ssh_key(k + 12, received), on_wire::ssh_key(k + 13, received)],
),
backups_enabled: states::present(states::flag(1, k)),
snapshot_list_time: states::maybe(k, states::time_on_wire(states::number(22, k + 14))).into(),
snapshot_list_failure_message: states::present(states::plain(
k,
states::text("snapshot_list_failure_message", k),
)),
backup_retention_hours: states::present(states::plain(k, states::number(4, k))),
acme_enabled: states::present(states::flag(2, k)),
apps_domain: states::present(states::plain(k, states::text("apps_domain", k))),
daemon_version: states::present(states::plain(k, states::text("daemon_version", k))),
docker_version: states::present(states::plain(k, states::text("docker_version", k))),
boot_time: states::maybe(k, states::time_on_wire(states::number(18, k + 21))).into(),
restart_required_time: states::maybe(k, states::time_on_wire(states::number(19, k + 22))).into(),
scheduled_restart_time: states::maybe(k, states::time_on_wire(states::number(20, k + 23))).into(),
sessions: states::many(
k,
[
on_wire::machine_session(k + 24, received),
on_wire::machine_session(k + 25, received),
],
),
..Default::default()
};
if received && k % 2 == 1 {
message.__buffa_unknown_fields.push(states::later_field());
}
message
}
pub fn machine_session(k: usize, received: bool) -> wire::MachineSession {
let mut message = wire::MachineSession {
session_id: states::present(states::plain(k, states::text("session_id", k))),
kind: states::set(on_wire::machine_session_kind(k + 1)),
project_id: states::present(states::plain(k, states::text("project_id", k))),
service: states::present(states::plain(k, states::text("service", k))),
port: states::present(states::plain(k, states::number(5, k))),
start_time: states::maybe(k, states::time_on_wire(states::number(6, k + 5))).into(),
client_address: states::present(states::plain(k, states::text("client_address", k))),
ssh_key_label: states::present(states::plain(k, states::text("ssh_key_label", k))),
ssh_key_fingerprint: states::present(states::plain(k, states::text("ssh_key_fingerprint", k))),
..Default::default()
};
if received && k % 2 == 1 {
message.__buffa_unknown_fields.push(states::later_field());
}
message
}
pub fn disk_usage(k: usize, received: bool) -> wire::DiskUsage {
let mut message = wire::DiskUsage {
images_bytes: states::present(states::plain(k, u64::from(states::number(1, k)) << 32)),
build_cache_bytes: states::marked(k, u64::from(states::number(2, k)) << 32),
volumes_bytes: states::present(states::plain(k, u64::from(states::number(3, k)) << 32)),
container_layers_bytes: states::present(states::plain(k, u64::from(states::number(4, k)) << 32)),
project_files_bytes: states::present(states::plain(k, u64::from(states::number(5, k)) << 32)),
container_logs_bytes: states::present(states::plain(k, u64::from(states::number(6, k)) << 32)),
http_traffic_bytes: states::present(states::plain(k, u64::from(states::number(7, k)) << 32)),
..Default::default()
};
if received && k % 2 == 1 {
message.__buffa_unknown_fields.push(states::later_field());
}
message
}
pub fn ssh_key(k: usize, received: bool) -> wire::SshKey {
let mut message = wire::SshKey {
public_key: states::present(states::plain(k, states::text("public_key", k))),
label: states::present(states::plain(k, states::text("label", k))),
fingerprint: states::present(states::plain(k, states::text("fingerprint", k))),
..Default::default()
};
if received && k % 2 == 1 {
message.__buffa_unknown_fields.push(states::later_field());
}
message
}
pub fn github_connection(k: usize, received: bool) -> wire::GithubConnection {
let mut message = wire::GithubConnection {
app_name: states::present(states::plain(k, states::text("app_name", k))),
install_url: states::present(states::plain(k, states::text("install_url", k))),
repositories: states::many(
k,
[
on_wire::github_repository(k + 2, received),
on_wire::github_repository(k + 3, received),
],
),
repository_count: states::present(states::plain(k, states::number(4, k))),
webhooks_enabled: states::present(states::flag(1, k)),
..Default::default()
};
if received && k % 2 == 1 {
message.__buffa_unknown_fields.push(states::later_field());
}
message
}
pub fn github_repository(k: usize, received: bool) -> wire::GithubRepository {
let mut message = wire::GithubRepository {
repository: states::present(states::plain(k, states::text("repository", k))),
default_branch: states::present(states::plain(k, states::text("default_branch", k))),
private: states::present(states::flag(1, k)),
push_time: states::maybe(k, states::time_on_wire(states::number(4, k + 3))).into(),
..Default::default()
};
if received && k % 2 == 1 {
message.__buffa_unknown_fields.push(states::later_field());
}
message
}
pub fn deleted_project(k: usize, received: bool) -> wire::DeletedProject {
let mut message = wire::DeletedProject {
project_id: states::present(states::plain(k, states::text("project_id", k))),
newest_snapshot: states::maybe(k, on_wire::snapshot(k + 1, received)).into(),
snapshot_count: states::present(states::plain(k, states::number(3, k))),
..Default::default()
};
if received && k % 2 == 1 {
message.__buffa_unknown_fields.push(states::later_field());
}
message
}
pub fn run_machine_action_request(k: usize, received: bool) -> wire::RunMachineActionRequest {
let mut message = wire::RunMachineActionRequest {
action: match k % 12 {
0 | 1 => None,
2 => Some(wire::__buffa::oneof::run_machine_action_request::Action::AddSshKey(
Box::new(on_wire::ssh_key(k, received)),
)),
3 => Some(
wire::__buffa::oneof::run_machine_action_request::Action::RemoveSshKeyFingerprint(states::text(
"remove_ssh_key_fingerprint",
k,
)),
),
4 => Some(
wire::__buffa::oneof::run_machine_action_request::Action::RestartMachine(Box::new(
on_wire::restart_machine_action(k, received),
)),
),
5 => Some(wire::__buffa::oneof::run_machine_action_request::Action::CancelRestart(
true,
)),
6 => Some(wire::__buffa::oneof::run_machine_action_request::Action::EndSessionId(
states::text("end_session_id", k),
)),
7 => Some(wire::__buffa::oneof::run_machine_action_request::Action::AddSshKey(
Default::default(),
)),
8 => Some(
wire::__buffa::oneof::run_machine_action_request::Action::RemoveSshKeyFingerprint(
Default::default(),
),
),
9 => Some(wire::__buffa::oneof::run_machine_action_request::Action::RestartMachine(Default::default())),
10 => Some(wire::__buffa::oneof::run_machine_action_request::Action::CancelRestart(
Default::default(),
)),
_ => Some(wire::__buffa::oneof::run_machine_action_request::Action::EndSessionId(
Default::default(),
)),
},
..Default::default()
};
if received && k % 2 == 1 {
message.__buffa_unknown_fields.push(states::later_field());
}
message
}
pub fn restart_machine_action(k: usize, received: bool) -> wire::RestartMachineAction {
let mut message = wire::RestartMachineAction {
restart_time: states::maybe(k, states::time_on_wire(states::number(1, k))).into(),
at_maintenance_window: states::present(states::flag(1, k)),
interrupt_operations: states::present(states::flag(2, k)),
..Default::default()
};
if received && k % 2 == 1 {
message.__buffa_unknown_fields.push(states::later_field());
}
message
}
pub fn run_machine_action_response(k: usize, received: bool) -> wire::RunMachineActionResponse {
let mut message = wire::RunMachineActionResponse {
machine: states::maybe(k, on_wire::machine(k, received)).into(),
..Default::default()
};
if received && k % 2 == 1 {
message.__buffa_unknown_fields.push(states::later_field());
}
message
}
pub fn project_metadata(k: usize, received: bool) -> wire::ProjectMetadata {
let mut message = wire::ProjectMetadata {
name: states::marked(k, states::text("name", k)),
emoji: states::marked(k, states::text("emoji", k)),
description: states::marked(k, states::text("description", k)),
notes: states::marked(k, states::text("notes", k)),
..Default::default()
};
if received && k % 2 == 1 {
message.__buffa_unknown_fields.push(states::later_field());
}
message
}
pub fn project_summary(k: usize, received: bool) -> wire::ProjectSummary {
let mut message = wire::ProjectSummary {
project_id: states::present(states::plain(k, states::text("project_id", k))),
metadata: states::maybe(k, on_wire::project_metadata(k + 1, received)).into(),
problems: states::many(
k,
[
on_wire::project_problem(k + 2, received),
on_wire::project_problem(k + 3, received),
],
),
services: states::many(
k,
[
on_wire::service_summary(k + 3, received),
on_wire::service_summary(k + 4, received),
],
),
url: states::present(states::plain(k, states::text("url", k))),
hosts: states::many(k, [states::text("hosts", k), states::text("hosts", k + 1)]),
http_traffic_last_day: states::maybe(k, on_wire::http_traffic_summary(k + 6, received)).into(),
cpu_used_cores: states::present(states::plain(k, f64::from(states::number(8, k)) + 0.5)),
memory_used_bytes: states::present(states::plain(k, u64::from(states::number(9, k)) << 32)),
deploy_time: states::maybe(k, states::time_on_wire(states::number(10, k + 9))).into(),
running_operations: states::many(
k,
[
on_wire::operation(k + 10, received),
on_wire::operation(k + 11, received),
],
),
pinned: states::present(states::flag(1, k)),
disk_used_bytes: states::present(states::plain(k, u64::from(states::number(13, k)) << 32)),
..Default::default()
};
if received && k % 2 == 1 {
message.__buffa_unknown_fields.push(states::later_field());
}
message
}
pub fn service_summary(k: usize, received: bool) -> wire::ServiceSummary {
let mut message = wire::ServiceSummary {
service: states::present(states::plain(k, states::text("service", k))),
state: states::set(on_wire::service_state(k + 1)),
..Default::default()
};
if received && k % 2 == 1 {
message.__buffa_unknown_fields.push(states::later_field());
}
message
}
pub fn project_problem(k: usize, received: bool) -> wire::ProjectProblem {
let mut message = wire::ProjectProblem {
kind: states::set(on_wire::project_problem_kind(k)),
service: states::present(states::plain(k, states::text("service", k))),
operation_id: states::present(states::plain(k, states::text("operation_id", k))),
since_time: states::maybe(k, states::time_on_wire(states::number(4, k + 3))).into(),
problem_message: states::present(states::plain(k, states::text("problem_message", k))),
..Default::default()
};
if received && k % 2 == 1 {
message.__buffa_unknown_fields.push(states::later_field());
}
message
}
pub fn get_project_request(k: usize, received: bool) -> wire::GetProjectRequest {
let mut message = wire::GetProjectRequest {
project_id: states::present(states::plain(k, states::text("project_id", k))),
include_secret_values: states::present(states::flag(1, k)),
snapshots_before: states::maybe(k, states::time_on_wire(states::number(3, k + 2))).into(),
snapshots_volume: states::present(states::plain(k, states::text("snapshots_volume", k))),
..Default::default()
};
if received && k % 2 == 1 {
message.__buffa_unknown_fields.push(states::later_field());
}
message
}
pub fn get_project_response(k: usize, received: bool) -> wire::GetProjectResponse {
let mut message = wire::GetProjectResponse {
project: states::maybe(k, on_wire::project(k, received)).into(),
..Default::default()
};
if received && k % 2 == 1 {
message.__buffa_unknown_fields.push(states::later_field());
}
message
}
pub fn project(k: usize, received: bool) -> wire::Project {
let mut message = wire::Project {
project_id: states::present(states::plain(k, states::text("project_id", k))),
metadata: states::maybe(k, on_wire::project_metadata(k + 1, received)).into(),
problems: states::many(
k,
[
on_wire::project_problem(k + 2, received),
on_wire::project_problem(k + 3, received),
],
),
url: states::present(states::plain(k, states::text("url", k))),
cpu_used_cores: states::present(states::plain(k, f64::from(states::number(5, k)) + 0.5)),
memory_used_bytes: states::present(states::plain(k, u64::from(states::number(6, k)) << 32)),
deploy_id: states::present(states::plain(k, states::text("deploy_id", k))),
deploy_status: states::set(on_wire::operation_status(k + 7)),
deploy_time: states::maybe(k, states::time_on_wire(states::number(8, k + 8))).into(),
x_pethost_applies_at_once: states::present(states::flag(1, k)),
services: states::many(
k,
[on_wire::service(k + 10, received), on_wire::service(k + 11, received)],
),
volumes: states::many(
k,
[on_wire::volume(k + 11, received), on_wire::volume(k + 12, received)],
),
routes: states::many(k, [on_wire::route(k + 12, received), on_wire::route(k + 13, received)]),
hosts: states::many(k, [on_wire::host(k + 13, received), on_wire::host(k + 14, received)]),
password_protected: states::present(states::flag(2, k)),
operations: states::many(
k,
[
on_wire::operation(k + 15, received),
on_wire::operation(k + 16, received),
],
),
snapshots: states::many(
k,
[on_wire::snapshot(k + 16, received), on_wire::snapshot(k + 17, received)],
),
snapshot_count: states::present(states::plain(k, states::number(15, k))),
snapshot_list_time: states::maybe(k, states::time_on_wire(states::number(20, k + 18))).into(),
http_traffic_last_day: states::maybe(k, on_wire::http_traffic_summary(k + 19, received)).into(),
source: states::maybe(k, on_wire::project_source(k + 20, received)).into(),
running_services_action: states::maybe(k, on_wire::running_services_action(k + 21, received)).into(),
..Default::default()
};
if received && k % 2 == 1 {
message.__buffa_unknown_fields.push(states::later_field());
}
message
}
pub fn running_services_action(k: usize, received: bool) -> wire::RunningServicesAction {
let mut message = wire::RunningServicesAction {
kind: states::set(on_wire::services_action_kind(k)),
services: states::many(k, [states::text("services", k), states::text("services", k + 1)]),
start_time: states::maybe(k, states::time_on_wire(states::number(3, k + 2))).into(),
..Default::default()
};
if received && k % 2 == 1 {
message.__buffa_unknown_fields.push(states::later_field());
}
message
}
pub fn project_source(k: usize, received: bool) -> wire::ProjectSource {
let mut message = wire::ProjectSource {
kind: match k % 6 {
0 | 1 => None,
2 => Some(wire::__buffa::oneof::project_source::Kind::Files(true)),
3 => Some(wire::__buffa::oneof::project_source::Kind::Github(Box::new(
on_wire::github_source(k, received),
))),
4 => Some(wire::__buffa::oneof::project_source::Kind::Files(Default::default())),
_ => Some(wire::__buffa::oneof::project_source::Kind::Github(Default::default())),
},
..Default::default()
};
if received && k % 2 == 1 {
message.__buffa_unknown_fields.push(states::later_field());
}
message
}
pub fn github_source(k: usize, received: bool) -> wire::GithubSource {
let mut message = wire::GithubSource {
repository: states::marked(k, states::text("repository", k)),
branch: states::marked(k, states::text("branch", k)),
directory: states::marked(k, states::text("directory", k)),
auto_deploy: states::marked(k, true),
newest_commit: states::maybe(k, on_wire::github_commit(k + 4, received)).into(),
deployed_commit: states::maybe(k, on_wire::github_commit(k + 5, received)).into(),
pinned: states::present(states::flag(1, k)),
auto_deploy_pending: states::present(states::flag(2, k)),
..Default::default()
};
if received && k % 2 == 1 {
message.__buffa_unknown_fields.push(states::later_field());
}
message
}
pub fn github_commit(k: usize, received: bool) -> wire::GithubCommit {
let mut message = wire::GithubCommit {
sha: states::present(states::plain(k, states::text("sha", k))),
title: states::present(states::plain(k, states::text("title", k))),
url: states::present(states::plain(k, states::text("url", k))),
..Default::default()
};
if received && k % 2 == 1 {
message.__buffa_unknown_fields.push(states::later_field());
}
message
}
pub fn service(k: usize, received: bool) -> wire::Service {
let mut message = wire::Service {
service: states::present(states::plain(k, states::text("service", k))),
state: states::set(on_wire::service_state(k + 1)),
container_running: states::present(states::flag(1, k)),
image: states::present(states::plain(k, states::text("image", k))),
builds_image: states::present(states::flag(2, k)),
image_digest: states::present(states::plain(k, states::text("image_digest", k))),
image_size_bytes: states::present(states::plain(k, u64::from(states::number(6, k)) << 32)),
command: states::many(k, [states::text("command", k), states::text("command", k + 1)]),
run_as_user: states::present(states::plain(k, states::text("run_as_user", k))),
start_time: states::maybe(k, states::time_on_wire(states::number(9, k + 9))).into(),
finish_time: states::maybe(k, states::time_on_wire(states::number(10, k + 10))).into(),
exit_code: states::marked(k, -(states::number(11, k) as i32)),
out_of_memory: states::present(states::flag(3, k)),
restart_count: states::present(states::plain(k, states::number(13, k))),
cpu_used_cores: states::present(states::plain(k, f64::from(states::number(14, k)) + 0.5)),
memory_used_bytes: states::present(states::plain(k, u64::from(states::number(15, k)) << 32)),
memory_limit_bytes: states::present(states::plain(k, u64::from(states::number(16, k)) << 32)),
cpu_limit_cores: states::present(states::plain(k, f64::from(states::number(17, k)) + 0.5)),
writable_layer_bytes: states::present(states::plain(k, u64::from(states::number(18, k)) << 32)),
ports: states::many(k, [states::number(19, k), states::number(19, k + 1)]),
listening_ports: states::many(k, [states::number(28, k), states::number(28, k + 1)]),
published_ports: states::many(
k,
[
on_wire::published_port(k + 21, received),
on_wire::published_port(k + 22, received),
],
),
volume_mounts: states::many(
k,
[
on_wire::volume_mount(k + 22, received),
on_wire::volume_mount(k + 23, received),
],
),
restart_policy: states::set(on_wire::restart_policy(k + 23)),
health_check: states::maybe(k, on_wire::health_check(k + 24, received)).into(),
environment: states::many(
k,
[
on_wire::environment_variable(k + 25, received),
on_wire::environment_variable(k + 26, received),
],
),
env_files: states::many(k, [states::text("env_files", k), states::text("env_files", k + 1)]),
ssh_command: states::present(states::plain(k, states::text("ssh_command", k))),
..Default::default()
};
if received && k % 2 == 1 {
message.__buffa_unknown_fields.push(states::later_field());
}
message
}
pub fn published_port(k: usize, received: bool) -> wire::PublishedPort {
let mut message = wire::PublishedPort {
machine_port: states::present(states::plain(k, states::number(1, k))),
container_port: states::present(states::plain(k, states::number(2, k))),
protocol: states::present(states::plain(k, states::text("protocol", k))),
machine_only: states::present(states::flag(1, k)),
..Default::default()
};
if received && k % 2 == 1 {
message.__buffa_unknown_fields.push(states::later_field());
}
message
}
pub fn volume_mount(k: usize, received: bool) -> wire::VolumeMount {
let mut message = wire::VolumeMount {
volume: states::present(states::plain(k, states::text("volume", k))),
container_path: states::present(states::plain(k, states::text("container_path", k))),
..Default::default()
};
if received && k % 2 == 1 {
message.__buffa_unknown_fields.push(states::later_field());
}
message
}
pub fn health_check(k: usize, received: bool) -> wire::HealthCheck {
let mut message = wire::HealthCheck {
command: states::many(k, [states::text("command", k), states::text("command", k + 1)]),
interval_seconds: states::present(states::plain(k, states::number(2, k))),
status: states::set(on_wire::health_status(k + 2)),
consecutive_failure_count: states::present(states::plain(k, states::number(4, k))),
recent_results_passed: states::many(k, [true, true]),
last_failure_output: states::present(states::plain(k, states::text("last_failure_output", k))),
..Default::default()
};
if received && k % 2 == 1 {
message.__buffa_unknown_fields.push(states::later_field());
}
message
}
pub fn environment_variable(k: usize, received: bool) -> wire::EnvironmentVariable {
let mut message = wire::EnvironmentVariable {
name: states::present(states::plain(k, states::text("name", k))),
value: states::present(states::plain(k, states::text("value", k))),
secret: states::present(states::flag(1, k)),
source_file: states::present(states::plain(k, states::text("source_file", k))),
from_env_file_variables: states::many(
k,
[
states::text("from_env_file_variables", k),
states::text("from_env_file_variables", k + 1),
],
),
value_left_out: states::present(states::flag(2, k)),
..Default::default()
};
if received && k % 2 == 1 {
message.__buffa_unknown_fields.push(states::later_field());
}
message
}
pub fn volume(k: usize, received: bool) -> wire::Volume {
let mut message = wire::Volume {
volume: states::present(states::plain(k, states::text("volume", k))),
size_bytes: states::present(states::plain(k, u64::from(states::number(2, k)) << 32)),
mounted_by: states::many(
k,
[
on_wire::volume_mounted_by(k + 2, received),
on_wire::volume_mounted_by(k + 3, received),
],
),
last_backup_time: states::maybe(k, states::time_on_wire(states::number(4, k + 3))).into(),
snapshot_count: states::present(states::plain(k, states::number(6, k))),
declared: states::present(states::flag(1, k)),
..Default::default()
};
if received && k % 2 == 1 {
message.__buffa_unknown_fields.push(states::later_field());
}
message
}
pub fn volume_mounted_by(k: usize, received: bool) -> wire::VolumeMountedBy {
let mut message = wire::VolumeMountedBy {
service: states::present(states::plain(k, states::text("service", k))),
container_path: states::present(states::plain(k, states::text("container_path", k))),
..Default::default()
};
if received && k % 2 == 1 {
message.__buffa_unknown_fields.push(states::later_field());
}
message
}
pub fn host(k: usize, received: bool) -> wire::Host {
let mut message = wire::Host {
host: states::present(states::plain(k, states::text("host", k))),
url: states::present(states::plain(k, states::text("url", k))),
certificate_source: states::set(on_wire::certificate_source(k + 2)),
certificate_expire_time: states::maybe(k, states::time_on_wire(states::number(4, k + 3))).into(),
unavailable_message: states::present(states::plain(k, states::text("unavailable_message", k))),
..Default::default()
};
if received && k % 2 == 1 {
message.__buffa_unknown_fields.push(states::later_field());
}
message
}
pub fn route(k: usize, received: bool) -> wire::Route {
let mut message = wire::Route {
host: states::present(states::plain(k, states::text("host", k))),
path: states::present(states::plain(k, states::text("path", k))),
service: states::present(states::plain(k, states::text("service", k))),
port: states::present(states::plain(k, states::number(4, k))),
strip_path: states::present(states::flag(1, k)),
..Default::default()
};
if received && k % 2 == 1 {
message.__buffa_unknown_fields.push(states::later_field());
}
message
}
pub fn operation(k: usize, received: bool) -> wire::Operation {
let mut message = wire::Operation {
operation_id: states::present(states::plain(k, states::text("operation_id", k))),
kind: states::set(on_wire::operation_kind(k + 1)),
status: states::set(on_wire::operation_status(k + 2)),
start_time: states::maybe(k, states::time_on_wire(states::number(4, k + 3))).into(),
finish_time: states::maybe(k, states::time_on_wire(states::number(5, k + 4))).into(),
failure_message: states::present(states::plain(k, states::text("failure_message", k))),
deploy_failure_reason: states::set(on_wire::deploy_failure_reason(k + 6)),
made_current: states::present(states::flag(1, k)),
service: states::present(states::plain(k, states::text("service", k))),
failed_exit_code: states::present(states::plain(k, -(states::number(10, k) as i32))),
snapshot_id: states::present(states::plain(k, states::text("snapshot_id", k))),
restored_volumes: states::many(
k,
[
states::text("restored_volumes", k),
states::text("restored_volumes", k + 1),
],
),
undo_snapshot_id: states::present(states::plain(k, states::text("undo_snapshot_id", k))),
github_commit: states::maybe(k, on_wire::github_commit(k + 13, received)).into(),
archive_name: states::present(states::plain(k, states::text("archive_name", k))),
adjustments: states::many(k, [states::text("adjustments", k), states::text("adjustments", k + 1)]),
changed_paths: states::many(
k,
[states::text("changed_paths", k), states::text("changed_paths", k + 1)],
),
changed_path_count: states::present(states::plain(k, states::number(18, k))),
files_kept: states::present(states::flag(2, k)),
..Default::default()
};
if received && k % 2 == 1 {
message.__buffa_unknown_fields.push(states::later_field());
}
message
}
pub fn snapshot(k: usize, received: bool) -> wire::Snapshot {
let mut message = wire::Snapshot {
snapshot_id: states::present(states::plain(k, states::text("snapshot_id", k))),
create_time: states::maybe(k, states::time_on_wire(states::number(2, k + 1))).into(),
size_bytes: states::present(states::plain(k, u64::from(states::number(3, k)) << 32)),
volumes: states::many(k, [states::text("volumes", k), states::text("volumes", k + 1)]),
..Default::default()
};
if received && k % 2 == 1 {
message.__buffa_unknown_fields.push(states::later_field());
}
message
}
pub fn http_traffic_summary(k: usize, received: bool) -> wire::HttpTrafficSummary {
let mut message = wire::HttpTrafficSummary {
request_count: states::present(states::plain(k, u64::from(states::number(1, k)) << 32)),
server_error_count: states::present(states::plain(k, u64::from(states::number(2, k)) << 32)),
latency_p50_ms: states::present(states::plain(k, states::number(3, k))),
latency_p95_ms: states::present(states::plain(k, states::number(4, k))),
..Default::default()
};
if received && k % 2 == 1 {
message.__buffa_unknown_fields.push(states::later_field());
}
message
}
pub fn create_project_request(k: usize, received: bool) -> wire::CreateProjectRequest {
let mut message = wire::CreateProjectRequest {
project_id: states::present(states::plain(k, states::text("project_id", k))),
source: states::maybe(k, on_wire::project_source(k + 1, received)).into(),
upload_id: states::present(states::plain(k, states::text("upload_id", k))),
files: states::many(
k,
[
on_wire::file_change(k + 3, received),
on_wire::file_change(k + 4, received),
],
),
x_pethost: states::maybe(k, on_wire::project_extension(k + 4, received)).into(),
timeout_seconds: states::present(states::plain(k, states::number(6, k))),
operation_id: states::present(states::plain(k, states::text("operation_id", k))),
wait_seconds: states::marked(k, states::number(9, k)),
..Default::default()
};
if received && k % 2 == 1 {
message.__buffa_unknown_fields.push(states::later_field());
}
message
}
pub fn create_project_response(k: usize, received: bool) -> wire::CreateProjectResponse {
let mut message = wire::CreateProjectResponse {
operation: states::maybe(k, on_wire::operation(k, received)).into(),
violations: states::many(
k,
[
on_wire::spec_violation(k + 1, received),
on_wire::spec_violation(k + 2, received),
],
),
adjustments: states::many(k, [states::text("adjustments", k), states::text("adjustments", k + 1)]),
project: states::maybe(k, on_wire::project(k + 3, received)).into(),
log: states::many(
k,
[
on_wire::operation_log_line(k + 4, received),
on_wire::operation_log_line(k + 5, received),
],
),
..Default::default()
};
if received && k % 2 == 1 {
message.__buffa_unknown_fields.push(states::later_field());
}
message
}
pub fn deploy_project_request(k: usize, received: bool) -> wire::DeployProjectRequest {
let mut message = wire::DeployProjectRequest {
project_id: states::present(states::plain(k, states::text("project_id", k))),
base_deploy_id: states::present(states::plain(k, states::text("base_deploy_id", k))),
files: states::many(
k,
[
on_wire::file_change(k + 2, received),
on_wire::file_change(k + 3, received),
],
),
x_pethost: states::maybe(k, on_wire::project_extension(k + 3, received)).into(),
mount_volume: states::maybe(k, on_wire::mount_volume(k + 4, received)).into(),
timeout_seconds: states::present(states::plain(k, states::number(4, k))),
operation_id: states::present(states::plain(k, states::text("operation_id", k))),
version: match k % 10 {
0 | 1 => None,
2 => Some(wire::__buffa::oneof::deploy_project_request::Version::UploadId(
states::text("upload_id", k),
)),
3 => Some(wire::__buffa::oneof::deploy_project_request::Version::Commit(
states::text("commit", k),
)),
4 => Some(wire::__buffa::oneof::deploy_project_request::Version::NewestCommit(
true,
)),
5 => Some(wire::__buffa::oneof::deploy_project_request::Version::RollbackDeployId(
states::text("rollback_deploy_id", k),
)),
6 => Some(wire::__buffa::oneof::deploy_project_request::Version::UploadId(
Default::default(),
)),
7 => Some(wire::__buffa::oneof::deploy_project_request::Version::Commit(
Default::default(),
)),
8 => Some(wire::__buffa::oneof::deploy_project_request::Version::NewestCommit(
Default::default(),
)),
_ => Some(wire::__buffa::oneof::deploy_project_request::Version::RollbackDeployId(
Default::default(),
)),
},
wait_seconds: states::marked(k, states::number(13, k)),
..Default::default()
};
if received && k % 2 == 1 {
message.__buffa_unknown_fields.push(states::later_field());
}
message
}
pub fn mount_volume(k: usize, received: bool) -> wire::MountVolume {
let mut message = wire::MountVolume {
service: states::present(states::plain(k, states::text("service", k))),
volume: states::present(states::plain(k, states::text("volume", k))),
container_path: states::present(states::plain(k, states::text("container_path", k))),
..Default::default()
};
if received && k % 2 == 1 {
message.__buffa_unknown_fields.push(states::later_field());
}
message
}
pub fn project_extension(k: usize, received: bool) -> wire::ProjectExtension {
let mut message = wire::ProjectExtension {
metadata: states::maybe(k, on_wire::project_metadata(k, received)).into(),
routes: states::many(k, [on_wire::route(k + 1, received), on_wire::route(k + 2, received)]),
remove_routes: states::present(states::flag(1, k)),
password: states::present(states::plain(k, states::text("password", k))),
remove_password: states::present(states::flag(2, k)),
..Default::default()
};
if received && k % 2 == 1 {
message.__buffa_unknown_fields.push(states::later_field());
}
message
}
pub fn file_change(k: usize, received: bool) -> wire::FileChange {
let mut message = wire::FileChange {
path: states::present(states::plain(k, states::text("path", k))),
change: match k % 14 {
0 | 1 => None,
2 => Some(wire::__buffa::oneof::file_change::Change::Text(states::text("text", k))),
3 => Some(wire::__buffa::oneof::file_change::Change::Data(
states::text("data", k).into_bytes(),
)),
4 => Some(wire::__buffa::oneof::file_change::Change::MakeDirectory(true)),
5 => Some(wire::__buffa::oneof::file_change::Change::Delete(true)),
6 => Some(wire::__buffa::oneof::file_change::Change::DeleteTree(true)),
7 => Some(wire::__buffa::oneof::file_change::Change::RenameTo(states::text(
"rename_to",
k,
))),
8 => Some(wire::__buffa::oneof::file_change::Change::Text(Default::default())),
9 => Some(wire::__buffa::oneof::file_change::Change::Data(Default::default())),
10 => Some(wire::__buffa::oneof::file_change::Change::MakeDirectory(
Default::default(),
)),
11 => Some(wire::__buffa::oneof::file_change::Change::Delete(Default::default())),
12 => Some(wire::__buffa::oneof::file_change::Change::DeleteTree(Default::default())),
_ => Some(wire::__buffa::oneof::file_change::Change::RenameTo(Default::default())),
},
executable: states::present(states::flag(1, k)),
..Default::default()
};
if received && k % 2 == 1 {
message.__buffa_unknown_fields.push(states::later_field());
}
message
}
pub fn deploy_project_response(k: usize, received: bool) -> wire::DeployProjectResponse {
let mut message = wire::DeployProjectResponse {
operation: states::maybe(k, on_wire::operation(k, received)).into(),
violations: states::many(
k,
[
on_wire::spec_violation(k + 1, received),
on_wire::spec_violation(k + 2, received),
],
),
adjustments: states::many(k, [states::text("adjustments", k), states::text("adjustments", k + 1)]),
project: states::maybe(k, on_wire::project(k + 3, received)).into(),
log: states::many(
k,
[
on_wire::operation_log_line(k + 4, received),
on_wire::operation_log_line(k + 5, received),
],
),
..Default::default()
};
if received && k % 2 == 1 {
message.__buffa_unknown_fields.push(states::later_field());
}
message
}
pub fn spec_violation(k: usize, received: bool) -> wire::SpecViolation {
let mut message = wire::SpecViolation {
service: states::present(states::plain(k, states::text("service", k))),
location: states::present(states::plain(k, states::text("location", k))),
violation_message: states::present(states::plain(k, states::text("violation_message", k))),
..Default::default()
};
if received && k % 2 == 1 {
message.__buffa_unknown_fields.push(states::later_field());
}
message
}
pub fn list_commits_request(k: usize, received: bool) -> wire::ListCommitsRequest {
let mut message = wire::ListCommitsRequest {
project_id: states::present(states::plain(k, states::text("project_id", k))),
before_commit: states::present(states::plain(k, states::text("before_commit", k))),
..Default::default()
};
if received && k % 2 == 1 {
message.__buffa_unknown_fields.push(states::later_field());
}
message
}
pub fn list_commits_response(k: usize, received: bool) -> wire::ListCommitsResponse {
let mut message = wire::ListCommitsResponse {
commits: states::many(
k,
[
on_wire::branch_commit(k, received),
on_wire::branch_commit(k + 1, received),
],
),
more: states::present(states::flag(1, k)),
..Default::default()
};
if received && k % 2 == 1 {
message.__buffa_unknown_fields.push(states::later_field());
}
message
}
pub fn branch_commit(k: usize, received: bool) -> wire::BranchCommit {
let mut message = wire::BranchCommit {
commit: states::maybe(k, on_wire::github_commit(k, received)).into(),
author: states::present(states::plain(k, states::text("author", k))),
commit_time: states::maybe(k, states::time_on_wire(states::number(3, k + 2))).into(),
deployed: states::present(states::flag(1, k)),
last_deploy: states::maybe(k, on_wire::operation(k + 4, received)).into(),
newest: states::present(states::flag(2, k)),
..Default::default()
};
if received && k % 2 == 1 {
message.__buffa_unknown_fields.push(states::later_field());
}
message
}
pub fn run_project_action_request(k: usize, received: bool) -> wire::RunProjectActionRequest {
let mut message = wire::RunProjectActionRequest {
project_id: states::present(states::plain(k, states::text("project_id", k))),
action: match k % 22 {
0 | 1 => None,
2 => Some(wire::__buffa::oneof::run_project_action_request::Action::StartServices(
Box::new(on_wire::services_action(k, received)),
)),
3 => Some(wire::__buffa::oneof::run_project_action_request::Action::StopServices(
Box::new(on_wire::services_action(k, received)),
)),
4 => Some(
wire::__buffa::oneof::run_project_action_request::Action::RestartServices(Box::new(
on_wire::services_action(k, received),
)),
),
5 => Some(
wire::__buffa::oneof::run_project_action_request::Action::RecreateService(Box::new(
on_wire::recreate_service_action(k, received),
)),
),
6 => Some(wire::__buffa::oneof::run_project_action_request::Action::BackUp(
Box::new(on_wire::back_up_action(k, received)),
)),
7 => Some(
wire::__buffa::oneof::run_project_action_request::Action::RestoreSnapshot(Box::new(
on_wire::restore_snapshot_action(k, received),
)),
),
8 => Some(
wire::__buffa::oneof::run_project_action_request::Action::CancelOperation(Box::new(
on_wire::cancel_operation_action(k, received),
)),
),
9 => Some(wire::__buffa::oneof::run_project_action_request::Action::DeleteProject(
Box::new(on_wire::delete_project_action(k, received)),
)),
10 => Some(wire::__buffa::oneof::run_project_action_request::Action::SetSource(
Box::new(on_wire::project_source(k, received)),
)),
11 => Some(wire::__buffa::oneof::run_project_action_request::Action::DeleteVolume(
states::text("delete_volume", k),
)),
12 => Some(wire::__buffa::oneof::run_project_action_request::Action::StartServices(
Default::default(),
)),
13 => Some(wire::__buffa::oneof::run_project_action_request::Action::StopServices(
Default::default(),
)),
14 => {
Some(wire::__buffa::oneof::run_project_action_request::Action::RestartServices(Default::default()))
}
15 => {
Some(wire::__buffa::oneof::run_project_action_request::Action::RecreateService(Default::default()))
}
16 => Some(wire::__buffa::oneof::run_project_action_request::Action::BackUp(
Default::default(),
)),
17 => {
Some(wire::__buffa::oneof::run_project_action_request::Action::RestoreSnapshot(Default::default()))
}
18 => {
Some(wire::__buffa::oneof::run_project_action_request::Action::CancelOperation(Default::default()))
}
19 => Some(wire::__buffa::oneof::run_project_action_request::Action::DeleteProject(
Default::default(),
)),
20 => Some(wire::__buffa::oneof::run_project_action_request::Action::SetSource(
Default::default(),
)),
_ => Some(wire::__buffa::oneof::run_project_action_request::Action::DeleteVolume(
Default::default(),
)),
},
operation_id: states::present(states::plain(k, states::text("operation_id", k))),
wait_seconds: states::marked(k, states::number(13, k)),
..Default::default()
};
if received && k % 2 == 1 {
message.__buffa_unknown_fields.push(states::later_field());
}
message
}
pub fn services_action(k: usize, received: bool) -> wire::ServicesAction {
let mut message = wire::ServicesAction {
services: states::many(k, [states::text("services", k), states::text("services", k + 1)]),
..Default::default()
};
if received && k % 2 == 1 {
message.__buffa_unknown_fields.push(states::later_field());
}
message
}
pub fn recreate_service_action(k: usize, received: bool) -> wire::RecreateServiceAction {
let mut message = wire::RecreateServiceAction {
service: states::present(states::plain(k, states::text("service", k))),
pull_latest_image: states::present(states::flag(1, k)),
..Default::default()
};
if received && k % 2 == 1 {
message.__buffa_unknown_fields.push(states::later_field());
}
message
}
pub fn back_up_action(k: usize, received: bool) -> wire::BackUpAction {
let mut message = wire::BackUpAction { ..Default::default() };
if received && k % 2 == 1 {
message.__buffa_unknown_fields.push(states::later_field());
}
message
}
pub fn restore_snapshot_action(k: usize, received: bool) -> wire::RestoreSnapshotAction {
let mut message = wire::RestoreSnapshotAction {
snapshot_id: states::present(states::plain(k, states::text("snapshot_id", k))),
volumes: states::many(k, [states::text("volumes", k), states::text("volumes", k + 1)]),
..Default::default()
};
if received && k % 2 == 1 {
message.__buffa_unknown_fields.push(states::later_field());
}
message
}
pub fn cancel_operation_action(k: usize, received: bool) -> wire::CancelOperationAction {
let mut message = wire::CancelOperationAction {
operation_id: states::present(states::plain(k, states::text("operation_id", k))),
..Default::default()
};
if received && k % 2 == 1 {
message.__buffa_unknown_fields.push(states::later_field());
}
message
}
pub fn delete_project_action(k: usize, received: bool) -> wire::DeleteProjectAction {
let mut message = wire::DeleteProjectAction {
skip_final_backup: states::present(states::flag(1, k)),
..Default::default()
};
if received && k % 2 == 1 {
message.__buffa_unknown_fields.push(states::later_field());
}
message
}
pub fn run_project_action_response(k: usize, received: bool) -> wire::RunProjectActionResponse {
let mut message = wire::RunProjectActionResponse {
operation: states::maybe(k, on_wire::operation(k, received)).into(),
project: states::maybe(k, on_wire::project(k + 1, received)).into(),
log: states::many(
k,
[
on_wire::operation_log_line(k + 2, received),
on_wire::operation_log_line(k + 3, received),
],
),
..Default::default()
};
if received && k % 2 == 1 {
message.__buffa_unknown_fields.push(states::later_field());
}
message
}
pub fn get_operation_request(k: usize, received: bool) -> wire::GetOperationRequest {
let mut message = wire::GetOperationRequest {
project_id: states::present(states::plain(k, states::text("project_id", k))),
operation_id: states::present(states::plain(k, states::text("operation_id", k))),
wait_seconds: states::marked(k, states::number(3, k)),
after_log_line: states::marked(k, states::number(4, k)),
log_line_limit: states::marked(k, states::number(5, k)),
..Default::default()
};
if received && k % 2 == 1 {
message.__buffa_unknown_fields.push(states::later_field());
}
message
}
pub fn get_operation_response(k: usize, received: bool) -> wire::GetOperationResponse {
let mut message = wire::GetOperationResponse {
operation: states::maybe(k, on_wire::operation(k, received)).into(),
project: states::maybe(k, on_wire::project(k + 1, received)).into(),
log: states::many(
k,
[
on_wire::operation_log_line(k + 2, received),
on_wire::operation_log_line(k + 3, received),
],
),
log_line_count: states::present(states::plain(k, states::number(3, k))),
next_after_log_line: states::present(states::plain(k, states::number(4, k))),
..Default::default()
};
if received && k % 2 == 1 {
message.__buffa_unknown_fields.push(states::later_field());
}
message
}
pub fn operation_log_line(k: usize, received: bool) -> wire::OperationLogLine {
let mut message = wire::OperationLogLine {
time: states::maybe(k, states::time_on_wire(states::number(1, k))).into(),
text: states::present(states::plain(k, states::text("text", k))),
..Default::default()
};
if received && k % 2 == 1 {
message.__buffa_unknown_fields.push(states::later_field());
}
message
}
pub fn http_traffic_filter(k: usize, received: bool) -> wire::HttpTrafficFilter {
let mut message = wire::HttpTrafficFilter {
host: states::present(states::plain(k, states::text("host", k))),
method: states::present(states::plain(k, states::text("method", k))),
path_contains: states::present(states::plain(k, states::text("path_contains", k))),
path_pattern: states::present(states::plain(k, states::text("path_pattern", k))),
status_class: states::present(states::plain(k, states::number(5, k))),
..Default::default()
};
if received && k % 2 == 1 {
message.__buffa_unknown_fields.push(states::later_field());
}
message
}
pub fn query_http_traffic_request(k: usize, received: bool) -> wire::QueryHttpTrafficRequest {
let mut message = wire::QueryHttpTrafficRequest {
project_id: states::present(states::plain(k, states::text("project_id", k))),
filter: states::maybe(k, on_wire::http_traffic_filter(k + 1, received)).into(),
start_time: states::maybe(k, states::time_on_wire(states::number(3, k + 2))).into(),
end_time: states::maybe(k, states::time_on_wire(states::number(4, k + 3))).into(),
last_seconds: states::present(states::plain(k, states::number(8, k))),
bucket_width_seconds: states::present(states::plain(k, states::number(5, k))),
request_limit: states::present(states::plain(k, states::number(6, k))),
page_token: states::present(states::plain(k, states::text("page_token", k))),
..Default::default()
};
if received && k % 2 == 1 {
message.__buffa_unknown_fields.push(states::later_field());
}
message
}
pub fn query_http_traffic_response(k: usize, received: bool) -> wire::QueryHttpTrafficResponse {
let mut message = wire::QueryHttpTrafficResponse {
start_time: states::maybe(k, states::time_on_wire(states::number(1, k))).into(),
end_time: states::maybe(k, states::time_on_wire(states::number(2, k + 1))).into(),
oldest_kept_time: states::maybe(k, states::time_on_wire(states::number(8, k + 2))).into(),
summary: states::maybe(k, on_wire::http_traffic_summary(k + 3, received)).into(),
buckets: states::many(
k,
[
on_wire::http_traffic_bucket(k + 4, received),
on_wire::http_traffic_bucket(k + 5, received),
],
),
top_paths: states::many(
k,
[
on_wire::http_path_traffic(k + 5, received),
on_wire::http_path_traffic(k + 6, received),
],
),
newest_sequence: states::present(states::plain(k, u64::from(states::number(9, k)) << 32)),
requests: states::many(
k,
[
on_wire::http_request(k + 7, received),
on_wire::http_request(k + 8, received),
],
),
next_page_token: states::present(states::plain(k, states::text("next_page_token", k))),
tail_sequence: states::present(states::plain(k, u64::from(states::number(10, k)) << 32)),
..Default::default()
};
if received && k % 2 == 1 {
message.__buffa_unknown_fields.push(states::later_field());
}
message
}
pub fn http_traffic_bucket(k: usize, received: bool) -> wire::HttpTrafficBucket {
let mut message = wire::HttpTrafficBucket {
start_time: states::maybe(k, states::time_on_wire(states::number(1, k))).into(),
summary: states::maybe(k, on_wire::http_traffic_summary(k + 1, received)).into(),
..Default::default()
};
if received && k % 2 == 1 {
message.__buffa_unknown_fields.push(states::later_field());
}
message
}
pub fn http_path_traffic(k: usize, received: bool) -> wire::HttpPathTraffic {
let mut message = wire::HttpPathTraffic {
method: states::present(states::plain(k, states::text("method", k))),
path_pattern: states::present(states::plain(k, states::text("path_pattern", k))),
summary: states::maybe(k, on_wire::http_traffic_summary(k + 2, received)).into(),
..Default::default()
};
if received && k % 2 == 1 {
message.__buffa_unknown_fields.push(states::later_field());
}
message
}
pub fn http_request(k: usize, received: bool) -> wire::HttpRequest {
let mut message = wire::HttpRequest {
sequence: states::present(states::plain(k, u64::from(states::number(1, k)) << 32)),
finish_time: states::maybe(k, states::time_on_wire(states::number(2, k + 1))).into(),
host: states::present(states::plain(k, states::text("host", k))),
method: states::present(states::plain(k, states::text("method", k))),
path: states::present(states::plain(k, states::text("path", k))),
path_pattern: states::present(states::plain(k, states::text("path_pattern", k))),
route_path: states::present(states::plain(k, states::text("route_path", k))),
service: states::present(states::plain(k, states::text("service", k))),
port: states::present(states::plain(k, states::number(9, k))),
status_code: states::present(states::plain(k, states::number(10, k))),
response_size_bytes: states::present(states::plain(k, u64::from(states::number(11, k)) << 32)),
duration_ms: states::present(states::plain(k, states::number(12, k))),
service_duration_ms: states::present(states::plain(k, states::number(13, k))),
client_ip_address: states::present(states::plain(k, states::text("client_ip_address", k))),
user_agent: states::present(states::plain(k, states::text("user_agent", k))),
..Default::default()
};
if received && k % 2 == 1 {
message.__buffa_unknown_fields.push(states::later_field());
}
message
}
pub fn container_log_filter(k: usize, received: bool) -> wire::ContainerLogFilter {
let mut message = wire::ContainerLogFilter {
service: states::present(states::plain(k, states::text("service", k))),
stream: states::set(on_wire::output_stream(k + 1)),
text_contains: states::present(states::plain(k, states::text("text_contains", k))),
..Default::default()
};
if received && k % 2 == 1 {
message.__buffa_unknown_fields.push(states::later_field());
}
message
}
pub fn query_container_logs_request(k: usize, received: bool) -> wire::QueryContainerLogsRequest {
let mut message = wire::QueryContainerLogsRequest {
project_id: states::present(states::plain(k, states::text("project_id", k))),
filter: states::maybe(k, on_wire::container_log_filter(k + 1, received)).into(),
start_time: states::maybe(k, states::time_on_wire(states::number(3, k + 2))).into(),
end_time: states::maybe(k, states::time_on_wire(states::number(4, k + 3))).into(),
last_seconds: states::present(states::plain(k, states::number(8, k))),
limit: states::present(states::plain(k, states::number(5, k))),
from_start: states::present(states::flag(1, k)),
page_token: states::present(states::plain(k, states::text("page_token", k))),
..Default::default()
};
if received && k % 2 == 1 {
message.__buffa_unknown_fields.push(states::later_field());
}
message
}
pub fn query_container_logs_response(k: usize, received: bool) -> wire::QueryContainerLogsResponse {
let mut message = wire::QueryContainerLogsResponse {
start_time: states::maybe(k, states::time_on_wire(states::number(4, k))).into(),
end_time: states::maybe(k, states::time_on_wire(states::number(5, k + 1))).into(),
oldest_kept_time: states::maybe(k, states::time_on_wire(states::number(6, k + 2))).into(),
lines: states::many(
k,
[on_wire::log_line(k + 3, received), on_wire::log_line(k + 4, received)],
),
next_page_token: states::present(states::plain(k, states::text("next_page_token", k))),
tail_cursor: states::present(states::plain(k, states::text("tail_cursor", k))),
..Default::default()
};
if received && k % 2 == 1 {
message.__buffa_unknown_fields.push(states::later_field());
}
message
}
pub fn log_line(k: usize, received: bool) -> wire::LogLine {
let mut message = wire::LogLine {
time: states::maybe(k, states::time_on_wire(states::number(1, k))).into(),
service: states::present(states::plain(k, states::text("service", k))),
stream: states::set(on_wire::output_stream(k + 2)),
text: states::present(states::plain(k, states::text("text", k))),
..Default::default()
};
if received && k % 2 == 1 {
message.__buffa_unknown_fields.push(states::later_field());
}
message
}
pub fn run_service_command_request(k: usize, received: bool) -> wire::RunServiceCommandRequest {
let mut message = wire::RunServiceCommandRequest {
project_id: states::present(states::plain(k, states::text("project_id", k))),
service: states::present(states::plain(k, states::text("service", k))),
command: states::many(k, [states::text("command", k), states::text("command", k + 1)]),
stdin: states::present(states::plain(k, states::text("stdin", k))),
run_as_user: states::present(states::plain(k, states::text("run_as_user", k))),
working_directory: states::present(states::plain(k, states::text("working_directory", k))),
timeout_seconds: states::present(states::plain(k, states::number(7, k))),
..Default::default()
};
if received && k % 2 == 1 {
message.__buffa_unknown_fields.push(states::later_field());
}
message
}
pub fn run_service_command_response(k: usize, received: bool) -> wire::RunServiceCommandResponse {
let mut message = wire::RunServiceCommandResponse {
exit_code: states::present(states::plain(k, -(states::number(1, k) as i32))),
timed_out: states::present(states::flag(1, k)),
stdout: states::present(states::plain(k, states::text("stdout", k))),
stderr: states::present(states::plain(k, states::text("stderr", k))),
output_truncated: states::present(states::flag(2, k)),
..Default::default()
};
if received && k % 2 == 1 {
message.__buffa_unknown_fields.push(states::later_field());
}
message
}
pub fn file_entry(k: usize, received: bool) -> wire::FileEntry {
let mut message = wire::FileEntry {
name: states::present(states::plain(k, states::text("name", k))),
r#type: states::set(on_wire::file_type(k + 1)),
size_bytes: states::present(states::plain(k, u64::from(states::number(3, k)) << 32)),
modify_time: states::maybe(k, states::time_on_wire(states::number(4, k + 3))).into(),
mode: states::present(states::plain(k, states::text("mode", k))),
owner_uid: states::present(states::plain(k, states::number(6, k))),
owner_gid: states::present(states::plain(k, states::number(7, k))),
symlink_target: states::present(states::plain(k, states::text("symlink_target", k))),
..Default::default()
};
if received && k % 2 == 1 {
message.__buffa_unknown_fields.push(states::later_field());
}
message
}
pub fn read_path_request(k: usize, received: bool) -> wire::ReadPathRequest {
let mut message = wire::ReadPathRequest {
project_id: states::present(states::plain(k, states::text("project_id", k))),
root: match k % 6 {
0 | 1 => None,
2 => Some(wire::__buffa::oneof::read_path_request::Root::Service(states::text(
"service", k,
))),
3 => Some(wire::__buffa::oneof::read_path_request::Root::Volume(states::text(
"volume", k,
))),
4 => Some(wire::__buffa::oneof::read_path_request::Root::Service(
Default::default(),
)),
_ => Some(wire::__buffa::oneof::read_path_request::Root::Volume(Default::default())),
},
path: states::present(states::plain(k, states::text("path", k))),
entry_limit: states::present(states::plain(k, states::number(6, k))),
offset_bytes: states::present(states::plain(k, u64::from(states::number(7, k)) << 32)),
length_bytes: states::present(states::plain(k, states::number(8, k))),
entry_page_token: states::present(states::plain(k, states::text("entry_page_token", k))),
..Default::default()
};
if received && k % 2 == 1 {
message.__buffa_unknown_fields.push(states::later_field());
}
message
}
pub fn read_path_response(k: usize, received: bool) -> wire::ReadPathResponse {
let mut message = wire::ReadPathResponse {
entry: states::maybe(k, on_wire::file_entry(k, received)).into(),
location: states::set(on_wire::file_location(k + 1)),
volume: states::present(states::plain(k, states::text("volume", k))),
entries: states::many(
k,
[
on_wire::file_entry(k + 3, received),
on_wire::file_entry(k + 4, received),
],
),
entry_count: states::present(states::plain(k, states::number(4, k))),
next_entry_page_token: states::present(states::plain(k, states::text("next_entry_page_token", k))),
text: states::present(states::plain(k, states::text("text", k))),
binary: states::present(states::flag(1, k)),
next_offset_bytes: states::present(states::plain(k, u64::from(states::number(7, k)) << 32)),
deploy_id: states::present(states::plain(k, states::text("deploy_id", k))),
..Default::default()
};
if received && k % 2 == 1 {
message.__buffa_unknown_fields.push(states::later_field());
}
message
}
pub fn create_transfer_request(k: usize, received: bool) -> wire::CreateTransferRequest {
let mut message = wire::CreateTransferRequest {
transfer: match k % 8 {
0 | 1 => None,
2 => Some(wire::__buffa::oneof::create_transfer_request::Transfer::UploadArchive(
Box::new(on_wire::archive_upload(k, received)),
)),
3 => Some(wire::__buffa::oneof::create_transfer_request::Transfer::UploadFile(
Box::new(on_wire::file_upload(k, received)),
)),
4 => Some(wire::__buffa::oneof::create_transfer_request::Transfer::Download(
Box::new(on_wire::path_download(k, received)),
)),
5 => Some(wire::__buffa::oneof::create_transfer_request::Transfer::UploadArchive(
Default::default(),
)),
6 => Some(wire::__buffa::oneof::create_transfer_request::Transfer::UploadFile(
Default::default(),
)),
_ => Some(wire::__buffa::oneof::create_transfer_request::Transfer::Download(
Default::default(),
)),
},
..Default::default()
};
if received && k % 2 == 1 {
message.__buffa_unknown_fields.push(states::later_field());
}
message
}
pub fn archive_upload(k: usize, received: bool) -> wire::ArchiveUpload {
let mut message = wire::ArchiveUpload {
file_name: states::present(states::plain(k, states::text("file_name", k))),
..Default::default()
};
if received && k % 2 == 1 {
message.__buffa_unknown_fields.push(states::later_field());
}
message
}
pub fn file_upload(k: usize, received: bool) -> wire::FileUpload {
let mut message = wire::FileUpload {
project_id: states::present(states::plain(k, states::text("project_id", k))),
root: match k % 6 {
0 | 1 => None,
2 => Some(wire::__buffa::oneof::file_upload::Root::Service(states::text(
"service", k,
))),
3 => Some(wire::__buffa::oneof::file_upload::Root::Volume(states::text(
"volume", k,
))),
4 => Some(wire::__buffa::oneof::file_upload::Root::Service(Default::default())),
_ => Some(wire::__buffa::oneof::file_upload::Root::Volume(Default::default())),
},
path: states::present(states::plain(k, states::text("path", k))),
..Default::default()
};
if received && k % 2 == 1 {
message.__buffa_unknown_fields.push(states::later_field());
}
message
}
pub fn path_download(k: usize, received: bool) -> wire::PathDownload {
let mut message = wire::PathDownload {
project_id: states::present(states::plain(k, states::text("project_id", k))),
root: match k % 6 {
0 | 1 => None,
2 => Some(wire::__buffa::oneof::path_download::Root::Service(states::text(
"service", k,
))),
3 => Some(wire::__buffa::oneof::path_download::Root::Volume(states::text(
"volume", k,
))),
4 => Some(wire::__buffa::oneof::path_download::Root::Service(Default::default())),
_ => Some(wire::__buffa::oneof::path_download::Root::Volume(Default::default())),
},
path: states::present(states::plain(k, states::text("path", k))),
..Default::default()
};
if received && k % 2 == 1 {
message.__buffa_unknown_fields.push(states::later_field());
}
message
}
pub fn create_transfer_response(k: usize, received: bool) -> wire::CreateTransferResponse {
let mut message = wire::CreateTransferResponse {
url: states::present(states::plain(k, states::text("url", k))),
http_method: states::present(states::plain(k, states::text("http_method", k))),
expire_time: states::maybe(k, states::time_on_wire(states::number(3, k + 2))).into(),
command: states::present(states::plain(k, states::text("command", k))),
upload_id: states::present(states::plain(k, states::text("upload_id", k))),
replaces: states::present(states::flag(1, k)),
file_name: states::present(states::plain(k, states::text("file_name", k))),
..Default::default()
};
if received && k % 2 == 1 {
message.__buffa_unknown_fields.push(states::later_field());
}
message
}
pub fn project_busy(k: usize, received: bool) -> wire::ProjectBusy {
let mut message = wire::ProjectBusy {
operation_id: states::present(states::plain(k, states::text("operation_id", k))),
kind: states::set(on_wire::operation_kind(k + 1)),
start_time: states::maybe(k, states::time_on_wire(states::number(3, k + 2))).into(),
..Default::default()
};
if received && k % 2 == 1 {
message.__buffa_unknown_fields.push(states::later_field());
}
message
}
pub fn project_changed(k: usize, received: bool) -> wire::ProjectChanged {
let mut message = wire::ProjectChanged { ..Default::default() };
if received && k % 2 == 1 {
message.__buffa_unknown_fields.push(states::later_field());
}
message
}
pub fn machine_unreachable(k: usize, received: bool) -> wire::MachineUnreachable {
let mut message = wire::MachineUnreachable { ..Default::default() };
if received && k % 2 == 1 {
message.__buffa_unknown_fields.push(states::later_field());
}
message
}
pub fn no_machine(k: usize, received: bool) -> wire::NoMachine {
let mut message = wire::NoMachine {
reason: states::set(on_wire::no_machine_reason(k)),
url: states::present(states::plain(k, states::text("url", k))),
..Default::default()
};
if received && k % 2 == 1 {
message.__buffa_unknown_fields.push(states::later_field());
}
message
}
}
#[tokio::test]
async fn get_machine_request_is_sent() {
for k in 0..2 {
let request = samples::get_machine_request(k);
let expected = on_wire::get_machine_request(k, false);
let answer = ok(&wire::GetMachineResponse::default());
let call = |client: Client| async move { client.get_machine(request).await };
let (sent, response): (wire::GetMachineRequest, _) = exchange("GetMachine", answer, call).await;
assert_eq!(sent, expected, "at k = {k}");
assert_eq!(response.unwrap(), types::GetMachineResponse::default(), "at k = {k}");
}
}
#[tokio::test]
async fn run_machine_action_request_is_sent() {
for k in 0..12 {
let request = samples::run_machine_action_request(k);
let expected = on_wire::run_machine_action_request(k, false);
let answer = ok(&wire::RunMachineActionResponse::default());
let call = |client: Client| async move { client.run_machine_action(request).await };
let (sent, response): (wire::RunMachineActionRequest, _) = exchange("RunMachineAction", answer, call).await;
assert_eq!(sent, expected, "at k = {k}");
assert_eq!(
response.unwrap(),
types::RunMachineActionResponse::default(),
"at k = {k}"
);
}
}
#[tokio::test]
async fn get_project_request_is_sent() {
for k in 0..2 {
let request = samples::get_project_request(k);
let expected = on_wire::get_project_request(k, false);
let answer = ok(&wire::GetProjectResponse::default());
let call = |client: Client| async move { client.get_project(request).await };
let (sent, response): (wire::GetProjectRequest, _) = exchange("GetProject", answer, call).await;
assert_eq!(sent, expected, "at k = {k}");
assert_eq!(response.unwrap(), types::GetProjectResponse::default(), "at k = {k}");
}
}
#[tokio::test]
async fn create_project_request_is_sent() {
for k in 0..3 {
let request = samples::create_project_request(k);
let expected = on_wire::create_project_request(k, false);
let answer = ok(&wire::CreateProjectResponse::default());
let call = |client: Client| async move { client.create_project(request).await };
let (sent, response): (wire::CreateProjectRequest, _) = exchange("CreateProject", answer, call).await;
assert_eq!(sent, expected, "at k = {k}");
assert_eq!(response.unwrap(), types::CreateProjectResponse::default(), "at k = {k}");
}
}
#[tokio::test]
async fn deploy_project_request_is_sent() {
for k in 0..10 {
let request = samples::deploy_project_request(k);
let expected = on_wire::deploy_project_request(k, false);
let answer = ok(&wire::DeployProjectResponse::default());
let call = |client: Client| async move { client.deploy_project(request).await };
let (sent, response): (wire::DeployProjectRequest, _) = exchange("DeployProject", answer, call).await;
assert_eq!(sent, expected, "at k = {k}");
assert_eq!(response.unwrap(), types::DeployProjectResponse::default(), "at k = {k}");
}
}
#[tokio::test]
async fn list_commits_request_is_sent() {
for k in 0..2 {
let request = samples::list_commits_request(k);
let expected = on_wire::list_commits_request(k, false);
let answer = ok(&wire::ListCommitsResponse::default());
let call = |client: Client| async move { client.list_commits(request).await };
let (sent, response): (wire::ListCommitsRequest, _) = exchange("ListCommits", answer, call).await;
assert_eq!(sent, expected, "at k = {k}");
assert_eq!(response.unwrap(), types::ListCommitsResponse::default(), "at k = {k}");
}
}
#[tokio::test]
async fn run_project_action_request_is_sent() {
for k in 0..22 {
let request = samples::run_project_action_request(k);
let expected = on_wire::run_project_action_request(k, false);
let answer = ok(&wire::RunProjectActionResponse::default());
let call = |client: Client| async move { client.run_project_action(request).await };
let (sent, response): (wire::RunProjectActionRequest, _) = exchange("RunProjectAction", answer, call).await;
assert_eq!(sent, expected, "at k = {k}");
assert_eq!(
response.unwrap(),
types::RunProjectActionResponse::default(),
"at k = {k}"
);
}
}
#[tokio::test]
async fn get_operation_request_is_sent() {
for k in 0..3 {
let request = samples::get_operation_request(k);
let expected = on_wire::get_operation_request(k, false);
let answer = ok(&wire::GetOperationResponse::default());
let call = |client: Client| async move { client.get_operation(request).await };
let (sent, response): (wire::GetOperationRequest, _) = exchange("GetOperation", answer, call).await;
assert_eq!(sent, expected, "at k = {k}");
assert_eq!(response.unwrap(), types::GetOperationResponse::default(), "at k = {k}");
}
}
#[tokio::test]
async fn query_http_traffic_request_is_sent() {
for k in 0..2 {
let request = samples::query_http_traffic_request(k);
let expected = on_wire::query_http_traffic_request(k, false);
let answer = ok(&wire::QueryHttpTrafficResponse::default());
let call = |client: Client| async move { client.query_http_traffic(request).await };
let (sent, response): (wire::QueryHttpTrafficRequest, _) = exchange("QueryHttpTraffic", answer, call).await;
assert_eq!(sent, expected, "at k = {k}");
assert_eq!(
response.unwrap(),
types::QueryHttpTrafficResponse::default(),
"at k = {k}"
);
}
}
#[tokio::test]
async fn query_container_logs_request_is_sent() {
for k in 0..2 {
let request = samples::query_container_logs_request(k);
let expected = on_wire::query_container_logs_request(k, false);
let answer = ok(&wire::QueryContainerLogsResponse::default());
let call = |client: Client| async move { client.query_container_logs(request).await };
let (sent, response): (wire::QueryContainerLogsRequest, _) = exchange("QueryContainerLogs", answer, call).await;
assert_eq!(sent, expected, "at k = {k}");
assert_eq!(
response.unwrap(),
types::QueryContainerLogsResponse::default(),
"at k = {k}"
);
}
}
#[tokio::test]
async fn run_service_command_request_is_sent() {
for k in 0..2 {
let request = samples::run_service_command_request(k);
let expected = on_wire::run_service_command_request(k, false);
let answer = ok(&wire::RunServiceCommandResponse::default());
let call = |client: Client| async move { client.run_service_command(request).await };
let (sent, response): (wire::RunServiceCommandRequest, _) = exchange("RunServiceCommand", answer, call).await;
assert_eq!(sent, expected, "at k = {k}");
assert_eq!(
response.unwrap(),
types::RunServiceCommandResponse::default(),
"at k = {k}"
);
}
}
#[tokio::test]
async fn read_path_request_is_sent() {
for k in 0..6 {
let request = samples::read_path_request(k);
let expected = on_wire::read_path_request(k, false);
let answer = ok(&wire::ReadPathResponse::default());
let call = |client: Client| async move { client.read_path(request).await };
let (sent, response): (wire::ReadPathRequest, _) = exchange("ReadPath", answer, call).await;
assert_eq!(sent, expected, "at k = {k}");
assert_eq!(response.unwrap(), types::ReadPathResponse::default(), "at k = {k}");
}
}
#[tokio::test]
async fn create_transfer_request_is_sent() {
for k in 0..8 {
let request = samples::create_transfer_request(k);
let expected = on_wire::create_transfer_request(k, false);
let answer = ok(&wire::CreateTransferResponse::default());
let call = |client: Client| async move { client.create_transfer(request).await };
let (sent, response): (wire::CreateTransferRequest, _) = exchange("CreateTransfer", answer, call).await;
assert_eq!(sent, expected, "at k = {k}");
assert_eq!(
response.unwrap(),
types::CreateTransferResponse::default(),
"at k = {k}"
);
}
}
#[tokio::test]
async fn ssh_key_is_sent() {
for k in 0..2 {
let request = states::make(|message: &mut types::RunMachineActionRequest| {
message.action = Some(types::RunMachineActionRequestAction::AddSshKey(samples::ssh_key(k)))
});
let expected = states::make(|message: &mut wire::RunMachineActionRequest| {
message.action = Some(wire::__buffa::oneof::run_machine_action_request::Action::AddSshKey(
Box::new(on_wire::ssh_key(k, false)),
))
});
let answer = ok(&wire::RunMachineActionResponse::default());
let call = |client: Client| async move { client.run_machine_action(request).await };
let (sent, response): (wire::RunMachineActionRequest, _) = exchange("RunMachineAction", answer, call).await;
assert_eq!(sent, expected, "at k = {k}");
assert_eq!(
response.unwrap(),
types::RunMachineActionResponse::default(),
"at k = {k}"
);
}
}
#[tokio::test]
async fn restart_machine_action_is_sent() {
for k in 0..2 {
let request = states::make(|message: &mut types::RunMachineActionRequest| {
message.action = Some(types::RunMachineActionRequestAction::RestartMachine(
samples::restart_machine_action(k),
))
});
let expected = states::make(|message: &mut wire::RunMachineActionRequest| {
message.action = Some(
wire::__buffa::oneof::run_machine_action_request::Action::RestartMachine(Box::new(
on_wire::restart_machine_action(k, false),
)),
)
});
let answer = ok(&wire::RunMachineActionResponse::default());
let call = |client: Client| async move { client.run_machine_action(request).await };
let (sent, response): (wire::RunMachineActionRequest, _) = exchange("RunMachineAction", answer, call).await;
assert_eq!(sent, expected, "at k = {k}");
assert_eq!(
response.unwrap(),
types::RunMachineActionResponse::default(),
"at k = {k}"
);
}
}
#[tokio::test]
async fn project_source_is_sent() {
for k in 0..6 {
let request =
states::make(|message: &mut types::CreateProjectRequest| message.source = Some(samples::project_source(k)));
let expected = states::make(|message: &mut wire::CreateProjectRequest| {
message.source = Some(on_wire::project_source(k, false)).into()
});
let answer = ok(&wire::CreateProjectResponse::default());
let call = |client: Client| async move { client.create_project(request).await };
let (sent, response): (wire::CreateProjectRequest, _) = exchange("CreateProject", answer, call).await;
assert_eq!(sent, expected, "at k = {k}");
assert_eq!(response.unwrap(), types::CreateProjectResponse::default(), "at k = {k}");
}
}
#[tokio::test]
async fn file_change_is_sent() {
for k in 0..14 {
let request =
states::make(|message: &mut types::CreateProjectRequest| message.files = vec![samples::file_change(k)]);
let expected = states::make(|message: &mut wire::CreateProjectRequest| {
message.files = vec![on_wire::file_change(k, false)]
});
let answer = ok(&wire::CreateProjectResponse::default());
let call = |client: Client| async move { client.create_project(request).await };
let (sent, response): (wire::CreateProjectRequest, _) = exchange("CreateProject", answer, call).await;
assert_eq!(sent, expected, "at k = {k}");
assert_eq!(response.unwrap(), types::CreateProjectResponse::default(), "at k = {k}");
}
}
#[tokio::test]
async fn project_extension_is_sent() {
for k in 0..2 {
let request = states::make(|message: &mut types::CreateProjectRequest| {
message.x_pethost = Some(samples::project_extension(k))
});
let expected = states::make(|message: &mut wire::CreateProjectRequest| {
message.x_pethost = Some(on_wire::project_extension(k, false)).into()
});
let answer = ok(&wire::CreateProjectResponse::default());
let call = |client: Client| async move { client.create_project(request).await };
let (sent, response): (wire::CreateProjectRequest, _) = exchange("CreateProject", answer, call).await;
assert_eq!(sent, expected, "at k = {k}");
assert_eq!(response.unwrap(), types::CreateProjectResponse::default(), "at k = {k}");
}
}
#[tokio::test]
async fn mount_volume_is_sent() {
for k in 0..2 {
let request = states::make(|message: &mut types::DeployProjectRequest| {
message.mount_volume = Some(samples::mount_volume(k))
});
let expected = states::make(|message: &mut wire::DeployProjectRequest| {
message.mount_volume = Some(on_wire::mount_volume(k, false)).into()
});
let answer = ok(&wire::DeployProjectResponse::default());
let call = |client: Client| async move { client.deploy_project(request).await };
let (sent, response): (wire::DeployProjectRequest, _) = exchange("DeployProject", answer, call).await;
assert_eq!(sent, expected, "at k = {k}");
assert_eq!(response.unwrap(), types::DeployProjectResponse::default(), "at k = {k}");
}
}
#[tokio::test]
async fn services_action_is_sent() {
for k in 0..2 {
let request = states::make(|message: &mut types::RunProjectActionRequest| {
message.action = Some(types::RunProjectActionRequestAction::StartServices(
samples::services_action(k),
))
});
let expected = states::make(|message: &mut wire::RunProjectActionRequest| {
message.action = Some(wire::__buffa::oneof::run_project_action_request::Action::StartServices(
Box::new(on_wire::services_action(k, false)),
))
});
let answer = ok(&wire::RunProjectActionResponse::default());
let call = |client: Client| async move { client.run_project_action(request).await };
let (sent, response): (wire::RunProjectActionRequest, _) = exchange("RunProjectAction", answer, call).await;
assert_eq!(sent, expected, "at k = {k}");
assert_eq!(
response.unwrap(),
types::RunProjectActionResponse::default(),
"at k = {k}"
);
}
}
#[tokio::test]
async fn recreate_service_action_is_sent() {
for k in 0..2 {
let request = states::make(|message: &mut types::RunProjectActionRequest| {
message.action = Some(types::RunProjectActionRequestAction::RecreateService(
samples::recreate_service_action(k),
))
});
let expected = states::make(|message: &mut wire::RunProjectActionRequest| {
message.action = Some(
wire::__buffa::oneof::run_project_action_request::Action::RecreateService(Box::new(
on_wire::recreate_service_action(k, false),
)),
)
});
let answer = ok(&wire::RunProjectActionResponse::default());
let call = |client: Client| async move { client.run_project_action(request).await };
let (sent, response): (wire::RunProjectActionRequest, _) = exchange("RunProjectAction", answer, call).await;
assert_eq!(sent, expected, "at k = {k}");
assert_eq!(
response.unwrap(),
types::RunProjectActionResponse::default(),
"at k = {k}"
);
}
}
#[tokio::test]
async fn back_up_action_is_sent() {
for k in 0..2 {
let request = states::make(|message: &mut types::RunProjectActionRequest| {
message.action = Some(types::RunProjectActionRequestAction::BackUp(samples::back_up_action(k)))
});
let expected = states::make(|message: &mut wire::RunProjectActionRequest| {
message.action = Some(wire::__buffa::oneof::run_project_action_request::Action::BackUp(
Box::new(on_wire::back_up_action(k, false)),
))
});
let answer = ok(&wire::RunProjectActionResponse::default());
let call = |client: Client| async move { client.run_project_action(request).await };
let (sent, response): (wire::RunProjectActionRequest, _) = exchange("RunProjectAction", answer, call).await;
assert_eq!(sent, expected, "at k = {k}");
assert_eq!(
response.unwrap(),
types::RunProjectActionResponse::default(),
"at k = {k}"
);
}
}
#[tokio::test]
async fn restore_snapshot_action_is_sent() {
for k in 0..2 {
let request = states::make(|message: &mut types::RunProjectActionRequest| {
message.action = Some(types::RunProjectActionRequestAction::RestoreSnapshot(
samples::restore_snapshot_action(k),
))
});
let expected = states::make(|message: &mut wire::RunProjectActionRequest| {
message.action = Some(
wire::__buffa::oneof::run_project_action_request::Action::RestoreSnapshot(Box::new(
on_wire::restore_snapshot_action(k, false),
)),
)
});
let answer = ok(&wire::RunProjectActionResponse::default());
let call = |client: Client| async move { client.run_project_action(request).await };
let (sent, response): (wire::RunProjectActionRequest, _) = exchange("RunProjectAction", answer, call).await;
assert_eq!(sent, expected, "at k = {k}");
assert_eq!(
response.unwrap(),
types::RunProjectActionResponse::default(),
"at k = {k}"
);
}
}
#[tokio::test]
async fn cancel_operation_action_is_sent() {
for k in 0..2 {
let request = states::make(|message: &mut types::RunProjectActionRequest| {
message.action = Some(types::RunProjectActionRequestAction::CancelOperation(
samples::cancel_operation_action(k),
))
});
let expected = states::make(|message: &mut wire::RunProjectActionRequest| {
message.action = Some(
wire::__buffa::oneof::run_project_action_request::Action::CancelOperation(Box::new(
on_wire::cancel_operation_action(k, false),
)),
)
});
let answer = ok(&wire::RunProjectActionResponse::default());
let call = |client: Client| async move { client.run_project_action(request).await };
let (sent, response): (wire::RunProjectActionRequest, _) = exchange("RunProjectAction", answer, call).await;
assert_eq!(sent, expected, "at k = {k}");
assert_eq!(
response.unwrap(),
types::RunProjectActionResponse::default(),
"at k = {k}"
);
}
}
#[tokio::test]
async fn delete_project_action_is_sent() {
for k in 0..2 {
let request = states::make(|message: &mut types::RunProjectActionRequest| {
message.action = Some(types::RunProjectActionRequestAction::DeleteProject(
samples::delete_project_action(k),
))
});
let expected = states::make(|message: &mut wire::RunProjectActionRequest| {
message.action = Some(wire::__buffa::oneof::run_project_action_request::Action::DeleteProject(
Box::new(on_wire::delete_project_action(k, false)),
))
});
let answer = ok(&wire::RunProjectActionResponse::default());
let call = |client: Client| async move { client.run_project_action(request).await };
let (sent, response): (wire::RunProjectActionRequest, _) = exchange("RunProjectAction", answer, call).await;
assert_eq!(sent, expected, "at k = {k}");
assert_eq!(
response.unwrap(),
types::RunProjectActionResponse::default(),
"at k = {k}"
);
}
}
#[tokio::test]
async fn http_traffic_filter_is_sent() {
for k in 0..2 {
let request = states::make(|message: &mut types::QueryHttpTrafficRequest| {
message.filter = Some(samples::http_traffic_filter(k))
});
let expected = states::make(|message: &mut wire::QueryHttpTrafficRequest| {
message.filter = Some(on_wire::http_traffic_filter(k, false)).into()
});
let answer = ok(&wire::QueryHttpTrafficResponse::default());
let call = |client: Client| async move { client.query_http_traffic(request).await };
let (sent, response): (wire::QueryHttpTrafficRequest, _) = exchange("QueryHttpTraffic", answer, call).await;
assert_eq!(sent, expected, "at k = {k}");
assert_eq!(
response.unwrap(),
types::QueryHttpTrafficResponse::default(),
"at k = {k}"
);
}
}
#[tokio::test]
async fn container_log_filter_is_sent() {
for k in 0..4 {
let request = states::make(|message: &mut types::QueryContainerLogsRequest| {
message.filter = Some(samples::container_log_filter(k))
});
let expected = states::make(|message: &mut wire::QueryContainerLogsRequest| {
message.filter = Some(on_wire::container_log_filter(k, false)).into()
});
let answer = ok(&wire::QueryContainerLogsResponse::default());
let call = |client: Client| async move { client.query_container_logs(request).await };
let (sent, response): (wire::QueryContainerLogsRequest, _) = exchange("QueryContainerLogs", answer, call).await;
assert_eq!(sent, expected, "at k = {k}");
assert_eq!(
response.unwrap(),
types::QueryContainerLogsResponse::default(),
"at k = {k}"
);
}
}
#[tokio::test]
async fn archive_upload_is_sent() {
for k in 0..2 {
let request = states::make(|message: &mut types::CreateTransferRequest| {
message.transfer = Some(types::CreateTransferRequestTransfer::UploadArchive(
samples::archive_upload(k),
))
});
let expected = states::make(|message: &mut wire::CreateTransferRequest| {
message.transfer = Some(wire::__buffa::oneof::create_transfer_request::Transfer::UploadArchive(
Box::new(on_wire::archive_upload(k, false)),
))
});
let answer = ok(&wire::CreateTransferResponse::default());
let call = |client: Client| async move { client.create_transfer(request).await };
let (sent, response): (wire::CreateTransferRequest, _) = exchange("CreateTransfer", answer, call).await;
assert_eq!(sent, expected, "at k = {k}");
assert_eq!(
response.unwrap(),
types::CreateTransferResponse::default(),
"at k = {k}"
);
}
}
#[tokio::test]
async fn file_upload_is_sent() {
for k in 0..6 {
let request = states::make(|message: &mut types::CreateTransferRequest| {
message.transfer = Some(types::CreateTransferRequestTransfer::UploadFile(samples::file_upload(
k,
)))
});
let expected = states::make(|message: &mut wire::CreateTransferRequest| {
message.transfer = Some(wire::__buffa::oneof::create_transfer_request::Transfer::UploadFile(
Box::new(on_wire::file_upload(k, false)),
))
});
let answer = ok(&wire::CreateTransferResponse::default());
let call = |client: Client| async move { client.create_transfer(request).await };
let (sent, response): (wire::CreateTransferRequest, _) = exchange("CreateTransfer", answer, call).await;
assert_eq!(sent, expected, "at k = {k}");
assert_eq!(
response.unwrap(),
types::CreateTransferResponse::default(),
"at k = {k}"
);
}
}
#[tokio::test]
async fn path_download_is_sent() {
for k in 0..6 {
let request = states::make(|message: &mut types::CreateTransferRequest| {
message.transfer = Some(types::CreateTransferRequestTransfer::Download(samples::path_download(
k,
)))
});
let expected = states::make(|message: &mut wire::CreateTransferRequest| {
message.transfer = Some(wire::__buffa::oneof::create_transfer_request::Transfer::Download(
Box::new(on_wire::path_download(k, false)),
))
});
let answer = ok(&wire::CreateTransferResponse::default());
let call = |client: Client| async move { client.create_transfer(request).await };
let (sent, response): (wire::CreateTransferRequest, _) = exchange("CreateTransfer", answer, call).await;
assert_eq!(sent, expected, "at k = {k}");
assert_eq!(
response.unwrap(),
types::CreateTransferResponse::default(),
"at k = {k}"
);
}
}
#[tokio::test]
async fn github_source_is_sent() {
for k in 0..3 {
let request = states::make(|message: &mut types::CreateProjectRequest| {
message.source = Some(states::make(|message: &mut types::ProjectSource| {
message.kind = Some(types::ProjectSourceKind::Github(samples::github_source(k)))
}))
});
let expected = states::make(|message: &mut wire::CreateProjectRequest| {
message.source = Some(states::make(|message: &mut wire::ProjectSource| {
message.kind = Some(wire::__buffa::oneof::project_source::Kind::Github(Box::new(
on_wire::github_source(k, false),
)))
}))
.into()
});
let answer = ok(&wire::CreateProjectResponse::default());
let call = |client: Client| async move { client.create_project(request).await };
let (sent, response): (wire::CreateProjectRequest, _) = exchange("CreateProject", answer, call).await;
assert_eq!(sent, expected, "at k = {k}");
assert_eq!(response.unwrap(), types::CreateProjectResponse::default(), "at k = {k}");
}
}
#[tokio::test]
async fn project_metadata_is_sent() {
for k in 0..3 {
let request = states::make(|message: &mut types::CreateProjectRequest| {
message.x_pethost = Some(states::make(|message: &mut types::ProjectExtension| {
message.metadata = Some(samples::project_metadata(k))
}))
});
let expected = states::make(|message: &mut wire::CreateProjectRequest| {
message.x_pethost = Some(states::make(|message: &mut wire::ProjectExtension| {
message.metadata = Some(on_wire::project_metadata(k, false)).into()
}))
.into()
});
let answer = ok(&wire::CreateProjectResponse::default());
let call = |client: Client| async move { client.create_project(request).await };
let (sent, response): (wire::CreateProjectRequest, _) = exchange("CreateProject", answer, call).await;
assert_eq!(sent, expected, "at k = {k}");
assert_eq!(response.unwrap(), types::CreateProjectResponse::default(), "at k = {k}");
}
}
#[tokio::test]
async fn route_is_sent() {
for k in 0..2 {
let request = states::make(|message: &mut types::CreateProjectRequest| {
message.x_pethost = Some(states::make(|message: &mut types::ProjectExtension| {
message.routes = vec![samples::route(k)]
}))
});
let expected = states::make(|message: &mut wire::CreateProjectRequest| {
message.x_pethost = Some(states::make(|message: &mut wire::ProjectExtension| {
message.routes = vec![on_wire::route(k, false)]
}))
.into()
});
let answer = ok(&wire::CreateProjectResponse::default());
let call = |client: Client| async move { client.create_project(request).await };
let (sent, response): (wire::CreateProjectRequest, _) = exchange("CreateProject", answer, call).await;
assert_eq!(sent, expected, "at k = {k}");
assert_eq!(response.unwrap(), types::CreateProjectResponse::default(), "at k = {k}");
}
}
#[tokio::test]
async fn github_commit_is_sent() {
for k in 0..2 {
let request = states::make(|message: &mut types::CreateProjectRequest| {
message.source = Some(states::make(|message: &mut types::ProjectSource| {
message.kind = Some(types::ProjectSourceKind::Github(states::make(
|message: &mut types::GithubSource| message.newest_commit = Some(samples::github_commit(k)),
)))
}))
});
let expected = states::make(|message: &mut wire::CreateProjectRequest| {
message.source = Some(states::make(|message: &mut wire::ProjectSource| {
message.kind = Some(wire::__buffa::oneof::project_source::Kind::Github(Box::new(
states::make(|message: &mut wire::GithubSource| {
message.newest_commit = Some(on_wire::github_commit(k, false)).into()
}),
)))
}))
.into()
});
let answer = ok(&wire::CreateProjectResponse::default());
let call = |client: Client| async move { client.create_project(request).await };
let (sent, response): (wire::CreateProjectRequest, _) = exchange("CreateProject", answer, call).await;
assert_eq!(sent, expected, "at k = {k}");
assert_eq!(response.unwrap(), types::CreateProjectResponse::default(), "at k = {k}");
}
}
#[tokio::test]
async fn get_machine_response_is_received() {
for k in 0..2 {
let answer = ok(&on_wire::get_machine_response(k, true));
let expected = samples::get_machine_response(k);
let call = |client: Client| async move { client.get_machine(types::GetMachineRequest::default()).await };
let (_, response): (wire::GetMachineRequest, _) = exchange("GetMachine", answer, call).await;
assert_eq!(response.unwrap(), expected, "at k = {k}");
}
}
#[tokio::test]
async fn run_machine_action_response_is_received() {
for k in 0..2 {
let answer = ok(&on_wire::run_machine_action_response(k, true));
let expected = samples::run_machine_action_response(k);
let call = |client: Client| async move {
client
.run_machine_action(types::RunMachineActionRequest::default())
.await
};
let (_, response): (wire::RunMachineActionRequest, _) = exchange("RunMachineAction", answer, call).await;
assert_eq!(response.unwrap(), expected, "at k = {k}");
}
}
#[tokio::test]
async fn get_project_response_is_received() {
for k in 0..2 {
let answer = ok(&on_wire::get_project_response(k, true));
let expected = samples::get_project_response(k);
let call = |client: Client| async move { client.get_project(types::GetProjectRequest::default()).await };
let (_, response): (wire::GetProjectRequest, _) = exchange("GetProject", answer, call).await;
assert_eq!(response.unwrap(), expected, "at k = {k}");
}
}
#[tokio::test]
async fn create_project_response_is_received() {
for k in 0..2 {
let answer = ok(&on_wire::create_project_response(k, true));
let expected = samples::create_project_response(k);
let call = |client: Client| async move { client.create_project(types::CreateProjectRequest::default()).await };
let (_, response): (wire::CreateProjectRequest, _) = exchange("CreateProject", answer, call).await;
assert_eq!(response.unwrap(), expected, "at k = {k}");
}
}
#[tokio::test]
async fn deploy_project_response_is_received() {
for k in 0..2 {
let answer = ok(&on_wire::deploy_project_response(k, true));
let expected = samples::deploy_project_response(k);
let call = |client: Client| async move { client.deploy_project(types::DeployProjectRequest::default()).await };
let (_, response): (wire::DeployProjectRequest, _) = exchange("DeployProject", answer, call).await;
assert_eq!(response.unwrap(), expected, "at k = {k}");
}
}
#[tokio::test]
async fn list_commits_response_is_received() {
for k in 0..2 {
let answer = ok(&on_wire::list_commits_response(k, true));
let expected = samples::list_commits_response(k);
let call = |client: Client| async move { client.list_commits(types::ListCommitsRequest::default()).await };
let (_, response): (wire::ListCommitsRequest, _) = exchange("ListCommits", answer, call).await;
assert_eq!(response.unwrap(), expected, "at k = {k}");
}
}
#[tokio::test]
async fn run_project_action_response_is_received() {
for k in 0..2 {
let answer = ok(&on_wire::run_project_action_response(k, true));
let expected = samples::run_project_action_response(k);
let call = |client: Client| async move {
client
.run_project_action(types::RunProjectActionRequest::default())
.await
};
let (_, response): (wire::RunProjectActionRequest, _) = exchange("RunProjectAction", answer, call).await;
assert_eq!(response.unwrap(), expected, "at k = {k}");
}
}
#[tokio::test]
async fn get_operation_response_is_received() {
for k in 0..2 {
let answer = ok(&on_wire::get_operation_response(k, true));
let expected = samples::get_operation_response(k);
let call = |client: Client| async move { client.get_operation(types::GetOperationRequest::default()).await };
let (_, response): (wire::GetOperationRequest, _) = exchange("GetOperation", answer, call).await;
assert_eq!(response.unwrap(), expected, "at k = {k}");
}
}
#[tokio::test]
async fn query_http_traffic_response_is_received() {
for k in 0..2 {
let answer = ok(&on_wire::query_http_traffic_response(k, true));
let expected = samples::query_http_traffic_response(k);
let call = |client: Client| async move {
client
.query_http_traffic(types::QueryHttpTrafficRequest::default())
.await
};
let (_, response): (wire::QueryHttpTrafficRequest, _) = exchange("QueryHttpTraffic", answer, call).await;
assert_eq!(response.unwrap(), expected, "at k = {k}");
}
}
#[tokio::test]
async fn query_container_logs_response_is_received() {
for k in 0..2 {
let answer = ok(&on_wire::query_container_logs_response(k, true));
let expected = samples::query_container_logs_response(k);
let call = |client: Client| async move {
client
.query_container_logs(types::QueryContainerLogsRequest::default())
.await
};
let (_, response): (wire::QueryContainerLogsRequest, _) = exchange("QueryContainerLogs", answer, call).await;
assert_eq!(response.unwrap(), expected, "at k = {k}");
}
}
#[tokio::test]
async fn run_service_command_response_is_received() {
for k in 0..2 {
let answer = ok(&on_wire::run_service_command_response(k, true));
let expected = samples::run_service_command_response(k);
let call = |client: Client| async move {
client
.run_service_command(types::RunServiceCommandRequest::default())
.await
};
let (_, response): (wire::RunServiceCommandRequest, _) = exchange("RunServiceCommand", answer, call).await;
assert_eq!(response.unwrap(), expected, "at k = {k}");
}
}
#[tokio::test]
async fn read_path_response_is_received() {
for k in 0..5 {
let answer = ok(&on_wire::read_path_response(k, true));
let expected = samples::read_path_response(k);
let call = |client: Client| async move { client.read_path(types::ReadPathRequest::default()).await };
let (_, response): (wire::ReadPathRequest, _) = exchange("ReadPath", answer, call).await;
assert_eq!(response.unwrap(), expected, "at k = {k}");
}
}
#[tokio::test]
async fn create_transfer_response_is_received() {
for k in 0..2 {
let answer = ok(&on_wire::create_transfer_response(k, true));
let expected = samples::create_transfer_response(k);
let call =
|client: Client| async move { client.create_transfer(types::CreateTransferRequest::default()).await };
let (_, response): (wire::CreateTransferRequest, _) = exchange("CreateTransfer", answer, call).await;
assert_eq!(response.unwrap(), expected, "at k = {k}");
}
}
#[tokio::test]
async fn project_busy_is_received() {
for k in 0..7 {
let detail = on_wire::project_busy(k, true).encode_to_vec();
let expected = ErrorDetail::ProjectBusy(samples::project_busy(k));
let answer = failure(
"unavailable",
503,
&[("pethost.panel.v1.ProjectBusy", detail.as_slice())],
&STANDARD_NO_PAD,
);
let call = |client: Client| async move { client.get_machine(types::GetMachineRequest::default()).await };
let (_, response): (wire::GetMachineRequest, _) = exchange("GetMachine", answer, call).await;
assert_eq!(response.unwrap_err().details(), [expected], "at k = {k}");
}
}
#[tokio::test]
async fn project_changed_is_received() {
for k in 0..2 {
let detail = on_wire::project_changed(k, true).encode_to_vec();
let expected = ErrorDetail::ProjectChanged(samples::project_changed(k));
let answer = failure(
"unavailable",
503,
&[("pethost.panel.v1.ProjectChanged", detail.as_slice())],
&STANDARD_NO_PAD,
);
let call = |client: Client| async move { client.get_machine(types::GetMachineRequest::default()).await };
let (_, response): (wire::GetMachineRequest, _) = exchange("GetMachine", answer, call).await;
assert_eq!(response.unwrap_err().details(), [expected], "at k = {k}");
}
}
#[tokio::test]
async fn machine_unreachable_is_received() {
for k in 0..2 {
let detail = on_wire::machine_unreachable(k, true).encode_to_vec();
let expected = ErrorDetail::MachineUnreachable(samples::machine_unreachable(k));
let answer = failure(
"unavailable",
503,
&[("pethost.panel.v1.MachineUnreachable", detail.as_slice())],
&STANDARD_NO_PAD,
);
let call = |client: Client| async move { client.get_machine(types::GetMachineRequest::default()).await };
let (_, response): (wire::GetMachineRequest, _) = exchange("GetMachine", answer, call).await;
assert_eq!(response.unwrap_err().details(), [expected], "at k = {k}");
}
}
#[tokio::test]
async fn no_machine_is_received() {
for k in 0..4 {
let detail = on_wire::no_machine(k, true).encode_to_vec();
let expected = ErrorDetail::NoMachine(samples::no_machine(k));
let answer = failure(
"unavailable",
503,
&[("pethost.panel.v1.NoMachine", detail.as_slice())],
&STANDARD_NO_PAD,
);
let call = |client: Client| async move { client.get_machine(types::GetMachineRequest::default()).await };
let (_, response): (wire::GetMachineRequest, _) = exchange("GetMachine", answer, call).await;
assert_eq!(response.unwrap_err().details(), [expected], "at k = {k}");
}
}
#[tokio::test]
async fn machine_is_received() {
for k in 0..2 {
let answer = ok(&states::make(|message: &mut wire::GetMachineResponse| {
message.machine = Some(on_wire::machine(k, true)).into()
}));
let expected =
states::make(|message: &mut types::GetMachineResponse| message.machine = Some(samples::machine(k)));
let call = |client: Client| async move { client.get_machine(types::GetMachineRequest::default()).await };
let (_, response): (wire::GetMachineRequest, _) = exchange("GetMachine", answer, call).await;
assert_eq!(response.unwrap(), expected, "at k = {k}");
}
}
#[tokio::test]
async fn project_summary_is_received() {
for k in 0..2 {
let answer = ok(&states::make(|message: &mut wire::GetMachineResponse| {
message.projects = vec![on_wire::project_summary(k, true)]
}));
let expected = states::make(|message: &mut types::GetMachineResponse| {
message.projects = vec![samples::project_summary(k)]
});
let call = |client: Client| async move { client.get_machine(types::GetMachineRequest::default()).await };
let (_, response): (wire::GetMachineRequest, _) = exchange("GetMachine", answer, call).await;
assert_eq!(response.unwrap(), expected, "at k = {k}");
}
}
#[tokio::test]
async fn deleted_project_is_received() {
for k in 0..2 {
let answer = ok(&states::make(|message: &mut wire::GetMachineResponse| {
message.deleted_projects = vec![on_wire::deleted_project(k, true)]
}));
let expected = states::make(|message: &mut types::GetMachineResponse| {
message.deleted_projects = vec![samples::deleted_project(k)]
});
let call = |client: Client| async move { client.get_machine(types::GetMachineRequest::default()).await };
let (_, response): (wire::GetMachineRequest, _) = exchange("GetMachine", answer, call).await;
assert_eq!(response.unwrap(), expected, "at k = {k}");
}
}
#[tokio::test]
async fn github_connection_is_received() {
for k in 0..2 {
let answer = ok(&states::make(|message: &mut wire::GetMachineResponse| {
message.github = Some(on_wire::github_connection(k, true)).into()
}));
let expected = states::make(|message: &mut types::GetMachineResponse| {
message.github = Some(samples::github_connection(k))
});
let call = |client: Client| async move { client.get_machine(types::GetMachineRequest::default()).await };
let (_, response): (wire::GetMachineRequest, _) = exchange("GetMachine", answer, call).await;
assert_eq!(response.unwrap(), expected, "at k = {k}");
}
}
#[tokio::test]
async fn project_is_received() {
for k in 0..6 {
let answer = ok(&states::make(|message: &mut wire::GetProjectResponse| {
message.project = Some(on_wire::project(k, true)).into()
}));
let expected =
states::make(|message: &mut types::GetProjectResponse| message.project = Some(samples::project(k)));
let call = |client: Client| async move { client.get_project(types::GetProjectRequest::default()).await };
let (_, response): (wire::GetProjectRequest, _) = exchange("GetProject", answer, call).await;
assert_eq!(response.unwrap(), expected, "at k = {k}");
}
}
#[tokio::test]
async fn operation_is_received() {
for k in 0..13 {
let answer = ok(&states::make(|message: &mut wire::CreateProjectResponse| {
message.operation = Some(on_wire::operation(k, true)).into()
}));
let expected =
states::make(|message: &mut types::CreateProjectResponse| message.operation = Some(samples::operation(k)));
let call = |client: Client| async move { client.create_project(types::CreateProjectRequest::default()).await };
let (_, response): (wire::CreateProjectRequest, _) = exchange("CreateProject", answer, call).await;
assert_eq!(response.unwrap(), expected, "at k = {k}");
}
}
#[tokio::test]
async fn spec_violation_is_received() {
for k in 0..2 {
let answer = ok(&states::make(|message: &mut wire::CreateProjectResponse| {
message.violations = vec![on_wire::spec_violation(k, true)]
}));
let expected = states::make(|message: &mut types::CreateProjectResponse| {
message.violations = vec![samples::spec_violation(k)]
});
let call = |client: Client| async move { client.create_project(types::CreateProjectRequest::default()).await };
let (_, response): (wire::CreateProjectRequest, _) = exchange("CreateProject", answer, call).await;
assert_eq!(response.unwrap(), expected, "at k = {k}");
}
}
#[tokio::test]
async fn operation_log_line_is_received() {
for k in 0..2 {
let answer = ok(&states::make(|message: &mut wire::CreateProjectResponse| {
message.log = vec![on_wire::operation_log_line(k, true)]
}));
let expected = states::make(|message: &mut types::CreateProjectResponse| {
message.log = vec![samples::operation_log_line(k)]
});
let call = |client: Client| async move { client.create_project(types::CreateProjectRequest::default()).await };
let (_, response): (wire::CreateProjectRequest, _) = exchange("CreateProject", answer, call).await;
assert_eq!(response.unwrap(), expected, "at k = {k}");
}
}
#[tokio::test]
async fn branch_commit_is_received() {
for k in 0..2 {
let answer = ok(&states::make(|message: &mut wire::ListCommitsResponse| {
message.commits = vec![on_wire::branch_commit(k, true)]
}));
let expected =
states::make(|message: &mut types::ListCommitsResponse| message.commits = vec![samples::branch_commit(k)]);
let call = |client: Client| async move { client.list_commits(types::ListCommitsRequest::default()).await };
let (_, response): (wire::ListCommitsRequest, _) = exchange("ListCommits", answer, call).await;
assert_eq!(response.unwrap(), expected, "at k = {k}");
}
}
#[tokio::test]
async fn http_traffic_summary_is_received() {
for k in 0..2 {
let answer = ok(&states::make(|message: &mut wire::QueryHttpTrafficResponse| {
message.summary = Some(on_wire::http_traffic_summary(k, true)).into()
}));
let expected = states::make(|message: &mut types::QueryHttpTrafficResponse| {
message.summary = Some(samples::http_traffic_summary(k))
});
let call = |client: Client| async move {
client
.query_http_traffic(types::QueryHttpTrafficRequest::default())
.await
};
let (_, response): (wire::QueryHttpTrafficRequest, _) = exchange("QueryHttpTraffic", answer, call).await;
assert_eq!(response.unwrap(), expected, "at k = {k}");
}
}
#[tokio::test]
async fn http_traffic_bucket_is_received() {
for k in 0..2 {
let answer = ok(&states::make(|message: &mut wire::QueryHttpTrafficResponse| {
message.buckets = vec![on_wire::http_traffic_bucket(k, true)]
}));
let expected = states::make(|message: &mut types::QueryHttpTrafficResponse| {
message.buckets = vec![samples::http_traffic_bucket(k)]
});
let call = |client: Client| async move {
client
.query_http_traffic(types::QueryHttpTrafficRequest::default())
.await
};
let (_, response): (wire::QueryHttpTrafficRequest, _) = exchange("QueryHttpTraffic", answer, call).await;
assert_eq!(response.unwrap(), expected, "at k = {k}");
}
}
#[tokio::test]
async fn http_path_traffic_is_received() {
for k in 0..2 {
let answer = ok(&states::make(|message: &mut wire::QueryHttpTrafficResponse| {
message.top_paths = vec![on_wire::http_path_traffic(k, true)]
}));
let expected = states::make(|message: &mut types::QueryHttpTrafficResponse| {
message.top_paths = vec![samples::http_path_traffic(k)]
});
let call = |client: Client| async move {
client
.query_http_traffic(types::QueryHttpTrafficRequest::default())
.await
};
let (_, response): (wire::QueryHttpTrafficRequest, _) = exchange("QueryHttpTraffic", answer, call).await;
assert_eq!(response.unwrap(), expected, "at k = {k}");
}
}
#[tokio::test]
async fn http_request_is_received() {
for k in 0..2 {
let answer = ok(&states::make(|message: &mut wire::QueryHttpTrafficResponse| {
message.requests = vec![on_wire::http_request(k, true)]
}));
let expected = states::make(|message: &mut types::QueryHttpTrafficResponse| {
message.requests = vec![samples::http_request(k)]
});
let call = |client: Client| async move {
client
.query_http_traffic(types::QueryHttpTrafficRequest::default())
.await
};
let (_, response): (wire::QueryHttpTrafficRequest, _) = exchange("QueryHttpTraffic", answer, call).await;
assert_eq!(response.unwrap(), expected, "at k = {k}");
}
}
#[tokio::test]
async fn log_line_is_received() {
for k in 0..4 {
let answer = ok(&states::make(|message: &mut wire::QueryContainerLogsResponse| {
message.lines = vec![on_wire::log_line(k, true)]
}));
let expected =
states::make(|message: &mut types::QueryContainerLogsResponse| message.lines = vec![samples::log_line(k)]);
let call = |client: Client| async move {
client
.query_container_logs(types::QueryContainerLogsRequest::default())
.await
};
let (_, response): (wire::QueryContainerLogsRequest, _) = exchange("QueryContainerLogs", answer, call).await;
assert_eq!(response.unwrap(), expected, "at k = {k}");
}
}
#[tokio::test]
async fn file_entry_is_received() {
for k in 0..6 {
let answer = ok(&states::make(|message: &mut wire::ReadPathResponse| {
message.entry = Some(on_wire::file_entry(k, true)).into()
}));
let expected =
states::make(|message: &mut types::ReadPathResponse| message.entry = Some(samples::file_entry(k)));
let call = |client: Client| async move { client.read_path(types::ReadPathRequest::default()).await };
let (_, response): (wire::ReadPathRequest, _) = exchange("ReadPath", answer, call).await;
assert_eq!(response.unwrap(), expected, "at k = {k}");
}
}
#[tokio::test]
async fn disk_usage_is_received() {
for k in 0..3 {
let answer = ok(&states::make(|message: &mut wire::GetMachineResponse| {
message.machine = Some(states::make(|message: &mut wire::Machine| {
message.disk_usage = Some(on_wire::disk_usage(k, true)).into()
}))
.into()
}));
let expected = states::make(|message: &mut types::GetMachineResponse| {
message.machine = Some(states::make(|message: &mut types::Machine| {
message.disk_usage = Some(samples::disk_usage(k))
}))
});
let call = |client: Client| async move { client.get_machine(types::GetMachineRequest::default()).await };
let (_, response): (wire::GetMachineRequest, _) = exchange("GetMachine", answer, call).await;
assert_eq!(response.unwrap(), expected, "at k = {k}");
}
}
#[tokio::test]
async fn ssh_key_is_received() {
for k in 0..2 {
let answer = ok(&states::make(|message: &mut wire::GetMachineResponse| {
message.machine = Some(states::make(|message: &mut wire::Machine| {
message.ssh_keys = vec![on_wire::ssh_key(k, true)]
}))
.into()
}));
let expected = states::make(|message: &mut types::GetMachineResponse| {
message.machine = Some(states::make(|message: &mut types::Machine| {
message.ssh_keys = vec![samples::ssh_key(k)]
}))
});
let call = |client: Client| async move { client.get_machine(types::GetMachineRequest::default()).await };
let (_, response): (wire::GetMachineRequest, _) = exchange("GetMachine", answer, call).await;
assert_eq!(response.unwrap(), expected, "at k = {k}");
}
}
#[tokio::test]
async fn machine_session_is_received() {
for k in 0..7 {
let answer = ok(&states::make(|message: &mut wire::GetMachineResponse| {
message.machine = Some(states::make(|message: &mut wire::Machine| {
message.sessions = vec![on_wire::machine_session(k, true)]
}))
.into()
}));
let expected = states::make(|message: &mut types::GetMachineResponse| {
message.machine = Some(states::make(|message: &mut types::Machine| {
message.sessions = vec![samples::machine_session(k)]
}))
});
let call = |client: Client| async move { client.get_machine(types::GetMachineRequest::default()).await };
let (_, response): (wire::GetMachineRequest, _) = exchange("GetMachine", answer, call).await;
assert_eq!(response.unwrap(), expected, "at k = {k}");
}
}
#[tokio::test]
async fn project_metadata_is_received() {
for k in 0..3 {
let answer = ok(&states::make(|message: &mut wire::GetMachineResponse| {
message.projects = vec![states::make(|message: &mut wire::ProjectSummary| {
message.metadata = Some(on_wire::project_metadata(k, true)).into()
})]
}));
let expected = states::make(|message: &mut types::GetMachineResponse| {
message.projects = vec![states::make(|message: &mut types::ProjectSummary| {
message.metadata = Some(samples::project_metadata(k))
})]
});
let call = |client: Client| async move { client.get_machine(types::GetMachineRequest::default()).await };
let (_, response): (wire::GetMachineRequest, _) = exchange("GetMachine", answer, call).await;
assert_eq!(response.unwrap(), expected, "at k = {k}");
}
}
#[tokio::test]
async fn project_problem_is_received() {
for k in 0..12 {
let answer = ok(&states::make(|message: &mut wire::GetMachineResponse| {
message.projects = vec![states::make(|message: &mut wire::ProjectSummary| {
message.problems = vec![on_wire::project_problem(k, true)]
})]
}));
let expected = states::make(|message: &mut types::GetMachineResponse| {
message.projects = vec![states::make(|message: &mut types::ProjectSummary| {
message.problems = vec![samples::project_problem(k)]
})]
});
let call = |client: Client| async move { client.get_machine(types::GetMachineRequest::default()).await };
let (_, response): (wire::GetMachineRequest, _) = exchange("GetMachine", answer, call).await;
assert_eq!(response.unwrap(), expected, "at k = {k}");
}
}
#[tokio::test]
async fn service_summary_is_received() {
for k in 0..10 {
let answer = ok(&states::make(|message: &mut wire::GetMachineResponse| {
message.projects = vec![states::make(|message: &mut wire::ProjectSummary| {
message.services = vec![on_wire::service_summary(k, true)]
})]
}));
let expected = states::make(|message: &mut types::GetMachineResponse| {
message.projects = vec![states::make(|message: &mut types::ProjectSummary| {
message.services = vec![samples::service_summary(k)]
})]
});
let call = |client: Client| async move { client.get_machine(types::GetMachineRequest::default()).await };
let (_, response): (wire::GetMachineRequest, _) = exchange("GetMachine", answer, call).await;
assert_eq!(response.unwrap(), expected, "at k = {k}");
}
}
#[tokio::test]
async fn snapshot_is_received() {
for k in 0..2 {
let answer = ok(&states::make(|message: &mut wire::GetMachineResponse| {
message.deleted_projects = vec![states::make(|message: &mut wire::DeletedProject| {
message.newest_snapshot = Some(on_wire::snapshot(k, true)).into()
})]
}));
let expected = states::make(|message: &mut types::GetMachineResponse| {
message.deleted_projects = vec![states::make(|message: &mut types::DeletedProject| {
message.newest_snapshot = Some(samples::snapshot(k))
})]
});
let call = |client: Client| async move { client.get_machine(types::GetMachineRequest::default()).await };
let (_, response): (wire::GetMachineRequest, _) = exchange("GetMachine", answer, call).await;
assert_eq!(response.unwrap(), expected, "at k = {k}");
}
}
#[tokio::test]
async fn github_repository_is_received() {
for k in 0..2 {
let answer = ok(&states::make(|message: &mut wire::GetMachineResponse| {
message.github = Some(states::make(|message: &mut wire::GithubConnection| {
message.repositories = vec![on_wire::github_repository(k, true)]
}))
.into()
}));
let expected = states::make(|message: &mut types::GetMachineResponse| {
message.github = Some(states::make(|message: &mut types::GithubConnection| {
message.repositories = vec![samples::github_repository(k)]
}))
});
let call = |client: Client| async move { client.get_machine(types::GetMachineRequest::default()).await };
let (_, response): (wire::GetMachineRequest, _) = exchange("GetMachine", answer, call).await;
assert_eq!(response.unwrap(), expected, "at k = {k}");
}
}
#[tokio::test]
async fn service_is_received() {
for k in 0..10 {
let answer = ok(&states::make(|message: &mut wire::GetProjectResponse| {
message.project = Some(states::make(|message: &mut wire::Project| {
message.services = vec![on_wire::service(k, true)]
}))
.into()
}));
let expected = states::make(|message: &mut types::GetProjectResponse| {
message.project = Some(states::make(|message: &mut types::Project| {
message.services = vec![samples::service(k)]
}))
});
let call = |client: Client| async move { client.get_project(types::GetProjectRequest::default()).await };
let (_, response): (wire::GetProjectRequest, _) = exchange("GetProject", answer, call).await;
assert_eq!(response.unwrap(), expected, "at k = {k}");
}
}
#[tokio::test]
async fn volume_is_received() {
for k in 0..2 {
let answer = ok(&states::make(|message: &mut wire::GetProjectResponse| {
message.project = Some(states::make(|message: &mut wire::Project| {
message.volumes = vec![on_wire::volume(k, true)]
}))
.into()
}));
let expected = states::make(|message: &mut types::GetProjectResponse| {
message.project = Some(states::make(|message: &mut types::Project| {
message.volumes = vec![samples::volume(k)]
}))
});
let call = |client: Client| async move { client.get_project(types::GetProjectRequest::default()).await };
let (_, response): (wire::GetProjectRequest, _) = exchange("GetProject", answer, call).await;
assert_eq!(response.unwrap(), expected, "at k = {k}");
}
}
#[tokio::test]
async fn route_is_received() {
for k in 0..2 {
let answer = ok(&states::make(|message: &mut wire::GetProjectResponse| {
message.project = Some(states::make(|message: &mut wire::Project| {
message.routes = vec![on_wire::route(k, true)]
}))
.into()
}));
let expected = states::make(|message: &mut types::GetProjectResponse| {
message.project = Some(states::make(|message: &mut types::Project| {
message.routes = vec![samples::route(k)]
}))
});
let call = |client: Client| async move { client.get_project(types::GetProjectRequest::default()).await };
let (_, response): (wire::GetProjectRequest, _) = exchange("GetProject", answer, call).await;
assert_eq!(response.unwrap(), expected, "at k = {k}");
}
}
#[tokio::test]
async fn host_is_received() {
for k in 0..5 {
let answer = ok(&states::make(|message: &mut wire::GetProjectResponse| {
message.project = Some(states::make(|message: &mut wire::Project| {
message.hosts = vec![on_wire::host(k, true)]
}))
.into()
}));
let expected = states::make(|message: &mut types::GetProjectResponse| {
message.project = Some(states::make(|message: &mut types::Project| {
message.hosts = vec![samples::host(k)]
}))
});
let call = |client: Client| async move { client.get_project(types::GetProjectRequest::default()).await };
let (_, response): (wire::GetProjectRequest, _) = exchange("GetProject", answer, call).await;
assert_eq!(response.unwrap(), expected, "at k = {k}");
}
}
#[tokio::test]
async fn project_source_is_received() {
for k in 0..6 {
let answer = ok(&states::make(|message: &mut wire::GetProjectResponse| {
message.project = Some(states::make(|message: &mut wire::Project| {
message.source = Some(on_wire::project_source(k, true)).into()
}))
.into()
}));
let expected = states::make(|message: &mut types::GetProjectResponse| {
message.project = Some(states::make(|message: &mut types::Project| {
message.source = Some(samples::project_source(k))
}))
});
let call = |client: Client| async move { client.get_project(types::GetProjectRequest::default()).await };
let (_, response): (wire::GetProjectRequest, _) = exchange("GetProject", answer, call).await;
assert_eq!(response.unwrap(), expected, "at k = {k}");
}
}
#[tokio::test]
async fn running_services_action_is_received() {
for k in 0..5 {
let answer = ok(&states::make(|message: &mut wire::GetProjectResponse| {
message.project = Some(states::make(|message: &mut wire::Project| {
message.running_services_action = Some(on_wire::running_services_action(k, true)).into()
}))
.into()
}));
let expected = states::make(|message: &mut types::GetProjectResponse| {
message.project = Some(states::make(|message: &mut types::Project| {
message.running_services_action = Some(samples::running_services_action(k))
}))
});
let call = |client: Client| async move { client.get_project(types::GetProjectRequest::default()).await };
let (_, response): (wire::GetProjectRequest, _) = exchange("GetProject", answer, call).await;
assert_eq!(response.unwrap(), expected, "at k = {k}");
}
}
#[tokio::test]
async fn github_commit_is_received() {
for k in 0..2 {
let answer = ok(&states::make(|message: &mut wire::CreateProjectResponse| {
message.operation = Some(states::make(|message: &mut wire::Operation| {
message.github_commit = Some(on_wire::github_commit(k, true)).into()
}))
.into()
}));
let expected = states::make(|message: &mut types::CreateProjectResponse| {
message.operation = Some(states::make(|message: &mut types::Operation| {
message.github_commit = Some(samples::github_commit(k))
}))
});
let call = |client: Client| async move { client.create_project(types::CreateProjectRequest::default()).await };
let (_, response): (wire::CreateProjectRequest, _) = exchange("CreateProject", answer, call).await;
assert_eq!(response.unwrap(), expected, "at k = {k}");
}
}
#[tokio::test]
async fn published_port_is_received() {
for k in 0..2 {
let answer = ok(&states::make(|message: &mut wire::GetProjectResponse| {
message.project = Some(states::make(|message: &mut wire::Project| {
message.services = vec![states::make(|message: &mut wire::Service| {
message.published_ports = vec![on_wire::published_port(k, true)]
})]
}))
.into()
}));
let expected = states::make(|message: &mut types::GetProjectResponse| {
message.project = Some(states::make(|message: &mut types::Project| {
message.services = vec![states::make(|message: &mut types::Service| {
message.published_ports = vec![samples::published_port(k)]
})]
}))
});
let call = |client: Client| async move { client.get_project(types::GetProjectRequest::default()).await };
let (_, response): (wire::GetProjectRequest, _) = exchange("GetProject", answer, call).await;
assert_eq!(response.unwrap(), expected, "at k = {k}");
}
}
#[tokio::test]
async fn volume_mount_is_received() {
for k in 0..2 {
let answer = ok(&states::make(|message: &mut wire::GetProjectResponse| {
message.project = Some(states::make(|message: &mut wire::Project| {
message.services = vec![states::make(|message: &mut wire::Service| {
message.volume_mounts = vec![on_wire::volume_mount(k, true)]
})]
}))
.into()
}));
let expected = states::make(|message: &mut types::GetProjectResponse| {
message.project = Some(states::make(|message: &mut types::Project| {
message.services = vec![states::make(|message: &mut types::Service| {
message.volume_mounts = vec![samples::volume_mount(k)]
})]
}))
});
let call = |client: Client| async move { client.get_project(types::GetProjectRequest::default()).await };
let (_, response): (wire::GetProjectRequest, _) = exchange("GetProject", answer, call).await;
assert_eq!(response.unwrap(), expected, "at k = {k}");
}
}
#[tokio::test]
async fn health_check_is_received() {
for k in 0..5 {
let answer = ok(&states::make(|message: &mut wire::GetProjectResponse| {
message.project = Some(states::make(|message: &mut wire::Project| {
message.services = vec![states::make(|message: &mut wire::Service| {
message.health_check = Some(on_wire::health_check(k, true)).into()
})]
}))
.into()
}));
let expected = states::make(|message: &mut types::GetProjectResponse| {
message.project = Some(states::make(|message: &mut types::Project| {
message.services = vec![states::make(|message: &mut types::Service| {
message.health_check = Some(samples::health_check(k))
})]
}))
});
let call = |client: Client| async move { client.get_project(types::GetProjectRequest::default()).await };
let (_, response): (wire::GetProjectRequest, _) = exchange("GetProject", answer, call).await;
assert_eq!(response.unwrap(), expected, "at k = {k}");
}
}
#[tokio::test]
async fn environment_variable_is_received() {
for k in 0..2 {
let answer = ok(&states::make(|message: &mut wire::GetProjectResponse| {
message.project = Some(states::make(|message: &mut wire::Project| {
message.services = vec![states::make(|message: &mut wire::Service| {
message.environment = vec![on_wire::environment_variable(k, true)]
})]
}))
.into()
}));
let expected = states::make(|message: &mut types::GetProjectResponse| {
message.project = Some(states::make(|message: &mut types::Project| {
message.services = vec![states::make(|message: &mut types::Service| {
message.environment = vec![samples::environment_variable(k)]
})]
}))
});
let call = |client: Client| async move { client.get_project(types::GetProjectRequest::default()).await };
let (_, response): (wire::GetProjectRequest, _) = exchange("GetProject", answer, call).await;
assert_eq!(response.unwrap(), expected, "at k = {k}");
}
}
#[tokio::test]
async fn volume_mounted_by_is_received() {
for k in 0..2 {
let answer = ok(&states::make(|message: &mut wire::GetProjectResponse| {
message.project = Some(states::make(|message: &mut wire::Project| {
message.volumes = vec![states::make(|message: &mut wire::Volume| {
message.mounted_by = vec![on_wire::volume_mounted_by(k, true)]
})]
}))
.into()
}));
let expected = states::make(|message: &mut types::GetProjectResponse| {
message.project = Some(states::make(|message: &mut types::Project| {
message.volumes = vec![states::make(|message: &mut types::Volume| {
message.mounted_by = vec![samples::volume_mounted_by(k)]
})]
}))
});
let call = |client: Client| async move { client.get_project(types::GetProjectRequest::default()).await };
let (_, response): (wire::GetProjectRequest, _) = exchange("GetProject", answer, call).await;
assert_eq!(response.unwrap(), expected, "at k = {k}");
}
}
#[tokio::test]
async fn github_source_is_received() {
for k in 0..3 {
let answer = ok(&states::make(|message: &mut wire::GetProjectResponse| {
message.project = Some(states::make(|message: &mut wire::Project| {
message.source = Some(states::make(|message: &mut wire::ProjectSource| {
message.kind = Some(wire::__buffa::oneof::project_source::Kind::Github(Box::new(
on_wire::github_source(k, true),
)))
}))
.into()
}))
.into()
}));
let expected = states::make(|message: &mut types::GetProjectResponse| {
message.project = Some(states::make(|message: &mut types::Project| {
message.source = Some(states::make(|message: &mut types::ProjectSource| {
message.kind = Some(types::ProjectSourceKind::Github(samples::github_source(k)))
}))
}))
});
let call = |client: Client| async move { client.get_project(types::GetProjectRequest::default()).await };
let (_, response): (wire::GetProjectRequest, _) = exchange("GetProject", answer, call).await;
assert_eq!(response.unwrap(), expected, "at k = {k}");
}
}
async fn failed(answer: Answer) -> Error {
let call = |client: Client| async move { client.get_machine(types::GetMachineRequest::default()).await };
let (_, response): (wire::GetMachineRequest, _) = exchange("GetMachine", answer, call).await;
response.unwrap_err()
}
#[tokio::test]
async fn each_code_of_the_protocol_is_its_error_code() {
let codes = [
("canceled", 499, ErrorCode::Canceled),
("unknown", 500, ErrorCode::Unknown),
("invalid_argument", 400, ErrorCode::InvalidArgument),
("deadline_exceeded", 504, ErrorCode::DeadlineExceeded),
("not_found", 404, ErrorCode::NotFound),
("already_exists", 409, ErrorCode::AlreadyExists),
("permission_denied", 403, ErrorCode::PermissionDenied),
("resource_exhausted", 429, ErrorCode::ResourceExhausted),
("failed_precondition", 400, ErrorCode::FailedPrecondition),
("aborted", 409, ErrorCode::Aborted),
("out_of_range", 400, ErrorCode::OutOfRange),
("unimplemented", 501, ErrorCode::Unimplemented),
("internal", 500, ErrorCode::Internal),
("unavailable", 503, ErrorCode::Unavailable),
("data_loss", 500, ErrorCode::DataLoss),
("unauthenticated", 401, ErrorCode::Unauthenticated),
];
for (name, status, code) in codes {
let error = failed(failure(name, status, &[], &STANDARD_NO_PAD)).await;
assert_eq!(error.code(), code);
assert_eq!(error.code().as_str(), name);
assert_eq!(error.message(), MESSAGE);
assert_eq!(error.to_string(), format!("{name}: {MESSAGE}"));
assert!(error.details().is_empty(), "{name}");
}
}
#[tokio::test]
async fn a_detail_the_crate_cannot_read_is_left_out() {
let details: [(&str, &[u8]); 2] = [
("pethost.panel.v1.NoSuchDetailYet", b""),
("pethost.panel.v1.ProjectBusy", b"\x0a\x7f"),
];
let error = failed(failure("aborted", 409, &details, &STANDARD_NO_PAD)).await;
assert_eq!(error.code(), ErrorCode::Aborted);
assert!(error.details().is_empty(), "{:?}", error.details());
}
#[tokio::test]
async fn a_detail_is_read_with_padding_and_without() {
for length in 0..3 {
let mut detail = wire::ProjectBusy::default();
detail.__buffa_unknown_fields.push(buffa::UnknownField {
number: 29,
data: buffa::UnknownFieldData::LengthDelimited(vec![0; length]),
});
let detail = detail.encode_to_vec();
for encode in [&STANDARD, &STANDARD_NO_PAD] {
let answer = failure(
"unavailable",
503,
&[("pethost.panel.v1.ProjectBusy", detail.as_slice())],
encode,
);
assert_eq!(failed(answer).await.details().len(), 1, "{length} more bytes");
}
}
}
#[tokio::test]
async fn a_call_that_reaches_nothing_is_unavailable() {
let listener = TcpListener::bind("127.0.0.1:0").await.unwrap();
let address = listener.local_addr().unwrap();
drop(listener);
let client = Client::with_base_url(TOKEN, &format!("http://{address}")).unwrap();
let error = client
.get_machine(types::GetMachineRequest::default())
.await
.unwrap_err();
assert_eq!(error.code(), ErrorCode::Unavailable);
assert!(std::error::Error::source(&error).is_some());
}
#[test]
fn a_base_url_that_is_none_is_refused() {
for base_url in ["not a url", "console.pethost.dev", "ftp://console.pethost.dev"] {
let error = Client::with_base_url(TOKEN, base_url).unwrap_err();
assert_eq!(error.code(), ErrorCode::InvalidArgument, "{base_url}");
}
}
#[tokio::test]
async fn a_client_prints_without_its_token() {
let printed = format!("{:?}", Client::new(TOKEN));
assert!(printed.contains("https://console.pethost.dev"), "{printed}");
assert!(!printed.contains(TOKEN), "{printed}");
}
#[tokio::test]
async fn a_client_and_its_calls_cross_threads() {
fn shared<T: Clone + Send + Sync>() {}
fn sent<T: Send>(_: &T) {}
shared::<Client>();
shared::<Error>();
sent(&Client::new(TOKEN).get_machine(types::GetMachineRequest::default()));
}
#[test]
fn a_time_prints_as_rfc_3339() {
let print = |seconds, nanos| Timestamp { seconds, nanos }.to_string();
assert_eq!(print(0, 0), "1970-01-01T00:00:00Z");
assert_eq!(print(-1, 500_000_000), "1969-12-31T23:59:59.5Z");
assert_eq!(print(951_782_400, 250_000_000), "2000-02-29T00:00:00.25Z");
assert_eq!(print(1_791_279_000, 1), "2026-10-06T09:30:00.000000001Z");
}
#[test]
fn a_time_is_the_system_clocks_both_ways() {
let before_1970 = std::time::UNIX_EPOCH - Duration::from_millis(1500);
let time = Timestamp::from(before_1970);
assert_eq!((time.seconds, time.nanos), (-2, 500_000_000));
assert_eq!(time.to_system_time(), Some(before_1970));
}