use crate::proto::pethost::panel::v1 as wire;
use crate::types;
fn present<T: Default + PartialEq>(value: T) -> Option<T> {
(value != T::default()).then_some(value)
}
fn machine_session_kind_from_wire(value: buffa::EnumValue<wire::MachineSessionKind>) -> types::MachineSessionKind {
match value {
buffa::EnumValue::Known(wire::MachineSessionKind::MACHINE_SESSION_KIND_UNSPECIFIED) => {
types::MachineSessionKind::Unspecified
}
buffa::EnumValue::Known(wire::MachineSessionKind::MACHINE_SESSION_KIND_WEB_TERMINAL) => {
types::MachineSessionKind::WebTerminal
}
buffa::EnumValue::Known(wire::MachineSessionKind::MACHINE_SESSION_KIND_SSH_TERMINAL) => {
types::MachineSessionKind::SshTerminal
}
buffa::EnumValue::Known(wire::MachineSessionKind::MACHINE_SESSION_KIND_SSH_COMMAND) => {
types::MachineSessionKind::SshCommand
}
buffa::EnumValue::Known(wire::MachineSessionKind::MACHINE_SESSION_KIND_SFTP) => types::MachineSessionKind::Sftp,
buffa::EnumValue::Known(wire::MachineSessionKind::MACHINE_SESSION_KIND_TUNNEL) => {
types::MachineSessionKind::Tunnel
}
buffa::EnumValue::Unknown(number) => types::MachineSessionKind::Unrecognized(number),
}
}
fn project_problem_kind_from_wire(value: buffa::EnumValue<wire::ProjectProblemKind>) -> types::ProjectProblemKind {
match value {
buffa::EnumValue::Known(wire::ProjectProblemKind::PROJECT_PROBLEM_KIND_UNSPECIFIED) => {
types::ProjectProblemKind::Unspecified
}
buffa::EnumValue::Known(wire::ProjectProblemKind::PROJECT_PROBLEM_KIND_DEPLOY_FAILED) => {
types::ProjectProblemKind::DeployFailed
}
buffa::EnumValue::Known(wire::ProjectProblemKind::PROJECT_PROBLEM_KIND_SERVICE_UNHEALTHY) => {
types::ProjectProblemKind::ServiceUnhealthy
}
buffa::EnumValue::Known(wire::ProjectProblemKind::PROJECT_PROBLEM_KIND_SERVICE_RESTARTING) => {
types::ProjectProblemKind::ServiceRestarting
}
buffa::EnumValue::Known(wire::ProjectProblemKind::PROJECT_PROBLEM_KIND_SERVICE_OUT_OF_MEMORY) => {
types::ProjectProblemKind::ServiceOutOfMemory
}
buffa::EnumValue::Known(wire::ProjectProblemKind::PROJECT_PROBLEM_KIND_BACKUP_FAILED) => {
types::ProjectProblemKind::BackupFailed
}
buffa::EnumValue::Known(wire::ProjectProblemKind::PROJECT_PROBLEM_KIND_DEPLOY_CANCELLED) => {
types::ProjectProblemKind::DeployCancelled
}
buffa::EnumValue::Known(wire::ProjectProblemKind::PROJECT_PROBLEM_KIND_SERVICE_EXITED) => {
types::ProjectProblemKind::ServiceExited
}
buffa::EnumValue::Known(wire::ProjectProblemKind::PROJECT_PROBLEM_KIND_RESTORE_FAILED) => {
types::ProjectProblemKind::RestoreFailed
}
buffa::EnumValue::Known(wire::ProjectProblemKind::PROJECT_PROBLEM_KIND_AUTO_DEPLOY_REFUSED) => {
types::ProjectProblemKind::AutoDeployRefused
}
buffa::EnumValue::Known(wire::ProjectProblemKind::PROJECT_PROBLEM_KIND_SERVICE_PORT_CLOSED) => {
types::ProjectProblemKind::ServicePortClosed
}
buffa::EnumValue::Unknown(number) => types::ProjectProblemKind::Unrecognized(number),
}
}
fn services_action_kind_from_wire(value: buffa::EnumValue<wire::ServicesActionKind>) -> types::ServicesActionKind {
match value {
buffa::EnumValue::Known(wire::ServicesActionKind::SERVICES_ACTION_KIND_UNSPECIFIED) => {
types::ServicesActionKind::Unspecified
}
buffa::EnumValue::Known(wire::ServicesActionKind::SERVICES_ACTION_KIND_START) => {
types::ServicesActionKind::Start
}
buffa::EnumValue::Known(wire::ServicesActionKind::SERVICES_ACTION_KIND_STOP) => types::ServicesActionKind::Stop,
buffa::EnumValue::Known(wire::ServicesActionKind::SERVICES_ACTION_KIND_RESTART) => {
types::ServicesActionKind::Restart
}
buffa::EnumValue::Unknown(number) => types::ServicesActionKind::Unrecognized(number),
}
}
fn service_state_from_wire(value: buffa::EnumValue<wire::ServiceState>) -> types::ServiceState {
match value {
buffa::EnumValue::Known(wire::ServiceState::SERVICE_STATE_UNSPECIFIED) => types::ServiceState::Unspecified,
buffa::EnumValue::Known(wire::ServiceState::SERVICE_STATE_NOT_CREATED) => types::ServiceState::NotCreated,
buffa::EnumValue::Known(wire::ServiceState::SERVICE_STATE_STARTING) => types::ServiceState::Starting,
buffa::EnumValue::Known(wire::ServiceState::SERVICE_STATE_RUNNING) => types::ServiceState::Running,
buffa::EnumValue::Known(wire::ServiceState::SERVICE_STATE_HEALTHY) => types::ServiceState::Healthy,
buffa::EnumValue::Known(wire::ServiceState::SERVICE_STATE_UNHEALTHY) => types::ServiceState::Unhealthy,
buffa::EnumValue::Known(wire::ServiceState::SERVICE_STATE_RESTARTING) => types::ServiceState::Restarting,
buffa::EnumValue::Known(wire::ServiceState::SERVICE_STATE_STOPPED) => types::ServiceState::Stopped,
buffa::EnumValue::Known(wire::ServiceState::SERVICE_STATE_EXITED) => types::ServiceState::Exited,
buffa::EnumValue::Unknown(number) => types::ServiceState::Unrecognized(number),
}
}
fn restart_policy_from_wire(value: buffa::EnumValue<wire::RestartPolicy>) -> types::RestartPolicy {
match value {
buffa::EnumValue::Known(wire::RestartPolicy::RESTART_POLICY_UNSPECIFIED) => types::RestartPolicy::Unspecified,
buffa::EnumValue::Known(wire::RestartPolicy::RESTART_POLICY_NO) => types::RestartPolicy::No,
buffa::EnumValue::Known(wire::RestartPolicy::RESTART_POLICY_ON_FAILURE) => types::RestartPolicy::OnFailure,
buffa::EnumValue::Known(wire::RestartPolicy::RESTART_POLICY_UNLESS_STOPPED) => {
types::RestartPolicy::UnlessStopped
}
buffa::EnumValue::Known(wire::RestartPolicy::RESTART_POLICY_ALWAYS) => types::RestartPolicy::Always,
buffa::EnumValue::Unknown(number) => types::RestartPolicy::Unrecognized(number),
}
}
fn health_status_from_wire(value: buffa::EnumValue<wire::HealthStatus>) -> types::HealthStatus {
match value {
buffa::EnumValue::Known(wire::HealthStatus::HEALTH_STATUS_UNSPECIFIED) => types::HealthStatus::Unspecified,
buffa::EnumValue::Known(wire::HealthStatus::HEALTH_STATUS_STARTING) => types::HealthStatus::Starting,
buffa::EnumValue::Known(wire::HealthStatus::HEALTH_STATUS_HEALTHY) => types::HealthStatus::Healthy,
buffa::EnumValue::Known(wire::HealthStatus::HEALTH_STATUS_UNHEALTHY) => types::HealthStatus::Unhealthy,
buffa::EnumValue::Unknown(number) => types::HealthStatus::Unrecognized(number),
}
}
fn certificate_source_from_wire(value: buffa::EnumValue<wire::CertificateSource>) -> types::CertificateSource {
match value {
buffa::EnumValue::Known(wire::CertificateSource::CERTIFICATE_SOURCE_UNSPECIFIED) => {
types::CertificateSource::Unspecified
}
buffa::EnumValue::Known(wire::CertificateSource::CERTIFICATE_SOURCE_NONE) => types::CertificateSource::None,
buffa::EnumValue::Known(wire::CertificateSource::CERTIFICATE_SOURCE_INSTALLED) => {
types::CertificateSource::Installed
}
buffa::EnumValue::Known(wire::CertificateSource::CERTIFICATE_SOURCE_AUTOMATIC) => {
types::CertificateSource::Automatic
}
buffa::EnumValue::Unknown(number) => types::CertificateSource::Unrecognized(number),
}
}
fn operation_kind_from_wire(value: buffa::EnumValue<wire::OperationKind>) -> types::OperationKind {
match value {
buffa::EnumValue::Known(wire::OperationKind::OPERATION_KIND_UNSPECIFIED) => types::OperationKind::Unspecified,
buffa::EnumValue::Known(wire::OperationKind::OPERATION_KIND_DEPLOY) => types::OperationKind::Deploy,
buffa::EnumValue::Known(wire::OperationKind::OPERATION_KIND_RECREATE_SERVICE) => {
types::OperationKind::RecreateService
}
buffa::EnumValue::Known(wire::OperationKind::OPERATION_KIND_BACKUP) => types::OperationKind::Backup,
buffa::EnumValue::Known(wire::OperationKind::OPERATION_KIND_RESTORE) => types::OperationKind::Restore,
buffa::EnumValue::Known(wire::OperationKind::OPERATION_KIND_DELETE) => types::OperationKind::Delete,
buffa::EnumValue::Unknown(number) => types::OperationKind::Unrecognized(number),
}
}
fn operation_status_from_wire(value: buffa::EnumValue<wire::OperationStatus>) -> types::OperationStatus {
match value {
buffa::EnumValue::Known(wire::OperationStatus::OPERATION_STATUS_UNSPECIFIED) => {
types::OperationStatus::Unspecified
}
buffa::EnumValue::Known(wire::OperationStatus::OPERATION_STATUS_IN_PROGRESS) => {
types::OperationStatus::InProgress
}
buffa::EnumValue::Known(wire::OperationStatus::OPERATION_STATUS_SUCCEEDED) => types::OperationStatus::Succeeded,
buffa::EnumValue::Known(wire::OperationStatus::OPERATION_STATUS_FAILED) => types::OperationStatus::Failed,
buffa::EnumValue::Known(wire::OperationStatus::OPERATION_STATUS_CANCELLED) => types::OperationStatus::Cancelled,
buffa::EnumValue::Unknown(number) => types::OperationStatus::Unrecognized(number),
}
}
fn deploy_failure_reason_from_wire(value: buffa::EnumValue<wire::DeployFailureReason>) -> types::DeployFailureReason {
match value {
buffa::EnumValue::Known(wire::DeployFailureReason::DEPLOY_FAILURE_REASON_UNSPECIFIED) => {
types::DeployFailureReason::Unspecified
}
buffa::EnumValue::Known(wire::DeployFailureReason::DEPLOY_FAILURE_REASON_IMAGE_PULL_FAILED) => {
types::DeployFailureReason::ImagePullFailed
}
buffa::EnumValue::Known(wire::DeployFailureReason::DEPLOY_FAILURE_REASON_IMAGE_BUILD_FAILED) => {
types::DeployFailureReason::ImageBuildFailed
}
buffa::EnumValue::Known(wire::DeployFailureReason::DEPLOY_FAILURE_REASON_CONTAINER_START_FAILED) => {
types::DeployFailureReason::ContainerStartFailed
}
buffa::EnumValue::Known(wire::DeployFailureReason::DEPLOY_FAILURE_REASON_DISK_FULL) => {
types::DeployFailureReason::DiskFull
}
buffa::EnumValue::Known(wire::DeployFailureReason::DEPLOY_FAILURE_REASON_INTERNAL) => {
types::DeployFailureReason::Internal
}
buffa::EnumValue::Known(wire::DeployFailureReason::DEPLOY_FAILURE_REASON_PORT_UNAVAILABLE) => {
types::DeployFailureReason::PortUnavailable
}
buffa::EnumValue::Known(wire::DeployFailureReason::DEPLOY_FAILURE_REASON_CONTAINER_EXITED) => {
types::DeployFailureReason::ContainerExited
}
buffa::EnumValue::Known(wire::DeployFailureReason::DEPLOY_FAILURE_REASON_CONTAINER_UNHEALTHY) => {
types::DeployFailureReason::ContainerUnhealthy
}
buffa::EnumValue::Known(wire::DeployFailureReason::DEPLOY_FAILURE_REASON_TIMED_OUT) => {
types::DeployFailureReason::TimedOut
}
buffa::EnumValue::Known(wire::DeployFailureReason::DEPLOY_FAILURE_REASON_UNCOVERED_IMAGE_VOLUME) => {
types::DeployFailureReason::UncoveredImageVolume
}
buffa::EnumValue::Known(wire::DeployFailureReason::DEPLOY_FAILURE_REASON_BUILD_MEMORY_UNAVAILABLE) => {
types::DeployFailureReason::BuildMemoryUnavailable
}
buffa::EnumValue::Unknown(number) => types::DeployFailureReason::Unrecognized(number),
}
}
fn output_stream_from_wire(value: buffa::EnumValue<wire::OutputStream>) -> types::OutputStream {
match value {
buffa::EnumValue::Known(wire::OutputStream::OUTPUT_STREAM_UNSPECIFIED) => types::OutputStream::Unspecified,
buffa::EnumValue::Known(wire::OutputStream::OUTPUT_STREAM_STDOUT) => types::OutputStream::Stdout,
buffa::EnumValue::Known(wire::OutputStream::OUTPUT_STREAM_STDERR) => types::OutputStream::Stderr,
buffa::EnumValue::Unknown(number) => types::OutputStream::Unrecognized(number),
}
}
fn output_stream_to_wire(value: types::OutputStream) -> buffa::EnumValue<wire::OutputStream> {
match value {
types::OutputStream::Unspecified => buffa::EnumValue::Known(wire::OutputStream::OUTPUT_STREAM_UNSPECIFIED),
types::OutputStream::Stdout => buffa::EnumValue::Known(wire::OutputStream::OUTPUT_STREAM_STDOUT),
types::OutputStream::Stderr => buffa::EnumValue::Known(wire::OutputStream::OUTPUT_STREAM_STDERR),
types::OutputStream::Unrecognized(number) => buffa::EnumValue::from(number),
}
}
fn file_type_from_wire(value: buffa::EnumValue<wire::FileType>) -> types::FileType {
match value {
buffa::EnumValue::Known(wire::FileType::FILE_TYPE_UNSPECIFIED) => types::FileType::Unspecified,
buffa::EnumValue::Known(wire::FileType::FILE_TYPE_FILE) => types::FileType::File,
buffa::EnumValue::Known(wire::FileType::FILE_TYPE_DIRECTORY) => types::FileType::Directory,
buffa::EnumValue::Known(wire::FileType::FILE_TYPE_SYMLINK) => types::FileType::Symlink,
buffa::EnumValue::Known(wire::FileType::FILE_TYPE_OTHER) => types::FileType::Other,
buffa::EnumValue::Unknown(number) => types::FileType::Unrecognized(number),
}
}
fn file_location_from_wire(value: buffa::EnumValue<wire::FileLocation>) -> types::FileLocation {
match value {
buffa::EnumValue::Known(wire::FileLocation::FILE_LOCATION_UNSPECIFIED) => types::FileLocation::Unspecified,
buffa::EnumValue::Known(wire::FileLocation::FILE_LOCATION_CONTAINER) => types::FileLocation::Container,
buffa::EnumValue::Known(wire::FileLocation::FILE_LOCATION_VOLUME) => types::FileLocation::Volume,
buffa::EnumValue::Known(wire::FileLocation::FILE_LOCATION_PROJECT_FILES) => types::FileLocation::ProjectFiles,
buffa::EnumValue::Unknown(number) => types::FileLocation::Unrecognized(number),
}
}
fn no_machine_reason_from_wire(value: buffa::EnumValue<wire::NoMachineReason>) -> types::NoMachineReason {
match value {
buffa::EnumValue::Known(wire::NoMachineReason::NO_MACHINE_REASON_UNSPECIFIED) => {
types::NoMachineReason::Unspecified
}
buffa::EnumValue::Known(wire::NoMachineReason::NO_MACHINE_REASON_NO_PLAN) => types::NoMachineReason::NoPlan,
buffa::EnumValue::Known(wire::NoMachineReason::NO_MACHINE_REASON_BEING_PREPARED) => {
types::NoMachineReason::BeingPrepared
}
buffa::EnumValue::Unknown(number) => types::NoMachineReason::Unrecognized(number),
}
}
impl From<types::GetMachineRequest> for wire::GetMachineRequest {
fn from(message: types::GetMachineRequest) -> Self {
let types::GetMachineRequest {} = message;
Self {
__buffa_unknown_fields: Default::default(),
}
}
}
impl From<wire::GetMachineResponse> for types::GetMachineResponse {
fn from(message: wire::GetMachineResponse) -> Self {
let wire::GetMachineResponse {
machine,
projects,
deleted_projects,
github,
__buffa_unknown_fields: _,
} = message;
Self {
machine: machine.into_option().map(types::Machine::from),
projects: projects.into_iter().map(types::ProjectSummary::from).collect(),
deleted_projects: deleted_projects.into_iter().map(types::DeletedProject::from).collect(),
github: github.into_option().map(types::GithubConnection::from),
}
}
}
impl From<wire::Machine> for types::Machine {
fn from(message: wire::Machine) -> Self {
let wire::Machine {
name,
location,
sample_time,
cpu_used_cores,
cpu_total_cores,
memory_used_bytes,
memory_total_bytes,
disk_used_bytes,
disk_total_bytes,
disk_usage,
hostname,
ssh_host_key_fingerprint,
ssh_keys,
backups_enabled,
snapshot_list_time,
snapshot_list_failure_message,
backup_retention_hours,
acme_enabled,
apps_domain,
daemon_version,
docker_version,
boot_time,
restart_required_time,
scheduled_restart_time,
sessions,
__buffa_unknown_fields: _,
} = message;
Self {
name: name.unwrap_or_default(),
location: location.unwrap_or_default(),
sample_time: sample_time.into_option().map(crate::timestamp::from_wire),
cpu_used_cores: cpu_used_cores.unwrap_or_default(),
cpu_total_cores: cpu_total_cores.unwrap_or_default(),
memory_used_bytes: memory_used_bytes.unwrap_or_default(),
memory_total_bytes: memory_total_bytes.unwrap_or_default(),
disk_used_bytes: disk_used_bytes.unwrap_or_default(),
disk_total_bytes: disk_total_bytes.unwrap_or_default(),
disk_usage: disk_usage.into_option().map(types::DiskUsage::from),
hostname: hostname.unwrap_or_default(),
ssh_host_key_fingerprint: ssh_host_key_fingerprint.unwrap_or_default(),
ssh_keys: ssh_keys.into_iter().map(types::SshKey::from).collect(),
backups_enabled: backups_enabled.unwrap_or_default(),
snapshot_list_time: snapshot_list_time.into_option().map(crate::timestamp::from_wire),
snapshot_list_failure_message: snapshot_list_failure_message.unwrap_or_default(),
backup_retention_hours: backup_retention_hours.unwrap_or_default(),
acme_enabled: acme_enabled.unwrap_or_default(),
apps_domain: apps_domain.unwrap_or_default(),
daemon_version: daemon_version.unwrap_or_default(),
docker_version: docker_version.unwrap_or_default(),
boot_time: boot_time.into_option().map(crate::timestamp::from_wire),
restart_required_time: restart_required_time.into_option().map(crate::timestamp::from_wire),
scheduled_restart_time: scheduled_restart_time.into_option().map(crate::timestamp::from_wire),
sessions: sessions.into_iter().map(types::MachineSession::from).collect(),
}
}
}
impl From<wire::MachineSession> for types::MachineSession {
fn from(message: wire::MachineSession) -> Self {
let wire::MachineSession {
session_id,
kind,
project_id,
service,
port,
start_time,
client_address,
ssh_key_label,
ssh_key_fingerprint,
__buffa_unknown_fields: _,
} = message;
Self {
session_id: session_id.unwrap_or_default(),
kind: kind.map(machine_session_kind_from_wire).unwrap_or_default(),
project_id: project_id.unwrap_or_default(),
service: service.unwrap_or_default(),
port: port.unwrap_or_default(),
start_time: start_time.into_option().map(crate::timestamp::from_wire),
client_address: client_address.unwrap_or_default(),
ssh_key_label: ssh_key_label.unwrap_or_default(),
ssh_key_fingerprint: ssh_key_fingerprint.unwrap_or_default(),
}
}
}
impl From<wire::DiskUsage> for types::DiskUsage {
fn from(message: wire::DiskUsage) -> Self {
let wire::DiskUsage {
images_bytes,
build_cache_bytes,
volumes_bytes,
container_layers_bytes,
project_files_bytes,
container_logs_bytes,
http_traffic_bytes,
__buffa_unknown_fields: _,
} = message;
Self {
images_bytes: images_bytes.unwrap_or_default(),
build_cache_bytes,
volumes_bytes: volumes_bytes.unwrap_or_default(),
container_layers_bytes: container_layers_bytes.unwrap_or_default(),
project_files_bytes: project_files_bytes.unwrap_or_default(),
container_logs_bytes: container_logs_bytes.unwrap_or_default(),
http_traffic_bytes: http_traffic_bytes.unwrap_or_default(),
}
}
}
impl From<types::SshKey> for wire::SshKey {
fn from(message: types::SshKey) -> Self {
let types::SshKey {
public_key,
label,
fingerprint,
} = message;
Self {
public_key: self::present(public_key),
label: self::present(label),
fingerprint: self::present(fingerprint),
__buffa_unknown_fields: Default::default(),
}
}
}
impl From<wire::SshKey> for types::SshKey {
fn from(message: wire::SshKey) -> Self {
let wire::SshKey {
public_key,
label,
fingerprint,
__buffa_unknown_fields: _,
} = message;
Self {
public_key: public_key.unwrap_or_default(),
label: label.unwrap_or_default(),
fingerprint: fingerprint.unwrap_or_default(),
}
}
}
impl From<wire::GithubConnection> for types::GithubConnection {
fn from(message: wire::GithubConnection) -> Self {
let wire::GithubConnection {
app_name,
install_url,
repositories,
repository_count,
webhooks_enabled,
__buffa_unknown_fields: _,
} = message;
Self {
app_name: app_name.unwrap_or_default(),
install_url: install_url.unwrap_or_default(),
repositories: repositories.into_iter().map(types::GithubRepository::from).collect(),
repository_count: repository_count.unwrap_or_default(),
webhooks_enabled: webhooks_enabled.unwrap_or_default(),
}
}
}
impl From<wire::GithubRepository> for types::GithubRepository {
fn from(message: wire::GithubRepository) -> Self {
let wire::GithubRepository {
repository,
default_branch,
private,
push_time,
__buffa_unknown_fields: _,
} = message;
Self {
repository: repository.unwrap_or_default(),
default_branch: default_branch.unwrap_or_default(),
private: private.unwrap_or_default(),
push_time: push_time.into_option().map(crate::timestamp::from_wire),
}
}
}
impl From<wire::DeletedProject> for types::DeletedProject {
fn from(message: wire::DeletedProject) -> Self {
let wire::DeletedProject {
project_id,
newest_snapshot,
snapshot_count,
__buffa_unknown_fields: _,
} = message;
Self {
project_id: project_id.unwrap_or_default(),
newest_snapshot: newest_snapshot.into_option().map(types::Snapshot::from),
snapshot_count: snapshot_count.unwrap_or_default(),
}
}
}
impl From<types::RunMachineActionRequest> for wire::RunMachineActionRequest {
fn from(message: types::RunMachineActionRequest) -> Self {
let types::RunMachineActionRequest { action } = message;
Self {
action: match action {
Some(types::RunMachineActionRequestAction::AddSshKey(value)) => {
Some(wire::__buffa::oneof::run_machine_action_request::Action::AddSshKey(
Box::new(wire::SshKey::from(value)),
))
}
Some(types::RunMachineActionRequestAction::RemoveSshKeyFingerprint(value)) => {
Some(wire::__buffa::oneof::run_machine_action_request::Action::RemoveSshKeyFingerprint(value))
}
Some(types::RunMachineActionRequestAction::RestartMachine(value)) => Some(
wire::__buffa::oneof::run_machine_action_request::Action::RestartMachine(Box::new(
wire::RestartMachineAction::from(value),
)),
),
Some(types::RunMachineActionRequestAction::CancelRestart(value)) => Some(
wire::__buffa::oneof::run_machine_action_request::Action::CancelRestart(value),
),
Some(types::RunMachineActionRequestAction::EndSessionId(value)) => Some(
wire::__buffa::oneof::run_machine_action_request::Action::EndSessionId(value),
),
None => None,
},
__buffa_unknown_fields: Default::default(),
}
}
}
impl From<types::RestartMachineAction> for wire::RestartMachineAction {
fn from(message: types::RestartMachineAction) -> Self {
let types::RestartMachineAction {
restart_time,
at_maintenance_window,
interrupt_operations,
} = message;
Self {
restart_time: restart_time.map(crate::timestamp::to_wire).into(),
at_maintenance_window: self::present(at_maintenance_window),
interrupt_operations: self::present(interrupt_operations),
__buffa_unknown_fields: Default::default(),
}
}
}
impl From<wire::RunMachineActionResponse> for types::RunMachineActionResponse {
fn from(message: wire::RunMachineActionResponse) -> Self {
let wire::RunMachineActionResponse {
machine,
__buffa_unknown_fields: _,
} = message;
Self {
machine: machine.into_option().map(types::Machine::from),
}
}
}
impl From<types::ProjectMetadata> for wire::ProjectMetadata {
fn from(message: types::ProjectMetadata) -> Self {
let types::ProjectMetadata {
name,
emoji,
description,
notes,
} = message;
Self {
name,
emoji,
description,
notes,
__buffa_unknown_fields: Default::default(),
}
}
}
impl From<wire::ProjectMetadata> for types::ProjectMetadata {
fn from(message: wire::ProjectMetadata) -> Self {
let wire::ProjectMetadata {
name,
emoji,
description,
notes,
__buffa_unknown_fields: _,
} = message;
Self {
name,
emoji,
description,
notes,
}
}
}
impl From<wire::ProjectSummary> for types::ProjectSummary {
fn from(message: wire::ProjectSummary) -> Self {
let wire::ProjectSummary {
project_id,
metadata,
problems,
services,
url,
hosts,
http_traffic_last_day,
cpu_used_cores,
memory_used_bytes,
deploy_time,
running_operations,
pinned,
disk_used_bytes,
__buffa_unknown_fields: _,
} = message;
Self {
project_id: project_id.unwrap_or_default(),
metadata: metadata.into_option().map(types::ProjectMetadata::from),
problems: problems.into_iter().map(types::ProjectProblem::from).collect(),
services: services.into_iter().map(types::ServiceSummary::from).collect(),
url: url.unwrap_or_default(),
hosts,
http_traffic_last_day: http_traffic_last_day.into_option().map(types::HttpTrafficSummary::from),
cpu_used_cores: cpu_used_cores.unwrap_or_default(),
memory_used_bytes: memory_used_bytes.unwrap_or_default(),
deploy_time: deploy_time.into_option().map(crate::timestamp::from_wire),
running_operations: running_operations.into_iter().map(types::Operation::from).collect(),
pinned: pinned.unwrap_or_default(),
disk_used_bytes: disk_used_bytes.unwrap_or_default(),
}
}
}
impl From<wire::ServiceSummary> for types::ServiceSummary {
fn from(message: wire::ServiceSummary) -> Self {
let wire::ServiceSummary {
service,
state,
__buffa_unknown_fields: _,
} = message;
Self {
service: service.unwrap_or_default(),
state: state.map(service_state_from_wire).unwrap_or_default(),
}
}
}
impl From<wire::ProjectProblem> for types::ProjectProblem {
fn from(message: wire::ProjectProblem) -> Self {
let wire::ProjectProblem {
kind,
service,
operation_id,
since_time,
problem_message,
__buffa_unknown_fields: _,
} = message;
Self {
kind: kind.map(project_problem_kind_from_wire).unwrap_or_default(),
service: service.unwrap_or_default(),
operation_id: operation_id.unwrap_or_default(),
since_time: since_time.into_option().map(crate::timestamp::from_wire),
problem_message: problem_message.unwrap_or_default(),
}
}
}
impl From<types::GetProjectRequest> for wire::GetProjectRequest {
fn from(message: types::GetProjectRequest) -> Self {
let types::GetProjectRequest {
project_id,
include_secret_values,
snapshots_before,
snapshots_volume,
} = message;
Self {
project_id: self::present(project_id),
include_secret_values: self::present(include_secret_values),
snapshots_before: snapshots_before.map(crate::timestamp::to_wire).into(),
snapshots_volume: self::present(snapshots_volume),
__buffa_unknown_fields: Default::default(),
}
}
}
impl From<wire::GetProjectResponse> for types::GetProjectResponse {
fn from(message: wire::GetProjectResponse) -> Self {
let wire::GetProjectResponse {
project,
__buffa_unknown_fields: _,
} = message;
Self {
project: project.into_option().map(types::Project::from),
}
}
}
impl From<wire::Project> for types::Project {
fn from(message: wire::Project) -> Self {
let wire::Project {
project_id,
metadata,
problems,
url,
cpu_used_cores,
memory_used_bytes,
deploy_id,
deploy_status,
deploy_time,
x_pethost_applies_at_once,
services,
volumes,
routes,
hosts,
password_protected,
operations,
snapshots,
snapshot_count,
snapshot_list_time,
http_traffic_last_day,
source,
running_services_action,
__buffa_unknown_fields: _,
} = message;
Self {
project_id: project_id.unwrap_or_default(),
metadata: metadata.into_option().map(types::ProjectMetadata::from),
problems: problems.into_iter().map(types::ProjectProblem::from).collect(),
url: url.unwrap_or_default(),
cpu_used_cores: cpu_used_cores.unwrap_or_default(),
memory_used_bytes: memory_used_bytes.unwrap_or_default(),
deploy_id: deploy_id.unwrap_or_default(),
deploy_status: deploy_status.map(operation_status_from_wire).unwrap_or_default(),
deploy_time: deploy_time.into_option().map(crate::timestamp::from_wire),
x_pethost_applies_at_once: x_pethost_applies_at_once.unwrap_or_default(),
services: services.into_iter().map(types::Service::from).collect(),
volumes: volumes.into_iter().map(types::Volume::from).collect(),
routes: routes.into_iter().map(types::Route::from).collect(),
hosts: hosts.into_iter().map(types::Host::from).collect(),
password_protected: password_protected.unwrap_or_default(),
operations: operations.into_iter().map(types::Operation::from).collect(),
snapshots: snapshots.into_iter().map(types::Snapshot::from).collect(),
snapshot_count: snapshot_count.unwrap_or_default(),
snapshot_list_time: snapshot_list_time.into_option().map(crate::timestamp::from_wire),
http_traffic_last_day: http_traffic_last_day.into_option().map(types::HttpTrafficSummary::from),
source: source.into_option().map(types::ProjectSource::from),
running_services_action: running_services_action
.into_option()
.map(types::RunningServicesAction::from),
}
}
}
impl From<wire::RunningServicesAction> for types::RunningServicesAction {
fn from(message: wire::RunningServicesAction) -> Self {
let wire::RunningServicesAction {
kind,
services,
start_time,
__buffa_unknown_fields: _,
} = message;
Self {
kind: kind.map(services_action_kind_from_wire).unwrap_or_default(),
services,
start_time: start_time.into_option().map(crate::timestamp::from_wire),
}
}
}
impl From<types::ProjectSource> for wire::ProjectSource {
fn from(message: types::ProjectSource) -> Self {
let types::ProjectSource { kind } = message;
Self {
kind: match kind {
Some(types::ProjectSourceKind::Files(value)) => {
Some(wire::__buffa::oneof::project_source::Kind::Files(value))
}
Some(types::ProjectSourceKind::Github(value)) => Some(
wire::__buffa::oneof::project_source::Kind::Github(Box::new(wire::GithubSource::from(value))),
),
None | Some(types::ProjectSourceKind::Unrecognized) => None,
},
__buffa_unknown_fields: Default::default(),
}
}
}
impl From<wire::ProjectSource> for types::ProjectSource {
fn from(message: wire::ProjectSource) -> Self {
let wire::ProjectSource {
kind,
__buffa_unknown_fields,
} = message;
Self {
kind: match kind {
Some(wire::__buffa::oneof::project_source::Kind::Files(value)) => {
Some(types::ProjectSourceKind::Files(value))
}
Some(wire::__buffa::oneof::project_source::Kind::Github(value)) => {
Some(types::ProjectSourceKind::Github(types::GithubSource::from(*value)))
}
None if !__buffa_unknown_fields.is_empty() => Some(types::ProjectSourceKind::Unrecognized),
None => None,
},
}
}
}
impl From<types::GithubSource> for wire::GithubSource {
fn from(message: types::GithubSource) -> Self {
let types::GithubSource {
repository,
branch,
directory,
auto_deploy,
newest_commit,
deployed_commit,
pinned,
auto_deploy_pending,
} = message;
Self {
repository,
branch,
directory,
auto_deploy,
newest_commit: newest_commit.map(wire::GithubCommit::from).into(),
deployed_commit: deployed_commit.map(wire::GithubCommit::from).into(),
pinned: self::present(pinned),
auto_deploy_pending: self::present(auto_deploy_pending),
__buffa_unknown_fields: Default::default(),
}
}
}
impl From<wire::GithubSource> for types::GithubSource {
fn from(message: wire::GithubSource) -> Self {
let wire::GithubSource {
repository,
branch,
directory,
auto_deploy,
newest_commit,
deployed_commit,
pinned,
auto_deploy_pending,
__buffa_unknown_fields: _,
} = message;
Self {
repository,
branch,
directory,
auto_deploy,
newest_commit: newest_commit.into_option().map(types::GithubCommit::from),
deployed_commit: deployed_commit.into_option().map(types::GithubCommit::from),
pinned: pinned.unwrap_or_default(),
auto_deploy_pending: auto_deploy_pending.unwrap_or_default(),
}
}
}
impl From<types::GithubCommit> for wire::GithubCommit {
fn from(message: types::GithubCommit) -> Self {
let types::GithubCommit { sha, title, url } = message;
Self {
sha: self::present(sha),
title: self::present(title),
url: self::present(url),
__buffa_unknown_fields: Default::default(),
}
}
}
impl From<wire::GithubCommit> for types::GithubCommit {
fn from(message: wire::GithubCommit) -> Self {
let wire::GithubCommit {
sha,
title,
url,
__buffa_unknown_fields: _,
} = message;
Self {
sha: sha.unwrap_or_default(),
title: title.unwrap_or_default(),
url: url.unwrap_or_default(),
}
}
}
impl From<wire::Service> for types::Service {
fn from(message: wire::Service) -> Self {
let wire::Service {
service,
state,
container_running,
image,
builds_image,
image_digest,
image_size_bytes,
command,
run_as_user,
start_time,
finish_time,
exit_code,
out_of_memory,
restart_count,
cpu_used_cores,
memory_used_bytes,
memory_limit_bytes,
cpu_limit_cores,
writable_layer_bytes,
ports,
listening_ports,
published_ports,
volume_mounts,
restart_policy,
health_check,
environment,
env_files,
ssh_command,
__buffa_unknown_fields: _,
} = message;
Self {
service: service.unwrap_or_default(),
state: state.map(service_state_from_wire).unwrap_or_default(),
container_running: container_running.unwrap_or_default(),
image: image.unwrap_or_default(),
builds_image: builds_image.unwrap_or_default(),
image_digest: image_digest.unwrap_or_default(),
image_size_bytes: image_size_bytes.unwrap_or_default(),
command,
run_as_user: run_as_user.unwrap_or_default(),
start_time: start_time.into_option().map(crate::timestamp::from_wire),
finish_time: finish_time.into_option().map(crate::timestamp::from_wire),
exit_code,
out_of_memory: out_of_memory.unwrap_or_default(),
restart_count: restart_count.unwrap_or_default(),
cpu_used_cores: cpu_used_cores.unwrap_or_default(),
memory_used_bytes: memory_used_bytes.unwrap_or_default(),
memory_limit_bytes: memory_limit_bytes.unwrap_or_default(),
cpu_limit_cores: cpu_limit_cores.unwrap_or_default(),
writable_layer_bytes: writable_layer_bytes.unwrap_or_default(),
ports,
listening_ports,
published_ports: published_ports.into_iter().map(types::PublishedPort::from).collect(),
volume_mounts: volume_mounts.into_iter().map(types::VolumeMount::from).collect(),
restart_policy: restart_policy.map(restart_policy_from_wire).unwrap_or_default(),
health_check: health_check.into_option().map(types::HealthCheck::from),
environment: environment.into_iter().map(types::EnvironmentVariable::from).collect(),
env_files,
ssh_command: ssh_command.unwrap_or_default(),
}
}
}
impl From<wire::PublishedPort> for types::PublishedPort {
fn from(message: wire::PublishedPort) -> Self {
let wire::PublishedPort {
machine_port,
container_port,
protocol,
machine_only,
__buffa_unknown_fields: _,
} = message;
Self {
machine_port: machine_port.unwrap_or_default(),
container_port: container_port.unwrap_or_default(),
protocol: protocol.unwrap_or_default(),
machine_only: machine_only.unwrap_or_default(),
}
}
}
impl From<wire::VolumeMount> for types::VolumeMount {
fn from(message: wire::VolumeMount) -> Self {
let wire::VolumeMount {
volume,
container_path,
__buffa_unknown_fields: _,
} = message;
Self {
volume: volume.unwrap_or_default(),
container_path: container_path.unwrap_or_default(),
}
}
}
impl From<wire::HealthCheck> for types::HealthCheck {
fn from(message: wire::HealthCheck) -> Self {
let wire::HealthCheck {
command,
interval_seconds,
status,
consecutive_failure_count,
recent_results_passed,
last_failure_output,
__buffa_unknown_fields: _,
} = message;
Self {
command,
interval_seconds: interval_seconds.unwrap_or_default(),
status: status.map(health_status_from_wire).unwrap_or_default(),
consecutive_failure_count: consecutive_failure_count.unwrap_or_default(),
recent_results_passed,
last_failure_output: last_failure_output.unwrap_or_default(),
}
}
}
impl From<wire::EnvironmentVariable> for types::EnvironmentVariable {
fn from(message: wire::EnvironmentVariable) -> Self {
let wire::EnvironmentVariable {
name,
value,
secret,
source_file,
from_env_file_variables,
value_left_out,
__buffa_unknown_fields: _,
} = message;
Self {
name: name.unwrap_or_default(),
value: value.unwrap_or_default(),
secret: secret.unwrap_or_default(),
source_file: source_file.unwrap_or_default(),
from_env_file_variables,
value_left_out: value_left_out.unwrap_or_default(),
}
}
}
impl From<wire::Volume> for types::Volume {
fn from(message: wire::Volume) -> Self {
let wire::Volume {
volume,
size_bytes,
mounted_by,
last_backup_time,
snapshot_count,
declared,
__buffa_unknown_fields: _,
} = message;
Self {
volume: volume.unwrap_or_default(),
size_bytes: size_bytes.unwrap_or_default(),
mounted_by: mounted_by.into_iter().map(types::VolumeMountedBy::from).collect(),
last_backup_time: last_backup_time.into_option().map(crate::timestamp::from_wire),
snapshot_count: snapshot_count.unwrap_or_default(),
declared: declared.unwrap_or_default(),
}
}
}
impl From<wire::VolumeMountedBy> for types::VolumeMountedBy {
fn from(message: wire::VolumeMountedBy) -> Self {
let wire::VolumeMountedBy {
service,
container_path,
__buffa_unknown_fields: _,
} = message;
Self {
service: service.unwrap_or_default(),
container_path: container_path.unwrap_or_default(),
}
}
}
impl From<wire::Host> for types::Host {
fn from(message: wire::Host) -> Self {
let wire::Host {
host,
url,
certificate_source,
certificate_expire_time,
unavailable_message,
__buffa_unknown_fields: _,
} = message;
Self {
host: host.unwrap_or_default(),
url: url.unwrap_or_default(),
certificate_source: certificate_source.map(certificate_source_from_wire).unwrap_or_default(),
certificate_expire_time: certificate_expire_time.into_option().map(crate::timestamp::from_wire),
unavailable_message: unavailable_message.unwrap_or_default(),
}
}
}
impl From<types::Route> for wire::Route {
fn from(message: types::Route) -> Self {
let types::Route {
host,
path,
service,
port,
strip_path,
} = message;
Self {
host: self::present(host),
path: self::present(path),
service: self::present(service),
port: self::present(port),
strip_path: self::present(strip_path),
__buffa_unknown_fields: Default::default(),
}
}
}
impl From<wire::Route> for types::Route {
fn from(message: wire::Route) -> Self {
let wire::Route {
host,
path,
service,
port,
strip_path,
__buffa_unknown_fields: _,
} = message;
Self {
host: host.unwrap_or_default(),
path: path.unwrap_or_default(),
service: service.unwrap_or_default(),
port: port.unwrap_or_default(),
strip_path: strip_path.unwrap_or_default(),
}
}
}
impl From<wire::Operation> for types::Operation {
fn from(message: wire::Operation) -> Self {
let wire::Operation {
operation_id,
kind,
status,
start_time,
finish_time,
failure_message,
deploy_failure_reason,
made_current,
service,
failed_exit_code,
snapshot_id,
restored_volumes,
undo_snapshot_id,
github_commit,
archive_name,
adjustments,
changed_paths,
changed_path_count,
files_kept,
__buffa_unknown_fields: _,
} = message;
Self {
operation_id: operation_id.unwrap_or_default(),
kind: kind.map(operation_kind_from_wire).unwrap_or_default(),
status: status.map(operation_status_from_wire).unwrap_or_default(),
start_time: start_time.into_option().map(crate::timestamp::from_wire),
finish_time: finish_time.into_option().map(crate::timestamp::from_wire),
failure_message: failure_message.unwrap_or_default(),
deploy_failure_reason: deploy_failure_reason
.map(deploy_failure_reason_from_wire)
.unwrap_or_default(),
made_current: made_current.unwrap_or_default(),
service: service.unwrap_or_default(),
failed_exit_code: failed_exit_code.unwrap_or_default(),
snapshot_id: snapshot_id.unwrap_or_default(),
restored_volumes,
undo_snapshot_id: undo_snapshot_id.unwrap_or_default(),
github_commit: github_commit.into_option().map(types::GithubCommit::from),
archive_name: archive_name.unwrap_or_default(),
adjustments,
changed_paths,
changed_path_count: changed_path_count.unwrap_or_default(),
files_kept: files_kept.unwrap_or_default(),
}
}
}
impl From<wire::Snapshot> for types::Snapshot {
fn from(message: wire::Snapshot) -> Self {
let wire::Snapshot {
snapshot_id,
create_time,
size_bytes,
volumes,
__buffa_unknown_fields: _,
} = message;
Self {
snapshot_id: snapshot_id.unwrap_or_default(),
create_time: create_time.into_option().map(crate::timestamp::from_wire),
size_bytes: size_bytes.unwrap_or_default(),
volumes,
}
}
}
impl From<wire::HttpTrafficSummary> for types::HttpTrafficSummary {
fn from(message: wire::HttpTrafficSummary) -> Self {
let wire::HttpTrafficSummary {
request_count,
server_error_count,
latency_p50_ms,
latency_p95_ms,
__buffa_unknown_fields: _,
} = message;
Self {
request_count: request_count.unwrap_or_default(),
server_error_count: server_error_count.unwrap_or_default(),
latency_p50_ms: latency_p50_ms.unwrap_or_default(),
latency_p95_ms: latency_p95_ms.unwrap_or_default(),
}
}
}
impl From<types::CreateProjectRequest> for wire::CreateProjectRequest {
fn from(message: types::CreateProjectRequest) -> Self {
let types::CreateProjectRequest {
project_id,
source,
upload_id,
files,
x_pethost,
timeout_seconds,
operation_id,
wait_seconds,
} = message;
Self {
project_id: self::present(project_id),
source: source.map(wire::ProjectSource::from).into(),
upload_id: self::present(upload_id),
files: files.into_iter().map(wire::FileChange::from).collect(),
x_pethost: x_pethost.map(wire::ProjectExtension::from).into(),
timeout_seconds: self::present(timeout_seconds),
operation_id: self::present(operation_id),
wait_seconds,
__buffa_unknown_fields: Default::default(),
}
}
}
impl From<wire::CreateProjectResponse> for types::CreateProjectResponse {
fn from(message: wire::CreateProjectResponse) -> Self {
let wire::CreateProjectResponse {
operation,
violations,
adjustments,
project,
log,
__buffa_unknown_fields: _,
} = message;
Self {
operation: operation.into_option().map(types::Operation::from),
violations: violations.into_iter().map(types::SpecViolation::from).collect(),
adjustments,
project: project.into_option().map(types::Project::from),
log: log.into_iter().map(types::OperationLogLine::from).collect(),
}
}
}
impl From<types::DeployProjectRequest> for wire::DeployProjectRequest {
fn from(message: types::DeployProjectRequest) -> Self {
let types::DeployProjectRequest {
project_id,
base_deploy_id,
files,
x_pethost,
mount_volume,
timeout_seconds,
operation_id,
version,
wait_seconds,
} = message;
Self {
project_id: self::present(project_id),
base_deploy_id: self::present(base_deploy_id),
files: files.into_iter().map(wire::FileChange::from).collect(),
x_pethost: x_pethost.map(wire::ProjectExtension::from).into(),
mount_volume: mount_volume.map(wire::MountVolume::from).into(),
timeout_seconds: self::present(timeout_seconds),
operation_id: self::present(operation_id),
version: match version {
Some(types::DeployProjectRequestVersion::UploadId(value)) => {
Some(wire::__buffa::oneof::deploy_project_request::Version::UploadId(value))
}
Some(types::DeployProjectRequestVersion::Commit(value)) => {
Some(wire::__buffa::oneof::deploy_project_request::Version::Commit(value))
}
Some(types::DeployProjectRequestVersion::NewestCommit(value)) => Some(
wire::__buffa::oneof::deploy_project_request::Version::NewestCommit(value),
),
Some(types::DeployProjectRequestVersion::RollbackDeployId(value)) => Some(
wire::__buffa::oneof::deploy_project_request::Version::RollbackDeployId(value),
),
None => None,
},
wait_seconds,
__buffa_unknown_fields: Default::default(),
}
}
}
impl From<types::MountVolume> for wire::MountVolume {
fn from(message: types::MountVolume) -> Self {
let types::MountVolume {
service,
volume,
container_path,
} = message;
Self {
service: self::present(service),
volume: self::present(volume),
container_path: self::present(container_path),
__buffa_unknown_fields: Default::default(),
}
}
}
impl From<types::ProjectExtension> for wire::ProjectExtension {
fn from(message: types::ProjectExtension) -> Self {
let types::ProjectExtension {
metadata,
routes,
remove_routes,
password,
remove_password,
} = message;
Self {
metadata: metadata.map(wire::ProjectMetadata::from).into(),
routes: routes.into_iter().map(wire::Route::from).collect(),
remove_routes: self::present(remove_routes),
password: self::present(password),
remove_password: self::present(remove_password),
__buffa_unknown_fields: Default::default(),
}
}
}
impl From<types::FileChange> for wire::FileChange {
fn from(message: types::FileChange) -> Self {
let types::FileChange {
path,
change,
executable,
} = message;
Self {
path: self::present(path),
change: match change {
Some(types::FileChangeChange::Text(value)) => {
Some(wire::__buffa::oneof::file_change::Change::Text(value))
}
Some(types::FileChangeChange::Data(value)) => {
Some(wire::__buffa::oneof::file_change::Change::Data(value))
}
Some(types::FileChangeChange::MakeDirectory(value)) => {
Some(wire::__buffa::oneof::file_change::Change::MakeDirectory(value))
}
Some(types::FileChangeChange::Delete(value)) => {
Some(wire::__buffa::oneof::file_change::Change::Delete(value))
}
Some(types::FileChangeChange::DeleteTree(value)) => {
Some(wire::__buffa::oneof::file_change::Change::DeleteTree(value))
}
Some(types::FileChangeChange::RenameTo(value)) => {
Some(wire::__buffa::oneof::file_change::Change::RenameTo(value))
}
None => None,
},
executable: self::present(executable),
__buffa_unknown_fields: Default::default(),
}
}
}
impl From<wire::DeployProjectResponse> for types::DeployProjectResponse {
fn from(message: wire::DeployProjectResponse) -> Self {
let wire::DeployProjectResponse {
operation,
violations,
adjustments,
project,
log,
__buffa_unknown_fields: _,
} = message;
Self {
operation: operation.into_option().map(types::Operation::from),
violations: violations.into_iter().map(types::SpecViolation::from).collect(),
adjustments,
project: project.into_option().map(types::Project::from),
log: log.into_iter().map(types::OperationLogLine::from).collect(),
}
}
}
impl From<wire::SpecViolation> for types::SpecViolation {
fn from(message: wire::SpecViolation) -> Self {
let wire::SpecViolation {
service,
location,
violation_message,
__buffa_unknown_fields: _,
} = message;
Self {
service: service.unwrap_or_default(),
location: location.unwrap_or_default(),
violation_message: violation_message.unwrap_or_default(),
}
}
}
impl From<types::ListCommitsRequest> for wire::ListCommitsRequest {
fn from(message: types::ListCommitsRequest) -> Self {
let types::ListCommitsRequest {
project_id,
before_commit,
} = message;
Self {
project_id: self::present(project_id),
before_commit: self::present(before_commit),
__buffa_unknown_fields: Default::default(),
}
}
}
impl From<wire::ListCommitsResponse> for types::ListCommitsResponse {
fn from(message: wire::ListCommitsResponse) -> Self {
let wire::ListCommitsResponse {
commits,
more,
__buffa_unknown_fields: _,
} = message;
Self {
commits: commits.into_iter().map(types::BranchCommit::from).collect(),
more: more.unwrap_or_default(),
}
}
}
impl From<wire::BranchCommit> for types::BranchCommit {
fn from(message: wire::BranchCommit) -> Self {
let wire::BranchCommit {
commit,
author,
commit_time,
deployed,
last_deploy,
newest,
__buffa_unknown_fields: _,
} = message;
Self {
commit: commit.into_option().map(types::GithubCommit::from),
author: author.unwrap_or_default(),
commit_time: commit_time.into_option().map(crate::timestamp::from_wire),
deployed: deployed.unwrap_or_default(),
last_deploy: last_deploy.into_option().map(types::Operation::from),
newest: newest.unwrap_or_default(),
}
}
}
impl From<types::RunProjectActionRequest> for wire::RunProjectActionRequest {
fn from(message: types::RunProjectActionRequest) -> Self {
let types::RunProjectActionRequest {
project_id,
action,
operation_id,
wait_seconds,
} = message;
Self {
project_id: self::present(project_id),
action: match action {
Some(types::RunProjectActionRequestAction::StartServices(value)) => {
Some(wire::__buffa::oneof::run_project_action_request::Action::StartServices(
Box::new(wire::ServicesAction::from(value)),
))
}
Some(types::RunProjectActionRequestAction::StopServices(value)) => {
Some(wire::__buffa::oneof::run_project_action_request::Action::StopServices(
Box::new(wire::ServicesAction::from(value)),
))
}
Some(types::RunProjectActionRequestAction::RestartServices(value)) => Some(
wire::__buffa::oneof::run_project_action_request::Action::RestartServices(Box::new(
wire::ServicesAction::from(value),
)),
),
Some(types::RunProjectActionRequestAction::RecreateService(value)) => Some(
wire::__buffa::oneof::run_project_action_request::Action::RecreateService(Box::new(
wire::RecreateServiceAction::from(value),
)),
),
Some(types::RunProjectActionRequestAction::BackUp(value)) => {
Some(wire::__buffa::oneof::run_project_action_request::Action::BackUp(
Box::new(wire::BackUpAction::from(value)),
))
}
Some(types::RunProjectActionRequestAction::RestoreSnapshot(value)) => Some(
wire::__buffa::oneof::run_project_action_request::Action::RestoreSnapshot(Box::new(
wire::RestoreSnapshotAction::from(value),
)),
),
Some(types::RunProjectActionRequestAction::CancelOperation(value)) => Some(
wire::__buffa::oneof::run_project_action_request::Action::CancelOperation(Box::new(
wire::CancelOperationAction::from(value),
)),
),
Some(types::RunProjectActionRequestAction::DeleteProject(value)) => {
Some(wire::__buffa::oneof::run_project_action_request::Action::DeleteProject(
Box::new(wire::DeleteProjectAction::from(value)),
))
}
Some(types::RunProjectActionRequestAction::SetSource(value)) => {
Some(wire::__buffa::oneof::run_project_action_request::Action::SetSource(
Box::new(wire::ProjectSource::from(value)),
))
}
Some(types::RunProjectActionRequestAction::DeleteVolume(value)) => Some(
wire::__buffa::oneof::run_project_action_request::Action::DeleteVolume(value),
),
None => None,
},
operation_id: self::present(operation_id),
wait_seconds,
__buffa_unknown_fields: Default::default(),
}
}
}
impl From<types::ServicesAction> for wire::ServicesAction {
fn from(message: types::ServicesAction) -> Self {
let types::ServicesAction { services } = message;
Self {
services,
__buffa_unknown_fields: Default::default(),
}
}
}
impl From<types::RecreateServiceAction> for wire::RecreateServiceAction {
fn from(message: types::RecreateServiceAction) -> Self {
let types::RecreateServiceAction {
service,
pull_latest_image,
} = message;
Self {
service: self::present(service),
pull_latest_image: self::present(pull_latest_image),
__buffa_unknown_fields: Default::default(),
}
}
}
impl From<types::BackUpAction> for wire::BackUpAction {
fn from(message: types::BackUpAction) -> Self {
let types::BackUpAction {} = message;
Self {
__buffa_unknown_fields: Default::default(),
}
}
}
impl From<types::RestoreSnapshotAction> for wire::RestoreSnapshotAction {
fn from(message: types::RestoreSnapshotAction) -> Self {
let types::RestoreSnapshotAction { snapshot_id, volumes } = message;
Self {
snapshot_id: self::present(snapshot_id),
volumes,
__buffa_unknown_fields: Default::default(),
}
}
}
impl From<types::CancelOperationAction> for wire::CancelOperationAction {
fn from(message: types::CancelOperationAction) -> Self {
let types::CancelOperationAction { operation_id } = message;
Self {
operation_id: self::present(operation_id),
__buffa_unknown_fields: Default::default(),
}
}
}
impl From<types::DeleteProjectAction> for wire::DeleteProjectAction {
fn from(message: types::DeleteProjectAction) -> Self {
let types::DeleteProjectAction { skip_final_backup } = message;
Self {
skip_final_backup: self::present(skip_final_backup),
__buffa_unknown_fields: Default::default(),
}
}
}
impl From<wire::RunProjectActionResponse> for types::RunProjectActionResponse {
fn from(message: wire::RunProjectActionResponse) -> Self {
let wire::RunProjectActionResponse {
operation,
project,
log,
__buffa_unknown_fields: _,
} = message;
Self {
operation: operation.into_option().map(types::Operation::from),
project: project.into_option().map(types::Project::from),
log: log.into_iter().map(types::OperationLogLine::from).collect(),
}
}
}
impl From<types::GetOperationRequest> for wire::GetOperationRequest {
fn from(message: types::GetOperationRequest) -> Self {
let types::GetOperationRequest {
project_id,
operation_id,
wait_seconds,
after_log_line,
log_line_limit,
} = message;
Self {
project_id: self::present(project_id),
operation_id: self::present(operation_id),
wait_seconds,
after_log_line,
log_line_limit,
__buffa_unknown_fields: Default::default(),
}
}
}
impl From<wire::GetOperationResponse> for types::GetOperationResponse {
fn from(message: wire::GetOperationResponse) -> Self {
let wire::GetOperationResponse {
operation,
project,
log,
log_line_count,
next_after_log_line,
__buffa_unknown_fields: _,
} = message;
Self {
operation: operation.into_option().map(types::Operation::from),
project: project.into_option().map(types::Project::from),
log: log.into_iter().map(types::OperationLogLine::from).collect(),
log_line_count: log_line_count.unwrap_or_default(),
next_after_log_line: next_after_log_line.unwrap_or_default(),
}
}
}
impl From<wire::OperationLogLine> for types::OperationLogLine {
fn from(message: wire::OperationLogLine) -> Self {
let wire::OperationLogLine {
time,
text,
__buffa_unknown_fields: _,
} = message;
Self {
time: time.into_option().map(crate::timestamp::from_wire),
text: text.unwrap_or_default(),
}
}
}
impl From<types::HttpTrafficFilter> for wire::HttpTrafficFilter {
fn from(message: types::HttpTrafficFilter) -> Self {
let types::HttpTrafficFilter {
host,
method,
path_contains,
path_pattern,
status_class,
} = message;
Self {
host: self::present(host),
method: self::present(method),
path_contains: self::present(path_contains),
path_pattern: self::present(path_pattern),
status_class: self::present(status_class),
__buffa_unknown_fields: Default::default(),
}
}
}
impl From<types::QueryHttpTrafficRequest> for wire::QueryHttpTrafficRequest {
fn from(message: types::QueryHttpTrafficRequest) -> Self {
let types::QueryHttpTrafficRequest {
project_id,
filter,
start_time,
end_time,
last_seconds,
bucket_width_seconds,
request_limit,
page_token,
} = message;
Self {
project_id: self::present(project_id),
filter: filter.map(wire::HttpTrafficFilter::from).into(),
start_time: start_time.map(crate::timestamp::to_wire).into(),
end_time: end_time.map(crate::timestamp::to_wire).into(),
last_seconds: self::present(last_seconds),
bucket_width_seconds: self::present(bucket_width_seconds),
request_limit: self::present(request_limit),
page_token: self::present(page_token),
__buffa_unknown_fields: Default::default(),
}
}
}
impl From<wire::QueryHttpTrafficResponse> for types::QueryHttpTrafficResponse {
fn from(message: wire::QueryHttpTrafficResponse) -> Self {
let wire::QueryHttpTrafficResponse {
start_time,
end_time,
oldest_kept_time,
summary,
buckets,
top_paths,
newest_sequence,
requests,
next_page_token,
tail_sequence,
__buffa_unknown_fields: _,
} = message;
Self {
start_time: start_time.into_option().map(crate::timestamp::from_wire),
end_time: end_time.into_option().map(crate::timestamp::from_wire),
oldest_kept_time: oldest_kept_time.into_option().map(crate::timestamp::from_wire),
summary: summary.into_option().map(types::HttpTrafficSummary::from),
buckets: buckets.into_iter().map(types::HttpTrafficBucket::from).collect(),
top_paths: top_paths.into_iter().map(types::HttpPathTraffic::from).collect(),
newest_sequence: newest_sequence.unwrap_or_default(),
requests: requests.into_iter().map(types::HttpRequest::from).collect(),
next_page_token: next_page_token.unwrap_or_default(),
tail_sequence: tail_sequence.unwrap_or_default(),
}
}
}
impl From<wire::HttpTrafficBucket> for types::HttpTrafficBucket {
fn from(message: wire::HttpTrafficBucket) -> Self {
let wire::HttpTrafficBucket {
start_time,
summary,
__buffa_unknown_fields: _,
} = message;
Self {
start_time: start_time.into_option().map(crate::timestamp::from_wire),
summary: summary.into_option().map(types::HttpTrafficSummary::from),
}
}
}
impl From<wire::HttpPathTraffic> for types::HttpPathTraffic {
fn from(message: wire::HttpPathTraffic) -> Self {
let wire::HttpPathTraffic {
method,
path_pattern,
summary,
__buffa_unknown_fields: _,
} = message;
Self {
method: method.unwrap_or_default(),
path_pattern: path_pattern.unwrap_or_default(),
summary: summary.into_option().map(types::HttpTrafficSummary::from),
}
}
}
impl From<wire::HttpRequest> for types::HttpRequest {
fn from(message: wire::HttpRequest) -> Self {
let wire::HttpRequest {
sequence,
finish_time,
host,
method,
path,
path_pattern,
route_path,
service,
port,
status_code,
response_size_bytes,
duration_ms,
service_duration_ms,
client_ip_address,
user_agent,
__buffa_unknown_fields: _,
} = message;
Self {
sequence: sequence.unwrap_or_default(),
finish_time: finish_time.into_option().map(crate::timestamp::from_wire),
host: host.unwrap_or_default(),
method: method.unwrap_or_default(),
path: path.unwrap_or_default(),
path_pattern: path_pattern.unwrap_or_default(),
route_path: route_path.unwrap_or_default(),
service: service.unwrap_or_default(),
port: port.unwrap_or_default(),
status_code: status_code.unwrap_or_default(),
response_size_bytes: response_size_bytes.unwrap_or_default(),
duration_ms: duration_ms.unwrap_or_default(),
service_duration_ms: service_duration_ms.unwrap_or_default(),
client_ip_address: client_ip_address.unwrap_or_default(),
user_agent: user_agent.unwrap_or_default(),
}
}
}
impl From<types::ContainerLogFilter> for wire::ContainerLogFilter {
fn from(message: types::ContainerLogFilter) -> Self {
let types::ContainerLogFilter {
service,
stream,
text_contains,
} = message;
Self {
service: self::present(service),
stream: self::present(stream).map(output_stream_to_wire),
text_contains: self::present(text_contains),
__buffa_unknown_fields: Default::default(),
}
}
}
impl From<types::QueryContainerLogsRequest> for wire::QueryContainerLogsRequest {
fn from(message: types::QueryContainerLogsRequest) -> Self {
let types::QueryContainerLogsRequest {
project_id,
filter,
start_time,
end_time,
last_seconds,
limit,
from_start,
page_token,
} = message;
Self {
project_id: self::present(project_id),
filter: filter.map(wire::ContainerLogFilter::from).into(),
start_time: start_time.map(crate::timestamp::to_wire).into(),
end_time: end_time.map(crate::timestamp::to_wire).into(),
last_seconds: self::present(last_seconds),
limit: self::present(limit),
from_start: self::present(from_start),
page_token: self::present(page_token),
__buffa_unknown_fields: Default::default(),
}
}
}
impl From<wire::QueryContainerLogsResponse> for types::QueryContainerLogsResponse {
fn from(message: wire::QueryContainerLogsResponse) -> Self {
let wire::QueryContainerLogsResponse {
start_time,
end_time,
oldest_kept_time,
lines,
next_page_token,
tail_cursor,
__buffa_unknown_fields: _,
} = message;
Self {
start_time: start_time.into_option().map(crate::timestamp::from_wire),
end_time: end_time.into_option().map(crate::timestamp::from_wire),
oldest_kept_time: oldest_kept_time.into_option().map(crate::timestamp::from_wire),
lines: lines.into_iter().map(types::LogLine::from).collect(),
next_page_token: next_page_token.unwrap_or_default(),
tail_cursor: tail_cursor.unwrap_or_default(),
}
}
}
impl From<wire::LogLine> for types::LogLine {
fn from(message: wire::LogLine) -> Self {
let wire::LogLine {
time,
service,
stream,
text,
__buffa_unknown_fields: _,
} = message;
Self {
time: time.into_option().map(crate::timestamp::from_wire),
service: service.unwrap_or_default(),
stream: stream.map(output_stream_from_wire).unwrap_or_default(),
text: text.unwrap_or_default(),
}
}
}
impl From<types::RunServiceCommandRequest> for wire::RunServiceCommandRequest {
fn from(message: types::RunServiceCommandRequest) -> Self {
let types::RunServiceCommandRequest {
project_id,
service,
command,
stdin,
run_as_user,
working_directory,
timeout_seconds,
} = message;
Self {
project_id: self::present(project_id),
service: self::present(service),
command,
stdin: self::present(stdin),
run_as_user: self::present(run_as_user),
working_directory: self::present(working_directory),
timeout_seconds: self::present(timeout_seconds),
__buffa_unknown_fields: Default::default(),
}
}
}
impl From<wire::RunServiceCommandResponse> for types::RunServiceCommandResponse {
fn from(message: wire::RunServiceCommandResponse) -> Self {
let wire::RunServiceCommandResponse {
exit_code,
timed_out,
stdout,
stderr,
output_truncated,
__buffa_unknown_fields: _,
} = message;
Self {
exit_code: exit_code.unwrap_or_default(),
timed_out: timed_out.unwrap_or_default(),
stdout: stdout.unwrap_or_default(),
stderr: stderr.unwrap_or_default(),
output_truncated: output_truncated.unwrap_or_default(),
}
}
}
impl From<wire::FileEntry> for types::FileEntry {
fn from(message: wire::FileEntry) -> Self {
let wire::FileEntry {
name,
r#type,
size_bytes,
modify_time,
mode,
owner_uid,
owner_gid,
symlink_target,
__buffa_unknown_fields: _,
} = message;
Self {
name: name.unwrap_or_default(),
r#type: r#type.map(file_type_from_wire).unwrap_or_default(),
size_bytes: size_bytes.unwrap_or_default(),
modify_time: modify_time.into_option().map(crate::timestamp::from_wire),
mode: mode.unwrap_or_default(),
owner_uid: owner_uid.unwrap_or_default(),
owner_gid: owner_gid.unwrap_or_default(),
symlink_target: symlink_target.unwrap_or_default(),
}
}
}
impl From<types::ReadPathRequest> for wire::ReadPathRequest {
fn from(message: types::ReadPathRequest) -> Self {
let types::ReadPathRequest {
project_id,
root,
path,
entry_limit,
offset_bytes,
length_bytes,
entry_page_token,
} = message;
Self {
project_id: self::present(project_id),
root: match root {
Some(types::ReadPathRequestRoot::Service(value)) => {
Some(wire::__buffa::oneof::read_path_request::Root::Service(value))
}
Some(types::ReadPathRequestRoot::Volume(value)) => {
Some(wire::__buffa::oneof::read_path_request::Root::Volume(value))
}
None => None,
},
path: self::present(path),
entry_limit: self::present(entry_limit),
offset_bytes: self::present(offset_bytes),
length_bytes: self::present(length_bytes),
entry_page_token: self::present(entry_page_token),
__buffa_unknown_fields: Default::default(),
}
}
}
impl From<wire::ReadPathResponse> for types::ReadPathResponse {
fn from(message: wire::ReadPathResponse) -> Self {
let wire::ReadPathResponse {
entry,
location,
volume,
entries,
entry_count,
next_entry_page_token,
text,
binary,
next_offset_bytes,
deploy_id,
__buffa_unknown_fields: _,
} = message;
Self {
entry: entry.into_option().map(types::FileEntry::from),
location: location.map(file_location_from_wire).unwrap_or_default(),
volume: volume.unwrap_or_default(),
entries: entries.into_iter().map(types::FileEntry::from).collect(),
entry_count: entry_count.unwrap_or_default(),
next_entry_page_token: next_entry_page_token.unwrap_or_default(),
text: text.unwrap_or_default(),
binary: binary.unwrap_or_default(),
next_offset_bytes: next_offset_bytes.unwrap_or_default(),
deploy_id: deploy_id.unwrap_or_default(),
}
}
}
impl From<types::CreateTransferRequest> for wire::CreateTransferRequest {
fn from(message: types::CreateTransferRequest) -> Self {
let types::CreateTransferRequest { transfer } = message;
Self {
transfer: match transfer {
Some(types::CreateTransferRequestTransfer::UploadArchive(value)) => {
Some(wire::__buffa::oneof::create_transfer_request::Transfer::UploadArchive(
Box::new(wire::ArchiveUpload::from(value)),
))
}
Some(types::CreateTransferRequestTransfer::UploadFile(value)) => {
Some(wire::__buffa::oneof::create_transfer_request::Transfer::UploadFile(
Box::new(wire::FileUpload::from(value)),
))
}
Some(types::CreateTransferRequestTransfer::Download(value)) => {
Some(wire::__buffa::oneof::create_transfer_request::Transfer::Download(
Box::new(wire::PathDownload::from(value)),
))
}
None => None,
},
__buffa_unknown_fields: Default::default(),
}
}
}
impl From<types::ArchiveUpload> for wire::ArchiveUpload {
fn from(message: types::ArchiveUpload) -> Self {
let types::ArchiveUpload { file_name } = message;
Self {
file_name: self::present(file_name),
__buffa_unknown_fields: Default::default(),
}
}
}
impl From<types::FileUpload> for wire::FileUpload {
fn from(message: types::FileUpload) -> Self {
let types::FileUpload { project_id, root, path } = message;
Self {
project_id: self::present(project_id),
root: match root {
Some(types::FileUploadRoot::Service(value)) => {
Some(wire::__buffa::oneof::file_upload::Root::Service(value))
}
Some(types::FileUploadRoot::Volume(value)) => {
Some(wire::__buffa::oneof::file_upload::Root::Volume(value))
}
None => None,
},
path: self::present(path),
__buffa_unknown_fields: Default::default(),
}
}
}
impl From<types::PathDownload> for wire::PathDownload {
fn from(message: types::PathDownload) -> Self {
let types::PathDownload { project_id, root, path } = message;
Self {
project_id: self::present(project_id),
root: match root {
Some(types::PathDownloadRoot::Service(value)) => {
Some(wire::__buffa::oneof::path_download::Root::Service(value))
}
Some(types::PathDownloadRoot::Volume(value)) => {
Some(wire::__buffa::oneof::path_download::Root::Volume(value))
}
None => None,
},
path: self::present(path),
__buffa_unknown_fields: Default::default(),
}
}
}
impl From<wire::CreateTransferResponse> for types::CreateTransferResponse {
fn from(message: wire::CreateTransferResponse) -> Self {
let wire::CreateTransferResponse {
url,
http_method,
expire_time,
command,
upload_id,
replaces,
file_name,
__buffa_unknown_fields: _,
} = message;
Self {
url: url.unwrap_or_default(),
http_method: http_method.unwrap_or_default(),
expire_time: expire_time.into_option().map(crate::timestamp::from_wire),
command: command.unwrap_or_default(),
upload_id: upload_id.unwrap_or_default(),
replaces: replaces.unwrap_or_default(),
file_name: file_name.unwrap_or_default(),
}
}
}
impl From<wire::ProjectBusy> for types::ProjectBusy {
fn from(message: wire::ProjectBusy) -> Self {
let wire::ProjectBusy {
operation_id,
kind,
start_time,
__buffa_unknown_fields: _,
} = message;
Self {
operation_id: operation_id.unwrap_or_default(),
kind: kind.map(operation_kind_from_wire).unwrap_or_default(),
start_time: start_time.into_option().map(crate::timestamp::from_wire),
}
}
}
impl From<wire::ProjectChanged> for types::ProjectChanged {
fn from(message: wire::ProjectChanged) -> Self {
let wire::ProjectChanged {
__buffa_unknown_fields: _,
} = message;
Self {}
}
}
impl From<wire::MachineUnreachable> for types::MachineUnreachable {
fn from(message: wire::MachineUnreachable) -> Self {
let wire::MachineUnreachable {
__buffa_unknown_fields: _,
} = message;
Self {}
}
}
impl From<wire::NoMachine> for types::NoMachine {
fn from(message: wire::NoMachine) -> Self {
let wire::NoMachine {
reason,
url,
__buffa_unknown_fields: _,
} = message;
Self {
reason: reason.map(no_machine_reason_from_wire).unwrap_or_default(),
url: url.unwrap_or_default(),
}
}
}