From 7fd5b31e8385d7b749382e50d1353e3eb197ad1f Mon Sep 17 00:00:00 2001 From: KCarretto Date: Tue, 23 Jan 2024 17:29:48 -0500 Subject: [PATCH] [feature] Structured Reporting - Files (#496) * update protobufs * Use c2pb enum on process ent, rename to HostProcess, add fields * Migrate to c2pb for Host_Platform enum * Fix enums, added tests * Added ReportFile gRPC API * Generate Rust Bindings * minor cleanup --- implants/lib/c2/src/c2.rs | 259 +- tavern/internal/c2/api_claim_tasks.go | 3 +- tavern/internal/c2/api_report_file.go | 141 + tavern/internal/c2/api_report_file_test.go | 251 + tavern/internal/c2/api_report_process_list.go | 14 +- tavern/internal/c2/c2.proto | 122 +- tavern/internal/c2/c2pb/c2.pb.go | 1070 +- tavern/internal/c2/c2pb/c2_grpc.pb.go | 218 +- tavern/internal/c2/c2pb/enum_host_platform.go | 62 + .../c2/c2pb/enum_host_platform_test.go | 51 + .../internal/c2/c2pb/enum_process_status.go | 67 + .../c2/c2pb/enum_process_status_test.go | 51 + tavern/internal/c2/c2test/ent.go | 1 + tavern/internal/c2/convert.go | 22 - tavern/internal/ent/client.go | 428 +- tavern/internal/ent/ent.go | 22 +- tavern/internal/ent/file.go | 2 +- tavern/internal/ent/gql_collection.go | 283 +- tavern/internal/ent/gql_edge.go | 56 +- tavern/internal/ent/gql_mutation_input.go | 12 + tavern/internal/ent/gql_node.go | 52 +- tavern/internal/ent/gql_pagination.go | 630 +- tavern/internal/ent/gql_where_input.go | 1112 +- tavern/internal/ent/hook/hook.go | 24 +- tavern/internal/ent/host.go | 76 +- tavern/internal/ent/host/host.go | 90 +- tavern/internal/ent/host/where.go | 34 +- tavern/internal/ent/host_create.go | 71 +- tavern/internal/ent/host_query.go | 131 +- tavern/internal/ent/host_update.go | 254 +- tavern/internal/ent/hostfile.go | 280 + tavern/internal/ent/hostfile/hostfile.go | 192 + tavern/internal/ent/hostfile/where.go | 697 ++ tavern/internal/ent/hostfile_create.go | 1118 ++ tavern/internal/ent/hostfile_delete.go | 88 + tavern/internal/ent/hostfile_query.go | 701 ++ tavern/internal/ent/hostfile_update.go | 784 ++ tavern/internal/ent/hostprocess.go | 303 + .../process.go => hostprocess/hostprocess.go} | 92 +- tavern/internal/ent/hostprocess/where.go | 778 ++ tavern/internal/ent/hostprocess_create.go | 1202 +++ tavern/internal/ent/hostprocess_delete.go | 88 + tavern/internal/ent/hostprocess_query.go | 701 ++ tavern/internal/ent/hostprocess_update.go | 785 ++ tavern/internal/ent/migrate/schema.go | 90 +- tavern/internal/ent/mutation.go | 1987 +++- tavern/internal/ent/predicate/predicate.go | 7 +- tavern/internal/ent/privacy/privacy.go | 44 +- tavern/internal/ent/process.go | 234 - tavern/internal/ent/process/where.go | 392 - tavern/internal/ent/process_create.go | 758 -- tavern/internal/ent/process_delete.go | 88 - tavern/internal/ent/process_query.go | 701 -- tavern/internal/ent/process_update.go | 510 - tavern/internal/ent/runtime/runtime.go | 72 +- tavern/internal/ent/schema/file.go | 2 +- tavern/internal/ent/schema/host.go | 8 +- tavern/internal/ent/schema/host_file.go | 124 + tavern/internal/ent/schema/host_file_test.go | 69 + .../schema/{process.go => host_process.go} | 33 +- tavern/internal/ent/schema/task.go | 4 +- tavern/internal/ent/task.go | 63 +- tavern/internal/ent/task/task.go | 38 +- tavern/internal/ent/task/where.go | 25 +- tavern/internal/ent/task_create.go | 48 +- tavern/internal/ent/task_query.go | 131 +- tavern/internal/ent/task_update.go | 229 +- tavern/internal/ent/tx.go | 9 +- tavern/internal/graphql/ent.resolvers.go | 81 +- .../graphql/generated/ent.generated.go | 9502 +++++++++++------ .../graphql/generated/inputs.generated.go | 2 +- .../graphql/generated/mutation.generated.go | 2 + .../graphql/generated/root_.generated.go | 828 +- tavern/internal/graphql/gqlgen.yml | 7 +- .../internal/graphql/models/gqlgen_models.go | 4 +- tavern/internal/graphql/quest_test.go | 6 +- tavern/internal/graphql/schema.graphql | 529 +- tavern/internal/graphql/schema/ent.graphql | 529 +- .../mutations/createQuest/NoFiles.yml | 4 +- .../mutations/createQuest/WithFiles.yml | 4 +- .../testdata/mutations/createTag/Group.yml | 4 +- .../mutations/createTag/MultipleHosts.yml | 8 +- .../testdata/mutations/createTag/Service.yml | 4 +- .../mutations/createTome/WithFiles.yml | 4 +- .../mutations/deleteTome/PermissionDenied.yml | 4 +- .../mutations/deleteTome/Singular.yml | 4 +- .../updateBeacon/ChangeNameError.yml | 4 +- .../testdata/mutations/updateHost/AddTag.yml | 4 +- .../mutations/updateHost/ChangeHostname.yml | 6 +- .../mutations/updateHost/RemoveTag.yml | 4 +- .../mutations/updateTag/ChangeName.yml | 4 +- .../mutations/updateTome/PermissionDenied.yml | 4 +- .../mutations/updateTome/Singular.yml | 4 +- .../testdata/queries/beacons/FilterByID.yml | 4 +- .../testdata/queries/beacons/Singular.yml | 4 +- .../testdata/queries/hosts/Multiple.yml | 8 +- .../testdata/queries/hosts/Singular.yml | 4 +- .../testdata/queries/quests/FilterByID.yml | 4 +- .../testdata/queries/quests/Singular.yml | 4 +- .../queries/tasks/BackwardPaginate.yml | 4 +- .../testdata/queries/tasks/FilterByID.yml | 4 +- .../queries/tasks/ForwardPaginate.yml | 4 +- .../testdata/queries/tasks/Multiple.yml | 4 +- .../queries/tasks/OrderByPaginate.yml | 4 +- .../testdata/queries/tasks/Singular.yml | 4 +- tavern/internal/www/schema.graphql | 529 +- tavern/test_data.go | 5 +- 107 files changed, 23305 insertions(+), 7921 deletions(-) create mode 100644 tavern/internal/c2/api_report_file.go create mode 100644 tavern/internal/c2/api_report_file_test.go create mode 100644 tavern/internal/c2/c2pb/enum_host_platform.go create mode 100644 tavern/internal/c2/c2pb/enum_host_platform_test.go create mode 100644 tavern/internal/c2/c2pb/enum_process_status.go create mode 100644 tavern/internal/c2/c2pb/enum_process_status_test.go delete mode 100644 tavern/internal/c2/convert.go create mode 100644 tavern/internal/ent/hostfile.go create mode 100644 tavern/internal/ent/hostfile/hostfile.go create mode 100644 tavern/internal/ent/hostfile/where.go create mode 100644 tavern/internal/ent/hostfile_create.go create mode 100644 tavern/internal/ent/hostfile_delete.go create mode 100644 tavern/internal/ent/hostfile_query.go create mode 100644 tavern/internal/ent/hostfile_update.go create mode 100644 tavern/internal/ent/hostprocess.go rename tavern/internal/ent/{process/process.go => hostprocess/hostprocess.go} (61%) create mode 100644 tavern/internal/ent/hostprocess/where.go create mode 100644 tavern/internal/ent/hostprocess_create.go create mode 100644 tavern/internal/ent/hostprocess_delete.go create mode 100644 tavern/internal/ent/hostprocess_query.go create mode 100644 tavern/internal/ent/hostprocess_update.go delete mode 100644 tavern/internal/ent/process.go delete mode 100644 tavern/internal/ent/process/where.go delete mode 100644 tavern/internal/ent/process_create.go delete mode 100644 tavern/internal/ent/process_delete.go delete mode 100644 tavern/internal/ent/process_query.go delete mode 100644 tavern/internal/ent/process_update.go create mode 100644 tavern/internal/ent/schema/host_file.go create mode 100644 tavern/internal/ent/schema/host_file_test.go rename tavern/internal/ent/schema/{process.go => host_process.go} (53%) diff --git a/implants/lib/c2/src/c2.rs b/implants/lib/c2/src/c2.rs index c80ea3fe5..918fd6298 100644 --- a/implants/lib/c2/src/c2.rs +++ b/implants/lib/c2/src/c2.rs @@ -1,3 +1,26 @@ +/// Agent information to identify the type of beacon. +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Agent { + #[prost(string, tag = "1")] + pub identifier: ::prost::alloc::string::String, +} +/// Beacon information that is unique to the current running beacon. +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Beacon { + #[prost(string, tag = "1")] + pub identifier: ::prost::alloc::string::String, + #[prost(string, tag = "2")] + pub principal: ::prost::alloc::string::String, + #[prost(message, optional, tag = "3")] + pub host: ::core::option::Option, + #[prost(message, optional, tag = "4")] + pub agent: ::core::option::Option, + /// Duration until next callback, in seconds. + #[prost(uint64, tag = "5")] + pub interval: u64, +} /// Host information for the system a beacon is running on. #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -59,28 +82,103 @@ pub mod host { } } } -/// Agent information to identify the type of beacon. +/// Process running on the host system. #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] -pub struct Agent { - #[prost(string, tag = "1")] - pub identifier: ::prost::alloc::string::String, -} -/// Beacon information that is unique to the current running beacon. -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct Beacon { - #[prost(string, tag = "1")] - pub identifier: ::prost::alloc::string::String, - #[prost(string, tag = "2")] +pub struct Process { + #[prost(uint64, tag = "1")] + pub pid: u64, + #[prost(uint64, tag = "2")] + pub ppid: u64, + #[prost(string, tag = "3")] + pub name: ::prost::alloc::string::String, + #[prost(string, tag = "4")] pub principal: ::prost::alloc::string::String, - #[prost(message, optional, tag = "3")] - pub host: ::core::option::Option, - #[prost(message, optional, tag = "4")] - pub agent: ::core::option::Option, - /// Duration until next callback, in seconds. - #[prost(uint64, tag = "5")] - pub interval: u64, + #[prost(string, tag = "5")] + pub path: ::prost::alloc::string::String, + #[prost(string, tag = "6")] + pub cmd: ::prost::alloc::string::String, + #[prost(string, tag = "7")] + pub env: ::prost::alloc::string::String, + #[prost(string, tag = "8")] + pub cwd: ::prost::alloc::string::String, + #[prost(enumeration = "process::Status", tag = "9")] + pub status: i32, +} +/// Nested message and enum types in `Process`. +pub mod process { + #[derive( + Clone, + Copy, + Debug, + PartialEq, + Eq, + Hash, + PartialOrd, + Ord, + ::prost::Enumeration + )] + #[repr(i32)] + pub enum Status { + Unspecified = 0, + Unknown = 1, + Idle = 2, + Run = 3, + Sleep = 4, + Stop = 5, + Zombie = 6, + Tracing = 7, + Dead = 8, + WakeKill = 9, + Waking = 10, + Parked = 11, + LockBlocked = 12, + UninteruptibleDiskSleep = 13, + } + impl Status { + /// String value of the enum field names used in the ProtoBuf definition. + /// + /// The values are not transformed in any way and thus are considered stable + /// (if the ProtoBuf definition does not change) and safe for programmatic use. + pub fn as_str_name(&self) -> &'static str { + match self { + Status::Unspecified => "STATUS_UNSPECIFIED", + Status::Unknown => "STATUS_UNKNOWN", + Status::Idle => "STATUS_IDLE", + Status::Run => "STATUS_RUN", + Status::Sleep => "STATUS_SLEEP", + Status::Stop => "STATUS_STOP", + Status::Zombie => "STATUS_ZOMBIE", + Status::Tracing => "STATUS_TRACING", + Status::Dead => "STATUS_DEAD", + Status::WakeKill => "STATUS_WAKE_KILL", + Status::Waking => "STATUS_WAKING", + Status::Parked => "STATUS_PARKED", + Status::LockBlocked => "STATUS_LOCK_BLOCKED", + Status::UninteruptibleDiskSleep => "STATUS_UNINTERUPTIBLE_DISK_SLEEP", + } + } + /// Creates an enum from field names used in the ProtoBuf definition. + pub fn from_str_name(value: &str) -> ::core::option::Option { + match value { + "STATUS_UNSPECIFIED" => Some(Self::Unspecified), + "STATUS_UNKNOWN" => Some(Self::Unknown), + "STATUS_IDLE" => Some(Self::Idle), + "STATUS_RUN" => Some(Self::Run), + "STATUS_SLEEP" => Some(Self::Sleep), + "STATUS_STOP" => Some(Self::Stop), + "STATUS_ZOMBIE" => Some(Self::Zombie), + "STATUS_TRACING" => Some(Self::Tracing), + "STATUS_DEAD" => Some(Self::Dead), + "STATUS_WAKE_KILL" => Some(Self::WakeKill), + "STATUS_WAKING" => Some(Self::Waking), + "STATUS_PARKED" => Some(Self::Parked), + "STATUS_LOCK_BLOCKED" => Some(Self::LockBlocked), + "STATUS_UNINTERUPTIBLE_DISK_SLEEP" => Some(Self::UninteruptibleDiskSleep), + _ => None, + } + } + } } /// Task instructions for the beacon to execute. #[allow(clippy::derive_partial_eq_without_eq)] @@ -124,17 +222,6 @@ pub struct TaskOutput { #[prost(message, optional, tag = "5")] pub exec_finished_at: ::core::option::Option<::prost_types::Timestamp>, } -/// Process running on the system. -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct Process { - #[prost(uint64, tag = "1")] - pub pid: u64, - #[prost(string, tag = "2")] - pub name: ::prost::alloc::string::String, - #[prost(string, tag = "3")] - pub principal: ::prost::alloc::string::String, -} /// /// RPC Messages #[allow(clippy::derive_partial_eq_without_eq)] @@ -151,15 +238,6 @@ pub struct ClaimTasksResponse { } #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] -pub struct ReportTaskOutputRequest { - #[prost(message, optional, tag = "1")] - pub output: ::core::option::Option, -} -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct ReportTaskOutputResponse {} -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] pub struct DownloadFileRequest { #[prost(string, tag = "1")] pub name: ::prost::alloc::string::String, @@ -172,6 +250,29 @@ pub struct DownloadFileResponse { } #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] +pub struct ReportFileRequest { + #[prost(int64, tag = "1")] + pub task_id: i64, + #[prost(string, tag = "2")] + pub path: ::prost::alloc::string::String, + #[prost(string, tag = "3")] + pub owner: ::prost::alloc::string::String, + #[prost(string, tag = "4")] + pub group: ::prost::alloc::string::String, + #[prost(string, tag = "5")] + pub permissions: ::prost::alloc::string::String, + #[prost(int64, tag = "6")] + pub size: i64, + #[prost(string, tag = "7")] + pub sha3_256_hash: ::prost::alloc::string::String, + #[prost(bytes = "vec", tag = "8")] + pub chunk: ::prost::alloc::vec::Vec, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ReportFileResponse {} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] pub struct ReportProcessListRequest { #[prost(message, repeated, tag = "1")] pub list: ::prost::alloc::vec::Vec, @@ -181,6 +282,15 @@ pub struct ReportProcessListRequest { #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct ReportProcessListResponse {} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ReportTaskOutputRequest { + #[prost(message, optional, tag = "1")] + pub output: ::core::option::Option, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ReportTaskOutputResponse {} /// Generated client implementations. pub mod c2_client { #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)] @@ -266,6 +376,8 @@ pub mod c2_client { self.inner = self.inner.max_encoding_message_size(limit); self } + /// + /// Contact the server for new tasks to execute. pub async fn claim_tasks( &mut self, request: impl tonic::IntoRequest, @@ -288,11 +400,19 @@ pub mod c2_client { req.extensions_mut().insert(GrpcMethod::new("c2.C2", "ClaimTasks")); self.inner.unary(req, path, codec).await } - pub async fn report_task_output( + /// + /// Download a file from the server, returning one or more chunks of data. + /// The maximum size of these chunks is determined by the server. + /// The server should reply with two headers: + /// - "sha3-256-checksum": A SHA3-256 digest of the entire file contents. + /// - "file-size": The number of bytes contained by the file. + /// + /// If no associated file can be found, a NotFound status error is returned. + pub async fn download_file( &mut self, - request: impl tonic::IntoRequest, + request: impl tonic::IntoRequest, ) -> std::result::Result< - tonic::Response, + tonic::Response>, tonic::Status, > { self.inner @@ -305,10 +425,39 @@ pub mod c2_client { ) })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/c2.C2/ReportTaskOutput"); + let path = http::uri::PathAndQuery::from_static("/c2.C2/DownloadFile"); let mut req = request.into_request(); - req.extensions_mut().insert(GrpcMethod::new("c2.C2", "ReportTaskOutput")); - self.inner.unary(req, path, codec).await + req.extensions_mut().insert(GrpcMethod::new("c2.C2", "DownloadFile")); + self.inner.server_streaming(req, path, codec).await + } + /// + /// Report a file from the host to the server. + /// Providing content of the file is optional. If content is provided: + /// - Hash will automatically be calculated and the provided hash will be ignored. + /// - Size will automatically be calculated and the provided size will be ignored. + /// Content is provided as chunks, the size of which are up to the agent to define (based on memory constraints). + /// Any existing files at the provided path for the host are replaced. + pub async fn report_file( + &mut self, + request: impl tonic::IntoStreamingRequest, + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { + self.inner + .ready() + .await + .map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; + let codec = tonic::codec::ProstCodec::default(); + let path = http::uri::PathAndQuery::from_static("/c2.C2/ReportFile"); + let mut req = request.into_streaming_request(); + req.extensions_mut().insert(GrpcMethod::new("c2.C2", "ReportFile")); + self.inner.client_streaming(req, path, codec).await } /// /// Report the active list of running processes. This list will replace any previously reported @@ -336,18 +485,12 @@ pub mod c2_client { self.inner.unary(req, path, codec).await } /// - /// Download a file from the server, returning one or more chunks of data. - /// The maximum size of these chunks is determined by the server. - /// The server should reply with two headers: - /// - "sha3-256-checksum": A SHA3-256 digest of the entire file contents. - /// - "file-size": The number of bytes contained by the file. - /// - /// If no associated file can be found, a NotFound status error is returned. - pub async fn download_file( + /// Report execution output for a task. + pub async fn report_task_output( &mut self, - request: impl tonic::IntoRequest, + request: impl tonic::IntoRequest, ) -> std::result::Result< - tonic::Response>, + tonic::Response, tonic::Status, > { self.inner @@ -360,10 +503,10 @@ pub mod c2_client { ) })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/c2.C2/DownloadFile"); + let path = http::uri::PathAndQuery::from_static("/c2.C2/ReportTaskOutput"); let mut req = request.into_request(); - req.extensions_mut().insert(GrpcMethod::new("c2.C2", "DownloadFile")); - self.inner.server_streaming(req, path, codec).await + req.extensions_mut().insert(GrpcMethod::new("c2.C2", "ReportTaskOutput")); + self.inner.unary(req, path, codec).await } } } diff --git a/tavern/internal/c2/api_claim_tasks.go b/tavern/internal/c2/api_claim_tasks.go index 4aeb7087d..0a1c147fa 100644 --- a/tavern/internal/c2/api_claim_tasks.go +++ b/tavern/internal/c2/api_claim_tasks.go @@ -39,13 +39,12 @@ func (srv *Server) ClaimTasks(ctx context.Context, req *c2pb.ClaimTasksRequest) if req.Beacon.Agent.Identifier == "" { return nil, status.Errorf(codes.InvalidArgument, "must provide agent identifier") } - hostPlaform := convertHostPlatform(req.Beacon.Host.Platform) // Upsert the host hostID, err := srv.graph.Host.Create(). SetIdentifier(req.Beacon.Host.Identifier). SetName(req.Beacon.Host.Name). - SetPlatform(hostPlaform). + SetPlatform(req.Beacon.Host.Platform). SetPrimaryIP(req.Beacon.Host.PrimaryIp). SetLastSeenAt(now). OnConflict(). diff --git a/tavern/internal/c2/api_report_file.go b/tavern/internal/c2/api_report_file.go new file mode 100644 index 000000000..1b6439af1 --- /dev/null +++ b/tavern/internal/c2/api_report_file.go @@ -0,0 +1,141 @@ +package c2 + +import ( + "fmt" + "io" + + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + "realm.pub/tavern/internal/c2/c2pb" + "realm.pub/tavern/internal/ent" + "realm.pub/tavern/internal/ent/hostfile" +) + +func (srv *Server) ReportFile(stream c2pb.C2_ReportFileServer) error { + + var ( + taskID int64 + path string + owner string + group string + permissions string + size int + hash string + + content []byte + ) + + // Loop Input Stream + for { + req, err := stream.Recv() + if err == io.EOF { + break + } + if err != nil { + return status.Errorf(codes.Internal, "failed to receive report_file request: %v", err) + } + + // Collect args + if taskID == 0 { + taskID = req.GetTaskId() + } + if path == "" { + path = req.GetPath() + } + if owner == "" { + owner = req.GetOwner() + } + if group == "" { + group = req.GetGroup() + } + if permissions == "" { + permissions = req.GetPermissions() + } + if size == 0 { + size = int(req.GetSize()) + } + if hash == "" { + hash = req.GetSha3_256Hash() + } + content = append(content, req.GetChunk()...) + } + + // Input Validation + if taskID == 0 { + return status.Errorf(codes.InvalidArgument, "must provide valid task id") + } + if path == "" { + return status.Errorf(codes.InvalidArgument, "must provide valid path") + } + + // Load Task + task, err := srv.graph.Task.Get(stream.Context(), int(taskID)) + if ent.IsNotFound(err) { + return status.Errorf(codes.NotFound, "failed to find related task") + } + if err != nil { + return status.Errorf(codes.Internal, "failed to load task: %v", err) + } + + // Load Host + host, err := task.QueryBeacon().QueryHost().Only(stream.Context()) + if err != nil { + return status.Errorf(codes.Internal, "failed to load host") + } + + // Load Existing Files + existingFiles, err := host.QueryFiles(). + Where( + hostfile.Path(path), + ).All(stream.Context()) + if err != nil { + return status.Errorf(codes.Internal, "failed to load existing host files: %v", err) + } + + // Prepare Transaction + tx, err := srv.graph.Tx(stream.Context()) + if err != nil { + return status.Errorf(codes.Internal, "failed to initialize transaction: %v", err) + } + client := tx.Client() + + // Rollback transaction if we panic + defer func() { + if v := recover(); v != nil { + tx.Rollback() + panic(v) + } + }() + + // Create File + f, err := client.HostFile.Create(). + SetHostID(host.ID). + SetTaskID(task.ID). + SetPath(path). + SetOwner(owner). + SetGroup(group). + SetPermissions(permissions). + SetSize(size). + SetHash(hash). + SetContent(content). + Save(stream.Context()) + if err != nil { + return rollback(tx, fmt.Errorf("failed to create host file: %w", err)) + } + + // Clear Previous Files, Set New File + _, err = client.Host.UpdateOneID(host.ID). + AddFiles(f). + RemoveFiles(existingFiles...). + Save(stream.Context()) + if err != nil { + return rollback(tx, fmt.Errorf("failed to remove previous host files: %w", err)) + } + + // Commit Transaction + if err := tx.Commit(); err != nil { + return rollback(tx, fmt.Errorf("failed to commit transaction: %w", err)) + } + + return stream.SendAndClose(&c2pb.ReportFileResponse{}) +} diff --git a/tavern/internal/c2/api_report_file_test.go b/tavern/internal/c2/api_report_file_test.go new file mode 100644 index 000000000..130666784 --- /dev/null +++ b/tavern/internal/c2/api_report_file_test.go @@ -0,0 +1,251 @@ +package c2_test + +import ( + "context" + "testing" + + "github.com/google/go-cmp/cmp" + "github.com/google/go-cmp/cmp/cmpopts" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + "google.golang.org/protobuf/testing/protocmp" + "realm.pub/tavern/internal/c2/c2pb" + "realm.pub/tavern/internal/c2/c2test" + "realm.pub/tavern/internal/ent" +) + +func TestReportFile(t *testing.T) { + // Setup Dependencies + ctx := context.Background() + client, graph, close := c2test.New(t) + defer close() + + // Test Data + existingBeacons := []*ent.Beacon{ + c2test.NewRandomBeacon(ctx, graph), + c2test.NewRandomBeacon(ctx, graph), + } + existingHosts := []*ent.Host{ + existingBeacons[0].QueryHost().OnlyX(ctx), + existingBeacons[1].QueryHost().OnlyX(ctx), + } + existingTasks := []*ent.Task{ + c2test.NewRandomAssignedTask(ctx, graph, existingBeacons[0].Identifier), + c2test.NewRandomAssignedTask(ctx, graph, existingBeacons[0].Identifier), + c2test.NewRandomAssignedTask(ctx, graph, existingBeacons[0].Identifier), + c2test.NewRandomAssignedTask(ctx, graph, existingBeacons[1].Identifier), + } + existingHostFiles := []*ent.HostFile{ + graph.HostFile.Create(). + SetPath("/existing/path"). + SetOwner("test_user"). + SetHost(existingHosts[0]). + SetTask(existingTasks[0]). + SaveX(ctx), + graph.HostFile.Create(). + SetPath("/existing/path_2"). + SetOwner("test_user"). + SetHost(existingHosts[0]). + SetTask(existingTasks[1]). + SaveX(ctx), + graph.HostFile.Create(). + SetPath("/existing/path"). + SetOwner("test_user"). + SetHost(existingHosts[0]). + SetTask(existingTasks[1]). + SaveX(ctx), + } + existingHosts[0].Update(). + AddFiles( + existingHostFiles[1], + existingHostFiles[2], + ). + SaveX(ctx) + + // Test Cases + tests := []struct { + name string + reqs []*c2pb.ReportFileRequest + host *ent.Host + + wantCode codes.Code + wantResp *c2pb.ReportFileResponse + wantHostFiles []string + wantPath string + wantOwner string + wantGroup string + wantPermissions string + wantSize int + wantHash string + wantContent []byte + }{ + { + name: "MissingTaskID", + reqs: []*c2pb.ReportFileRequest{ + { + Path: "/test", + }, + }, + wantCode: codes.InvalidArgument, + }, + { + name: "MissingPath", + reqs: []*c2pb.ReportFileRequest{ + { + TaskId: 1234, + }, + }, + wantCode: codes.InvalidArgument, + }, + { + name: "NewFile_Single", + reqs: []*c2pb.ReportFileRequest{ + { + TaskId: int64(existingTasks[2].ID), + Path: "/new/file", + Owner: "root", + Group: "wheel", + Permissions: "0664", + Size: 999999, + Sha3_256Hash: "I_AM_IGNORED", + Chunk: []byte("death"), + }, + }, + host: existingHosts[0], + wantCode: codes.OK, + wantResp: &c2pb.ReportFileResponse{}, + wantHostFiles: []string{ + "/existing/path", + "/existing/path_2", + "/new/file", + }, + wantPath: "/new/file", + wantOwner: "root", + wantGroup: "wheel", + wantPermissions: "0664", + wantSize: 5, + wantHash: "da4b6723781fc3c92cf4e303532668f1352034a4250efa47f225a4243e33c89b", + wantContent: []byte("death"), + }, + { + name: "NewFile_MultiChunk", + reqs: []*c2pb.ReportFileRequest{ + { + TaskId: int64(existingTasks[2].ID), + Path: "/another/new/file", + Chunk: []byte("death"), + }, + { + Chunk: []byte("note"), + }, + }, + host: existingHosts[0], + wantCode: codes.OK, + wantResp: &c2pb.ReportFileResponse{}, + wantHostFiles: []string{ + "/existing/path_2", + "/existing/path", + "/new/file", + "/another/new/file", + }, + wantPath: "/another/new/file", + wantSize: 9, + wantHash: "a89332a42f5fbfcda0711dd7615aee897a9977f2b6adf12bb2db41a1b9f79a90", + wantContent: []byte("deathnote"), + }, + { + name: "Replace_File", + reqs: []*c2pb.ReportFileRequest{ + { + TaskId: int64(existingTasks[2].ID), + Path: "/another/new/file", + Chunk: []byte("replaced"), + }, + }, + host: existingHosts[0], + wantCode: codes.OK, + wantResp: &c2pb.ReportFileResponse{}, + wantHostFiles: []string{ + "/existing/path_2", + "/existing/path", + "/new/file", + "/another/new/file", + }, + wantPath: "/another/new/file", + wantSize: 8, + wantHash: "e0f00440c4d0ee2fd0b63b59402faf9a9d6b6c26a41c2353141328ae8df80832", + wantContent: []byte("replaced"), + }, + { + name: "No_Prexisting_Files", + reqs: []*c2pb.ReportFileRequest{ + { + TaskId: int64(existingTasks[3].ID), + Path: "/no/other/files", + Chunk: []byte("meow"), + }, + }, + host: existingHosts[1], + wantCode: codes.OK, + wantResp: &c2pb.ReportFileResponse{}, + wantHostFiles: []string{"/no/other/files"}, + wantPath: "/no/other/files", + wantSize: 4, + wantHash: "ecb287a944d62ba58b7e7310529172a9c121957c2edea47a948919c342ca9467", + wantContent: []byte("meow"), + }, + } + + // Run Tests + for _, tc := range tests { + t.Run(tc.name, func(t *testing.T) { + // gRPC + rClient, err := client.ReportFile(ctx) + require.NoError(t, err) + for _, req := range tc.reqs { + rClient.Send(req) + } + resp, err := rClient.CloseAndRecv() + + // Assert Response Code + require.Equal(t, tc.wantCode.String(), status.Code(err).String(), err) + if status.Code(err) != codes.OK { + // Do not continue if we expected error code + return + } + + // Assert Response + if diff := cmp.Diff(tc.wantResp, resp, protocmp.Transform()); diff != "" { + t.Errorf("invalid response (-want +got): %v", diff) + } + + // Load Files + testHost := graph.Host.GetX(ctx, tc.host.ID) + testHostFiles := testHost.QueryFiles().AllX(ctx) + testHostFilePaths := make([]string, 0, len(testHostFiles)) + var testFile *ent.HostFile + for _, f := range testHostFiles { + testHostFilePaths = append(testHostFilePaths, f.Path) + if f.Path == tc.wantPath { + testFile = f + } + } + require.NotNil(t, testFile, "%q file was not associated with host", tc.wantPath) + + // Assert Files + sorter := func(a, b string) bool { return a < b } + if diff := cmp.Diff(tc.wantHostFiles, testHostFilePaths, cmpopts.SortSlices(sorter)); diff != "" { + t.Errorf("invalid host file associations (-want +got): %v", diff) + } + assert.Equal(t, tc.wantPath, testFile.Path) + assert.Equal(t, tc.wantOwner, testFile.Owner) + assert.Equal(t, tc.wantGroup, testFile.Group) + assert.Equal(t, tc.wantPermissions, testFile.Permissions) + assert.Equal(t, tc.wantSize, testFile.Size) + assert.Equal(t, tc.wantHash, testFile.Hash) + }) + } + +} diff --git a/tavern/internal/c2/api_report_process_list.go b/tavern/internal/c2/api_report_process_list.go index 2a990d587..c062377df 100644 --- a/tavern/internal/c2/api_report_process_list.go +++ b/tavern/internal/c2/api_report_process_list.go @@ -50,18 +50,24 @@ func (srv *Server) ReportProcessList(ctx context.Context, req *c2pb.ReportProces }() // Create Processes - builders := make([]*ent.ProcessCreate, 0, len(req.List)) + builders := make([]*ent.HostProcessCreate, 0, len(req.List)) for _, proc := range req.List { builders = append(builders, - txGraph.Process.Create(). + txGraph.HostProcess.Create(). SetHostID(host.ID). SetTaskID(task.ID). SetPid(proc.Pid). + SetPpid(proc.Ppid). SetName(proc.Name). - SetPrincipal(proc.Principal), + SetPrincipal(proc.Principal). + SetPath(proc.Path). + SetCmd(proc.Cmd). + SetEnv(proc.Env). + SetCwd(proc.Cwd). + SetStatus(proc.Status), ) } - processList, err := txGraph.Process.CreateBulk(builders...).Save(ctx) + processList, err := txGraph.HostProcess.CreateBulk(builders...).Save(ctx) if err != nil { return nil, rollback(tx, fmt.Errorf("failed to create process list: %w", err)) } diff --git a/tavern/internal/c2/c2.proto b/tavern/internal/c2/c2.proto index 2306a49c9..86c19c7d2 100644 --- a/tavern/internal/c2/c2.proto +++ b/tavern/internal/c2/c2.proto @@ -11,6 +11,20 @@ import "google/protobuf/timestamp.proto"; * Messages */ +// Agent information to identify the type of beacon. +message Agent { + string identifier = 1; +} + +// Beacon information that is unique to the current running beacon. +message Beacon { + string identifier = 1; + string principal = 2; + Host host = 3; + Agent agent = 4; + uint64 interval = 5; // Duration until next callback, in seconds. +} + // Host information for the system a beacon is running on. message Host { string identifier = 1; @@ -28,19 +42,37 @@ message Host { string primary_ip = 4; } -// Agent information to identify the type of beacon. -message Agent { - string identifier = 1; +// Process running on the host system. +message Process { + uint64 pid = 1; + uint64 ppid = 2; + string name = 3; + string principal = 4; + + string path = 5; + string cmd = 6; + string env = 7; + string cwd = 8; + + enum Status { + STATUS_UNSPECIFIED = 0; + STATUS_UNKNOWN = 1; + STATUS_IDLE = 2; + STATUS_RUN = 3; + STATUS_SLEEP = 4; + STATUS_STOP = 5; + STATUS_ZOMBIE = 6; + STATUS_TRACING = 7; + STATUS_DEAD = 8; + STATUS_WAKE_KILL = 9; + STATUS_WAKING = 10; + STATUS_PARKED = 11; + STATUS_LOCK_BLOCKED = 12; + STATUS_UNINTERUPTIBLE_DISK_SLEEP = 13; + } + Status status = 9; } -// Beacon information that is unique to the current running beacon. -message Beacon { - string identifier = 1; - string principal = 2; - Host host = 3; - Agent agent = 4; - uint64 interval = 5; // Duration until next callback, in seconds. -} // Task instructions for the beacon to execute. message Task { @@ -69,12 +101,6 @@ message TaskOutput { google.protobuf.Timestamp exec_finished_at = 5; } -// Process running on the system. -message Process { - uint64 pid = 1; - string name = 2; - string principal = 3; -} /* * RPC Messages @@ -82,45 +108,51 @@ message Process { message ClaimTasksRequest { Beacon beacon = 1; } - message ClaimTasksResponse { repeated Task tasks = 1; } -message ReportTaskOutputRequest { - TaskOutput output = 1; -} - -message ReportTaskOutputResponse {} - message DownloadFileRequest { string name = 1; } - message DownloadFileResponse { bytes chunk = 1; } +message ReportFileRequest { + int64 task_id = 1; + string path = 2; + string owner = 3; + string group = 4; + string permissions = 5; + int64 size = 6; + string sha3_256_hash = 7; + + bytes chunk = 8; +} +message ReportFileResponse {} + message ReportProcessListRequest { repeated Process list = 1; int64 task_id = 2; } - message ReportProcessListResponse {} +message ReportTaskOutputRequest { + TaskOutput output = 1; +} + +message ReportTaskOutputResponse {} + /* * Service */ service C2 { - rpc ClaimTasks(ClaimTasksRequest) returns (ClaimTasksResponse) {} - rpc ReportTaskOutput(ReportTaskOutputRequest) returns (ReportTaskOutputResponse) {} - /* - * Report the active list of running processes. This list will replace any previously reported - * lists for the same host. + * Contact the server for new tasks to execute. */ - rpc ReportProcessList(ReportProcessListRequest) returns (ReportProcessListResponse); + rpc ClaimTasks(ClaimTasksRequest) returns (ClaimTasksResponse) {} /* * Download a file from the server, returning one or more chunks of data. @@ -131,5 +163,29 @@ service C2 { * * If no associated file can be found, a NotFound status error is returned. */ - rpc DownloadFile(DownloadFileRequest) returns (stream DownloadFileResponse); + rpc DownloadFile(DownloadFileRequest) returns (stream DownloadFileResponse); + + /* + * Report a file from the host to the server. + * Providing content of the file is optional. If content is provided: + * - Hash will automatically be calculated and the provided hash will be ignored. + * - Size will automatically be calculated and the provided size will be ignored. + * Content is provided as chunks, the size of which are up to the agent to define (based on memory constraints). + * Any existing files at the provided path for the host are replaced. + */ + rpc ReportFile(stream ReportFileRequest) returns (ReportFileResponse); + + /* + * Report the active list of running processes. This list will replace any previously reported + * lists for the same host. + */ + rpc ReportProcessList(ReportProcessListRequest) returns (ReportProcessListResponse); + + /* + * Report execution output for a task. + */ + rpc ReportTaskOutput(ReportTaskOutputRequest) returns (ReportTaskOutputResponse) {} + + + } diff --git a/tavern/internal/c2/c2pb/c2.pb.go b/tavern/internal/c2/c2pb/c2.pb.go index 052e99f89..179a732a8 100644 --- a/tavern/internal/c2/c2pb/c2.pb.go +++ b/tavern/internal/c2/c2pb/c2.pb.go @@ -73,79 +73,89 @@ func (x Host_Platform) Number() protoreflect.EnumNumber { // Deprecated: Use Host_Platform.Descriptor instead. func (Host_Platform) EnumDescriptor() ([]byte, []int) { - return file_c2_proto_rawDescGZIP(), []int{0, 0} + return file_c2_proto_rawDescGZIP(), []int{2, 0} } -// Host information for the system a beacon is running on. -type Host struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields +type Process_Status int32 - Identifier string `protobuf:"bytes,1,opt,name=identifier,proto3" json:"identifier,omitempty"` - Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` - Platform Host_Platform `protobuf:"varint,3,opt,name=platform,proto3,enum=c2.Host_Platform" json:"platform,omitempty"` - PrimaryIp string `protobuf:"bytes,4,opt,name=primary_ip,json=primaryIp,proto3" json:"primary_ip,omitempty"` -} +const ( + Process_STATUS_UNSPECIFIED Process_Status = 0 + Process_STATUS_UNKNOWN Process_Status = 1 + Process_STATUS_IDLE Process_Status = 2 + Process_STATUS_RUN Process_Status = 3 + Process_STATUS_SLEEP Process_Status = 4 + Process_STATUS_STOP Process_Status = 5 + Process_STATUS_ZOMBIE Process_Status = 6 + Process_STATUS_TRACING Process_Status = 7 + Process_STATUS_DEAD Process_Status = 8 + Process_STATUS_WAKE_KILL Process_Status = 9 + Process_STATUS_WAKING Process_Status = 10 + Process_STATUS_PARKED Process_Status = 11 + Process_STATUS_LOCK_BLOCKED Process_Status = 12 + Process_STATUS_UNINTERUPTIBLE_DISK_SLEEP Process_Status = 13 +) -func (x *Host) Reset() { - *x = Host{} - if protoimpl.UnsafeEnabled { - mi := &file_c2_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) +// Enum value maps for Process_Status. +var ( + Process_Status_name = map[int32]string{ + 0: "STATUS_UNSPECIFIED", + 1: "STATUS_UNKNOWN", + 2: "STATUS_IDLE", + 3: "STATUS_RUN", + 4: "STATUS_SLEEP", + 5: "STATUS_STOP", + 6: "STATUS_ZOMBIE", + 7: "STATUS_TRACING", + 8: "STATUS_DEAD", + 9: "STATUS_WAKE_KILL", + 10: "STATUS_WAKING", + 11: "STATUS_PARKED", + 12: "STATUS_LOCK_BLOCKED", + 13: "STATUS_UNINTERUPTIBLE_DISK_SLEEP", + } + Process_Status_value = map[string]int32{ + "STATUS_UNSPECIFIED": 0, + "STATUS_UNKNOWN": 1, + "STATUS_IDLE": 2, + "STATUS_RUN": 3, + "STATUS_SLEEP": 4, + "STATUS_STOP": 5, + "STATUS_ZOMBIE": 6, + "STATUS_TRACING": 7, + "STATUS_DEAD": 8, + "STATUS_WAKE_KILL": 9, + "STATUS_WAKING": 10, + "STATUS_PARKED": 11, + "STATUS_LOCK_BLOCKED": 12, + "STATUS_UNINTERUPTIBLE_DISK_SLEEP": 13, } -} - -func (x *Host) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Host) ProtoMessage() {} +) -func (x *Host) ProtoReflect() protoreflect.Message { - mi := &file_c2_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) +func (x Process_Status) Enum() *Process_Status { + p := new(Process_Status) + *p = x + return p } -// Deprecated: Use Host.ProtoReflect.Descriptor instead. -func (*Host) Descriptor() ([]byte, []int) { - return file_c2_proto_rawDescGZIP(), []int{0} +func (x Process_Status) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) } -func (x *Host) GetIdentifier() string { - if x != nil { - return x.Identifier - } - return "" +func (Process_Status) Descriptor() protoreflect.EnumDescriptor { + return file_c2_proto_enumTypes[1].Descriptor() } -func (x *Host) GetName() string { - if x != nil { - return x.Name - } - return "" +func (Process_Status) Type() protoreflect.EnumType { + return &file_c2_proto_enumTypes[1] } -func (x *Host) GetPlatform() Host_Platform { - if x != nil { - return x.Platform - } - return Host_PLATFORM_UNSPECIFIED +func (x Process_Status) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) } -func (x *Host) GetPrimaryIp() string { - if x != nil { - return x.PrimaryIp - } - return "" +// Deprecated: Use Process_Status.Descriptor instead. +func (Process_Status) EnumDescriptor() ([]byte, []int) { + return file_c2_proto_rawDescGZIP(), []int{3, 0} } // Agent information to identify the type of beacon. @@ -160,7 +170,7 @@ type Agent struct { func (x *Agent) Reset() { *x = Agent{} if protoimpl.UnsafeEnabled { - mi := &file_c2_proto_msgTypes[1] + mi := &file_c2_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -173,7 +183,7 @@ func (x *Agent) String() string { func (*Agent) ProtoMessage() {} func (x *Agent) ProtoReflect() protoreflect.Message { - mi := &file_c2_proto_msgTypes[1] + mi := &file_c2_proto_msgTypes[0] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -186,7 +196,7 @@ func (x *Agent) ProtoReflect() protoreflect.Message { // Deprecated: Use Agent.ProtoReflect.Descriptor instead. func (*Agent) Descriptor() ([]byte, []int) { - return file_c2_proto_rawDescGZIP(), []int{1} + return file_c2_proto_rawDescGZIP(), []int{0} } func (x *Agent) GetIdentifier() string { @@ -212,7 +222,7 @@ type Beacon struct { func (x *Beacon) Reset() { *x = Beacon{} if protoimpl.UnsafeEnabled { - mi := &file_c2_proto_msgTypes[2] + mi := &file_c2_proto_msgTypes[1] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -225,7 +235,7 @@ func (x *Beacon) String() string { func (*Beacon) ProtoMessage() {} func (x *Beacon) ProtoReflect() protoreflect.Message { - mi := &file_c2_proto_msgTypes[2] + mi := &file_c2_proto_msgTypes[1] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -238,7 +248,7 @@ func (x *Beacon) ProtoReflect() protoreflect.Message { // Deprecated: Use Beacon.ProtoReflect.Descriptor instead. func (*Beacon) Descriptor() ([]byte, []int) { - return file_c2_proto_rawDescGZIP(), []int{2} + return file_c2_proto_rawDescGZIP(), []int{1} } func (x *Beacon) GetIdentifier() string { @@ -276,6 +286,190 @@ func (x *Beacon) GetInterval() uint64 { return 0 } +// Host information for the system a beacon is running on. +type Host struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Identifier string `protobuf:"bytes,1,opt,name=identifier,proto3" json:"identifier,omitempty"` + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` + Platform Host_Platform `protobuf:"varint,3,opt,name=platform,proto3,enum=c2.Host_Platform" json:"platform,omitempty"` + PrimaryIp string `protobuf:"bytes,4,opt,name=primary_ip,json=primaryIp,proto3" json:"primary_ip,omitempty"` +} + +func (x *Host) Reset() { + *x = Host{} + if protoimpl.UnsafeEnabled { + mi := &file_c2_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Host) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Host) ProtoMessage() {} + +func (x *Host) ProtoReflect() protoreflect.Message { + mi := &file_c2_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Host.ProtoReflect.Descriptor instead. +func (*Host) Descriptor() ([]byte, []int) { + return file_c2_proto_rawDescGZIP(), []int{2} +} + +func (x *Host) GetIdentifier() string { + if x != nil { + return x.Identifier + } + return "" +} + +func (x *Host) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *Host) GetPlatform() Host_Platform { + if x != nil { + return x.Platform + } + return Host_PLATFORM_UNSPECIFIED +} + +func (x *Host) GetPrimaryIp() string { + if x != nil { + return x.PrimaryIp + } + return "" +} + +// Process running on the host system. +type Process struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Pid uint64 `protobuf:"varint,1,opt,name=pid,proto3" json:"pid,omitempty"` + Ppid uint64 `protobuf:"varint,2,opt,name=ppid,proto3" json:"ppid,omitempty"` + Name string `protobuf:"bytes,3,opt,name=name,proto3" json:"name,omitempty"` + Principal string `protobuf:"bytes,4,opt,name=principal,proto3" json:"principal,omitempty"` + Path string `protobuf:"bytes,5,opt,name=path,proto3" json:"path,omitempty"` + Cmd string `protobuf:"bytes,6,opt,name=cmd,proto3" json:"cmd,omitempty"` + Env string `protobuf:"bytes,7,opt,name=env,proto3" json:"env,omitempty"` + Cwd string `protobuf:"bytes,8,opt,name=cwd,proto3" json:"cwd,omitempty"` + Status Process_Status `protobuf:"varint,9,opt,name=status,proto3,enum=c2.Process_Status" json:"status,omitempty"` +} + +func (x *Process) Reset() { + *x = Process{} + if protoimpl.UnsafeEnabled { + mi := &file_c2_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Process) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Process) ProtoMessage() {} + +func (x *Process) ProtoReflect() protoreflect.Message { + mi := &file_c2_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Process.ProtoReflect.Descriptor instead. +func (*Process) Descriptor() ([]byte, []int) { + return file_c2_proto_rawDescGZIP(), []int{3} +} + +func (x *Process) GetPid() uint64 { + if x != nil { + return x.Pid + } + return 0 +} + +func (x *Process) GetPpid() uint64 { + if x != nil { + return x.Ppid + } + return 0 +} + +func (x *Process) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *Process) GetPrincipal() string { + if x != nil { + return x.Principal + } + return "" +} + +func (x *Process) GetPath() string { + if x != nil { + return x.Path + } + return "" +} + +func (x *Process) GetCmd() string { + if x != nil { + return x.Cmd + } + return "" +} + +func (x *Process) GetEnv() string { + if x != nil { + return x.Env + } + return "" +} + +func (x *Process) GetCwd() string { + if x != nil { + return x.Cwd + } + return "" +} + +func (x *Process) GetStatus() Process_Status { + if x != nil { + return x.Status + } + return Process_STATUS_UNSPECIFIED +} + // Task instructions for the beacon to execute. type Task struct { state protoimpl.MessageState @@ -292,7 +486,7 @@ type Task struct { func (x *Task) Reset() { *x = Task{} if protoimpl.UnsafeEnabled { - mi := &file_c2_proto_msgTypes[3] + mi := &file_c2_proto_msgTypes[4] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -305,7 +499,7 @@ func (x *Task) String() string { func (*Task) ProtoMessage() {} func (x *Task) ProtoReflect() protoreflect.Message { - mi := &file_c2_proto_msgTypes[3] + mi := &file_c2_proto_msgTypes[4] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -318,7 +512,7 @@ func (x *Task) ProtoReflect() protoreflect.Message { // Deprecated: Use Task.ProtoReflect.Descriptor instead. func (*Task) Descriptor() ([]byte, []int) { - return file_c2_proto_rawDescGZIP(), []int{3} + return file_c2_proto_rawDescGZIP(), []int{4} } func (x *Task) GetId() int64 { @@ -368,7 +562,7 @@ type TaskError struct { func (x *TaskError) Reset() { *x = TaskError{} if protoimpl.UnsafeEnabled { - mi := &file_c2_proto_msgTypes[4] + mi := &file_c2_proto_msgTypes[5] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -381,7 +575,7 @@ func (x *TaskError) String() string { func (*TaskError) ProtoMessage() {} func (x *TaskError) ProtoReflect() protoreflect.Message { - mi := &file_c2_proto_msgTypes[4] + mi := &file_c2_proto_msgTypes[5] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -394,7 +588,7 @@ func (x *TaskError) ProtoReflect() protoreflect.Message { // Deprecated: Use TaskError.ProtoReflect.Descriptor instead. func (*TaskError) Descriptor() ([]byte, []int) { - return file_c2_proto_rawDescGZIP(), []int{4} + return file_c2_proto_rawDescGZIP(), []int{5} } func (x *TaskError) GetMsg() string { @@ -422,7 +616,7 @@ type TaskOutput struct { func (x *TaskOutput) Reset() { *x = TaskOutput{} if protoimpl.UnsafeEnabled { - mi := &file_c2_proto_msgTypes[5] + mi := &file_c2_proto_msgTypes[6] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -435,7 +629,7 @@ func (x *TaskOutput) String() string { func (*TaskOutput) ProtoMessage() {} func (x *TaskOutput) ProtoReflect() protoreflect.Message { - mi := &file_c2_proto_msgTypes[5] + mi := &file_c2_proto_msgTypes[6] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -448,7 +642,7 @@ func (x *TaskOutput) ProtoReflect() protoreflect.Message { // Deprecated: Use TaskOutput.ProtoReflect.Descriptor instead. func (*TaskOutput) Descriptor() ([]byte, []int) { - return file_c2_proto_rawDescGZIP(), []int{5} + return file_c2_proto_rawDescGZIP(), []int{6} } func (x *TaskOutput) GetId() int64 { @@ -460,94 +654,30 @@ func (x *TaskOutput) GetId() int64 { func (x *TaskOutput) GetOutput() string { if x != nil { - return x.Output - } - return "" -} - -func (x *TaskOutput) GetError() *TaskError { - if x != nil { - return x.Error - } - return nil -} - -func (x *TaskOutput) GetExecStartedAt() *timestamp.Timestamp { - if x != nil { - return x.ExecStartedAt - } - return nil -} - -func (x *TaskOutput) GetExecFinishedAt() *timestamp.Timestamp { - if x != nil { - return x.ExecFinishedAt - } - return nil -} - -// Process running on the system. -type Process struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Pid uint64 `protobuf:"varint,1,opt,name=pid,proto3" json:"pid,omitempty"` - Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` - Principal string `protobuf:"bytes,3,opt,name=principal,proto3" json:"principal,omitempty"` -} - -func (x *Process) Reset() { - *x = Process{} - if protoimpl.UnsafeEnabled { - mi := &file_c2_proto_msgTypes[6] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Process) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Process) ProtoMessage() {} - -func (x *Process) ProtoReflect() protoreflect.Message { - mi := &file_c2_proto_msgTypes[6] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Process.ProtoReflect.Descriptor instead. -func (*Process) Descriptor() ([]byte, []int) { - return file_c2_proto_rawDescGZIP(), []int{6} + return x.Output + } + return "" } -func (x *Process) GetPid() uint64 { +func (x *TaskOutput) GetError() *TaskError { if x != nil { - return x.Pid + return x.Error } - return 0 + return nil } -func (x *Process) GetName() string { +func (x *TaskOutput) GetExecStartedAt() *timestamp.Timestamp { if x != nil { - return x.Name + return x.ExecStartedAt } - return "" + return nil } -func (x *Process) GetPrincipal() string { +func (x *TaskOutput) GetExecFinishedAt() *timestamp.Timestamp { if x != nil { - return x.Principal + return x.ExecFinishedAt } - return "" + return nil } // RPC Messages @@ -645,16 +775,16 @@ func (x *ClaimTasksResponse) GetTasks() []*Task { return nil } -type ReportTaskOutputRequest struct { +type DownloadFileRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Output *TaskOutput `protobuf:"bytes,1,opt,name=output,proto3" json:"output,omitempty"` + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` } -func (x *ReportTaskOutputRequest) Reset() { - *x = ReportTaskOutputRequest{} +func (x *DownloadFileRequest) Reset() { + *x = DownloadFileRequest{} if protoimpl.UnsafeEnabled { mi := &file_c2_proto_msgTypes[9] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -662,13 +792,13 @@ func (x *ReportTaskOutputRequest) Reset() { } } -func (x *ReportTaskOutputRequest) String() string { +func (x *DownloadFileRequest) String() string { return protoimpl.X.MessageStringOf(x) } -func (*ReportTaskOutputRequest) ProtoMessage() {} +func (*DownloadFileRequest) ProtoMessage() {} -func (x *ReportTaskOutputRequest) ProtoReflect() protoreflect.Message { +func (x *DownloadFileRequest) ProtoReflect() protoreflect.Message { mi := &file_c2_proto_msgTypes[9] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -680,26 +810,28 @@ func (x *ReportTaskOutputRequest) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use ReportTaskOutputRequest.ProtoReflect.Descriptor instead. -func (*ReportTaskOutputRequest) Descriptor() ([]byte, []int) { +// Deprecated: Use DownloadFileRequest.ProtoReflect.Descriptor instead. +func (*DownloadFileRequest) Descriptor() ([]byte, []int) { return file_c2_proto_rawDescGZIP(), []int{9} } -func (x *ReportTaskOutputRequest) GetOutput() *TaskOutput { +func (x *DownloadFileRequest) GetName() string { if x != nil { - return x.Output + return x.Name } - return nil + return "" } -type ReportTaskOutputResponse struct { +type DownloadFileResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields + + Chunk []byte `protobuf:"bytes,1,opt,name=chunk,proto3" json:"chunk,omitempty"` } -func (x *ReportTaskOutputResponse) Reset() { - *x = ReportTaskOutputResponse{} +func (x *DownloadFileResponse) Reset() { + *x = DownloadFileResponse{} if protoimpl.UnsafeEnabled { mi := &file_c2_proto_msgTypes[10] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -707,13 +839,13 @@ func (x *ReportTaskOutputResponse) Reset() { } } -func (x *ReportTaskOutputResponse) String() string { +func (x *DownloadFileResponse) String() string { return protoimpl.X.MessageStringOf(x) } -func (*ReportTaskOutputResponse) ProtoMessage() {} +func (*DownloadFileResponse) ProtoMessage() {} -func (x *ReportTaskOutputResponse) ProtoReflect() protoreflect.Message { +func (x *DownloadFileResponse) ProtoReflect() protoreflect.Message { mi := &file_c2_proto_msgTypes[10] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -725,21 +857,35 @@ func (x *ReportTaskOutputResponse) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use ReportTaskOutputResponse.ProtoReflect.Descriptor instead. -func (*ReportTaskOutputResponse) Descriptor() ([]byte, []int) { +// Deprecated: Use DownloadFileResponse.ProtoReflect.Descriptor instead. +func (*DownloadFileResponse) Descriptor() ([]byte, []int) { return file_c2_proto_rawDescGZIP(), []int{10} } -type DownloadFileRequest struct { +func (x *DownloadFileResponse) GetChunk() []byte { + if x != nil { + return x.Chunk + } + return nil +} + +type ReportFileRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + TaskId int64 `protobuf:"varint,1,opt,name=task_id,json=taskId,proto3" json:"task_id,omitempty"` + Path string `protobuf:"bytes,2,opt,name=path,proto3" json:"path,omitempty"` + Owner string `protobuf:"bytes,3,opt,name=owner,proto3" json:"owner,omitempty"` + Group string `protobuf:"bytes,4,opt,name=group,proto3" json:"group,omitempty"` + Permissions string `protobuf:"bytes,5,opt,name=permissions,proto3" json:"permissions,omitempty"` + Size int64 `protobuf:"varint,6,opt,name=size,proto3" json:"size,omitempty"` + Sha3_256Hash string `protobuf:"bytes,7,opt,name=sha3_256_hash,json=sha3256Hash,proto3" json:"sha3_256_hash,omitempty"` + Chunk []byte `protobuf:"bytes,8,opt,name=chunk,proto3" json:"chunk,omitempty"` } -func (x *DownloadFileRequest) Reset() { - *x = DownloadFileRequest{} +func (x *ReportFileRequest) Reset() { + *x = ReportFileRequest{} if protoimpl.UnsafeEnabled { mi := &file_c2_proto_msgTypes[11] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -747,13 +893,13 @@ func (x *DownloadFileRequest) Reset() { } } -func (x *DownloadFileRequest) String() string { +func (x *ReportFileRequest) String() string { return protoimpl.X.MessageStringOf(x) } -func (*DownloadFileRequest) ProtoMessage() {} +func (*ReportFileRequest) ProtoMessage() {} -func (x *DownloadFileRequest) ProtoReflect() protoreflect.Message { +func (x *ReportFileRequest) ProtoReflect() protoreflect.Message { mi := &file_c2_proto_msgTypes[11] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -765,28 +911,75 @@ func (x *DownloadFileRequest) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use DownloadFileRequest.ProtoReflect.Descriptor instead. -func (*DownloadFileRequest) Descriptor() ([]byte, []int) { +// Deprecated: Use ReportFileRequest.ProtoReflect.Descriptor instead. +func (*ReportFileRequest) Descriptor() ([]byte, []int) { return file_c2_proto_rawDescGZIP(), []int{11} } -func (x *DownloadFileRequest) GetName() string { +func (x *ReportFileRequest) GetTaskId() int64 { if x != nil { - return x.Name + return x.TaskId + } + return 0 +} + +func (x *ReportFileRequest) GetPath() string { + if x != nil { + return x.Path } return "" } -type DownloadFileResponse struct { +func (x *ReportFileRequest) GetOwner() string { + if x != nil { + return x.Owner + } + return "" +} + +func (x *ReportFileRequest) GetGroup() string { + if x != nil { + return x.Group + } + return "" +} + +func (x *ReportFileRequest) GetPermissions() string { + if x != nil { + return x.Permissions + } + return "" +} + +func (x *ReportFileRequest) GetSize() int64 { + if x != nil { + return x.Size + } + return 0 +} + +func (x *ReportFileRequest) GetSha3_256Hash() string { + if x != nil { + return x.Sha3_256Hash + } + return "" +} + +func (x *ReportFileRequest) GetChunk() []byte { + if x != nil { + return x.Chunk + } + return nil +} + +type ReportFileResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - - Chunk []byte `protobuf:"bytes,1,opt,name=chunk,proto3" json:"chunk,omitempty"` } -func (x *DownloadFileResponse) Reset() { - *x = DownloadFileResponse{} +func (x *ReportFileResponse) Reset() { + *x = ReportFileResponse{} if protoimpl.UnsafeEnabled { mi := &file_c2_proto_msgTypes[12] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -794,13 +987,13 @@ func (x *DownloadFileResponse) Reset() { } } -func (x *DownloadFileResponse) String() string { +func (x *ReportFileResponse) String() string { return protoimpl.X.MessageStringOf(x) } -func (*DownloadFileResponse) ProtoMessage() {} +func (*ReportFileResponse) ProtoMessage() {} -func (x *DownloadFileResponse) ProtoReflect() protoreflect.Message { +func (x *ReportFileResponse) ProtoReflect() protoreflect.Message { mi := &file_c2_proto_msgTypes[12] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -812,18 +1005,11 @@ func (x *DownloadFileResponse) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use DownloadFileResponse.ProtoReflect.Descriptor instead. -func (*DownloadFileResponse) Descriptor() ([]byte, []int) { +// Deprecated: Use ReportFileResponse.ProtoReflect.Descriptor instead. +func (*ReportFileResponse) Descriptor() ([]byte, []int) { return file_c2_proto_rawDescGZIP(), []int{12} } -func (x *DownloadFileResponse) GetChunk() []byte { - if x != nil { - return x.Chunk - } - return nil -} - type ReportProcessListRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -917,125 +1103,257 @@ func (*ReportProcessListResponse) Descriptor() ([]byte, []int) { return file_c2_proto_rawDescGZIP(), []int{14} } +type ReportTaskOutputRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Output *TaskOutput `protobuf:"bytes,1,opt,name=output,proto3" json:"output,omitempty"` +} + +func (x *ReportTaskOutputRequest) Reset() { + *x = ReportTaskOutputRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_c2_proto_msgTypes[15] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ReportTaskOutputRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ReportTaskOutputRequest) ProtoMessage() {} + +func (x *ReportTaskOutputRequest) ProtoReflect() protoreflect.Message { + mi := &file_c2_proto_msgTypes[15] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ReportTaskOutputRequest.ProtoReflect.Descriptor instead. +func (*ReportTaskOutputRequest) Descriptor() ([]byte, []int) { + return file_c2_proto_rawDescGZIP(), []int{15} +} + +func (x *ReportTaskOutputRequest) GetOutput() *TaskOutput { + if x != nil { + return x.Output + } + return nil +} + +type ReportTaskOutputResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *ReportTaskOutputResponse) Reset() { + *x = ReportTaskOutputResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_c2_proto_msgTypes[16] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ReportTaskOutputResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ReportTaskOutputResponse) ProtoMessage() {} + +func (x *ReportTaskOutputResponse) ProtoReflect() protoreflect.Message { + mi := &file_c2_proto_msgTypes[16] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ReportTaskOutputResponse.ProtoReflect.Descriptor instead. +func (*ReportTaskOutputResponse) Descriptor() ([]byte, []int) { + return file_c2_proto_rawDescGZIP(), []int{16} +} + var File_c2_proto protoreflect.FileDescriptor var file_c2_proto_rawDesc = []byte{ 0x0a, 0x08, 0x63, 0x32, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x02, 0x63, 0x32, 0x1a, 0x1f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, - 0xfe, 0x01, 0x0a, 0x04, 0x48, 0x6f, 0x73, 0x74, 0x12, 0x1e, 0x0a, 0x0a, 0x69, 0x64, 0x65, 0x6e, + 0x27, 0x0a, 0x05, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x12, 0x1e, 0x0a, 0x0a, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x69, 0x64, - 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x2d, 0x0a, 0x08, - 0x70, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x11, - 0x2e, 0x63, 0x32, 0x2e, 0x48, 0x6f, 0x73, 0x74, 0x2e, 0x50, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, - 0x6d, 0x52, 0x08, 0x70, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x12, 0x1d, 0x0a, 0x0a, 0x70, - 0x72, 0x69, 0x6d, 0x61, 0x72, 0x79, 0x5f, 0x69, 0x70, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x09, 0x70, 0x72, 0x69, 0x6d, 0x61, 0x72, 0x79, 0x49, 0x70, 0x22, 0x74, 0x0a, 0x08, 0x50, 0x6c, - 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x12, 0x18, 0x0a, 0x14, 0x50, 0x4c, 0x41, 0x54, 0x46, 0x4f, - 0x52, 0x4d, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, - 0x12, 0x14, 0x0a, 0x10, 0x50, 0x4c, 0x41, 0x54, 0x46, 0x4f, 0x52, 0x4d, 0x5f, 0x57, 0x49, 0x4e, - 0x44, 0x4f, 0x57, 0x53, 0x10, 0x01, 0x12, 0x12, 0x0a, 0x0e, 0x50, 0x4c, 0x41, 0x54, 0x46, 0x4f, - 0x52, 0x4d, 0x5f, 0x4c, 0x49, 0x4e, 0x55, 0x58, 0x10, 0x02, 0x12, 0x12, 0x0a, 0x0e, 0x50, 0x4c, - 0x41, 0x54, 0x46, 0x4f, 0x52, 0x4d, 0x5f, 0x4d, 0x41, 0x43, 0x4f, 0x53, 0x10, 0x03, 0x12, 0x10, - 0x0a, 0x0c, 0x50, 0x4c, 0x41, 0x54, 0x46, 0x4f, 0x52, 0x4d, 0x5f, 0x42, 0x53, 0x44, 0x10, 0x04, - 0x22, 0x27, 0x0a, 0x05, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x12, 0x1e, 0x0a, 0x0a, 0x69, 0x64, 0x65, - 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x69, - 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x22, 0xa1, 0x01, 0x0a, 0x06, 0x42, 0x65, - 0x61, 0x63, 0x6f, 0x6e, 0x12, 0x1e, 0x0a, 0x0a, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, - 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, - 0x66, 0x69, 0x65, 0x72, 0x12, 0x1c, 0x0a, 0x09, 0x70, 0x72, 0x69, 0x6e, 0x63, 0x69, 0x70, 0x61, - 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x70, 0x72, 0x69, 0x6e, 0x63, 0x69, 0x70, - 0x61, 0x6c, 0x12, 0x1c, 0x0a, 0x04, 0x68, 0x6f, 0x73, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, - 0x32, 0x08, 0x2e, 0x63, 0x32, 0x2e, 0x48, 0x6f, 0x73, 0x74, 0x52, 0x04, 0x68, 0x6f, 0x73, 0x74, - 0x12, 0x1f, 0x0a, 0x05, 0x61, 0x67, 0x65, 0x6e, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, - 0x09, 0x2e, 0x63, 0x32, 0x2e, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x52, 0x05, 0x61, 0x67, 0x65, 0x6e, - 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x76, 0x61, 0x6c, 0x18, 0x05, 0x20, - 0x01, 0x28, 0x04, 0x52, 0x08, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x76, 0x61, 0x6c, 0x22, 0xe9, 0x01, - 0x0a, 0x04, 0x54, 0x61, 0x73, 0x6b, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x65, 0x6c, 0x64, 0x72, 0x69, 0x74, - 0x63, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x65, 0x6c, 0x64, 0x72, 0x69, 0x74, - 0x63, 0x68, 0x12, 0x38, 0x0a, 0x0a, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x73, - 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x63, 0x32, 0x2e, 0x54, 0x61, 0x73, 0x6b, - 0x2e, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, - 0x52, 0x0a, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x73, 0x12, 0x1d, 0x0a, 0x0a, - 0x66, 0x69, 0x6c, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x09, - 0x52, 0x09, 0x66, 0x69, 0x6c, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x12, 0x1d, 0x0a, 0x0a, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x09, 0x71, 0x75, 0x65, 0x73, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x1a, 0x3d, 0x0a, 0x0f, 0x50, 0x61, - 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, - 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, - 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, - 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x1d, 0x0a, 0x09, 0x54, 0x61, 0x73, - 0x6b, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x12, 0x10, 0x0a, 0x03, 0x6d, 0x73, 0x67, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x03, 0x6d, 0x73, 0x67, 0x22, 0xe3, 0x01, 0x0a, 0x0a, 0x54, 0x61, 0x73, - 0x6b, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x6f, 0x75, 0x74, 0x70, 0x75, - 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x6f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x12, - 0x23, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0d, - 0x2e, 0x63, 0x32, 0x2e, 0x54, 0x61, 0x73, 0x6b, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x52, 0x05, 0x65, - 0x72, 0x72, 0x6f, 0x72, 0x12, 0x42, 0x0a, 0x0f, 0x65, 0x78, 0x65, 0x63, 0x5f, 0x73, 0x74, 0x61, - 0x72, 0x74, 0x65, 0x64, 0x5f, 0x61, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, - 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, - 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0d, 0x65, 0x78, 0x65, 0x63, 0x53, - 0x74, 0x61, 0x72, 0x74, 0x65, 0x64, 0x41, 0x74, 0x12, 0x44, 0x0a, 0x10, 0x65, 0x78, 0x65, 0x63, - 0x5f, 0x66, 0x69, 0x6e, 0x69, 0x73, 0x68, 0x65, 0x64, 0x5f, 0x61, 0x74, 0x18, 0x05, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0e, - 0x65, 0x78, 0x65, 0x63, 0x46, 0x69, 0x6e, 0x69, 0x73, 0x68, 0x65, 0x64, 0x41, 0x74, 0x22, 0x4d, + 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x22, 0xa1, 0x01, 0x0a, 0x06, 0x42, 0x65, 0x61, + 0x63, 0x6f, 0x6e, 0x12, 0x1e, 0x0a, 0x0a, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, + 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, + 0x69, 0x65, 0x72, 0x12, 0x1c, 0x0a, 0x09, 0x70, 0x72, 0x69, 0x6e, 0x63, 0x69, 0x70, 0x61, 0x6c, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x70, 0x72, 0x69, 0x6e, 0x63, 0x69, 0x70, 0x61, + 0x6c, 0x12, 0x1c, 0x0a, 0x04, 0x68, 0x6f, 0x73, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x08, 0x2e, 0x63, 0x32, 0x2e, 0x48, 0x6f, 0x73, 0x74, 0x52, 0x04, 0x68, 0x6f, 0x73, 0x74, 0x12, + 0x1f, 0x0a, 0x05, 0x61, 0x67, 0x65, 0x6e, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x09, + 0x2e, 0x63, 0x32, 0x2e, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x52, 0x05, 0x61, 0x67, 0x65, 0x6e, 0x74, + 0x12, 0x1a, 0x0a, 0x08, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x76, 0x61, 0x6c, 0x18, 0x05, 0x20, 0x01, + 0x28, 0x04, 0x52, 0x08, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x76, 0x61, 0x6c, 0x22, 0xfe, 0x01, 0x0a, + 0x04, 0x48, 0x6f, 0x73, 0x74, 0x12, 0x1e, 0x0a, 0x0a, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, + 0x69, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x69, 0x64, 0x65, 0x6e, 0x74, + 0x69, 0x66, 0x69, 0x65, 0x72, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x2d, 0x0a, 0x08, 0x70, 0x6c, 0x61, + 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x11, 0x2e, 0x63, 0x32, + 0x2e, 0x48, 0x6f, 0x73, 0x74, 0x2e, 0x50, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x52, 0x08, + 0x70, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x12, 0x1d, 0x0a, 0x0a, 0x70, 0x72, 0x69, 0x6d, + 0x61, 0x72, 0x79, 0x5f, 0x69, 0x70, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x70, 0x72, + 0x69, 0x6d, 0x61, 0x72, 0x79, 0x49, 0x70, 0x22, 0x74, 0x0a, 0x08, 0x50, 0x6c, 0x61, 0x74, 0x66, + 0x6f, 0x72, 0x6d, 0x12, 0x18, 0x0a, 0x14, 0x50, 0x4c, 0x41, 0x54, 0x46, 0x4f, 0x52, 0x4d, 0x5f, + 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x14, 0x0a, + 0x10, 0x50, 0x4c, 0x41, 0x54, 0x46, 0x4f, 0x52, 0x4d, 0x5f, 0x57, 0x49, 0x4e, 0x44, 0x4f, 0x57, + 0x53, 0x10, 0x01, 0x12, 0x12, 0x0a, 0x0e, 0x50, 0x4c, 0x41, 0x54, 0x46, 0x4f, 0x52, 0x4d, 0x5f, + 0x4c, 0x49, 0x4e, 0x55, 0x58, 0x10, 0x02, 0x12, 0x12, 0x0a, 0x0e, 0x50, 0x4c, 0x41, 0x54, 0x46, + 0x4f, 0x52, 0x4d, 0x5f, 0x4d, 0x41, 0x43, 0x4f, 0x53, 0x10, 0x03, 0x12, 0x10, 0x0a, 0x0c, 0x50, + 0x4c, 0x41, 0x54, 0x46, 0x4f, 0x52, 0x4d, 0x5f, 0x42, 0x53, 0x44, 0x10, 0x04, 0x22, 0x85, 0x04, 0x0a, 0x07, 0x50, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x12, 0x10, 0x0a, 0x03, 0x70, 0x69, 0x64, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x03, 0x70, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, - 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, - 0x1c, 0x0a, 0x09, 0x70, 0x72, 0x69, 0x6e, 0x63, 0x69, 0x70, 0x61, 0x6c, 0x18, 0x03, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x09, 0x70, 0x72, 0x69, 0x6e, 0x63, 0x69, 0x70, 0x61, 0x6c, 0x22, 0x37, 0x0a, - 0x11, 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x54, 0x61, 0x73, 0x6b, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x12, 0x22, 0x0a, 0x06, 0x62, 0x65, 0x61, 0x63, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x0a, 0x2e, 0x63, 0x32, 0x2e, 0x42, 0x65, 0x61, 0x63, 0x6f, 0x6e, 0x52, 0x06, - 0x62, 0x65, 0x61, 0x63, 0x6f, 0x6e, 0x22, 0x34, 0x0a, 0x12, 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x54, - 0x61, 0x73, 0x6b, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1e, 0x0a, 0x05, - 0x74, 0x61, 0x73, 0x6b, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x08, 0x2e, 0x63, 0x32, - 0x2e, 0x54, 0x61, 0x73, 0x6b, 0x52, 0x05, 0x74, 0x61, 0x73, 0x6b, 0x73, 0x22, 0x41, 0x0a, 0x17, - 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x54, 0x61, 0x73, 0x6b, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x26, 0x0a, 0x06, 0x6f, 0x75, 0x74, 0x70, 0x75, - 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x63, 0x32, 0x2e, 0x54, 0x61, 0x73, - 0x6b, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x52, 0x06, 0x6f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x22, - 0x1a, 0x0a, 0x18, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x54, 0x61, 0x73, 0x6b, 0x4f, 0x75, 0x74, - 0x70, 0x75, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x29, 0x0a, 0x13, 0x44, - 0x6f, 0x77, 0x6e, 0x6c, 0x6f, 0x61, 0x64, 0x46, 0x69, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x2c, 0x0a, 0x14, 0x44, 0x6f, 0x77, 0x6e, 0x6c, 0x6f, - 0x61, 0x64, 0x46, 0x69, 0x6c, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x14, - 0x0a, 0x05, 0x63, 0x68, 0x75, 0x6e, 0x6b, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x63, - 0x68, 0x75, 0x6e, 0x6b, 0x22, 0x54, 0x0a, 0x18, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x50, 0x72, - 0x6f, 0x63, 0x65, 0x73, 0x73, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x12, 0x1f, 0x0a, 0x04, 0x6c, 0x69, 0x73, 0x74, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0b, - 0x2e, 0x63, 0x32, 0x2e, 0x50, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x52, 0x04, 0x6c, 0x69, 0x73, - 0x74, 0x12, 0x17, 0x0a, 0x07, 0x74, 0x61, 0x73, 0x6b, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x03, 0x52, 0x06, 0x74, 0x61, 0x73, 0x6b, 0x49, 0x64, 0x22, 0x1b, 0x0a, 0x19, 0x52, 0x65, - 0x70, 0x6f, 0x72, 0x74, 0x50, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x4c, 0x69, 0x73, 0x74, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, 0xab, 0x02, 0x0a, 0x02, 0x43, 0x32, 0x12, 0x3d, - 0x0a, 0x0a, 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x54, 0x61, 0x73, 0x6b, 0x73, 0x12, 0x15, 0x2e, 0x63, - 0x32, 0x2e, 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x54, 0x61, 0x73, 0x6b, 0x73, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x63, 0x32, 0x2e, 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x54, 0x61, - 0x73, 0x6b, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x4f, 0x0a, - 0x10, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x54, 0x61, 0x73, 0x6b, 0x4f, 0x75, 0x74, 0x70, 0x75, - 0x74, 0x12, 0x1b, 0x2e, 0x63, 0x32, 0x2e, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x54, 0x61, 0x73, - 0x6b, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1c, - 0x2e, 0x63, 0x32, 0x2e, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x54, 0x61, 0x73, 0x6b, 0x4f, 0x75, - 0x74, 0x70, 0x75, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x50, - 0x0a, 0x11, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x50, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x4c, - 0x69, 0x73, 0x74, 0x12, 0x1c, 0x2e, 0x63, 0x32, 0x2e, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x50, - 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x1a, 0x1d, 0x2e, 0x63, 0x32, 0x2e, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x50, 0x72, 0x6f, - 0x63, 0x65, 0x73, 0x73, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x12, 0x43, 0x0a, 0x0c, 0x44, 0x6f, 0x77, 0x6e, 0x6c, 0x6f, 0x61, 0x64, 0x46, 0x69, 0x6c, 0x65, - 0x12, 0x17, 0x2e, 0x63, 0x32, 0x2e, 0x44, 0x6f, 0x77, 0x6e, 0x6c, 0x6f, 0x61, 0x64, 0x46, 0x69, - 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e, 0x63, 0x32, 0x2e, 0x44, - 0x6f, 0x77, 0x6e, 0x6c, 0x6f, 0x61, 0x64, 0x46, 0x69, 0x6c, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x30, 0x01, 0x42, 0x2e, 0x5a, 0x2c, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, - 0x63, 0x6f, 0x6d, 0x2f, 0x6b, 0x63, 0x61, 0x72, 0x72, 0x65, 0x74, 0x74, 0x6f, 0x2f, 0x74, 0x61, - 0x76, 0x65, 0x72, 0x6e, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x63, 0x32, - 0x2f, 0x63, 0x32, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x03, 0x70, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x70, + 0x70, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x04, 0x70, 0x70, 0x69, 0x64, 0x12, + 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, + 0x61, 0x6d, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x70, 0x72, 0x69, 0x6e, 0x63, 0x69, 0x70, 0x61, 0x6c, + 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x70, 0x72, 0x69, 0x6e, 0x63, 0x69, 0x70, 0x61, + 0x6c, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x61, 0x74, 0x68, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x04, 0x70, 0x61, 0x74, 0x68, 0x12, 0x10, 0x0a, 0x03, 0x63, 0x6d, 0x64, 0x18, 0x06, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x03, 0x63, 0x6d, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x65, 0x6e, 0x76, 0x18, 0x07, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x65, 0x6e, 0x76, 0x12, 0x10, 0x0a, 0x03, 0x63, 0x77, 0x64, + 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x63, 0x77, 0x64, 0x12, 0x2a, 0x0a, 0x06, 0x73, + 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x09, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x12, 0x2e, 0x63, 0x32, + 0x2e, 0x50, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, + 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x22, 0xab, 0x02, 0x0a, 0x06, 0x53, 0x74, 0x61, 0x74, + 0x75, 0x73, 0x12, 0x16, 0x0a, 0x12, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x55, 0x4e, 0x53, + 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x12, 0x0a, 0x0e, 0x53, 0x54, + 0x41, 0x54, 0x55, 0x53, 0x5f, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x01, 0x12, 0x0f, + 0x0a, 0x0b, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x49, 0x44, 0x4c, 0x45, 0x10, 0x02, 0x12, + 0x0e, 0x0a, 0x0a, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x52, 0x55, 0x4e, 0x10, 0x03, 0x12, + 0x10, 0x0a, 0x0c, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x53, 0x4c, 0x45, 0x45, 0x50, 0x10, + 0x04, 0x12, 0x0f, 0x0a, 0x0b, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x53, 0x54, 0x4f, 0x50, + 0x10, 0x05, 0x12, 0x11, 0x0a, 0x0d, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x5a, 0x4f, 0x4d, + 0x42, 0x49, 0x45, 0x10, 0x06, 0x12, 0x12, 0x0a, 0x0e, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, + 0x54, 0x52, 0x41, 0x43, 0x49, 0x4e, 0x47, 0x10, 0x07, 0x12, 0x0f, 0x0a, 0x0b, 0x53, 0x54, 0x41, + 0x54, 0x55, 0x53, 0x5f, 0x44, 0x45, 0x41, 0x44, 0x10, 0x08, 0x12, 0x14, 0x0a, 0x10, 0x53, 0x54, + 0x41, 0x54, 0x55, 0x53, 0x5f, 0x57, 0x41, 0x4b, 0x45, 0x5f, 0x4b, 0x49, 0x4c, 0x4c, 0x10, 0x09, + 0x12, 0x11, 0x0a, 0x0d, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x57, 0x41, 0x4b, 0x49, 0x4e, + 0x47, 0x10, 0x0a, 0x12, 0x11, 0x0a, 0x0d, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x50, 0x41, + 0x52, 0x4b, 0x45, 0x44, 0x10, 0x0b, 0x12, 0x17, 0x0a, 0x13, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, + 0x5f, 0x4c, 0x4f, 0x43, 0x4b, 0x5f, 0x42, 0x4c, 0x4f, 0x43, 0x4b, 0x45, 0x44, 0x10, 0x0c, 0x12, + 0x24, 0x0a, 0x20, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x55, 0x4e, 0x49, 0x4e, 0x54, 0x45, + 0x52, 0x55, 0x50, 0x54, 0x49, 0x42, 0x4c, 0x45, 0x5f, 0x44, 0x49, 0x53, 0x4b, 0x5f, 0x53, 0x4c, + 0x45, 0x45, 0x50, 0x10, 0x0d, 0x22, 0xe9, 0x01, 0x0a, 0x04, 0x54, 0x61, 0x73, 0x6b, 0x12, 0x0e, + 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x1a, + 0x0a, 0x08, 0x65, 0x6c, 0x64, 0x72, 0x69, 0x74, 0x63, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x08, 0x65, 0x6c, 0x64, 0x72, 0x69, 0x74, 0x63, 0x68, 0x12, 0x38, 0x0a, 0x0a, 0x70, 0x61, + 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x18, + 0x2e, 0x63, 0x32, 0x2e, 0x54, 0x61, 0x73, 0x6b, 0x2e, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, + 0x65, 0x72, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x0a, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x65, + 0x74, 0x65, 0x72, 0x73, 0x12, 0x1d, 0x0a, 0x0a, 0x66, 0x69, 0x6c, 0x65, 0x5f, 0x6e, 0x61, 0x6d, + 0x65, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x09, 0x52, 0x09, 0x66, 0x69, 0x6c, 0x65, 0x4e, 0x61, + 0x6d, 0x65, 0x73, 0x12, 0x1d, 0x0a, 0x0a, 0x71, 0x75, 0x65, 0x73, 0x74, 0x5f, 0x6e, 0x61, 0x6d, + 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x71, 0x75, 0x65, 0x73, 0x74, 0x4e, 0x61, + 0x6d, 0x65, 0x1a, 0x3d, 0x0a, 0x0f, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x73, + 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, + 0x01, 0x22, 0x1d, 0x0a, 0x09, 0x54, 0x61, 0x73, 0x6b, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x12, 0x10, + 0x0a, 0x03, 0x6d, 0x73, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6d, 0x73, 0x67, + 0x22, 0xe3, 0x01, 0x0a, 0x0a, 0x54, 0x61, 0x73, 0x6b, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x12, + 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x12, + 0x16, 0x0a, 0x06, 0x6f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x06, 0x6f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x12, 0x23, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, + 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x63, 0x32, 0x2e, 0x54, 0x61, 0x73, 0x6b, + 0x45, 0x72, 0x72, 0x6f, 0x72, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x12, 0x42, 0x0a, 0x0f, + 0x65, 0x78, 0x65, 0x63, 0x5f, 0x73, 0x74, 0x61, 0x72, 0x74, 0x65, 0x64, 0x5f, 0x61, 0x74, 0x18, + 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, + 0x70, 0x52, 0x0d, 0x65, 0x78, 0x65, 0x63, 0x53, 0x74, 0x61, 0x72, 0x74, 0x65, 0x64, 0x41, 0x74, + 0x12, 0x44, 0x0a, 0x10, 0x65, 0x78, 0x65, 0x63, 0x5f, 0x66, 0x69, 0x6e, 0x69, 0x73, 0x68, 0x65, + 0x64, 0x5f, 0x61, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, + 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, + 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0e, 0x65, 0x78, 0x65, 0x63, 0x46, 0x69, 0x6e, 0x69, + 0x73, 0x68, 0x65, 0x64, 0x41, 0x74, 0x22, 0x37, 0x0a, 0x11, 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x54, + 0x61, 0x73, 0x6b, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x22, 0x0a, 0x06, 0x62, + 0x65, 0x61, 0x63, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0a, 0x2e, 0x63, 0x32, + 0x2e, 0x42, 0x65, 0x61, 0x63, 0x6f, 0x6e, 0x52, 0x06, 0x62, 0x65, 0x61, 0x63, 0x6f, 0x6e, 0x22, + 0x34, 0x0a, 0x12, 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x54, 0x61, 0x73, 0x6b, 0x73, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1e, 0x0a, 0x05, 0x74, 0x61, 0x73, 0x6b, 0x73, 0x18, 0x01, + 0x20, 0x03, 0x28, 0x0b, 0x32, 0x08, 0x2e, 0x63, 0x32, 0x2e, 0x54, 0x61, 0x73, 0x6b, 0x52, 0x05, + 0x74, 0x61, 0x73, 0x6b, 0x73, 0x22, 0x29, 0x0a, 0x13, 0x44, 0x6f, 0x77, 0x6e, 0x6c, 0x6f, 0x61, + 0x64, 0x46, 0x69, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, + 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, + 0x22, 0x2c, 0x0a, 0x14, 0x44, 0x6f, 0x77, 0x6e, 0x6c, 0x6f, 0x61, 0x64, 0x46, 0x69, 0x6c, 0x65, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x63, 0x68, 0x75, 0x6e, + 0x6b, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x63, 0x68, 0x75, 0x6e, 0x6b, 0x22, 0xdc, + 0x01, 0x0a, 0x11, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x46, 0x69, 0x6c, 0x65, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x12, 0x17, 0x0a, 0x07, 0x74, 0x61, 0x73, 0x6b, 0x5f, 0x69, 0x64, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x74, 0x61, 0x73, 0x6b, 0x49, 0x64, 0x12, 0x12, 0x0a, + 0x04, 0x70, 0x61, 0x74, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x70, 0x61, 0x74, + 0x68, 0x12, 0x14, 0x0a, 0x05, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x05, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x12, 0x14, 0x0a, 0x05, 0x67, 0x72, 0x6f, 0x75, 0x70, + 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x12, 0x20, 0x0a, + 0x0b, 0x70, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x05, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x0b, 0x70, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x12, + 0x12, 0x0a, 0x04, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x03, 0x52, 0x04, 0x73, + 0x69, 0x7a, 0x65, 0x12, 0x22, 0x0a, 0x0d, 0x73, 0x68, 0x61, 0x33, 0x5f, 0x32, 0x35, 0x36, 0x5f, + 0x68, 0x61, 0x73, 0x68, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x73, 0x68, 0x61, 0x33, + 0x32, 0x35, 0x36, 0x48, 0x61, 0x73, 0x68, 0x12, 0x14, 0x0a, 0x05, 0x63, 0x68, 0x75, 0x6e, 0x6b, + 0x18, 0x08, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x63, 0x68, 0x75, 0x6e, 0x6b, 0x22, 0x14, 0x0a, + 0x12, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x46, 0x69, 0x6c, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x22, 0x54, 0x0a, 0x18, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x50, 0x72, 0x6f, + 0x63, 0x65, 0x73, 0x73, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, + 0x1f, 0x0a, 0x04, 0x6c, 0x69, 0x73, 0x74, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0b, 0x2e, + 0x63, 0x32, 0x2e, 0x50, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x52, 0x04, 0x6c, 0x69, 0x73, 0x74, + 0x12, 0x17, 0x0a, 0x07, 0x74, 0x61, 0x73, 0x6b, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x03, 0x52, 0x06, 0x74, 0x61, 0x73, 0x6b, 0x49, 0x64, 0x22, 0x1b, 0x0a, 0x19, 0x52, 0x65, 0x70, + 0x6f, 0x72, 0x74, 0x50, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x41, 0x0a, 0x17, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, + 0x54, 0x61, 0x73, 0x6b, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x12, 0x26, 0x0a, 0x06, 0x6f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x0e, 0x2e, 0x63, 0x32, 0x2e, 0x54, 0x61, 0x73, 0x6b, 0x4f, 0x75, 0x74, 0x70, 0x75, + 0x74, 0x52, 0x06, 0x6f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x22, 0x1a, 0x0a, 0x18, 0x52, 0x65, 0x70, + 0x6f, 0x72, 0x74, 0x54, 0x61, 0x73, 0x6b, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, 0xea, 0x02, 0x0a, 0x02, 0x43, 0x32, 0x12, 0x3d, 0x0a, 0x0a, + 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x54, 0x61, 0x73, 0x6b, 0x73, 0x12, 0x15, 0x2e, 0x63, 0x32, 0x2e, + 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x54, 0x61, 0x73, 0x6b, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x1a, 0x16, 0x2e, 0x63, 0x32, 0x2e, 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x54, 0x61, 0x73, 0x6b, + 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x43, 0x0a, 0x0c, 0x44, + 0x6f, 0x77, 0x6e, 0x6c, 0x6f, 0x61, 0x64, 0x46, 0x69, 0x6c, 0x65, 0x12, 0x17, 0x2e, 0x63, 0x32, + 0x2e, 0x44, 0x6f, 0x77, 0x6e, 0x6c, 0x6f, 0x61, 0x64, 0x46, 0x69, 0x6c, 0x65, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e, 0x63, 0x32, 0x2e, 0x44, 0x6f, 0x77, 0x6e, 0x6c, 0x6f, + 0x61, 0x64, 0x46, 0x69, 0x6c, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x30, 0x01, + 0x12, 0x3d, 0x0a, 0x0a, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x46, 0x69, 0x6c, 0x65, 0x12, 0x15, + 0x2e, 0x63, 0x32, 0x2e, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x46, 0x69, 0x6c, 0x65, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x63, 0x32, 0x2e, 0x52, 0x65, 0x70, 0x6f, 0x72, + 0x74, 0x46, 0x69, 0x6c, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x28, 0x01, 0x12, + 0x50, 0x0a, 0x11, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x50, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, + 0x4c, 0x69, 0x73, 0x74, 0x12, 0x1c, 0x2e, 0x63, 0x32, 0x2e, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, + 0x50, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x1a, 0x1d, 0x2e, 0x63, 0x32, 0x2e, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x50, 0x72, + 0x6f, 0x63, 0x65, 0x73, 0x73, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x12, 0x4f, 0x0a, 0x10, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x54, 0x61, 0x73, 0x6b, 0x4f, + 0x75, 0x74, 0x70, 0x75, 0x74, 0x12, 0x1b, 0x2e, 0x63, 0x32, 0x2e, 0x52, 0x65, 0x70, 0x6f, 0x72, + 0x74, 0x54, 0x61, 0x73, 0x6b, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x1a, 0x1c, 0x2e, 0x63, 0x32, 0x2e, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x54, 0x61, + 0x73, 0x6b, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x22, 0x00, 0x42, 0x2e, 0x5a, 0x2c, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, + 0x2f, 0x6b, 0x63, 0x61, 0x72, 0x72, 0x65, 0x74, 0x74, 0x6f, 0x2f, 0x74, 0x61, 0x76, 0x65, 0x72, + 0x6e, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x63, 0x32, 0x2f, 0x63, 0x32, + 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -1050,53 +1368,59 @@ func file_c2_proto_rawDescGZIP() []byte { return file_c2_proto_rawDescData } -var file_c2_proto_enumTypes = make([]protoimpl.EnumInfo, 1) -var file_c2_proto_msgTypes = make([]protoimpl.MessageInfo, 16) +var file_c2_proto_enumTypes = make([]protoimpl.EnumInfo, 2) +var file_c2_proto_msgTypes = make([]protoimpl.MessageInfo, 18) var file_c2_proto_goTypes = []interface{}{ (Host_Platform)(0), // 0: c2.Host.Platform - (*Host)(nil), // 1: c2.Host + (Process_Status)(0), // 1: c2.Process.Status (*Agent)(nil), // 2: c2.Agent (*Beacon)(nil), // 3: c2.Beacon - (*Task)(nil), // 4: c2.Task - (*TaskError)(nil), // 5: c2.TaskError - (*TaskOutput)(nil), // 6: c2.TaskOutput - (*Process)(nil), // 7: c2.Process - (*ClaimTasksRequest)(nil), // 8: c2.ClaimTasksRequest - (*ClaimTasksResponse)(nil), // 9: c2.ClaimTasksResponse - (*ReportTaskOutputRequest)(nil), // 10: c2.ReportTaskOutputRequest - (*ReportTaskOutputResponse)(nil), // 11: c2.ReportTaskOutputResponse - (*DownloadFileRequest)(nil), // 12: c2.DownloadFileRequest - (*DownloadFileResponse)(nil), // 13: c2.DownloadFileResponse - (*ReportProcessListRequest)(nil), // 14: c2.ReportProcessListRequest - (*ReportProcessListResponse)(nil), // 15: c2.ReportProcessListResponse - nil, // 16: c2.Task.ParametersEntry - (*timestamp.Timestamp)(nil), // 17: google.protobuf.Timestamp + (*Host)(nil), // 4: c2.Host + (*Process)(nil), // 5: c2.Process + (*Task)(nil), // 6: c2.Task + (*TaskError)(nil), // 7: c2.TaskError + (*TaskOutput)(nil), // 8: c2.TaskOutput + (*ClaimTasksRequest)(nil), // 9: c2.ClaimTasksRequest + (*ClaimTasksResponse)(nil), // 10: c2.ClaimTasksResponse + (*DownloadFileRequest)(nil), // 11: c2.DownloadFileRequest + (*DownloadFileResponse)(nil), // 12: c2.DownloadFileResponse + (*ReportFileRequest)(nil), // 13: c2.ReportFileRequest + (*ReportFileResponse)(nil), // 14: c2.ReportFileResponse + (*ReportProcessListRequest)(nil), // 15: c2.ReportProcessListRequest + (*ReportProcessListResponse)(nil), // 16: c2.ReportProcessListResponse + (*ReportTaskOutputRequest)(nil), // 17: c2.ReportTaskOutputRequest + (*ReportTaskOutputResponse)(nil), // 18: c2.ReportTaskOutputResponse + nil, // 19: c2.Task.ParametersEntry + (*timestamp.Timestamp)(nil), // 20: google.protobuf.Timestamp } var file_c2_proto_depIdxs = []int32{ - 0, // 0: c2.Host.platform:type_name -> c2.Host.Platform - 1, // 1: c2.Beacon.host:type_name -> c2.Host - 2, // 2: c2.Beacon.agent:type_name -> c2.Agent - 16, // 3: c2.Task.parameters:type_name -> c2.Task.ParametersEntry - 5, // 4: c2.TaskOutput.error:type_name -> c2.TaskError - 17, // 5: c2.TaskOutput.exec_started_at:type_name -> google.protobuf.Timestamp - 17, // 6: c2.TaskOutput.exec_finished_at:type_name -> google.protobuf.Timestamp - 3, // 7: c2.ClaimTasksRequest.beacon:type_name -> c2.Beacon - 4, // 8: c2.ClaimTasksResponse.tasks:type_name -> c2.Task - 6, // 9: c2.ReportTaskOutputRequest.output:type_name -> c2.TaskOutput - 7, // 10: c2.ReportProcessListRequest.list:type_name -> c2.Process - 8, // 11: c2.C2.ClaimTasks:input_type -> c2.ClaimTasksRequest - 10, // 12: c2.C2.ReportTaskOutput:input_type -> c2.ReportTaskOutputRequest - 14, // 13: c2.C2.ReportProcessList:input_type -> c2.ReportProcessListRequest - 12, // 14: c2.C2.DownloadFile:input_type -> c2.DownloadFileRequest - 9, // 15: c2.C2.ClaimTasks:output_type -> c2.ClaimTasksResponse - 11, // 16: c2.C2.ReportTaskOutput:output_type -> c2.ReportTaskOutputResponse - 15, // 17: c2.C2.ReportProcessList:output_type -> c2.ReportProcessListResponse - 13, // 18: c2.C2.DownloadFile:output_type -> c2.DownloadFileResponse - 15, // [15:19] is the sub-list for method output_type - 11, // [11:15] is the sub-list for method input_type - 11, // [11:11] is the sub-list for extension type_name - 11, // [11:11] is the sub-list for extension extendee - 0, // [0:11] is the sub-list for field type_name + 4, // 0: c2.Beacon.host:type_name -> c2.Host + 2, // 1: c2.Beacon.agent:type_name -> c2.Agent + 0, // 2: c2.Host.platform:type_name -> c2.Host.Platform + 1, // 3: c2.Process.status:type_name -> c2.Process.Status + 19, // 4: c2.Task.parameters:type_name -> c2.Task.ParametersEntry + 7, // 5: c2.TaskOutput.error:type_name -> c2.TaskError + 20, // 6: c2.TaskOutput.exec_started_at:type_name -> google.protobuf.Timestamp + 20, // 7: c2.TaskOutput.exec_finished_at:type_name -> google.protobuf.Timestamp + 3, // 8: c2.ClaimTasksRequest.beacon:type_name -> c2.Beacon + 6, // 9: c2.ClaimTasksResponse.tasks:type_name -> c2.Task + 5, // 10: c2.ReportProcessListRequest.list:type_name -> c2.Process + 8, // 11: c2.ReportTaskOutputRequest.output:type_name -> c2.TaskOutput + 9, // 12: c2.C2.ClaimTasks:input_type -> c2.ClaimTasksRequest + 11, // 13: c2.C2.DownloadFile:input_type -> c2.DownloadFileRequest + 13, // 14: c2.C2.ReportFile:input_type -> c2.ReportFileRequest + 15, // 15: c2.C2.ReportProcessList:input_type -> c2.ReportProcessListRequest + 17, // 16: c2.C2.ReportTaskOutput:input_type -> c2.ReportTaskOutputRequest + 10, // 17: c2.C2.ClaimTasks:output_type -> c2.ClaimTasksResponse + 12, // 18: c2.C2.DownloadFile:output_type -> c2.DownloadFileResponse + 14, // 19: c2.C2.ReportFile:output_type -> c2.ReportFileResponse + 16, // 20: c2.C2.ReportProcessList:output_type -> c2.ReportProcessListResponse + 18, // 21: c2.C2.ReportTaskOutput:output_type -> c2.ReportTaskOutputResponse + 17, // [17:22] is the sub-list for method output_type + 12, // [12:17] is the sub-list for method input_type + 12, // [12:12] is the sub-list for extension type_name + 12, // [12:12] is the sub-list for extension extendee + 0, // [0:12] is the sub-list for field type_name } func init() { file_c2_proto_init() } @@ -1106,7 +1430,7 @@ func file_c2_proto_init() { } if !protoimpl.UnsafeEnabled { file_c2_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Host); i { + switch v := v.(*Agent); i { case 0: return &v.state case 1: @@ -1118,7 +1442,7 @@ func file_c2_proto_init() { } } file_c2_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Agent); i { + switch v := v.(*Beacon); i { case 0: return &v.state case 1: @@ -1130,7 +1454,7 @@ func file_c2_proto_init() { } } file_c2_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Beacon); i { + switch v := v.(*Host); i { case 0: return &v.state case 1: @@ -1142,7 +1466,7 @@ func file_c2_proto_init() { } } file_c2_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Task); i { + switch v := v.(*Process); i { case 0: return &v.state case 1: @@ -1154,7 +1478,7 @@ func file_c2_proto_init() { } } file_c2_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*TaskError); i { + switch v := v.(*Task); i { case 0: return &v.state case 1: @@ -1166,7 +1490,7 @@ func file_c2_proto_init() { } } file_c2_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*TaskOutput); i { + switch v := v.(*TaskError); i { case 0: return &v.state case 1: @@ -1178,7 +1502,7 @@ func file_c2_proto_init() { } } file_c2_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Process); i { + switch v := v.(*TaskOutput); i { case 0: return &v.state case 1: @@ -1214,7 +1538,7 @@ func file_c2_proto_init() { } } file_c2_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ReportTaskOutputRequest); i { + switch v := v.(*DownloadFileRequest); i { case 0: return &v.state case 1: @@ -1226,7 +1550,7 @@ func file_c2_proto_init() { } } file_c2_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ReportTaskOutputResponse); i { + switch v := v.(*DownloadFileResponse); i { case 0: return &v.state case 1: @@ -1238,7 +1562,7 @@ func file_c2_proto_init() { } } file_c2_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*DownloadFileRequest); i { + switch v := v.(*ReportFileRequest); i { case 0: return &v.state case 1: @@ -1250,7 +1574,7 @@ func file_c2_proto_init() { } } file_c2_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*DownloadFileResponse); i { + switch v := v.(*ReportFileResponse); i { case 0: return &v.state case 1: @@ -1285,14 +1609,38 @@ func file_c2_proto_init() { return nil } } + file_c2_proto_msgTypes[15].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ReportTaskOutputRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_c2_proto_msgTypes[16].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ReportTaskOutputResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_c2_proto_rawDesc, - NumEnums: 1, - NumMessages: 16, + NumEnums: 2, + NumMessages: 18, NumExtensions: 0, NumServices: 1, }, diff --git a/tavern/internal/c2/c2pb/c2_grpc.pb.go b/tavern/internal/c2/c2pb/c2_grpc.pb.go index f7f22d65a..2595b7562 100644 --- a/tavern/internal/c2/c2pb/c2_grpc.pb.go +++ b/tavern/internal/c2/c2pb/c2_grpc.pb.go @@ -22,11 +22,8 @@ const _ = grpc.SupportPackageIsVersion7 // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. type C2Client interface { + // Contact the server for new tasks to execute. ClaimTasks(ctx context.Context, in *ClaimTasksRequest, opts ...grpc.CallOption) (*ClaimTasksResponse, error) - ReportTaskOutput(ctx context.Context, in *ReportTaskOutputRequest, opts ...grpc.CallOption) (*ReportTaskOutputResponse, error) - // Report the active list of running processes. This list will replace any previously reported - // lists for the same host. - ReportProcessList(ctx context.Context, in *ReportProcessListRequest, opts ...grpc.CallOption) (*ReportProcessListResponse, error) // Download a file from the server, returning one or more chunks of data. // The maximum size of these chunks is determined by the server. // The server should reply with two headers: @@ -35,6 +32,19 @@ type C2Client interface { // // If no associated file can be found, a NotFound status error is returned. DownloadFile(ctx context.Context, in *DownloadFileRequest, opts ...grpc.CallOption) (C2_DownloadFileClient, error) + // Report a file from the host to the server. + // Providing content of the file is optional. If content is provided: + // - Hash will automatically be calculated and the provided hash will be ignored. + // - Size will automatically be calculated and the provided size will be ignored. + // + // Content is provided as chunks, the size of which are up to the agent to define (based on memory constraints). + // Any existing files at the provided path for the host are replaced. + ReportFile(ctx context.Context, opts ...grpc.CallOption) (C2_ReportFileClient, error) + // Report the active list of running processes. This list will replace any previously reported + // lists for the same host. + ReportProcessList(ctx context.Context, in *ReportProcessListRequest, opts ...grpc.CallOption) (*ReportProcessListResponse, error) + // Report execution output for a task. + ReportTaskOutput(ctx context.Context, in *ReportTaskOutputRequest, opts ...grpc.CallOption) (*ReportTaskOutputResponse, error) } type c2Client struct { @@ -54,24 +64,6 @@ func (c *c2Client) ClaimTasks(ctx context.Context, in *ClaimTasksRequest, opts . return out, nil } -func (c *c2Client) ReportTaskOutput(ctx context.Context, in *ReportTaskOutputRequest, opts ...grpc.CallOption) (*ReportTaskOutputResponse, error) { - out := new(ReportTaskOutputResponse) - err := c.cc.Invoke(ctx, "/c2.C2/ReportTaskOutput", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *c2Client) ReportProcessList(ctx context.Context, in *ReportProcessListRequest, opts ...grpc.CallOption) (*ReportProcessListResponse, error) { - out := new(ReportProcessListResponse) - err := c.cc.Invoke(ctx, "/c2.C2/ReportProcessList", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - func (c *c2Client) DownloadFile(ctx context.Context, in *DownloadFileRequest, opts ...grpc.CallOption) (C2_DownloadFileClient, error) { stream, err := c.cc.NewStream(ctx, &C2_ServiceDesc.Streams[0], "/c2.C2/DownloadFile", opts...) if err != nil { @@ -104,15 +96,64 @@ func (x *c2DownloadFileClient) Recv() (*DownloadFileResponse, error) { return m, nil } +func (c *c2Client) ReportFile(ctx context.Context, opts ...grpc.CallOption) (C2_ReportFileClient, error) { + stream, err := c.cc.NewStream(ctx, &C2_ServiceDesc.Streams[1], "/c2.C2/ReportFile", opts...) + if err != nil { + return nil, err + } + x := &c2ReportFileClient{stream} + return x, nil +} + +type C2_ReportFileClient interface { + Send(*ReportFileRequest) error + CloseAndRecv() (*ReportFileResponse, error) + grpc.ClientStream +} + +type c2ReportFileClient struct { + grpc.ClientStream +} + +func (x *c2ReportFileClient) Send(m *ReportFileRequest) error { + return x.ClientStream.SendMsg(m) +} + +func (x *c2ReportFileClient) CloseAndRecv() (*ReportFileResponse, error) { + if err := x.ClientStream.CloseSend(); err != nil { + return nil, err + } + m := new(ReportFileResponse) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +func (c *c2Client) ReportProcessList(ctx context.Context, in *ReportProcessListRequest, opts ...grpc.CallOption) (*ReportProcessListResponse, error) { + out := new(ReportProcessListResponse) + err := c.cc.Invoke(ctx, "/c2.C2/ReportProcessList", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *c2Client) ReportTaskOutput(ctx context.Context, in *ReportTaskOutputRequest, opts ...grpc.CallOption) (*ReportTaskOutputResponse, error) { + out := new(ReportTaskOutputResponse) + err := c.cc.Invoke(ctx, "/c2.C2/ReportTaskOutput", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // C2Server is the server API for C2 service. // All implementations must embed UnimplementedC2Server // for forward compatibility type C2Server interface { + // Contact the server for new tasks to execute. ClaimTasks(context.Context, *ClaimTasksRequest) (*ClaimTasksResponse, error) - ReportTaskOutput(context.Context, *ReportTaskOutputRequest) (*ReportTaskOutputResponse, error) - // Report the active list of running processes. This list will replace any previously reported - // lists for the same host. - ReportProcessList(context.Context, *ReportProcessListRequest) (*ReportProcessListResponse, error) // Download a file from the server, returning one or more chunks of data. // The maximum size of these chunks is determined by the server. // The server should reply with two headers: @@ -121,6 +162,19 @@ type C2Server interface { // // If no associated file can be found, a NotFound status error is returned. DownloadFile(*DownloadFileRequest, C2_DownloadFileServer) error + // Report a file from the host to the server. + // Providing content of the file is optional. If content is provided: + // - Hash will automatically be calculated and the provided hash will be ignored. + // - Size will automatically be calculated and the provided size will be ignored. + // + // Content is provided as chunks, the size of which are up to the agent to define (based on memory constraints). + // Any existing files at the provided path for the host are replaced. + ReportFile(C2_ReportFileServer) error + // Report the active list of running processes. This list will replace any previously reported + // lists for the same host. + ReportProcessList(context.Context, *ReportProcessListRequest) (*ReportProcessListResponse, error) + // Report execution output for a task. + ReportTaskOutput(context.Context, *ReportTaskOutputRequest) (*ReportTaskOutputResponse, error) mustEmbedUnimplementedC2Server() } @@ -131,14 +185,17 @@ type UnimplementedC2Server struct { func (UnimplementedC2Server) ClaimTasks(context.Context, *ClaimTasksRequest) (*ClaimTasksResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method ClaimTasks not implemented") } -func (UnimplementedC2Server) ReportTaskOutput(context.Context, *ReportTaskOutputRequest) (*ReportTaskOutputResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method ReportTaskOutput not implemented") +func (UnimplementedC2Server) DownloadFile(*DownloadFileRequest, C2_DownloadFileServer) error { + return status.Errorf(codes.Unimplemented, "method DownloadFile not implemented") +} +func (UnimplementedC2Server) ReportFile(C2_ReportFileServer) error { + return status.Errorf(codes.Unimplemented, "method ReportFile not implemented") } func (UnimplementedC2Server) ReportProcessList(context.Context, *ReportProcessListRequest) (*ReportProcessListResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method ReportProcessList not implemented") } -func (UnimplementedC2Server) DownloadFile(*DownloadFileRequest, C2_DownloadFileServer) error { - return status.Errorf(codes.Unimplemented, "method DownloadFile not implemented") +func (UnimplementedC2Server) ReportTaskOutput(context.Context, *ReportTaskOutputRequest) (*ReportTaskOutputResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ReportTaskOutput not implemented") } func (UnimplementedC2Server) mustEmbedUnimplementedC2Server() {} @@ -171,63 +228,89 @@ func _C2_ClaimTasks_Handler(srv interface{}, ctx context.Context, dec func(inter return interceptor(ctx, in, info, handler) } -func _C2_ReportTaskOutput_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(ReportTaskOutputRequest) +func _C2_DownloadFile_Handler(srv interface{}, stream grpc.ServerStream) error { + m := new(DownloadFileRequest) + if err := stream.RecvMsg(m); err != nil { + return err + } + return srv.(C2Server).DownloadFile(m, &c2DownloadFileServer{stream}) +} + +type C2_DownloadFileServer interface { + Send(*DownloadFileResponse) error + grpc.ServerStream +} + +type c2DownloadFileServer struct { + grpc.ServerStream +} + +func (x *c2DownloadFileServer) Send(m *DownloadFileResponse) error { + return x.ServerStream.SendMsg(m) +} + +func _C2_ReportFile_Handler(srv interface{}, stream grpc.ServerStream) error { + return srv.(C2Server).ReportFile(&c2ReportFileServer{stream}) +} + +type C2_ReportFileServer interface { + SendAndClose(*ReportFileResponse) error + Recv() (*ReportFileRequest, error) + grpc.ServerStream +} + +type c2ReportFileServer struct { + grpc.ServerStream +} + +func (x *c2ReportFileServer) SendAndClose(m *ReportFileResponse) error { + return x.ServerStream.SendMsg(m) +} + +func (x *c2ReportFileServer) Recv() (*ReportFileRequest, error) { + m := new(ReportFileRequest) + if err := x.ServerStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +func _C2_ReportProcessList_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ReportProcessListRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(C2Server).ReportTaskOutput(ctx, in) + return srv.(C2Server).ReportProcessList(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/c2.C2/ReportTaskOutput", + FullMethod: "/c2.C2/ReportProcessList", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(C2Server).ReportTaskOutput(ctx, req.(*ReportTaskOutputRequest)) + return srv.(C2Server).ReportProcessList(ctx, req.(*ReportProcessListRequest)) } return interceptor(ctx, in, info, handler) } -func _C2_ReportProcessList_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(ReportProcessListRequest) +func _C2_ReportTaskOutput_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ReportTaskOutputRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(C2Server).ReportProcessList(ctx, in) + return srv.(C2Server).ReportTaskOutput(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/c2.C2/ReportProcessList", + FullMethod: "/c2.C2/ReportTaskOutput", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(C2Server).ReportProcessList(ctx, req.(*ReportProcessListRequest)) + return srv.(C2Server).ReportTaskOutput(ctx, req.(*ReportTaskOutputRequest)) } return interceptor(ctx, in, info, handler) } -func _C2_DownloadFile_Handler(srv interface{}, stream grpc.ServerStream) error { - m := new(DownloadFileRequest) - if err := stream.RecvMsg(m); err != nil { - return err - } - return srv.(C2Server).DownloadFile(m, &c2DownloadFileServer{stream}) -} - -type C2_DownloadFileServer interface { - Send(*DownloadFileResponse) error - grpc.ServerStream -} - -type c2DownloadFileServer struct { - grpc.ServerStream -} - -func (x *c2DownloadFileServer) Send(m *DownloadFileResponse) error { - return x.ServerStream.SendMsg(m) -} - // C2_ServiceDesc is the grpc.ServiceDesc for C2 service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) @@ -239,14 +322,14 @@ var C2_ServiceDesc = grpc.ServiceDesc{ MethodName: "ClaimTasks", Handler: _C2_ClaimTasks_Handler, }, - { - MethodName: "ReportTaskOutput", - Handler: _C2_ReportTaskOutput_Handler, - }, { MethodName: "ReportProcessList", Handler: _C2_ReportProcessList_Handler, }, + { + MethodName: "ReportTaskOutput", + Handler: _C2_ReportTaskOutput_Handler, + }, }, Streams: []grpc.StreamDesc{ { @@ -254,6 +337,11 @@ var C2_ServiceDesc = grpc.ServiceDesc{ Handler: _C2_DownloadFile_Handler, ServerStreams: true, }, + { + StreamName: "ReportFile", + Handler: _C2_ReportFile_Handler, + ClientStreams: true, + }, }, Metadata: "c2.proto", } diff --git a/tavern/internal/c2/c2pb/enum_host_platform.go b/tavern/internal/c2/c2pb/enum_host_platform.go new file mode 100644 index 000000000..f6a915488 --- /dev/null +++ b/tavern/internal/c2/c2pb/enum_host_platform.go @@ -0,0 +1,62 @@ +package c2pb + +import ( + "database/sql/driver" + "io" + + "github.com/99designs/gqlgen/graphql" +) + +// Values provides list valid values for Enum. +func (Host_Platform) Values() []string { + values := make([]string, 0, len(Host_Platform_name)) + for _, name := range Host_Platform_name { + values = append(values, name) + } + return values +} + +// Value provides the DB a string from int. +func (p Host_Platform) Value() (driver.Value, error) { + return p.String(), nil +} + +// Scan tells our code how to read the enum into our type. +func (p *Host_Platform) Scan(val any) error { + var name string + switch v := val.(type) { + case nil: + return nil + case string: + name = v + case []uint8: + name = string(v) + default: + *p = Host_PLATFORM_UNSPECIFIED + return nil + } + + status, ok := Host_Platform_value[name] + if !ok { + *p = Host_PLATFORM_UNSPECIFIED + return nil + } + *p = Host_Platform(status) + + return nil +} + +// MarshalGQL writes a formatted string value for GraphQL. +func (p Host_Platform) MarshalGQL(w io.Writer) { + graphql.MarshalString(p.String()).MarshalGQL(w) +} + +// UnmarshalGQL parses a GraphQL string representation into the enum. +func (p *Host_Platform) UnmarshalGQL(v interface{}) error { + str, err := graphql.UnmarshalString(v) + if err != nil { + return err + } + + return p.Scan(str) +} diff --git a/tavern/internal/c2/c2pb/enum_host_platform_test.go b/tavern/internal/c2/c2pb/enum_host_platform_test.go new file mode 100644 index 000000000..9896195c5 --- /dev/null +++ b/tavern/internal/c2/c2pb/enum_host_platform_test.go @@ -0,0 +1,51 @@ +package c2pb_test + +import ( + "testing" + + "github.com/stretchr/testify/assert" + "realm.pub/tavern/internal/c2/c2pb" +) + +func TestHostPlatformScan(t *testing.T) { + tests := []struct { + name string + scanVal any + wantPlatform c2pb.Host_Platform + }{ + { + name: "Linux_String", + scanVal: "PLATFORM_LINUX", + wantPlatform: c2pb.Host_PLATFORM_LINUX, + }, + { + name: "Windows_[]uint8", + scanVal: []uint8("PLATFORM_WINDOWS"), + wantPlatform: c2pb.Host_PLATFORM_WINDOWS, + }, + { + name: "Invalid", + scanVal: "NOT_A_PLATFORM", + wantPlatform: c2pb.Host_PLATFORM_UNSPECIFIED, + }, + { + name: "Empty", + scanVal: "", + wantPlatform: c2pb.Host_PLATFORM_UNSPECIFIED, + }, + { + name: "Nil", + scanVal: nil, + wantPlatform: c2pb.Host_PLATFORM_UNSPECIFIED, + }, + } + + for _, tc := range tests { + t.Run(tc.name, func(t *testing.T) { + platform := c2pb.Host_Platform(0) + err := (*c2pb.Host_Platform).Scan(&platform, tc.scanVal) + assert.NoError(t, err) + assert.Equal(t, tc.wantPlatform, platform) + }) + } +} diff --git a/tavern/internal/c2/c2pb/enum_process_status.go b/tavern/internal/c2/c2pb/enum_process_status.go new file mode 100644 index 000000000..2291531df --- /dev/null +++ b/tavern/internal/c2/c2pb/enum_process_status.go @@ -0,0 +1,67 @@ +package c2pb + +import ( + "database/sql/driver" + "io" + + "github.com/99designs/gqlgen/graphql" +) + +// Values provides list valid values for Enum. +func (Process_Status) Values() []string { + values := make([]string, 0, len(Process_Status_name)) + for _, name := range Process_Status_name { + values = append(values, name) + } + return values +} + +// Value provides the DB a string from int. +func (p Process_Status) Value() (driver.Value, error) { + return p.String(), nil +} + +// Scan tells our code how to read the enum into our type. +func (p *Process_Status) Scan(val any) error { + var name string + switch v := val.(type) { + case nil: + return nil + case string: + name = v + case []uint8: + name = string(v) + default: + *p = Process_STATUS_UNKNOWN + return nil + } + + if name == "" { + *p = Process_STATUS_UNSPECIFIED + return nil + } + + status, ok := Process_Status_value[name] + if !ok { + *p = Process_STATUS_UNKNOWN + return nil + } + *p = Process_Status(status) + + return nil +} + +// MarshalGQL writes a formatted string value for GraphQL. +func (p Process_Status) MarshalGQL(w io.Writer) { + graphql.MarshalString(p.String()).MarshalGQL(w) +} + +// UnmarshalGQL parses a GraphQL string representation into the enum. +func (p *Process_Status) UnmarshalGQL(v interface{}) error { + str, err := graphql.UnmarshalString(v) + if err != nil { + return err + } + + return p.Scan(str) +} diff --git a/tavern/internal/c2/c2pb/enum_process_status_test.go b/tavern/internal/c2/c2pb/enum_process_status_test.go new file mode 100644 index 000000000..c1febd695 --- /dev/null +++ b/tavern/internal/c2/c2pb/enum_process_status_test.go @@ -0,0 +1,51 @@ +package c2pb_test + +import ( + "testing" + + "github.com/stretchr/testify/assert" + "realm.pub/tavern/internal/c2/c2pb" +) + +func TestProcessStatusScan(t *testing.T) { + tests := []struct { + name string + scanVal any + wantStatus c2pb.Process_Status + }{ + { + name: "RUN_String", + scanVal: "STATUS_RUN", + wantStatus: c2pb.Process_STATUS_RUN, + }, + { + name: "IDLE_[]uint8", + scanVal: []uint8("STATUS_IDLE"), + wantStatus: c2pb.Process_STATUS_IDLE, + }, + { + name: "Invalid", + scanVal: "NOT_A_STATUS", + wantStatus: c2pb.Process_STATUS_UNKNOWN, + }, + { + name: "Empty", + scanVal: "", + wantStatus: c2pb.Process_STATUS_UNSPECIFIED, + }, + { + name: "Nil", + scanVal: nil, + wantStatus: c2pb.Process_STATUS_UNSPECIFIED, + }, + } + + for _, tc := range tests { + t.Run(tc.name, func(t *testing.T) { + status := c2pb.Process_Status(0) + err := (*c2pb.Process_Status).Scan(&status, tc.scanVal) + assert.NoError(t, err) + assert.Equal(t, tc.wantStatus, status) + }) + } +} diff --git a/tavern/internal/c2/c2test/ent.go b/tavern/internal/c2/c2test/ent.go index 652b441b4..eb61f26a6 100644 --- a/tavern/internal/c2/c2test/ent.go +++ b/tavern/internal/c2/c2test/ent.go @@ -18,6 +18,7 @@ import ( // NewRandomBeacon creates and returns a new randomized beacon. func NewRandomBeacon(ctx context.Context, graph *ent.Client) *ent.Beacon { host := graph.Host.Create(). + SetPlatform(c2pb.Host_PLATFORM_UNSPECIFIED). SetIdentifier(namegen.NewComplex()). SaveX(ctx) diff --git a/tavern/internal/c2/convert.go b/tavern/internal/c2/convert.go deleted file mode 100644 index 8277115ac..000000000 --- a/tavern/internal/c2/convert.go +++ /dev/null @@ -1,22 +0,0 @@ -package c2 - -import ( - "realm.pub/tavern/internal/c2/c2pb" - "realm.pub/tavern/internal/ent/host" -) - -// convertHostPlatform converts a c2pb.Host_Platform to a host.Platform. -func convertHostPlatform(platform c2pb.Host_Platform) host.Platform { - switch platform { - case c2pb.Host_PLATFORM_WINDOWS: - return host.PlatformWindows - case c2pb.Host_PLATFORM_LINUX: - return host.PlatformLinux - case c2pb.Host_PLATFORM_MACOS: - return host.PlatformMacOS - case c2pb.Host_PLATFORM_BSD: - return host.PlatformBSD - } - - return host.PlatformUnknown -} diff --git a/tavern/internal/ent/client.go b/tavern/internal/ent/client.go index 414bc9321..13658a6f4 100644 --- a/tavern/internal/ent/client.go +++ b/tavern/internal/ent/client.go @@ -18,7 +18,8 @@ import ( "realm.pub/tavern/internal/ent/beacon" "realm.pub/tavern/internal/ent/file" "realm.pub/tavern/internal/ent/host" - "realm.pub/tavern/internal/ent/process" + "realm.pub/tavern/internal/ent/hostfile" + "realm.pub/tavern/internal/ent/hostprocess" "realm.pub/tavern/internal/ent/quest" "realm.pub/tavern/internal/ent/tag" "realm.pub/tavern/internal/ent/task" @@ -37,8 +38,10 @@ type Client struct { File *FileClient // Host is the client for interacting with the Host builders. Host *HostClient - // Process is the client for interacting with the Process builders. - Process *ProcessClient + // HostFile is the client for interacting with the HostFile builders. + HostFile *HostFileClient + // HostProcess is the client for interacting with the HostProcess builders. + HostProcess *HostProcessClient // Quest is the client for interacting with the Quest builders. Quest *QuestClient // Tag is the client for interacting with the Tag builders. @@ -67,7 +70,8 @@ func (c *Client) init() { c.Beacon = NewBeaconClient(c.config) c.File = NewFileClient(c.config) c.Host = NewHostClient(c.config) - c.Process = NewProcessClient(c.config) + c.HostFile = NewHostFileClient(c.config) + c.HostProcess = NewHostProcessClient(c.config) c.Quest = NewQuestClient(c.config) c.Tag = NewTagClient(c.config) c.Task = NewTaskClient(c.config) @@ -156,17 +160,18 @@ func (c *Client) Tx(ctx context.Context) (*Tx, error) { cfg := c.config cfg.driver = tx return &Tx{ - ctx: ctx, - config: cfg, - Beacon: NewBeaconClient(cfg), - File: NewFileClient(cfg), - Host: NewHostClient(cfg), - Process: NewProcessClient(cfg), - Quest: NewQuestClient(cfg), - Tag: NewTagClient(cfg), - Task: NewTaskClient(cfg), - Tome: NewTomeClient(cfg), - User: NewUserClient(cfg), + ctx: ctx, + config: cfg, + Beacon: NewBeaconClient(cfg), + File: NewFileClient(cfg), + Host: NewHostClient(cfg), + HostFile: NewHostFileClient(cfg), + HostProcess: NewHostProcessClient(cfg), + Quest: NewQuestClient(cfg), + Tag: NewTagClient(cfg), + Task: NewTaskClient(cfg), + Tome: NewTomeClient(cfg), + User: NewUserClient(cfg), }, nil } @@ -184,17 +189,18 @@ func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error) cfg := c.config cfg.driver = &txDriver{tx: tx, drv: c.driver} return &Tx{ - ctx: ctx, - config: cfg, - Beacon: NewBeaconClient(cfg), - File: NewFileClient(cfg), - Host: NewHostClient(cfg), - Process: NewProcessClient(cfg), - Quest: NewQuestClient(cfg), - Tag: NewTagClient(cfg), - Task: NewTaskClient(cfg), - Tome: NewTomeClient(cfg), - User: NewUserClient(cfg), + ctx: ctx, + config: cfg, + Beacon: NewBeaconClient(cfg), + File: NewFileClient(cfg), + Host: NewHostClient(cfg), + HostFile: NewHostFileClient(cfg), + HostProcess: NewHostProcessClient(cfg), + Quest: NewQuestClient(cfg), + Tag: NewTagClient(cfg), + Task: NewTaskClient(cfg), + Tome: NewTomeClient(cfg), + User: NewUserClient(cfg), }, nil } @@ -224,7 +230,8 @@ func (c *Client) Close() error { // In order to add hooks to a specific client, call: `client.Node.Use(...)`. func (c *Client) Use(hooks ...Hook) { for _, n := range []interface{ Use(...Hook) }{ - c.Beacon, c.File, c.Host, c.Process, c.Quest, c.Tag, c.Task, c.Tome, c.User, + c.Beacon, c.File, c.Host, c.HostFile, c.HostProcess, c.Quest, c.Tag, c.Task, + c.Tome, c.User, } { n.Use(hooks...) } @@ -234,7 +241,8 @@ func (c *Client) Use(hooks ...Hook) { // In order to add interceptors to a specific client, call: `client.Node.Intercept(...)`. func (c *Client) Intercept(interceptors ...Interceptor) { for _, n := range []interface{ Intercept(...Interceptor) }{ - c.Beacon, c.File, c.Host, c.Process, c.Quest, c.Tag, c.Task, c.Tome, c.User, + c.Beacon, c.File, c.Host, c.HostFile, c.HostProcess, c.Quest, c.Tag, c.Task, + c.Tome, c.User, } { n.Intercept(interceptors...) } @@ -249,8 +257,10 @@ func (c *Client) Mutate(ctx context.Context, m Mutation) (Value, error) { return c.File.mutate(ctx, m) case *HostMutation: return c.Host.mutate(ctx, m) - case *ProcessMutation: - return c.Process.mutate(ctx, m) + case *HostFileMutation: + return c.HostFile.mutate(ctx, m) + case *HostProcessMutation: + return c.HostProcess.mutate(ctx, m) case *QuestMutation: return c.Quest.mutate(ctx, m) case *TagMutation: @@ -721,14 +731,30 @@ func (c *HostClient) QueryBeacons(h *Host) *BeaconQuery { return query } +// QueryFiles queries the files edge of a Host. +func (c *HostClient) QueryFiles(h *Host) *HostFileQuery { + query := (&HostFileClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := h.ID + step := sqlgraph.NewStep( + sqlgraph.From(host.Table, host.FieldID, id), + sqlgraph.To(hostfile.Table, hostfile.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, host.FilesTable, host.FilesColumn), + ) + fromV = sqlgraph.Neighbors(h.driver.Dialect(), step) + return fromV, nil + } + return query +} + // QueryProcesses queries the processes edge of a Host. -func (c *HostClient) QueryProcesses(h *Host) *ProcessQuery { - query := (&ProcessClient{config: c.config}).Query() +func (c *HostClient) QueryProcesses(h *Host) *HostProcessQuery { + query := (&HostProcessClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := h.ID step := sqlgraph.NewStep( sqlgraph.From(host.Table, host.FieldID, id), - sqlgraph.To(process.Table, process.FieldID), + sqlgraph.To(hostprocess.Table, hostprocess.FieldID), sqlgraph.Edge(sqlgraph.O2M, false, host.ProcessesTable, host.ProcessesColumn), ) fromV = sqlgraph.Neighbors(h.driver.Dialect(), step) @@ -762,107 +788,273 @@ func (c *HostClient) mutate(ctx context.Context, m *HostMutation) (Value, error) } } -// ProcessClient is a client for the Process schema. -type ProcessClient struct { +// HostFileClient is a client for the HostFile schema. +type HostFileClient struct { + config +} + +// NewHostFileClient returns a client for the HostFile from the given config. +func NewHostFileClient(c config) *HostFileClient { + return &HostFileClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `hostfile.Hooks(f(g(h())))`. +func (c *HostFileClient) Use(hooks ...Hook) { + c.hooks.HostFile = append(c.hooks.HostFile, hooks...) +} + +// Intercept adds a list of query interceptors to the interceptors stack. +// A call to `Intercept(f, g, h)` equals to `hostfile.Intercept(f(g(h())))`. +func (c *HostFileClient) Intercept(interceptors ...Interceptor) { + c.inters.HostFile = append(c.inters.HostFile, interceptors...) +} + +// Create returns a builder for creating a HostFile entity. +func (c *HostFileClient) Create() *HostFileCreate { + mutation := newHostFileMutation(c.config, OpCreate) + return &HostFileCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of HostFile entities. +func (c *HostFileClient) CreateBulk(builders ...*HostFileCreate) *HostFileCreateBulk { + return &HostFileCreateBulk{config: c.config, builders: builders} +} + +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *HostFileClient) MapCreateBulk(slice any, setFunc func(*HostFileCreate, int)) *HostFileCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &HostFileCreateBulk{err: fmt.Errorf("calling to HostFileClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*HostFileCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &HostFileCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for HostFile. +func (c *HostFileClient) Update() *HostFileUpdate { + mutation := newHostFileMutation(c.config, OpUpdate) + return &HostFileUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *HostFileClient) UpdateOne(hf *HostFile) *HostFileUpdateOne { + mutation := newHostFileMutation(c.config, OpUpdateOne, withHostFile(hf)) + return &HostFileUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOneID returns an update builder for the given id. +func (c *HostFileClient) UpdateOneID(id int) *HostFileUpdateOne { + mutation := newHostFileMutation(c.config, OpUpdateOne, withHostFileID(id)) + return &HostFileUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for HostFile. +func (c *HostFileClient) Delete() *HostFileDelete { + mutation := newHostFileMutation(c.config, OpDelete) + return &HostFileDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// DeleteOne returns a builder for deleting the given entity. +func (c *HostFileClient) DeleteOne(hf *HostFile) *HostFileDeleteOne { + return c.DeleteOneID(hf.ID) +} + +// DeleteOneID returns a builder for deleting the given entity by its id. +func (c *HostFileClient) DeleteOneID(id int) *HostFileDeleteOne { + builder := c.Delete().Where(hostfile.ID(id)) + builder.mutation.id = &id + builder.mutation.op = OpDeleteOne + return &HostFileDeleteOne{builder} +} + +// Query returns a query builder for HostFile. +func (c *HostFileClient) Query() *HostFileQuery { + return &HostFileQuery{ + config: c.config, + ctx: &QueryContext{Type: TypeHostFile}, + inters: c.Interceptors(), + } +} + +// Get returns a HostFile entity by its id. +func (c *HostFileClient) Get(ctx context.Context, id int) (*HostFile, error) { + return c.Query().Where(hostfile.ID(id)).Only(ctx) +} + +// GetX is like Get, but panics if an error occurs. +func (c *HostFileClient) GetX(ctx context.Context, id int) *HostFile { + obj, err := c.Get(ctx, id) + if err != nil { + panic(err) + } + return obj +} + +// QueryHost queries the host edge of a HostFile. +func (c *HostFileClient) QueryHost(hf *HostFile) *HostQuery { + query := (&HostClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := hf.ID + step := sqlgraph.NewStep( + sqlgraph.From(hostfile.Table, hostfile.FieldID, id), + sqlgraph.To(host.Table, host.FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, hostfile.HostTable, hostfile.HostColumn), + ) + fromV = sqlgraph.Neighbors(hf.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// QueryTask queries the task edge of a HostFile. +func (c *HostFileClient) QueryTask(hf *HostFile) *TaskQuery { + query := (&TaskClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := hf.ID + step := sqlgraph.NewStep( + sqlgraph.From(hostfile.Table, hostfile.FieldID, id), + sqlgraph.To(task.Table, task.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, hostfile.TaskTable, hostfile.TaskColumn), + ) + fromV = sqlgraph.Neighbors(hf.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// Hooks returns the client hooks. +func (c *HostFileClient) Hooks() []Hook { + hooks := c.hooks.HostFile + return append(hooks[:len(hooks):len(hooks)], hostfile.Hooks[:]...) +} + +// Interceptors returns the client interceptors. +func (c *HostFileClient) Interceptors() []Interceptor { + return c.inters.HostFile +} + +func (c *HostFileClient) mutate(ctx context.Context, m *HostFileMutation) (Value, error) { + switch m.Op() { + case OpCreate: + return (&HostFileCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdate: + return (&HostFileUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdateOne: + return (&HostFileUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpDelete, OpDeleteOne: + return (&HostFileDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) + default: + return nil, fmt.Errorf("ent: unknown HostFile mutation op: %q", m.Op()) + } +} + +// HostProcessClient is a client for the HostProcess schema. +type HostProcessClient struct { config } -// NewProcessClient returns a client for the Process from the given config. -func NewProcessClient(c config) *ProcessClient { - return &ProcessClient{config: c} +// NewHostProcessClient returns a client for the HostProcess from the given config. +func NewHostProcessClient(c config) *HostProcessClient { + return &HostProcessClient{config: c} } // Use adds a list of mutation hooks to the hooks stack. -// A call to `Use(f, g, h)` equals to `process.Hooks(f(g(h())))`. -func (c *ProcessClient) Use(hooks ...Hook) { - c.hooks.Process = append(c.hooks.Process, hooks...) +// A call to `Use(f, g, h)` equals to `hostprocess.Hooks(f(g(h())))`. +func (c *HostProcessClient) Use(hooks ...Hook) { + c.hooks.HostProcess = append(c.hooks.HostProcess, hooks...) } // Intercept adds a list of query interceptors to the interceptors stack. -// A call to `Intercept(f, g, h)` equals to `process.Intercept(f(g(h())))`. -func (c *ProcessClient) Intercept(interceptors ...Interceptor) { - c.inters.Process = append(c.inters.Process, interceptors...) +// A call to `Intercept(f, g, h)` equals to `hostprocess.Intercept(f(g(h())))`. +func (c *HostProcessClient) Intercept(interceptors ...Interceptor) { + c.inters.HostProcess = append(c.inters.HostProcess, interceptors...) } -// Create returns a builder for creating a Process entity. -func (c *ProcessClient) Create() *ProcessCreate { - mutation := newProcessMutation(c.config, OpCreate) - return &ProcessCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +// Create returns a builder for creating a HostProcess entity. +func (c *HostProcessClient) Create() *HostProcessCreate { + mutation := newHostProcessMutation(c.config, OpCreate) + return &HostProcessCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} } -// CreateBulk returns a builder for creating a bulk of Process entities. -func (c *ProcessClient) CreateBulk(builders ...*ProcessCreate) *ProcessCreateBulk { - return &ProcessCreateBulk{config: c.config, builders: builders} +// CreateBulk returns a builder for creating a bulk of HostProcess entities. +func (c *HostProcessClient) CreateBulk(builders ...*HostProcessCreate) *HostProcessCreateBulk { + return &HostProcessCreateBulk{config: c.config, builders: builders} } // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates // a builder and applies setFunc on it. -func (c *ProcessClient) MapCreateBulk(slice any, setFunc func(*ProcessCreate, int)) *ProcessCreateBulk { +func (c *HostProcessClient) MapCreateBulk(slice any, setFunc func(*HostProcessCreate, int)) *HostProcessCreateBulk { rv := reflect.ValueOf(slice) if rv.Kind() != reflect.Slice { - return &ProcessCreateBulk{err: fmt.Errorf("calling to ProcessClient.MapCreateBulk with wrong type %T, need slice", slice)} + return &HostProcessCreateBulk{err: fmt.Errorf("calling to HostProcessClient.MapCreateBulk with wrong type %T, need slice", slice)} } - builders := make([]*ProcessCreate, rv.Len()) + builders := make([]*HostProcessCreate, rv.Len()) for i := 0; i < rv.Len(); i++ { builders[i] = c.Create() setFunc(builders[i], i) } - return &ProcessCreateBulk{config: c.config, builders: builders} + return &HostProcessCreateBulk{config: c.config, builders: builders} } -// Update returns an update builder for Process. -func (c *ProcessClient) Update() *ProcessUpdate { - mutation := newProcessMutation(c.config, OpUpdate) - return &ProcessUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +// Update returns an update builder for HostProcess. +func (c *HostProcessClient) Update() *HostProcessUpdate { + mutation := newHostProcessMutation(c.config, OpUpdate) + return &HostProcessUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} } // UpdateOne returns an update builder for the given entity. -func (c *ProcessClient) UpdateOne(pr *Process) *ProcessUpdateOne { - mutation := newProcessMutation(c.config, OpUpdateOne, withProcess(pr)) - return &ProcessUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +func (c *HostProcessClient) UpdateOne(hp *HostProcess) *HostProcessUpdateOne { + mutation := newHostProcessMutation(c.config, OpUpdateOne, withHostProcess(hp)) + return &HostProcessUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} } // UpdateOneID returns an update builder for the given id. -func (c *ProcessClient) UpdateOneID(id int) *ProcessUpdateOne { - mutation := newProcessMutation(c.config, OpUpdateOne, withProcessID(id)) - return &ProcessUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +func (c *HostProcessClient) UpdateOneID(id int) *HostProcessUpdateOne { + mutation := newHostProcessMutation(c.config, OpUpdateOne, withHostProcessID(id)) + return &HostProcessUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} } -// Delete returns a delete builder for Process. -func (c *ProcessClient) Delete() *ProcessDelete { - mutation := newProcessMutation(c.config, OpDelete) - return &ProcessDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +// Delete returns a delete builder for HostProcess. +func (c *HostProcessClient) Delete() *HostProcessDelete { + mutation := newHostProcessMutation(c.config, OpDelete) + return &HostProcessDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} } // DeleteOne returns a builder for deleting the given entity. -func (c *ProcessClient) DeleteOne(pr *Process) *ProcessDeleteOne { - return c.DeleteOneID(pr.ID) +func (c *HostProcessClient) DeleteOne(hp *HostProcess) *HostProcessDeleteOne { + return c.DeleteOneID(hp.ID) } // DeleteOneID returns a builder for deleting the given entity by its id. -func (c *ProcessClient) DeleteOneID(id int) *ProcessDeleteOne { - builder := c.Delete().Where(process.ID(id)) +func (c *HostProcessClient) DeleteOneID(id int) *HostProcessDeleteOne { + builder := c.Delete().Where(hostprocess.ID(id)) builder.mutation.id = &id builder.mutation.op = OpDeleteOne - return &ProcessDeleteOne{builder} + return &HostProcessDeleteOne{builder} } -// Query returns a query builder for Process. -func (c *ProcessClient) Query() *ProcessQuery { - return &ProcessQuery{ +// Query returns a query builder for HostProcess. +func (c *HostProcessClient) Query() *HostProcessQuery { + return &HostProcessQuery{ config: c.config, - ctx: &QueryContext{Type: TypeProcess}, + ctx: &QueryContext{Type: TypeHostProcess}, inters: c.Interceptors(), } } -// Get returns a Process entity by its id. -func (c *ProcessClient) Get(ctx context.Context, id int) (*Process, error) { - return c.Query().Where(process.ID(id)).Only(ctx) +// Get returns a HostProcess entity by its id. +func (c *HostProcessClient) Get(ctx context.Context, id int) (*HostProcess, error) { + return c.Query().Where(hostprocess.ID(id)).Only(ctx) } // GetX is like Get, but panics if an error occurs. -func (c *ProcessClient) GetX(ctx context.Context, id int) *Process { +func (c *HostProcessClient) GetX(ctx context.Context, id int) *HostProcess { obj, err := c.Get(ctx, id) if err != nil { panic(err) @@ -870,60 +1062,60 @@ func (c *ProcessClient) GetX(ctx context.Context, id int) *Process { return obj } -// QueryHost queries the host edge of a Process. -func (c *ProcessClient) QueryHost(pr *Process) *HostQuery { +// QueryHost queries the host edge of a HostProcess. +func (c *HostProcessClient) QueryHost(hp *HostProcess) *HostQuery { query := (&HostClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := pr.ID + id := hp.ID step := sqlgraph.NewStep( - sqlgraph.From(process.Table, process.FieldID, id), + sqlgraph.From(hostprocess.Table, hostprocess.FieldID, id), sqlgraph.To(host.Table, host.FieldID), - sqlgraph.Edge(sqlgraph.M2O, false, process.HostTable, process.HostColumn), + sqlgraph.Edge(sqlgraph.M2O, false, hostprocess.HostTable, hostprocess.HostColumn), ) - fromV = sqlgraph.Neighbors(pr.driver.Dialect(), step) + fromV = sqlgraph.Neighbors(hp.driver.Dialect(), step) return fromV, nil } return query } -// QueryTask queries the task edge of a Process. -func (c *ProcessClient) QueryTask(pr *Process) *TaskQuery { +// QueryTask queries the task edge of a HostProcess. +func (c *HostProcessClient) QueryTask(hp *HostProcess) *TaskQuery { query := (&TaskClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := pr.ID + id := hp.ID step := sqlgraph.NewStep( - sqlgraph.From(process.Table, process.FieldID, id), + sqlgraph.From(hostprocess.Table, hostprocess.FieldID, id), sqlgraph.To(task.Table, task.FieldID), - sqlgraph.Edge(sqlgraph.M2O, true, process.TaskTable, process.TaskColumn), + sqlgraph.Edge(sqlgraph.M2O, true, hostprocess.TaskTable, hostprocess.TaskColumn), ) - fromV = sqlgraph.Neighbors(pr.driver.Dialect(), step) + fromV = sqlgraph.Neighbors(hp.driver.Dialect(), step) return fromV, nil } return query } // Hooks returns the client hooks. -func (c *ProcessClient) Hooks() []Hook { - return c.hooks.Process +func (c *HostProcessClient) Hooks() []Hook { + return c.hooks.HostProcess } // Interceptors returns the client interceptors. -func (c *ProcessClient) Interceptors() []Interceptor { - return c.inters.Process +func (c *HostProcessClient) Interceptors() []Interceptor { + return c.inters.HostProcess } -func (c *ProcessClient) mutate(ctx context.Context, m *ProcessMutation) (Value, error) { +func (c *HostProcessClient) mutate(ctx context.Context, m *HostProcessMutation) (Value, error) { switch m.Op() { case OpCreate: - return (&ProcessCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + return (&HostProcessCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) case OpUpdate: - return (&ProcessUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + return (&HostProcessUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) case OpUpdateOne: - return (&ProcessUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + return (&HostProcessUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) case OpDelete, OpDeleteOne: - return (&ProcessDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) + return (&HostProcessDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) default: - return nil, fmt.Errorf("ent: unknown Process mutation op: %q", m.Op()) + return nil, fmt.Errorf("ent: unknown HostProcess mutation op: %q", m.Op()) } } @@ -1413,14 +1605,30 @@ func (c *TaskClient) QueryBeacon(t *Task) *BeaconQuery { return query } +// QueryReportedFiles queries the reported_files edge of a Task. +func (c *TaskClient) QueryReportedFiles(t *Task) *HostFileQuery { + query := (&HostFileClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := t.ID + step := sqlgraph.NewStep( + sqlgraph.From(task.Table, task.FieldID, id), + sqlgraph.To(hostfile.Table, hostfile.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, task.ReportedFilesTable, task.ReportedFilesColumn), + ) + fromV = sqlgraph.Neighbors(t.driver.Dialect(), step) + return fromV, nil + } + return query +} + // QueryReportedProcesses queries the reported_processes edge of a Task. -func (c *TaskClient) QueryReportedProcesses(t *Task) *ProcessQuery { - query := (&ProcessClient{config: c.config}).Query() +func (c *TaskClient) QueryReportedProcesses(t *Task) *HostProcessQuery { + query := (&HostProcessClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := t.ID step := sqlgraph.NewStep( sqlgraph.From(task.Table, task.FieldID, id), - sqlgraph.To(process.Table, process.FieldID), + sqlgraph.To(hostprocess.Table, hostprocess.FieldID), sqlgraph.Edge(sqlgraph.O2M, false, task.ReportedProcessesTable, task.ReportedProcessesColumn), ) fromV = sqlgraph.Neighbors(t.driver.Dialect(), step) @@ -1773,9 +1981,11 @@ func (c *UserClient) mutate(ctx context.Context, m *UserMutation) (Value, error) // hooks and interceptors per client, for fast access. type ( hooks struct { - Beacon, File, Host, Process, Quest, Tag, Task, Tome, User []ent.Hook + Beacon, File, Host, HostFile, HostProcess, Quest, Tag, Task, Tome, + User []ent.Hook } inters struct { - Beacon, File, Host, Process, Quest, Tag, Task, Tome, User []ent.Interceptor + Beacon, File, Host, HostFile, HostProcess, Quest, Tag, Task, Tome, + User []ent.Interceptor } ) diff --git a/tavern/internal/ent/ent.go b/tavern/internal/ent/ent.go index 30b545ce8..0bd913aed 100644 --- a/tavern/internal/ent/ent.go +++ b/tavern/internal/ent/ent.go @@ -15,7 +15,8 @@ import ( "realm.pub/tavern/internal/ent/beacon" "realm.pub/tavern/internal/ent/file" "realm.pub/tavern/internal/ent/host" - "realm.pub/tavern/internal/ent/process" + "realm.pub/tavern/internal/ent/hostfile" + "realm.pub/tavern/internal/ent/hostprocess" "realm.pub/tavern/internal/ent/quest" "realm.pub/tavern/internal/ent/tag" "realm.pub/tavern/internal/ent/task" @@ -81,15 +82,16 @@ var ( func checkColumn(table, column string) error { initCheck.Do(func() { columnCheck = sql.NewColumnCheck(map[string]func(string) bool{ - beacon.Table: beacon.ValidColumn, - file.Table: file.ValidColumn, - host.Table: host.ValidColumn, - process.Table: process.ValidColumn, - quest.Table: quest.ValidColumn, - tag.Table: tag.ValidColumn, - task.Table: task.ValidColumn, - tome.Table: tome.ValidColumn, - user.Table: user.ValidColumn, + beacon.Table: beacon.ValidColumn, + file.Table: file.ValidColumn, + host.Table: host.ValidColumn, + hostfile.Table: hostfile.ValidColumn, + hostprocess.Table: hostprocess.ValidColumn, + quest.Table: quest.ValidColumn, + tag.Table: tag.ValidColumn, + task.Table: task.ValidColumn, + tome.Table: tome.ValidColumn, + user.Table: user.ValidColumn, }) }) return columnCheck(table, column) diff --git a/tavern/internal/ent/file.go b/tavern/internal/ent/file.go index 7033c1a06..84dced611 100644 --- a/tavern/internal/ent/file.go +++ b/tavern/internal/ent/file.go @@ -25,7 +25,7 @@ type File struct { Name string `json:"name,omitempty"` // The size of the file in bytes Size int `json:"size,omitempty"` - // A SHA3 digest of the content field + // A SHA3-256 digest of the content field Hash string `json:"hash,omitempty"` // The content of the file Content []byte `json:"content,omitempty"` diff --git a/tavern/internal/ent/gql_collection.go b/tavern/internal/ent/gql_collection.go index 2ba2ce8f4..e6cb37b56 100644 --- a/tavern/internal/ent/gql_collection.go +++ b/tavern/internal/ent/gql_collection.go @@ -11,7 +11,8 @@ import ( "realm.pub/tavern/internal/ent/beacon" "realm.pub/tavern/internal/ent/file" "realm.pub/tavern/internal/ent/host" - "realm.pub/tavern/internal/ent/process" + "realm.pub/tavern/internal/ent/hostfile" + "realm.pub/tavern/internal/ent/hostprocess" "realm.pub/tavern/internal/ent/quest" "realm.pub/tavern/internal/ent/tag" "realm.pub/tavern/internal/ent/task" @@ -331,16 +332,28 @@ func (h *HostQuery) collectField(ctx context.Context, opCtx *graphql.OperationCo h.WithNamedBeacons(alias, func(wq *BeaconQuery) { *wq = *query }) + case "files": + var ( + alias = field.Alias + path = append(path, alias) + query = (&HostFileClient{config: h.config}).Query() + ) + if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + return err + } + h.WithNamedFiles(alias, func(wq *HostFileQuery) { + *wq = *query + }) case "processes": var ( alias = field.Alias path = append(path, alias) - query = (&ProcessClient{config: h.config}).Query() + query = (&HostProcessClient{config: h.config}).Query() ) if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { return err } - h.WithNamedProcesses(alias, func(wq *ProcessQuery) { + h.WithNamedProcesses(alias, func(wq *HostProcessQuery) { *wq = *query }) case "createdAt": @@ -442,23 +455,167 @@ func newHostPaginateArgs(rv map[string]any) *hostPaginateArgs { } // CollectFields tells the query-builder to eagerly load connected nodes by resolver context. -func (pr *ProcessQuery) CollectFields(ctx context.Context, satisfies ...string) (*ProcessQuery, error) { +func (hf *HostFileQuery) CollectFields(ctx context.Context, satisfies ...string) (*HostFileQuery, error) { + fc := graphql.GetFieldContext(ctx) + if fc == nil { + return hf, nil + } + if err := hf.collectField(ctx, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { + return nil, err + } + return hf, nil +} + +func (hf *HostFileQuery) collectField(ctx context.Context, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { + path = append([]string(nil), path...) + var ( + unknownSeen bool + fieldSeen = make(map[string]struct{}, len(hostfile.Columns)) + selectedFields = []string{hostfile.FieldID} + ) + for _, field := range graphql.CollectFields(opCtx, collected.Selections, satisfies) { + switch field.Name { + case "host": + var ( + alias = field.Alias + path = append(path, alias) + query = (&HostClient{config: hf.config}).Query() + ) + if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + return err + } + hf.withHost = query + case "task": + var ( + alias = field.Alias + path = append(path, alias) + query = (&TaskClient{config: hf.config}).Query() + ) + if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + return err + } + hf.withTask = query + case "createdAt": + if _, ok := fieldSeen[hostfile.FieldCreatedAt]; !ok { + selectedFields = append(selectedFields, hostfile.FieldCreatedAt) + fieldSeen[hostfile.FieldCreatedAt] = struct{}{} + } + case "lastModifiedAt": + if _, ok := fieldSeen[hostfile.FieldLastModifiedAt]; !ok { + selectedFields = append(selectedFields, hostfile.FieldLastModifiedAt) + fieldSeen[hostfile.FieldLastModifiedAt] = struct{}{} + } + case "path": + if _, ok := fieldSeen[hostfile.FieldPath]; !ok { + selectedFields = append(selectedFields, hostfile.FieldPath) + fieldSeen[hostfile.FieldPath] = struct{}{} + } + case "owner": + if _, ok := fieldSeen[hostfile.FieldOwner]; !ok { + selectedFields = append(selectedFields, hostfile.FieldOwner) + fieldSeen[hostfile.FieldOwner] = struct{}{} + } + case "group": + if _, ok := fieldSeen[hostfile.FieldGroup]; !ok { + selectedFields = append(selectedFields, hostfile.FieldGroup) + fieldSeen[hostfile.FieldGroup] = struct{}{} + } + case "permissions": + if _, ok := fieldSeen[hostfile.FieldPermissions]; !ok { + selectedFields = append(selectedFields, hostfile.FieldPermissions) + fieldSeen[hostfile.FieldPermissions] = struct{}{} + } + case "size": + if _, ok := fieldSeen[hostfile.FieldSize]; !ok { + selectedFields = append(selectedFields, hostfile.FieldSize) + fieldSeen[hostfile.FieldSize] = struct{}{} + } + case "hash": + if _, ok := fieldSeen[hostfile.FieldHash]; !ok { + selectedFields = append(selectedFields, hostfile.FieldHash) + fieldSeen[hostfile.FieldHash] = struct{}{} + } + case "id": + case "__typename": + default: + unknownSeen = true + } + } + if !unknownSeen { + hf.Select(selectedFields...) + } + return nil +} + +type hostfilePaginateArgs struct { + first, last *int + after, before *Cursor + opts []HostFilePaginateOption +} + +func newHostFilePaginateArgs(rv map[string]any) *hostfilePaginateArgs { + args := &hostfilePaginateArgs{} + if rv == nil { + return args + } + if v := rv[firstField]; v != nil { + args.first = v.(*int) + } + if v := rv[lastField]; v != nil { + args.last = v.(*int) + } + if v := rv[afterField]; v != nil { + args.after = v.(*Cursor) + } + if v := rv[beforeField]; v != nil { + args.before = v.(*Cursor) + } + if v, ok := rv[orderByField]; ok { + switch v := v.(type) { + case map[string]any: + var ( + err1, err2 error + order = &HostFileOrder{Field: &HostFileOrderField{}, Direction: entgql.OrderDirectionAsc} + ) + if d, ok := v[directionField]; ok { + err1 = order.Direction.UnmarshalGQL(d) + } + if f, ok := v[fieldField]; ok { + err2 = order.Field.UnmarshalGQL(f) + } + if err1 == nil && err2 == nil { + args.opts = append(args.opts, WithHostFileOrder(order)) + } + case *HostFileOrder: + if v != nil { + args.opts = append(args.opts, WithHostFileOrder(v)) + } + } + } + if v, ok := rv[whereField].(*HostFileWhereInput); ok { + args.opts = append(args.opts, WithHostFileFilter(v.Filter)) + } + return args +} + +// CollectFields tells the query-builder to eagerly load connected nodes by resolver context. +func (hp *HostProcessQuery) CollectFields(ctx context.Context, satisfies ...string) (*HostProcessQuery, error) { fc := graphql.GetFieldContext(ctx) if fc == nil { - return pr, nil + return hp, nil } - if err := pr.collectField(ctx, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { + if err := hp.collectField(ctx, graphql.GetOperationContext(ctx), fc.Field, nil, satisfies...); err != nil { return nil, err } - return pr, nil + return hp, nil } -func (pr *ProcessQuery) collectField(ctx context.Context, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { +func (hp *HostProcessQuery) collectField(ctx context.Context, opCtx *graphql.OperationContext, collected graphql.CollectedField, path []string, satisfies ...string) error { path = append([]string(nil), path...) var ( unknownSeen bool - fieldSeen = make(map[string]struct{}, len(process.Columns)) - selectedFields = []string{process.FieldID} + fieldSeen = make(map[string]struct{}, len(hostprocess.Columns)) + selectedFields = []string{hostprocess.FieldID} ) for _, field := range graphql.CollectFields(opCtx, collected.Selections, satisfies) { switch field.Name { @@ -466,46 +623,76 @@ func (pr *ProcessQuery) collectField(ctx context.Context, opCtx *graphql.Operati var ( alias = field.Alias path = append(path, alias) - query = (&HostClient{config: pr.config}).Query() + query = (&HostClient{config: hp.config}).Query() ) if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { return err } - pr.withHost = query + hp.withHost = query case "task": var ( alias = field.Alias path = append(path, alias) - query = (&TaskClient{config: pr.config}).Query() + query = (&TaskClient{config: hp.config}).Query() ) if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { return err } - pr.withTask = query + hp.withTask = query case "createdAt": - if _, ok := fieldSeen[process.FieldCreatedAt]; !ok { - selectedFields = append(selectedFields, process.FieldCreatedAt) - fieldSeen[process.FieldCreatedAt] = struct{}{} + if _, ok := fieldSeen[hostprocess.FieldCreatedAt]; !ok { + selectedFields = append(selectedFields, hostprocess.FieldCreatedAt) + fieldSeen[hostprocess.FieldCreatedAt] = struct{}{} } case "lastModifiedAt": - if _, ok := fieldSeen[process.FieldLastModifiedAt]; !ok { - selectedFields = append(selectedFields, process.FieldLastModifiedAt) - fieldSeen[process.FieldLastModifiedAt] = struct{}{} + if _, ok := fieldSeen[hostprocess.FieldLastModifiedAt]; !ok { + selectedFields = append(selectedFields, hostprocess.FieldLastModifiedAt) + fieldSeen[hostprocess.FieldLastModifiedAt] = struct{}{} } case "pid": - if _, ok := fieldSeen[process.FieldPid]; !ok { - selectedFields = append(selectedFields, process.FieldPid) - fieldSeen[process.FieldPid] = struct{}{} + if _, ok := fieldSeen[hostprocess.FieldPid]; !ok { + selectedFields = append(selectedFields, hostprocess.FieldPid) + fieldSeen[hostprocess.FieldPid] = struct{}{} + } + case "ppid": + if _, ok := fieldSeen[hostprocess.FieldPpid]; !ok { + selectedFields = append(selectedFields, hostprocess.FieldPpid) + fieldSeen[hostprocess.FieldPpid] = struct{}{} } case "name": - if _, ok := fieldSeen[process.FieldName]; !ok { - selectedFields = append(selectedFields, process.FieldName) - fieldSeen[process.FieldName] = struct{}{} + if _, ok := fieldSeen[hostprocess.FieldName]; !ok { + selectedFields = append(selectedFields, hostprocess.FieldName) + fieldSeen[hostprocess.FieldName] = struct{}{} } case "principal": - if _, ok := fieldSeen[process.FieldPrincipal]; !ok { - selectedFields = append(selectedFields, process.FieldPrincipal) - fieldSeen[process.FieldPrincipal] = struct{}{} + if _, ok := fieldSeen[hostprocess.FieldPrincipal]; !ok { + selectedFields = append(selectedFields, hostprocess.FieldPrincipal) + fieldSeen[hostprocess.FieldPrincipal] = struct{}{} + } + case "path": + if _, ok := fieldSeen[hostprocess.FieldPath]; !ok { + selectedFields = append(selectedFields, hostprocess.FieldPath) + fieldSeen[hostprocess.FieldPath] = struct{}{} + } + case "cmd": + if _, ok := fieldSeen[hostprocess.FieldCmd]; !ok { + selectedFields = append(selectedFields, hostprocess.FieldCmd) + fieldSeen[hostprocess.FieldCmd] = struct{}{} + } + case "env": + if _, ok := fieldSeen[hostprocess.FieldEnv]; !ok { + selectedFields = append(selectedFields, hostprocess.FieldEnv) + fieldSeen[hostprocess.FieldEnv] = struct{}{} + } + case "cwd": + if _, ok := fieldSeen[hostprocess.FieldCwd]; !ok { + selectedFields = append(selectedFields, hostprocess.FieldCwd) + fieldSeen[hostprocess.FieldCwd] = struct{}{} + } + case "status": + if _, ok := fieldSeen[hostprocess.FieldStatus]; !ok { + selectedFields = append(selectedFields, hostprocess.FieldStatus) + fieldSeen[hostprocess.FieldStatus] = struct{}{} } case "id": case "__typename": @@ -514,19 +701,19 @@ func (pr *ProcessQuery) collectField(ctx context.Context, opCtx *graphql.Operati } } if !unknownSeen { - pr.Select(selectedFields...) + hp.Select(selectedFields...) } return nil } -type processPaginateArgs struct { +type hostprocessPaginateArgs struct { first, last *int after, before *Cursor - opts []ProcessPaginateOption + opts []HostProcessPaginateOption } -func newProcessPaginateArgs(rv map[string]any) *processPaginateArgs { - args := &processPaginateArgs{} +func newHostProcessPaginateArgs(rv map[string]any) *hostprocessPaginateArgs { + args := &hostprocessPaginateArgs{} if rv == nil { return args } @@ -547,7 +734,7 @@ func newProcessPaginateArgs(rv map[string]any) *processPaginateArgs { case map[string]any: var ( err1, err2 error - order = &ProcessOrder{Field: &ProcessOrderField{}, Direction: entgql.OrderDirectionAsc} + order = &HostProcessOrder{Field: &HostProcessOrderField{}, Direction: entgql.OrderDirectionAsc} ) if d, ok := v[directionField]; ok { err1 = order.Direction.UnmarshalGQL(d) @@ -556,16 +743,16 @@ func newProcessPaginateArgs(rv map[string]any) *processPaginateArgs { err2 = order.Field.UnmarshalGQL(f) } if err1 == nil && err2 == nil { - args.opts = append(args.opts, WithProcessOrder(order)) + args.opts = append(args.opts, WithHostProcessOrder(order)) } - case *ProcessOrder: + case *HostProcessOrder: if v != nil { - args.opts = append(args.opts, WithProcessOrder(v)) + args.opts = append(args.opts, WithHostProcessOrder(v)) } } } - if v, ok := rv[whereField].(*ProcessWhereInput); ok { - args.opts = append(args.opts, WithProcessFilter(v.Filter)) + if v, ok := rv[whereField].(*HostProcessWhereInput); ok { + args.opts = append(args.opts, WithHostProcessFilter(v.Filter)) } return args } @@ -863,16 +1050,28 @@ func (t *TaskQuery) collectField(ctx context.Context, opCtx *graphql.OperationCo return err } t.withBeacon = query + case "reportedFiles": + var ( + alias = field.Alias + path = append(path, alias) + query = (&HostFileClient{config: t.config}).Query() + ) + if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { + return err + } + t.WithNamedReportedFiles(alias, func(wq *HostFileQuery) { + *wq = *query + }) case "reportedProcesses": var ( alias = field.Alias path = append(path, alias) - query = (&ProcessClient{config: t.config}).Query() + query = (&HostProcessClient{config: t.config}).Query() ) if err := query.collectField(ctx, opCtx, field, path, satisfies...); err != nil { return err } - t.WithNamedReportedProcesses(alias, func(wq *ProcessQuery) { + t.WithNamedReportedProcesses(alias, func(wq *HostProcessQuery) { *wq = *query }) case "createdAt": diff --git a/tavern/internal/ent/gql_edge.go b/tavern/internal/ent/gql_edge.go index d9218ced7..cdf03a018 100644 --- a/tavern/internal/ent/gql_edge.go +++ b/tavern/internal/ent/gql_edge.go @@ -64,7 +64,19 @@ func (h *Host) Beacons(ctx context.Context) (result []*Beacon, err error) { return result, err } -func (h *Host) Processes(ctx context.Context) (result []*Process, err error) { +func (h *Host) Files(ctx context.Context) (result []*HostFile, err error) { + if fc := graphql.GetFieldContext(ctx); fc != nil && fc.Field.Alias != "" { + result, err = h.NamedFiles(graphql.GetFieldContext(ctx).Field.Alias) + } else { + result, err = h.Edges.FilesOrErr() + } + if IsNotLoaded(err) { + result, err = h.QueryFiles().All(ctx) + } + return result, err +} + +func (h *Host) Processes(ctx context.Context) (result []*HostProcess, err error) { if fc := graphql.GetFieldContext(ctx); fc != nil && fc.Field.Alias != "" { result, err = h.NamedProcesses(graphql.GetFieldContext(ctx).Field.Alias) } else { @@ -76,18 +88,34 @@ func (h *Host) Processes(ctx context.Context) (result []*Process, err error) { return result, err } -func (pr *Process) Host(ctx context.Context) (*Host, error) { - result, err := pr.Edges.HostOrErr() +func (hf *HostFile) Host(ctx context.Context) (*Host, error) { + result, err := hf.Edges.HostOrErr() + if IsNotLoaded(err) { + result, err = hf.QueryHost().Only(ctx) + } + return result, err +} + +func (hf *HostFile) Task(ctx context.Context) (*Task, error) { + result, err := hf.Edges.TaskOrErr() if IsNotLoaded(err) { - result, err = pr.QueryHost().Only(ctx) + result, err = hf.QueryTask().Only(ctx) } return result, err } -func (pr *Process) Task(ctx context.Context) (*Task, error) { - result, err := pr.Edges.TaskOrErr() +func (hp *HostProcess) Host(ctx context.Context) (*Host, error) { + result, err := hp.Edges.HostOrErr() if IsNotLoaded(err) { - result, err = pr.QueryTask().Only(ctx) + result, err = hp.QueryHost().Only(ctx) + } + return result, err +} + +func (hp *HostProcess) Task(ctx context.Context) (*Task, error) { + result, err := hp.Edges.TaskOrErr() + if IsNotLoaded(err) { + result, err = hp.QueryTask().Only(ctx) } return result, err } @@ -156,7 +184,19 @@ func (t *Task) Beacon(ctx context.Context) (*Beacon, error) { return result, err } -func (t *Task) ReportedProcesses(ctx context.Context) (result []*Process, err error) { +func (t *Task) ReportedFiles(ctx context.Context) (result []*HostFile, err error) { + if fc := graphql.GetFieldContext(ctx); fc != nil && fc.Field.Alias != "" { + result, err = t.NamedReportedFiles(graphql.GetFieldContext(ctx).Field.Alias) + } else { + result, err = t.Edges.ReportedFilesOrErr() + } + if IsNotLoaded(err) { + result, err = t.QueryReportedFiles().All(ctx) + } + return result, err +} + +func (t *Task) ReportedProcesses(ctx context.Context) (result []*HostProcess, err error) { if fc := graphql.GetFieldContext(ctx); fc != nil && fc.Field.Alias != "" { result, err = t.NamedReportedProcesses(graphql.GetFieldContext(ctx).Field.Alias) } else { diff --git a/tavern/internal/ent/gql_mutation_input.go b/tavern/internal/ent/gql_mutation_input.go index f82245cff..731c07cee 100644 --- a/tavern/internal/ent/gql_mutation_input.go +++ b/tavern/internal/ent/gql_mutation_input.go @@ -48,6 +48,9 @@ type UpdateHostInput struct { ClearBeacons bool AddBeaconIDs []int RemoveBeaconIDs []int + ClearFiles bool + AddFileIDs []int + RemoveFileIDs []int ClearProcesses bool AddProcessIDs []int RemoveProcessIDs []int @@ -82,6 +85,15 @@ func (i *UpdateHostInput) Mutate(m *HostMutation) { if v := i.RemoveBeaconIDs; len(v) > 0 { m.RemoveBeaconIDs(v...) } + if i.ClearFiles { + m.ClearFiles() + } + if v := i.AddFileIDs; len(v) > 0 { + m.AddFileIDs(v...) + } + if v := i.RemoveFileIDs; len(v) > 0 { + m.RemoveFileIDs(v...) + } if i.ClearProcesses { m.ClearProcesses() } diff --git a/tavern/internal/ent/gql_node.go b/tavern/internal/ent/gql_node.go index 0ee9cc249..f1f2d3aab 100644 --- a/tavern/internal/ent/gql_node.go +++ b/tavern/internal/ent/gql_node.go @@ -18,7 +18,8 @@ import ( "realm.pub/tavern/internal/ent/beacon" "realm.pub/tavern/internal/ent/file" "realm.pub/tavern/internal/ent/host" - "realm.pub/tavern/internal/ent/process" + "realm.pub/tavern/internal/ent/hostfile" + "realm.pub/tavern/internal/ent/hostprocess" "realm.pub/tavern/internal/ent/quest" "realm.pub/tavern/internal/ent/tag" "realm.pub/tavern/internal/ent/task" @@ -41,7 +42,10 @@ func (n *File) IsNode() {} func (n *Host) IsNode() {} // IsNode implements the Node interface check for GQLGen. -func (n *Process) IsNode() {} +func (n *HostFile) IsNode() {} + +// IsNode implements the Node interface check for GQLGen. +func (n *HostProcess) IsNode() {} // IsNode implements the Node interface check for GQLGen. func (n *Quest) IsNode() {} @@ -152,10 +156,22 @@ func (c *Client) noder(ctx context.Context, table string, id int) (Noder, error) return nil, err } return n, nil - case process.Table: - query := c.Process.Query(). - Where(process.ID(id)) - query, err := query.CollectFields(ctx, "Process") + case hostfile.Table: + query := c.HostFile.Query(). + Where(hostfile.ID(id)) + query, err := query.CollectFields(ctx, "HostFile") + if err != nil { + return nil, err + } + n, err := query.Only(ctx) + if err != nil { + return nil, err + } + return n, nil + case hostprocess.Table: + query := c.HostProcess.Query(). + Where(hostprocess.ID(id)) + query, err := query.CollectFields(ctx, "HostProcess") if err != nil { return nil, err } @@ -345,10 +361,26 @@ func (c *Client) noders(ctx context.Context, table string, ids []int) ([]Noder, *noder = node } } - case process.Table: - query := c.Process.Query(). - Where(process.IDIn(ids...)) - query, err := query.CollectFields(ctx, "Process") + case hostfile.Table: + query := c.HostFile.Query(). + Where(hostfile.IDIn(ids...)) + query, err := query.CollectFields(ctx, "HostFile") + if err != nil { + return nil, err + } + nodes, err := query.All(ctx) + if err != nil { + return nil, err + } + for _, node := range nodes { + for _, noder := range idmap[node.ID] { + *noder = node + } + } + case hostprocess.Table: + query := c.HostProcess.Query(). + Where(hostprocess.IDIn(ids...)) + query, err := query.CollectFields(ctx, "HostProcess") if err != nil { return nil, err } diff --git a/tavern/internal/ent/gql_pagination.go b/tavern/internal/ent/gql_pagination.go index a4058f3d6..153593e83 100644 --- a/tavern/internal/ent/gql_pagination.go +++ b/tavern/internal/ent/gql_pagination.go @@ -18,7 +18,8 @@ import ( "realm.pub/tavern/internal/ent/beacon" "realm.pub/tavern/internal/ent/file" "realm.pub/tavern/internal/ent/host" - "realm.pub/tavern/internal/ent/process" + "realm.pub/tavern/internal/ent/hostfile" + "realm.pub/tavern/internal/ent/hostprocess" "realm.pub/tavern/internal/ent/quest" "realm.pub/tavern/internal/ent/tag" "realm.pub/tavern/internal/ent/task" @@ -1129,20 +1130,20 @@ func (h *Host) ToEdge(order *HostOrder) *HostEdge { } } -// ProcessEdge is the edge representation of Process. -type ProcessEdge struct { - Node *Process `json:"node"` - Cursor Cursor `json:"cursor"` +// HostFileEdge is the edge representation of HostFile. +type HostFileEdge struct { + Node *HostFile `json:"node"` + Cursor Cursor `json:"cursor"` } -// ProcessConnection is the connection containing edges to Process. -type ProcessConnection struct { - Edges []*ProcessEdge `json:"edges"` - PageInfo PageInfo `json:"pageInfo"` - TotalCount int `json:"totalCount"` +// HostFileConnection is the connection containing edges to HostFile. +type HostFileConnection struct { + Edges []*HostFileEdge `json:"edges"` + PageInfo PageInfo `json:"pageInfo"` + TotalCount int `json:"totalCount"` } -func (c *ProcessConnection) build(nodes []*Process, pager *processPager, after *Cursor, first *int, before *Cursor, last *int) { +func (c *HostFileConnection) build(nodes []*HostFile, pager *hostfilePager, after *Cursor, first *int, before *Cursor, last *int) { c.PageInfo.HasNextPage = before != nil c.PageInfo.HasPreviousPage = after != nil if first != nil && *first+1 == len(nodes) { @@ -1152,21 +1153,21 @@ func (c *ProcessConnection) build(nodes []*Process, pager *processPager, after * c.PageInfo.HasPreviousPage = true nodes = nodes[:len(nodes)-1] } - var nodeAt func(int) *Process + var nodeAt func(int) *HostFile if last != nil { n := len(nodes) - 1 - nodeAt = func(i int) *Process { + nodeAt = func(i int) *HostFile { return nodes[n-i] } } else { - nodeAt = func(i int) *Process { + nodeAt = func(i int) *HostFile { return nodes[i] } } - c.Edges = make([]*ProcessEdge, len(nodes)) + c.Edges = make([]*HostFileEdge, len(nodes)) for i := range nodes { node := nodeAt(i) - c.Edges[i] = &ProcessEdge{ + c.Edges[i] = &HostFileEdge{ Node: node, Cursor: pager.toCursor(node), } @@ -1180,87 +1181,87 @@ func (c *ProcessConnection) build(nodes []*Process, pager *processPager, after * } } -// ProcessPaginateOption enables pagination customization. -type ProcessPaginateOption func(*processPager) error +// HostFilePaginateOption enables pagination customization. +type HostFilePaginateOption func(*hostfilePager) error -// WithProcessOrder configures pagination ordering. -func WithProcessOrder(order *ProcessOrder) ProcessPaginateOption { +// WithHostFileOrder configures pagination ordering. +func WithHostFileOrder(order *HostFileOrder) HostFilePaginateOption { if order == nil { - order = DefaultProcessOrder + order = DefaultHostFileOrder } o := *order - return func(pager *processPager) error { + return func(pager *hostfilePager) error { if err := o.Direction.Validate(); err != nil { return err } if o.Field == nil { - o.Field = DefaultProcessOrder.Field + o.Field = DefaultHostFileOrder.Field } pager.order = &o return nil } } -// WithProcessFilter configures pagination filter. -func WithProcessFilter(filter func(*ProcessQuery) (*ProcessQuery, error)) ProcessPaginateOption { - return func(pager *processPager) error { +// WithHostFileFilter configures pagination filter. +func WithHostFileFilter(filter func(*HostFileQuery) (*HostFileQuery, error)) HostFilePaginateOption { + return func(pager *hostfilePager) error { if filter == nil { - return errors.New("ProcessQuery filter cannot be nil") + return errors.New("HostFileQuery filter cannot be nil") } pager.filter = filter return nil } } -type processPager struct { +type hostfilePager struct { reverse bool - order *ProcessOrder - filter func(*ProcessQuery) (*ProcessQuery, error) + order *HostFileOrder + filter func(*HostFileQuery) (*HostFileQuery, error) } -func newProcessPager(opts []ProcessPaginateOption, reverse bool) (*processPager, error) { - pager := &processPager{reverse: reverse} +func newHostFilePager(opts []HostFilePaginateOption, reverse bool) (*hostfilePager, error) { + pager := &hostfilePager{reverse: reverse} for _, opt := range opts { if err := opt(pager); err != nil { return nil, err } } if pager.order == nil { - pager.order = DefaultProcessOrder + pager.order = DefaultHostFileOrder } return pager, nil } -func (p *processPager) applyFilter(query *ProcessQuery) (*ProcessQuery, error) { +func (p *hostfilePager) applyFilter(query *HostFileQuery) (*HostFileQuery, error) { if p.filter != nil { return p.filter(query) } return query, nil } -func (p *processPager) toCursor(pr *Process) Cursor { - return p.order.Field.toCursor(pr) +func (p *hostfilePager) toCursor(hf *HostFile) Cursor { + return p.order.Field.toCursor(hf) } -func (p *processPager) applyCursors(query *ProcessQuery, after, before *Cursor) (*ProcessQuery, error) { +func (p *hostfilePager) applyCursors(query *HostFileQuery, after, before *Cursor) (*HostFileQuery, error) { direction := p.order.Direction if p.reverse { direction = direction.Reverse() } - for _, predicate := range entgql.CursorsPredicate(after, before, DefaultProcessOrder.Field.column, p.order.Field.column, direction) { + for _, predicate := range entgql.CursorsPredicate(after, before, DefaultHostFileOrder.Field.column, p.order.Field.column, direction) { query = query.Where(predicate) } return query, nil } -func (p *processPager) applyOrder(query *ProcessQuery) *ProcessQuery { +func (p *hostfilePager) applyOrder(query *HostFileQuery) *HostFileQuery { direction := p.order.Direction if p.reverse { direction = direction.Reverse() } query = query.Order(p.order.Field.toTerm(direction.OrderTermOption())) - if p.order.Field != DefaultProcessOrder.Field { - query = query.Order(DefaultProcessOrder.Field.toTerm(direction.OrderTermOption())) + if p.order.Field != DefaultHostFileOrder.Field { + query = query.Order(DefaultHostFileOrder.Field.toTerm(direction.OrderTermOption())) } if len(query.ctx.Fields) > 0 { query.ctx.AppendFieldOnce(p.order.Field.column) @@ -1268,7 +1269,7 @@ func (p *processPager) applyOrder(query *ProcessQuery) *ProcessQuery { return query } -func (p *processPager) orderExpr(query *ProcessQuery) sql.Querier { +func (p *hostfilePager) orderExpr(query *HostFileQuery) sql.Querier { direction := p.order.Direction if p.reverse { direction = direction.Reverse() @@ -1278,33 +1279,33 @@ func (p *processPager) orderExpr(query *ProcessQuery) sql.Querier { } return sql.ExprFunc(func(b *sql.Builder) { b.Ident(p.order.Field.column).Pad().WriteString(string(direction)) - if p.order.Field != DefaultProcessOrder.Field { - b.Comma().Ident(DefaultProcessOrder.Field.column).Pad().WriteString(string(direction)) + if p.order.Field != DefaultHostFileOrder.Field { + b.Comma().Ident(DefaultHostFileOrder.Field.column).Pad().WriteString(string(direction)) } }) } -// Paginate executes the query and returns a relay based cursor connection to Process. -func (pr *ProcessQuery) Paginate( +// Paginate executes the query and returns a relay based cursor connection to HostFile. +func (hf *HostFileQuery) Paginate( ctx context.Context, after *Cursor, first *int, - before *Cursor, last *int, opts ...ProcessPaginateOption, -) (*ProcessConnection, error) { + before *Cursor, last *int, opts ...HostFilePaginateOption, +) (*HostFileConnection, error) { if err := validateFirstLast(first, last); err != nil { return nil, err } - pager, err := newProcessPager(opts, last != nil) + pager, err := newHostFilePager(opts, last != nil) if err != nil { return nil, err } - if pr, err = pager.applyFilter(pr); err != nil { + if hf, err = pager.applyFilter(hf); err != nil { return nil, err } - conn := &ProcessConnection{Edges: []*ProcessEdge{}} + conn := &HostFileConnection{Edges: []*HostFileEdge{}} ignoredEdges := !hasCollectedField(ctx, edgesField) if hasCollectedField(ctx, totalCountField) || hasCollectedField(ctx, pageInfoField) { hasPagination := after != nil || first != nil || before != nil || last != nil if hasPagination || ignoredEdges { - if conn.TotalCount, err = pr.Clone().Count(ctx); err != nil { + if conn.TotalCount, err = hf.Clone().Count(ctx); err != nil { return nil, err } conn.PageInfo.HasNextPage = first != nil && conn.TotalCount > 0 @@ -1314,19 +1315,19 @@ func (pr *ProcessQuery) Paginate( if ignoredEdges || (first != nil && *first == 0) || (last != nil && *last == 0) { return conn, nil } - if pr, err = pager.applyCursors(pr, after, before); err != nil { + if hf, err = pager.applyCursors(hf, after, before); err != nil { return nil, err } if limit := paginateLimit(first, last); limit != 0 { - pr.Limit(limit) + hf.Limit(limit) } if field := collectedField(ctx, edgesField, nodeField); field != nil { - if err := pr.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { + if err := hf.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { return nil, err } } - pr = pager.applyOrder(pr) - nodes, err := pr.All(ctx) + hf = pager.applyOrder(hf) + nodes, err := hf.All(ctx) if err != nil { return nil, err } @@ -1335,144 +1336,509 @@ func (pr *ProcessQuery) Paginate( } var ( - // ProcessOrderFieldCreatedAt orders Process by created_at. - ProcessOrderFieldCreatedAt = &ProcessOrderField{ - Value: func(pr *Process) (ent.Value, error) { - return pr.CreatedAt, nil - }, - column: process.FieldCreatedAt, - toTerm: process.ByCreatedAt, - toCursor: func(pr *Process) Cursor { + // HostFileOrderFieldCreatedAt orders HostFile by created_at. + HostFileOrderFieldCreatedAt = &HostFileOrderField{ + Value: func(hf *HostFile) (ent.Value, error) { + return hf.CreatedAt, nil + }, + column: hostfile.FieldCreatedAt, + toTerm: hostfile.ByCreatedAt, + toCursor: func(hf *HostFile) Cursor { return Cursor{ - ID: pr.ID, - Value: pr.CreatedAt, + ID: hf.ID, + Value: hf.CreatedAt, } }, } - // ProcessOrderFieldLastModifiedAt orders Process by last_modified_at. - ProcessOrderFieldLastModifiedAt = &ProcessOrderField{ - Value: func(pr *Process) (ent.Value, error) { - return pr.LastModifiedAt, nil + // HostFileOrderFieldLastModifiedAt orders HostFile by last_modified_at. + HostFileOrderFieldLastModifiedAt = &HostFileOrderField{ + Value: func(hf *HostFile) (ent.Value, error) { + return hf.LastModifiedAt, nil }, - column: process.FieldLastModifiedAt, - toTerm: process.ByLastModifiedAt, - toCursor: func(pr *Process) Cursor { + column: hostfile.FieldLastModifiedAt, + toTerm: hostfile.ByLastModifiedAt, + toCursor: func(hf *HostFile) Cursor { return Cursor{ - ID: pr.ID, - Value: pr.LastModifiedAt, + ID: hf.ID, + Value: hf.LastModifiedAt, } }, } - // ProcessOrderFieldPid orders Process by pid. - ProcessOrderFieldPid = &ProcessOrderField{ - Value: func(pr *Process) (ent.Value, error) { - return pr.Pid, nil + // HostFileOrderFieldPath orders HostFile by path. + HostFileOrderFieldPath = &HostFileOrderField{ + Value: func(hf *HostFile) (ent.Value, error) { + return hf.Path, nil }, - column: process.FieldPid, - toTerm: process.ByPid, - toCursor: func(pr *Process) Cursor { + column: hostfile.FieldPath, + toTerm: hostfile.ByPath, + toCursor: func(hf *HostFile) Cursor { return Cursor{ - ID: pr.ID, - Value: pr.Pid, + ID: hf.ID, + Value: hf.Path, } }, } - // ProcessOrderFieldName orders Process by name. - ProcessOrderFieldName = &ProcessOrderField{ - Value: func(pr *Process) (ent.Value, error) { - return pr.Name, nil + // HostFileOrderFieldSize orders HostFile by size. + HostFileOrderFieldSize = &HostFileOrderField{ + Value: func(hf *HostFile) (ent.Value, error) { + return hf.Size, nil }, - column: process.FieldName, - toTerm: process.ByName, - toCursor: func(pr *Process) Cursor { + column: hostfile.FieldSize, + toTerm: hostfile.BySize, + toCursor: func(hf *HostFile) Cursor { return Cursor{ - ID: pr.ID, - Value: pr.Name, + ID: hf.ID, + Value: hf.Size, } }, } ) // String implement fmt.Stringer interface. -func (f ProcessOrderField) String() string { +func (f HostFileOrderField) String() string { var str string switch f.column { - case ProcessOrderFieldCreatedAt.column: + case HostFileOrderFieldCreatedAt.column: str = "CREATED_AT" - case ProcessOrderFieldLastModifiedAt.column: + case HostFileOrderFieldLastModifiedAt.column: str = "LAST_MODIFIED_AT" - case ProcessOrderFieldPid.column: + case HostFileOrderFieldPath.column: + str = "NAME" + case HostFileOrderFieldSize.column: + str = "SIZE" + } + return str +} + +// MarshalGQL implements graphql.Marshaler interface. +func (f HostFileOrderField) MarshalGQL(w io.Writer) { + io.WriteString(w, strconv.Quote(f.String())) +} + +// UnmarshalGQL implements graphql.Unmarshaler interface. +func (f *HostFileOrderField) UnmarshalGQL(v interface{}) error { + str, ok := v.(string) + if !ok { + return fmt.Errorf("HostFileOrderField %T must be a string", v) + } + switch str { + case "CREATED_AT": + *f = *HostFileOrderFieldCreatedAt + case "LAST_MODIFIED_AT": + *f = *HostFileOrderFieldLastModifiedAt + case "NAME": + *f = *HostFileOrderFieldPath + case "SIZE": + *f = *HostFileOrderFieldSize + default: + return fmt.Errorf("%s is not a valid HostFileOrderField", str) + } + return nil +} + +// HostFileOrderField defines the ordering field of HostFile. +type HostFileOrderField struct { + // Value extracts the ordering value from the given HostFile. + Value func(*HostFile) (ent.Value, error) + column string // field or computed. + toTerm func(...sql.OrderTermOption) hostfile.OrderOption + toCursor func(*HostFile) Cursor +} + +// HostFileOrder defines the ordering of HostFile. +type HostFileOrder struct { + Direction OrderDirection `json:"direction"` + Field *HostFileOrderField `json:"field"` +} + +// DefaultHostFileOrder is the default ordering of HostFile. +var DefaultHostFileOrder = &HostFileOrder{ + Direction: entgql.OrderDirectionAsc, + Field: &HostFileOrderField{ + Value: func(hf *HostFile) (ent.Value, error) { + return hf.ID, nil + }, + column: hostfile.FieldID, + toTerm: hostfile.ByID, + toCursor: func(hf *HostFile) Cursor { + return Cursor{ID: hf.ID} + }, + }, +} + +// ToEdge converts HostFile into HostFileEdge. +func (hf *HostFile) ToEdge(order *HostFileOrder) *HostFileEdge { + if order == nil { + order = DefaultHostFileOrder + } + return &HostFileEdge{ + Node: hf, + Cursor: order.Field.toCursor(hf), + } +} + +// HostProcessEdge is the edge representation of HostProcess. +type HostProcessEdge struct { + Node *HostProcess `json:"node"` + Cursor Cursor `json:"cursor"` +} + +// HostProcessConnection is the connection containing edges to HostProcess. +type HostProcessConnection struct { + Edges []*HostProcessEdge `json:"edges"` + PageInfo PageInfo `json:"pageInfo"` + TotalCount int `json:"totalCount"` +} + +func (c *HostProcessConnection) build(nodes []*HostProcess, pager *hostprocessPager, after *Cursor, first *int, before *Cursor, last *int) { + c.PageInfo.HasNextPage = before != nil + c.PageInfo.HasPreviousPage = after != nil + if first != nil && *first+1 == len(nodes) { + c.PageInfo.HasNextPage = true + nodes = nodes[:len(nodes)-1] + } else if last != nil && *last+1 == len(nodes) { + c.PageInfo.HasPreviousPage = true + nodes = nodes[:len(nodes)-1] + } + var nodeAt func(int) *HostProcess + if last != nil { + n := len(nodes) - 1 + nodeAt = func(i int) *HostProcess { + return nodes[n-i] + } + } else { + nodeAt = func(i int) *HostProcess { + return nodes[i] + } + } + c.Edges = make([]*HostProcessEdge, len(nodes)) + for i := range nodes { + node := nodeAt(i) + c.Edges[i] = &HostProcessEdge{ + Node: node, + Cursor: pager.toCursor(node), + } + } + if l := len(c.Edges); l > 0 { + c.PageInfo.StartCursor = &c.Edges[0].Cursor + c.PageInfo.EndCursor = &c.Edges[l-1].Cursor + } + if c.TotalCount == 0 { + c.TotalCount = len(nodes) + } +} + +// HostProcessPaginateOption enables pagination customization. +type HostProcessPaginateOption func(*hostprocessPager) error + +// WithHostProcessOrder configures pagination ordering. +func WithHostProcessOrder(order *HostProcessOrder) HostProcessPaginateOption { + if order == nil { + order = DefaultHostProcessOrder + } + o := *order + return func(pager *hostprocessPager) error { + if err := o.Direction.Validate(); err != nil { + return err + } + if o.Field == nil { + o.Field = DefaultHostProcessOrder.Field + } + pager.order = &o + return nil + } +} + +// WithHostProcessFilter configures pagination filter. +func WithHostProcessFilter(filter func(*HostProcessQuery) (*HostProcessQuery, error)) HostProcessPaginateOption { + return func(pager *hostprocessPager) error { + if filter == nil { + return errors.New("HostProcessQuery filter cannot be nil") + } + pager.filter = filter + return nil + } +} + +type hostprocessPager struct { + reverse bool + order *HostProcessOrder + filter func(*HostProcessQuery) (*HostProcessQuery, error) +} + +func newHostProcessPager(opts []HostProcessPaginateOption, reverse bool) (*hostprocessPager, error) { + pager := &hostprocessPager{reverse: reverse} + for _, opt := range opts { + if err := opt(pager); err != nil { + return nil, err + } + } + if pager.order == nil { + pager.order = DefaultHostProcessOrder + } + return pager, nil +} + +func (p *hostprocessPager) applyFilter(query *HostProcessQuery) (*HostProcessQuery, error) { + if p.filter != nil { + return p.filter(query) + } + return query, nil +} + +func (p *hostprocessPager) toCursor(hp *HostProcess) Cursor { + return p.order.Field.toCursor(hp) +} + +func (p *hostprocessPager) applyCursors(query *HostProcessQuery, after, before *Cursor) (*HostProcessQuery, error) { + direction := p.order.Direction + if p.reverse { + direction = direction.Reverse() + } + for _, predicate := range entgql.CursorsPredicate(after, before, DefaultHostProcessOrder.Field.column, p.order.Field.column, direction) { + query = query.Where(predicate) + } + return query, nil +} + +func (p *hostprocessPager) applyOrder(query *HostProcessQuery) *HostProcessQuery { + direction := p.order.Direction + if p.reverse { + direction = direction.Reverse() + } + query = query.Order(p.order.Field.toTerm(direction.OrderTermOption())) + if p.order.Field != DefaultHostProcessOrder.Field { + query = query.Order(DefaultHostProcessOrder.Field.toTerm(direction.OrderTermOption())) + } + if len(query.ctx.Fields) > 0 { + query.ctx.AppendFieldOnce(p.order.Field.column) + } + return query +} + +func (p *hostprocessPager) orderExpr(query *HostProcessQuery) sql.Querier { + direction := p.order.Direction + if p.reverse { + direction = direction.Reverse() + } + if len(query.ctx.Fields) > 0 { + query.ctx.AppendFieldOnce(p.order.Field.column) + } + return sql.ExprFunc(func(b *sql.Builder) { + b.Ident(p.order.Field.column).Pad().WriteString(string(direction)) + if p.order.Field != DefaultHostProcessOrder.Field { + b.Comma().Ident(DefaultHostProcessOrder.Field.column).Pad().WriteString(string(direction)) + } + }) +} + +// Paginate executes the query and returns a relay based cursor connection to HostProcess. +func (hp *HostProcessQuery) Paginate( + ctx context.Context, after *Cursor, first *int, + before *Cursor, last *int, opts ...HostProcessPaginateOption, +) (*HostProcessConnection, error) { + if err := validateFirstLast(first, last); err != nil { + return nil, err + } + pager, err := newHostProcessPager(opts, last != nil) + if err != nil { + return nil, err + } + if hp, err = pager.applyFilter(hp); err != nil { + return nil, err + } + conn := &HostProcessConnection{Edges: []*HostProcessEdge{}} + ignoredEdges := !hasCollectedField(ctx, edgesField) + if hasCollectedField(ctx, totalCountField) || hasCollectedField(ctx, pageInfoField) { + hasPagination := after != nil || first != nil || before != nil || last != nil + if hasPagination || ignoredEdges { + if conn.TotalCount, err = hp.Clone().Count(ctx); err != nil { + return nil, err + } + conn.PageInfo.HasNextPage = first != nil && conn.TotalCount > 0 + conn.PageInfo.HasPreviousPage = last != nil && conn.TotalCount > 0 + } + } + if ignoredEdges || (first != nil && *first == 0) || (last != nil && *last == 0) { + return conn, nil + } + if hp, err = pager.applyCursors(hp, after, before); err != nil { + return nil, err + } + if limit := paginateLimit(first, last); limit != 0 { + hp.Limit(limit) + } + if field := collectedField(ctx, edgesField, nodeField); field != nil { + if err := hp.collectField(ctx, graphql.GetOperationContext(ctx), *field, []string{edgesField, nodeField}); err != nil { + return nil, err + } + } + hp = pager.applyOrder(hp) + nodes, err := hp.All(ctx) + if err != nil { + return nil, err + } + conn.build(nodes, pager, after, first, before, last) + return conn, nil +} + +var ( + // HostProcessOrderFieldCreatedAt orders HostProcess by created_at. + HostProcessOrderFieldCreatedAt = &HostProcessOrderField{ + Value: func(hp *HostProcess) (ent.Value, error) { + return hp.CreatedAt, nil + }, + column: hostprocess.FieldCreatedAt, + toTerm: hostprocess.ByCreatedAt, + toCursor: func(hp *HostProcess) Cursor { + return Cursor{ + ID: hp.ID, + Value: hp.CreatedAt, + } + }, + } + // HostProcessOrderFieldLastModifiedAt orders HostProcess by last_modified_at. + HostProcessOrderFieldLastModifiedAt = &HostProcessOrderField{ + Value: func(hp *HostProcess) (ent.Value, error) { + return hp.LastModifiedAt, nil + }, + column: hostprocess.FieldLastModifiedAt, + toTerm: hostprocess.ByLastModifiedAt, + toCursor: func(hp *HostProcess) Cursor { + return Cursor{ + ID: hp.ID, + Value: hp.LastModifiedAt, + } + }, + } + // HostProcessOrderFieldPid orders HostProcess by pid. + HostProcessOrderFieldPid = &HostProcessOrderField{ + Value: func(hp *HostProcess) (ent.Value, error) { + return hp.Pid, nil + }, + column: hostprocess.FieldPid, + toTerm: hostprocess.ByPid, + toCursor: func(hp *HostProcess) Cursor { + return Cursor{ + ID: hp.ID, + Value: hp.Pid, + } + }, + } + // HostProcessOrderFieldPpid orders HostProcess by ppid. + HostProcessOrderFieldPpid = &HostProcessOrderField{ + Value: func(hp *HostProcess) (ent.Value, error) { + return hp.Ppid, nil + }, + column: hostprocess.FieldPpid, + toTerm: hostprocess.ByPpid, + toCursor: func(hp *HostProcess) Cursor { + return Cursor{ + ID: hp.ID, + Value: hp.Ppid, + } + }, + } + // HostProcessOrderFieldName orders HostProcess by name. + HostProcessOrderFieldName = &HostProcessOrderField{ + Value: func(hp *HostProcess) (ent.Value, error) { + return hp.Name, nil + }, + column: hostprocess.FieldName, + toTerm: hostprocess.ByName, + toCursor: func(hp *HostProcess) Cursor { + return Cursor{ + ID: hp.ID, + Value: hp.Name, + } + }, + } +) + +// String implement fmt.Stringer interface. +func (f HostProcessOrderField) String() string { + var str string + switch f.column { + case HostProcessOrderFieldCreatedAt.column: + str = "CREATED_AT" + case HostProcessOrderFieldLastModifiedAt.column: + str = "LAST_MODIFIED_AT" + case HostProcessOrderFieldPid.column: str = "PROCESS_ID" - case ProcessOrderFieldName.column: + case HostProcessOrderFieldPpid.column: + str = "PARENT_PROCESS_ID" + case HostProcessOrderFieldName.column: str = "NAME" } return str } // MarshalGQL implements graphql.Marshaler interface. -func (f ProcessOrderField) MarshalGQL(w io.Writer) { +func (f HostProcessOrderField) MarshalGQL(w io.Writer) { io.WriteString(w, strconv.Quote(f.String())) } // UnmarshalGQL implements graphql.Unmarshaler interface. -func (f *ProcessOrderField) UnmarshalGQL(v interface{}) error { +func (f *HostProcessOrderField) UnmarshalGQL(v interface{}) error { str, ok := v.(string) if !ok { - return fmt.Errorf("ProcessOrderField %T must be a string", v) + return fmt.Errorf("HostProcessOrderField %T must be a string", v) } switch str { case "CREATED_AT": - *f = *ProcessOrderFieldCreatedAt + *f = *HostProcessOrderFieldCreatedAt case "LAST_MODIFIED_AT": - *f = *ProcessOrderFieldLastModifiedAt + *f = *HostProcessOrderFieldLastModifiedAt case "PROCESS_ID": - *f = *ProcessOrderFieldPid + *f = *HostProcessOrderFieldPid + case "PARENT_PROCESS_ID": + *f = *HostProcessOrderFieldPpid case "NAME": - *f = *ProcessOrderFieldName + *f = *HostProcessOrderFieldName default: - return fmt.Errorf("%s is not a valid ProcessOrderField", str) + return fmt.Errorf("%s is not a valid HostProcessOrderField", str) } return nil } -// ProcessOrderField defines the ordering field of Process. -type ProcessOrderField struct { - // Value extracts the ordering value from the given Process. - Value func(*Process) (ent.Value, error) +// HostProcessOrderField defines the ordering field of HostProcess. +type HostProcessOrderField struct { + // Value extracts the ordering value from the given HostProcess. + Value func(*HostProcess) (ent.Value, error) column string // field or computed. - toTerm func(...sql.OrderTermOption) process.OrderOption - toCursor func(*Process) Cursor + toTerm func(...sql.OrderTermOption) hostprocess.OrderOption + toCursor func(*HostProcess) Cursor } -// ProcessOrder defines the ordering of Process. -type ProcessOrder struct { - Direction OrderDirection `json:"direction"` - Field *ProcessOrderField `json:"field"` +// HostProcessOrder defines the ordering of HostProcess. +type HostProcessOrder struct { + Direction OrderDirection `json:"direction"` + Field *HostProcessOrderField `json:"field"` } -// DefaultProcessOrder is the default ordering of Process. -var DefaultProcessOrder = &ProcessOrder{ +// DefaultHostProcessOrder is the default ordering of HostProcess. +var DefaultHostProcessOrder = &HostProcessOrder{ Direction: entgql.OrderDirectionAsc, - Field: &ProcessOrderField{ - Value: func(pr *Process) (ent.Value, error) { - return pr.ID, nil + Field: &HostProcessOrderField{ + Value: func(hp *HostProcess) (ent.Value, error) { + return hp.ID, nil }, - column: process.FieldID, - toTerm: process.ByID, - toCursor: func(pr *Process) Cursor { - return Cursor{ID: pr.ID} + column: hostprocess.FieldID, + toTerm: hostprocess.ByID, + toCursor: func(hp *HostProcess) Cursor { + return Cursor{ID: hp.ID} }, }, } -// ToEdge converts Process into ProcessEdge. -func (pr *Process) ToEdge(order *ProcessOrder) *ProcessEdge { +// ToEdge converts HostProcess into HostProcessEdge. +func (hp *HostProcess) ToEdge(order *HostProcessOrder) *HostProcessEdge { if order == nil { - order = DefaultProcessOrder + order = DefaultHostProcessOrder } - return &ProcessEdge{ - Node: pr, - Cursor: order.Field.toCursor(pr), + return &HostProcessEdge{ + Node: hp, + Cursor: order.Field.toCursor(hp), } } diff --git a/tavern/internal/ent/gql_where_input.go b/tavern/internal/ent/gql_where_input.go index e41f865fe..e2c95f701 100644 --- a/tavern/internal/ent/gql_where_input.go +++ b/tavern/internal/ent/gql_where_input.go @@ -7,11 +7,13 @@ import ( "fmt" "time" + "realm.pub/tavern/internal/c2/c2pb" "realm.pub/tavern/internal/ent/beacon" "realm.pub/tavern/internal/ent/file" "realm.pub/tavern/internal/ent/host" + "realm.pub/tavern/internal/ent/hostfile" + "realm.pub/tavern/internal/ent/hostprocess" "realm.pub/tavern/internal/ent/predicate" - "realm.pub/tavern/internal/ent/process" "realm.pub/tavern/internal/ent/quest" "realm.pub/tavern/internal/ent/tag" "realm.pub/tavern/internal/ent/task" @@ -1014,10 +1016,10 @@ type HostWhereInput struct { PrimaryIPContainsFold *string `json:"primaryIPContainsFold,omitempty"` // "platform" field predicates. - Platform *host.Platform `json:"platform,omitempty"` - PlatformNEQ *host.Platform `json:"platformNEQ,omitempty"` - PlatformIn []host.Platform `json:"platformIn,omitempty"` - PlatformNotIn []host.Platform `json:"platformNotIn,omitempty"` + Platform *c2pb.Host_Platform `json:"platform,omitempty"` + PlatformNEQ *c2pb.Host_Platform `json:"platformNEQ,omitempty"` + PlatformIn []c2pb.Host_Platform `json:"platformIn,omitempty"` + PlatformNotIn []c2pb.Host_Platform `json:"platformNotIn,omitempty"` // "last_seen_at" field predicates. LastSeenAt *time.Time `json:"lastSeenAt,omitempty"` @@ -1039,9 +1041,13 @@ type HostWhereInput struct { HasBeacons *bool `json:"hasBeacons,omitempty"` HasBeaconsWith []*BeaconWhereInput `json:"hasBeaconsWith,omitempty"` + // "files" edge predicates. + HasFiles *bool `json:"hasFiles,omitempty"` + HasFilesWith []*HostFileWhereInput `json:"hasFilesWith,omitempty"` + // "processes" edge predicates. - HasProcesses *bool `json:"hasProcesses,omitempty"` - HasProcessesWith []*ProcessWhereInput `json:"hasProcessesWith,omitempty"` + HasProcesses *bool `json:"hasProcesses,omitempty"` + HasProcessesWith []*HostProcessWhereInput `json:"hasProcessesWith,omitempty"` } // AddPredicates adds custom predicates to the where input to be used during the filtering phase. @@ -1395,6 +1401,24 @@ func (i *HostWhereInput) P() (predicate.Host, error) { } predicates = append(predicates, host.HasBeaconsWith(with...)) } + if i.HasFiles != nil { + p := host.HasFiles() + if !*i.HasFiles { + p = host.Not(p) + } + predicates = append(predicates, p) + } + if len(i.HasFilesWith) > 0 { + with := make([]predicate.HostFile, 0, len(i.HasFilesWith)) + for _, w := range i.HasFilesWith { + p, err := w.P() + if err != nil { + return nil, fmt.Errorf("%w: field 'HasFilesWith'", err) + } + with = append(with, p) + } + predicates = append(predicates, host.HasFilesWith(with...)) + } if i.HasProcesses != nil { p := host.HasProcesses() if !*i.HasProcesses { @@ -1403,7 +1427,7 @@ func (i *HostWhereInput) P() (predicate.Host, error) { predicates = append(predicates, p) } if len(i.HasProcessesWith) > 0 { - with := make([]predicate.Process, 0, len(i.HasProcessesWith)) + with := make([]predicate.HostProcess, 0, len(i.HasProcessesWith)) for _, w := range i.HasProcessesWith { p, err := w.P() if err != nil { @@ -1423,12 +1447,584 @@ func (i *HostWhereInput) P() (predicate.Host, error) { } } -// ProcessWhereInput represents a where input for filtering Process queries. -type ProcessWhereInput struct { - Predicates []predicate.Process `json:"-"` - Not *ProcessWhereInput `json:"not,omitempty"` - Or []*ProcessWhereInput `json:"or,omitempty"` - And []*ProcessWhereInput `json:"and,omitempty"` +// HostFileWhereInput represents a where input for filtering HostFile queries. +type HostFileWhereInput struct { + Predicates []predicate.HostFile `json:"-"` + Not *HostFileWhereInput `json:"not,omitempty"` + Or []*HostFileWhereInput `json:"or,omitempty"` + And []*HostFileWhereInput `json:"and,omitempty"` + + // "id" field predicates. + ID *int `json:"id,omitempty"` + IDNEQ *int `json:"idNEQ,omitempty"` + IDIn []int `json:"idIn,omitempty"` + IDNotIn []int `json:"idNotIn,omitempty"` + IDGT *int `json:"idGT,omitempty"` + IDGTE *int `json:"idGTE,omitempty"` + IDLT *int `json:"idLT,omitempty"` + IDLTE *int `json:"idLTE,omitempty"` + + // "created_at" field predicates. + CreatedAt *time.Time `json:"createdAt,omitempty"` + CreatedAtNEQ *time.Time `json:"createdAtNEQ,omitempty"` + CreatedAtIn []time.Time `json:"createdAtIn,omitempty"` + CreatedAtNotIn []time.Time `json:"createdAtNotIn,omitempty"` + CreatedAtGT *time.Time `json:"createdAtGT,omitempty"` + CreatedAtGTE *time.Time `json:"createdAtGTE,omitempty"` + CreatedAtLT *time.Time `json:"createdAtLT,omitempty"` + CreatedAtLTE *time.Time `json:"createdAtLTE,omitempty"` + + // "last_modified_at" field predicates. + LastModifiedAt *time.Time `json:"lastModifiedAt,omitempty"` + LastModifiedAtNEQ *time.Time `json:"lastModifiedAtNEQ,omitempty"` + LastModifiedAtIn []time.Time `json:"lastModifiedAtIn,omitempty"` + LastModifiedAtNotIn []time.Time `json:"lastModifiedAtNotIn,omitempty"` + LastModifiedAtGT *time.Time `json:"lastModifiedAtGT,omitempty"` + LastModifiedAtGTE *time.Time `json:"lastModifiedAtGTE,omitempty"` + LastModifiedAtLT *time.Time `json:"lastModifiedAtLT,omitempty"` + LastModifiedAtLTE *time.Time `json:"lastModifiedAtLTE,omitempty"` + + // "path" field predicates. + Path *string `json:"path,omitempty"` + PathNEQ *string `json:"pathNEQ,omitempty"` + PathIn []string `json:"pathIn,omitempty"` + PathNotIn []string `json:"pathNotIn,omitempty"` + PathGT *string `json:"pathGT,omitempty"` + PathGTE *string `json:"pathGTE,omitempty"` + PathLT *string `json:"pathLT,omitempty"` + PathLTE *string `json:"pathLTE,omitempty"` + PathContains *string `json:"pathContains,omitempty"` + PathHasPrefix *string `json:"pathHasPrefix,omitempty"` + PathHasSuffix *string `json:"pathHasSuffix,omitempty"` + PathEqualFold *string `json:"pathEqualFold,omitempty"` + PathContainsFold *string `json:"pathContainsFold,omitempty"` + + // "owner" field predicates. + Owner *string `json:"owner,omitempty"` + OwnerNEQ *string `json:"ownerNEQ,omitempty"` + OwnerIn []string `json:"ownerIn,omitempty"` + OwnerNotIn []string `json:"ownerNotIn,omitempty"` + OwnerGT *string `json:"ownerGT,omitempty"` + OwnerGTE *string `json:"ownerGTE,omitempty"` + OwnerLT *string `json:"ownerLT,omitempty"` + OwnerLTE *string `json:"ownerLTE,omitempty"` + OwnerContains *string `json:"ownerContains,omitempty"` + OwnerHasPrefix *string `json:"ownerHasPrefix,omitempty"` + OwnerHasSuffix *string `json:"ownerHasSuffix,omitempty"` + OwnerIsNil bool `json:"ownerIsNil,omitempty"` + OwnerNotNil bool `json:"ownerNotNil,omitempty"` + OwnerEqualFold *string `json:"ownerEqualFold,omitempty"` + OwnerContainsFold *string `json:"ownerContainsFold,omitempty"` + + // "group" field predicates. + Group *string `json:"group,omitempty"` + GroupNEQ *string `json:"groupNEQ,omitempty"` + GroupIn []string `json:"groupIn,omitempty"` + GroupNotIn []string `json:"groupNotIn,omitempty"` + GroupGT *string `json:"groupGT,omitempty"` + GroupGTE *string `json:"groupGTE,omitempty"` + GroupLT *string `json:"groupLT,omitempty"` + GroupLTE *string `json:"groupLTE,omitempty"` + GroupContains *string `json:"groupContains,omitempty"` + GroupHasPrefix *string `json:"groupHasPrefix,omitempty"` + GroupHasSuffix *string `json:"groupHasSuffix,omitempty"` + GroupIsNil bool `json:"groupIsNil,omitempty"` + GroupNotNil bool `json:"groupNotNil,omitempty"` + GroupEqualFold *string `json:"groupEqualFold,omitempty"` + GroupContainsFold *string `json:"groupContainsFold,omitempty"` + + // "permissions" field predicates. + Permissions *string `json:"permissions,omitempty"` + PermissionsNEQ *string `json:"permissionsNEQ,omitempty"` + PermissionsIn []string `json:"permissionsIn,omitempty"` + PermissionsNotIn []string `json:"permissionsNotIn,omitempty"` + PermissionsGT *string `json:"permissionsGT,omitempty"` + PermissionsGTE *string `json:"permissionsGTE,omitempty"` + PermissionsLT *string `json:"permissionsLT,omitempty"` + PermissionsLTE *string `json:"permissionsLTE,omitempty"` + PermissionsContains *string `json:"permissionsContains,omitempty"` + PermissionsHasPrefix *string `json:"permissionsHasPrefix,omitempty"` + PermissionsHasSuffix *string `json:"permissionsHasSuffix,omitempty"` + PermissionsIsNil bool `json:"permissionsIsNil,omitempty"` + PermissionsNotNil bool `json:"permissionsNotNil,omitempty"` + PermissionsEqualFold *string `json:"permissionsEqualFold,omitempty"` + PermissionsContainsFold *string `json:"permissionsContainsFold,omitempty"` + + // "size" field predicates. + Size *int `json:"size,omitempty"` + SizeNEQ *int `json:"sizeNEQ,omitempty"` + SizeIn []int `json:"sizeIn,omitempty"` + SizeNotIn []int `json:"sizeNotIn,omitempty"` + SizeGT *int `json:"sizeGT,omitempty"` + SizeGTE *int `json:"sizeGTE,omitempty"` + SizeLT *int `json:"sizeLT,omitempty"` + SizeLTE *int `json:"sizeLTE,omitempty"` + + // "hash" field predicates. + Hash *string `json:"hash,omitempty"` + HashNEQ *string `json:"hashNEQ,omitempty"` + HashIn []string `json:"hashIn,omitempty"` + HashNotIn []string `json:"hashNotIn,omitempty"` + HashGT *string `json:"hashGT,omitempty"` + HashGTE *string `json:"hashGTE,omitempty"` + HashLT *string `json:"hashLT,omitempty"` + HashLTE *string `json:"hashLTE,omitempty"` + HashContains *string `json:"hashContains,omitempty"` + HashHasPrefix *string `json:"hashHasPrefix,omitempty"` + HashHasSuffix *string `json:"hashHasSuffix,omitempty"` + HashIsNil bool `json:"hashIsNil,omitempty"` + HashNotNil bool `json:"hashNotNil,omitempty"` + HashEqualFold *string `json:"hashEqualFold,omitempty"` + HashContainsFold *string `json:"hashContainsFold,omitempty"` + + // "host" edge predicates. + HasHost *bool `json:"hasHost,omitempty"` + HasHostWith []*HostWhereInput `json:"hasHostWith,omitempty"` + + // "task" edge predicates. + HasTask *bool `json:"hasTask,omitempty"` + HasTaskWith []*TaskWhereInput `json:"hasTaskWith,omitempty"` +} + +// AddPredicates adds custom predicates to the where input to be used during the filtering phase. +func (i *HostFileWhereInput) AddPredicates(predicates ...predicate.HostFile) { + i.Predicates = append(i.Predicates, predicates...) +} + +// Filter applies the HostFileWhereInput filter on the HostFileQuery builder. +func (i *HostFileWhereInput) Filter(q *HostFileQuery) (*HostFileQuery, error) { + if i == nil { + return q, nil + } + p, err := i.P() + if err != nil { + if err == ErrEmptyHostFileWhereInput { + return q, nil + } + return nil, err + } + return q.Where(p), nil +} + +// ErrEmptyHostFileWhereInput is returned in case the HostFileWhereInput is empty. +var ErrEmptyHostFileWhereInput = errors.New("ent: empty predicate HostFileWhereInput") + +// P returns a predicate for filtering hostfiles. +// An error is returned if the input is empty or invalid. +func (i *HostFileWhereInput) P() (predicate.HostFile, error) { + var predicates []predicate.HostFile + if i.Not != nil { + p, err := i.Not.P() + if err != nil { + return nil, fmt.Errorf("%w: field 'not'", err) + } + predicates = append(predicates, hostfile.Not(p)) + } + switch n := len(i.Or); { + case n == 1: + p, err := i.Or[0].P() + if err != nil { + return nil, fmt.Errorf("%w: field 'or'", err) + } + predicates = append(predicates, p) + case n > 1: + or := make([]predicate.HostFile, 0, n) + for _, w := range i.Or { + p, err := w.P() + if err != nil { + return nil, fmt.Errorf("%w: field 'or'", err) + } + or = append(or, p) + } + predicates = append(predicates, hostfile.Or(or...)) + } + switch n := len(i.And); { + case n == 1: + p, err := i.And[0].P() + if err != nil { + return nil, fmt.Errorf("%w: field 'and'", err) + } + predicates = append(predicates, p) + case n > 1: + and := make([]predicate.HostFile, 0, n) + for _, w := range i.And { + p, err := w.P() + if err != nil { + return nil, fmt.Errorf("%w: field 'and'", err) + } + and = append(and, p) + } + predicates = append(predicates, hostfile.And(and...)) + } + predicates = append(predicates, i.Predicates...) + if i.ID != nil { + predicates = append(predicates, hostfile.IDEQ(*i.ID)) + } + if i.IDNEQ != nil { + predicates = append(predicates, hostfile.IDNEQ(*i.IDNEQ)) + } + if len(i.IDIn) > 0 { + predicates = append(predicates, hostfile.IDIn(i.IDIn...)) + } + if len(i.IDNotIn) > 0 { + predicates = append(predicates, hostfile.IDNotIn(i.IDNotIn...)) + } + if i.IDGT != nil { + predicates = append(predicates, hostfile.IDGT(*i.IDGT)) + } + if i.IDGTE != nil { + predicates = append(predicates, hostfile.IDGTE(*i.IDGTE)) + } + if i.IDLT != nil { + predicates = append(predicates, hostfile.IDLT(*i.IDLT)) + } + if i.IDLTE != nil { + predicates = append(predicates, hostfile.IDLTE(*i.IDLTE)) + } + if i.CreatedAt != nil { + predicates = append(predicates, hostfile.CreatedAtEQ(*i.CreatedAt)) + } + if i.CreatedAtNEQ != nil { + predicates = append(predicates, hostfile.CreatedAtNEQ(*i.CreatedAtNEQ)) + } + if len(i.CreatedAtIn) > 0 { + predicates = append(predicates, hostfile.CreatedAtIn(i.CreatedAtIn...)) + } + if len(i.CreatedAtNotIn) > 0 { + predicates = append(predicates, hostfile.CreatedAtNotIn(i.CreatedAtNotIn...)) + } + if i.CreatedAtGT != nil { + predicates = append(predicates, hostfile.CreatedAtGT(*i.CreatedAtGT)) + } + if i.CreatedAtGTE != nil { + predicates = append(predicates, hostfile.CreatedAtGTE(*i.CreatedAtGTE)) + } + if i.CreatedAtLT != nil { + predicates = append(predicates, hostfile.CreatedAtLT(*i.CreatedAtLT)) + } + if i.CreatedAtLTE != nil { + predicates = append(predicates, hostfile.CreatedAtLTE(*i.CreatedAtLTE)) + } + if i.LastModifiedAt != nil { + predicates = append(predicates, hostfile.LastModifiedAtEQ(*i.LastModifiedAt)) + } + if i.LastModifiedAtNEQ != nil { + predicates = append(predicates, hostfile.LastModifiedAtNEQ(*i.LastModifiedAtNEQ)) + } + if len(i.LastModifiedAtIn) > 0 { + predicates = append(predicates, hostfile.LastModifiedAtIn(i.LastModifiedAtIn...)) + } + if len(i.LastModifiedAtNotIn) > 0 { + predicates = append(predicates, hostfile.LastModifiedAtNotIn(i.LastModifiedAtNotIn...)) + } + if i.LastModifiedAtGT != nil { + predicates = append(predicates, hostfile.LastModifiedAtGT(*i.LastModifiedAtGT)) + } + if i.LastModifiedAtGTE != nil { + predicates = append(predicates, hostfile.LastModifiedAtGTE(*i.LastModifiedAtGTE)) + } + if i.LastModifiedAtLT != nil { + predicates = append(predicates, hostfile.LastModifiedAtLT(*i.LastModifiedAtLT)) + } + if i.LastModifiedAtLTE != nil { + predicates = append(predicates, hostfile.LastModifiedAtLTE(*i.LastModifiedAtLTE)) + } + if i.Path != nil { + predicates = append(predicates, hostfile.PathEQ(*i.Path)) + } + if i.PathNEQ != nil { + predicates = append(predicates, hostfile.PathNEQ(*i.PathNEQ)) + } + if len(i.PathIn) > 0 { + predicates = append(predicates, hostfile.PathIn(i.PathIn...)) + } + if len(i.PathNotIn) > 0 { + predicates = append(predicates, hostfile.PathNotIn(i.PathNotIn...)) + } + if i.PathGT != nil { + predicates = append(predicates, hostfile.PathGT(*i.PathGT)) + } + if i.PathGTE != nil { + predicates = append(predicates, hostfile.PathGTE(*i.PathGTE)) + } + if i.PathLT != nil { + predicates = append(predicates, hostfile.PathLT(*i.PathLT)) + } + if i.PathLTE != nil { + predicates = append(predicates, hostfile.PathLTE(*i.PathLTE)) + } + if i.PathContains != nil { + predicates = append(predicates, hostfile.PathContains(*i.PathContains)) + } + if i.PathHasPrefix != nil { + predicates = append(predicates, hostfile.PathHasPrefix(*i.PathHasPrefix)) + } + if i.PathHasSuffix != nil { + predicates = append(predicates, hostfile.PathHasSuffix(*i.PathHasSuffix)) + } + if i.PathEqualFold != nil { + predicates = append(predicates, hostfile.PathEqualFold(*i.PathEqualFold)) + } + if i.PathContainsFold != nil { + predicates = append(predicates, hostfile.PathContainsFold(*i.PathContainsFold)) + } + if i.Owner != nil { + predicates = append(predicates, hostfile.OwnerEQ(*i.Owner)) + } + if i.OwnerNEQ != nil { + predicates = append(predicates, hostfile.OwnerNEQ(*i.OwnerNEQ)) + } + if len(i.OwnerIn) > 0 { + predicates = append(predicates, hostfile.OwnerIn(i.OwnerIn...)) + } + if len(i.OwnerNotIn) > 0 { + predicates = append(predicates, hostfile.OwnerNotIn(i.OwnerNotIn...)) + } + if i.OwnerGT != nil { + predicates = append(predicates, hostfile.OwnerGT(*i.OwnerGT)) + } + if i.OwnerGTE != nil { + predicates = append(predicates, hostfile.OwnerGTE(*i.OwnerGTE)) + } + if i.OwnerLT != nil { + predicates = append(predicates, hostfile.OwnerLT(*i.OwnerLT)) + } + if i.OwnerLTE != nil { + predicates = append(predicates, hostfile.OwnerLTE(*i.OwnerLTE)) + } + if i.OwnerContains != nil { + predicates = append(predicates, hostfile.OwnerContains(*i.OwnerContains)) + } + if i.OwnerHasPrefix != nil { + predicates = append(predicates, hostfile.OwnerHasPrefix(*i.OwnerHasPrefix)) + } + if i.OwnerHasSuffix != nil { + predicates = append(predicates, hostfile.OwnerHasSuffix(*i.OwnerHasSuffix)) + } + if i.OwnerIsNil { + predicates = append(predicates, hostfile.OwnerIsNil()) + } + if i.OwnerNotNil { + predicates = append(predicates, hostfile.OwnerNotNil()) + } + if i.OwnerEqualFold != nil { + predicates = append(predicates, hostfile.OwnerEqualFold(*i.OwnerEqualFold)) + } + if i.OwnerContainsFold != nil { + predicates = append(predicates, hostfile.OwnerContainsFold(*i.OwnerContainsFold)) + } + if i.Group != nil { + predicates = append(predicates, hostfile.GroupEQ(*i.Group)) + } + if i.GroupNEQ != nil { + predicates = append(predicates, hostfile.GroupNEQ(*i.GroupNEQ)) + } + if len(i.GroupIn) > 0 { + predicates = append(predicates, hostfile.GroupIn(i.GroupIn...)) + } + if len(i.GroupNotIn) > 0 { + predicates = append(predicates, hostfile.GroupNotIn(i.GroupNotIn...)) + } + if i.GroupGT != nil { + predicates = append(predicates, hostfile.GroupGT(*i.GroupGT)) + } + if i.GroupGTE != nil { + predicates = append(predicates, hostfile.GroupGTE(*i.GroupGTE)) + } + if i.GroupLT != nil { + predicates = append(predicates, hostfile.GroupLT(*i.GroupLT)) + } + if i.GroupLTE != nil { + predicates = append(predicates, hostfile.GroupLTE(*i.GroupLTE)) + } + if i.GroupContains != nil { + predicates = append(predicates, hostfile.GroupContains(*i.GroupContains)) + } + if i.GroupHasPrefix != nil { + predicates = append(predicates, hostfile.GroupHasPrefix(*i.GroupHasPrefix)) + } + if i.GroupHasSuffix != nil { + predicates = append(predicates, hostfile.GroupHasSuffix(*i.GroupHasSuffix)) + } + if i.GroupIsNil { + predicates = append(predicates, hostfile.GroupIsNil()) + } + if i.GroupNotNil { + predicates = append(predicates, hostfile.GroupNotNil()) + } + if i.GroupEqualFold != nil { + predicates = append(predicates, hostfile.GroupEqualFold(*i.GroupEqualFold)) + } + if i.GroupContainsFold != nil { + predicates = append(predicates, hostfile.GroupContainsFold(*i.GroupContainsFold)) + } + if i.Permissions != nil { + predicates = append(predicates, hostfile.PermissionsEQ(*i.Permissions)) + } + if i.PermissionsNEQ != nil { + predicates = append(predicates, hostfile.PermissionsNEQ(*i.PermissionsNEQ)) + } + if len(i.PermissionsIn) > 0 { + predicates = append(predicates, hostfile.PermissionsIn(i.PermissionsIn...)) + } + if len(i.PermissionsNotIn) > 0 { + predicates = append(predicates, hostfile.PermissionsNotIn(i.PermissionsNotIn...)) + } + if i.PermissionsGT != nil { + predicates = append(predicates, hostfile.PermissionsGT(*i.PermissionsGT)) + } + if i.PermissionsGTE != nil { + predicates = append(predicates, hostfile.PermissionsGTE(*i.PermissionsGTE)) + } + if i.PermissionsLT != nil { + predicates = append(predicates, hostfile.PermissionsLT(*i.PermissionsLT)) + } + if i.PermissionsLTE != nil { + predicates = append(predicates, hostfile.PermissionsLTE(*i.PermissionsLTE)) + } + if i.PermissionsContains != nil { + predicates = append(predicates, hostfile.PermissionsContains(*i.PermissionsContains)) + } + if i.PermissionsHasPrefix != nil { + predicates = append(predicates, hostfile.PermissionsHasPrefix(*i.PermissionsHasPrefix)) + } + if i.PermissionsHasSuffix != nil { + predicates = append(predicates, hostfile.PermissionsHasSuffix(*i.PermissionsHasSuffix)) + } + if i.PermissionsIsNil { + predicates = append(predicates, hostfile.PermissionsIsNil()) + } + if i.PermissionsNotNil { + predicates = append(predicates, hostfile.PermissionsNotNil()) + } + if i.PermissionsEqualFold != nil { + predicates = append(predicates, hostfile.PermissionsEqualFold(*i.PermissionsEqualFold)) + } + if i.PermissionsContainsFold != nil { + predicates = append(predicates, hostfile.PermissionsContainsFold(*i.PermissionsContainsFold)) + } + if i.Size != nil { + predicates = append(predicates, hostfile.SizeEQ(*i.Size)) + } + if i.SizeNEQ != nil { + predicates = append(predicates, hostfile.SizeNEQ(*i.SizeNEQ)) + } + if len(i.SizeIn) > 0 { + predicates = append(predicates, hostfile.SizeIn(i.SizeIn...)) + } + if len(i.SizeNotIn) > 0 { + predicates = append(predicates, hostfile.SizeNotIn(i.SizeNotIn...)) + } + if i.SizeGT != nil { + predicates = append(predicates, hostfile.SizeGT(*i.SizeGT)) + } + if i.SizeGTE != nil { + predicates = append(predicates, hostfile.SizeGTE(*i.SizeGTE)) + } + if i.SizeLT != nil { + predicates = append(predicates, hostfile.SizeLT(*i.SizeLT)) + } + if i.SizeLTE != nil { + predicates = append(predicates, hostfile.SizeLTE(*i.SizeLTE)) + } + if i.Hash != nil { + predicates = append(predicates, hostfile.HashEQ(*i.Hash)) + } + if i.HashNEQ != nil { + predicates = append(predicates, hostfile.HashNEQ(*i.HashNEQ)) + } + if len(i.HashIn) > 0 { + predicates = append(predicates, hostfile.HashIn(i.HashIn...)) + } + if len(i.HashNotIn) > 0 { + predicates = append(predicates, hostfile.HashNotIn(i.HashNotIn...)) + } + if i.HashGT != nil { + predicates = append(predicates, hostfile.HashGT(*i.HashGT)) + } + if i.HashGTE != nil { + predicates = append(predicates, hostfile.HashGTE(*i.HashGTE)) + } + if i.HashLT != nil { + predicates = append(predicates, hostfile.HashLT(*i.HashLT)) + } + if i.HashLTE != nil { + predicates = append(predicates, hostfile.HashLTE(*i.HashLTE)) + } + if i.HashContains != nil { + predicates = append(predicates, hostfile.HashContains(*i.HashContains)) + } + if i.HashHasPrefix != nil { + predicates = append(predicates, hostfile.HashHasPrefix(*i.HashHasPrefix)) + } + if i.HashHasSuffix != nil { + predicates = append(predicates, hostfile.HashHasSuffix(*i.HashHasSuffix)) + } + if i.HashIsNil { + predicates = append(predicates, hostfile.HashIsNil()) + } + if i.HashNotNil { + predicates = append(predicates, hostfile.HashNotNil()) + } + if i.HashEqualFold != nil { + predicates = append(predicates, hostfile.HashEqualFold(*i.HashEqualFold)) + } + if i.HashContainsFold != nil { + predicates = append(predicates, hostfile.HashContainsFold(*i.HashContainsFold)) + } + + if i.HasHost != nil { + p := hostfile.HasHost() + if !*i.HasHost { + p = hostfile.Not(p) + } + predicates = append(predicates, p) + } + if len(i.HasHostWith) > 0 { + with := make([]predicate.Host, 0, len(i.HasHostWith)) + for _, w := range i.HasHostWith { + p, err := w.P() + if err != nil { + return nil, fmt.Errorf("%w: field 'HasHostWith'", err) + } + with = append(with, p) + } + predicates = append(predicates, hostfile.HasHostWith(with...)) + } + if i.HasTask != nil { + p := hostfile.HasTask() + if !*i.HasTask { + p = hostfile.Not(p) + } + predicates = append(predicates, p) + } + if len(i.HasTaskWith) > 0 { + with := make([]predicate.Task, 0, len(i.HasTaskWith)) + for _, w := range i.HasTaskWith { + p, err := w.P() + if err != nil { + return nil, fmt.Errorf("%w: field 'HasTaskWith'", err) + } + with = append(with, p) + } + predicates = append(predicates, hostfile.HasTaskWith(with...)) + } + switch len(predicates) { + case 0: + return nil, ErrEmptyHostFileWhereInput + case 1: + return predicates[0], nil + default: + return hostfile.And(predicates...), nil + } +} + +// HostProcessWhereInput represents a where input for filtering HostProcess queries. +type HostProcessWhereInput struct { + Predicates []predicate.HostProcess `json:"-"` + Not *HostProcessWhereInput `json:"not,omitempty"` + Or []*HostProcessWhereInput `json:"or,omitempty"` + And []*HostProcessWhereInput `json:"and,omitempty"` // "id" field predicates. ID *int `json:"id,omitempty"` @@ -1470,6 +2066,16 @@ type ProcessWhereInput struct { PidLT *uint64 `json:"pidLT,omitempty"` PidLTE *uint64 `json:"pidLTE,omitempty"` + // "ppid" field predicates. + Ppid *uint64 `json:"ppid,omitempty"` + PpidNEQ *uint64 `json:"ppidNEQ,omitempty"` + PpidIn []uint64 `json:"ppidIn,omitempty"` + PpidNotIn []uint64 `json:"ppidNotIn,omitempty"` + PpidGT *uint64 `json:"ppidGT,omitempty"` + PpidGTE *uint64 `json:"ppidGTE,omitempty"` + PpidLT *uint64 `json:"ppidLT,omitempty"` + PpidLTE *uint64 `json:"ppidLTE,omitempty"` + // "name" field predicates. Name *string `json:"name,omitempty"` NameNEQ *string `json:"nameNEQ,omitempty"` @@ -1500,6 +2106,80 @@ type ProcessWhereInput struct { PrincipalEqualFold *string `json:"principalEqualFold,omitempty"` PrincipalContainsFold *string `json:"principalContainsFold,omitempty"` + // "path" field predicates. + Path *string `json:"path,omitempty"` + PathNEQ *string `json:"pathNEQ,omitempty"` + PathIn []string `json:"pathIn,omitempty"` + PathNotIn []string `json:"pathNotIn,omitempty"` + PathGT *string `json:"pathGT,omitempty"` + PathGTE *string `json:"pathGTE,omitempty"` + PathLT *string `json:"pathLT,omitempty"` + PathLTE *string `json:"pathLTE,omitempty"` + PathContains *string `json:"pathContains,omitempty"` + PathHasPrefix *string `json:"pathHasPrefix,omitempty"` + PathHasSuffix *string `json:"pathHasSuffix,omitempty"` + PathIsNil bool `json:"pathIsNil,omitempty"` + PathNotNil bool `json:"pathNotNil,omitempty"` + PathEqualFold *string `json:"pathEqualFold,omitempty"` + PathContainsFold *string `json:"pathContainsFold,omitempty"` + + // "cmd" field predicates. + Cmd *string `json:"cmd,omitempty"` + CmdNEQ *string `json:"cmdNEQ,omitempty"` + CmdIn []string `json:"cmdIn,omitempty"` + CmdNotIn []string `json:"cmdNotIn,omitempty"` + CmdGT *string `json:"cmdGT,omitempty"` + CmdGTE *string `json:"cmdGTE,omitempty"` + CmdLT *string `json:"cmdLT,omitempty"` + CmdLTE *string `json:"cmdLTE,omitempty"` + CmdContains *string `json:"cmdContains,omitempty"` + CmdHasPrefix *string `json:"cmdHasPrefix,omitempty"` + CmdHasSuffix *string `json:"cmdHasSuffix,omitempty"` + CmdIsNil bool `json:"cmdIsNil,omitempty"` + CmdNotNil bool `json:"cmdNotNil,omitempty"` + CmdEqualFold *string `json:"cmdEqualFold,omitempty"` + CmdContainsFold *string `json:"cmdContainsFold,omitempty"` + + // "env" field predicates. + Env *string `json:"env,omitempty"` + EnvNEQ *string `json:"envNEQ,omitempty"` + EnvIn []string `json:"envIn,omitempty"` + EnvNotIn []string `json:"envNotIn,omitempty"` + EnvGT *string `json:"envGT,omitempty"` + EnvGTE *string `json:"envGTE,omitempty"` + EnvLT *string `json:"envLT,omitempty"` + EnvLTE *string `json:"envLTE,omitempty"` + EnvContains *string `json:"envContains,omitempty"` + EnvHasPrefix *string `json:"envHasPrefix,omitempty"` + EnvHasSuffix *string `json:"envHasSuffix,omitempty"` + EnvIsNil bool `json:"envIsNil,omitempty"` + EnvNotNil bool `json:"envNotNil,omitempty"` + EnvEqualFold *string `json:"envEqualFold,omitempty"` + EnvContainsFold *string `json:"envContainsFold,omitempty"` + + // "cwd" field predicates. + Cwd *string `json:"cwd,omitempty"` + CwdNEQ *string `json:"cwdNEQ,omitempty"` + CwdIn []string `json:"cwdIn,omitempty"` + CwdNotIn []string `json:"cwdNotIn,omitempty"` + CwdGT *string `json:"cwdGT,omitempty"` + CwdGTE *string `json:"cwdGTE,omitempty"` + CwdLT *string `json:"cwdLT,omitempty"` + CwdLTE *string `json:"cwdLTE,omitempty"` + CwdContains *string `json:"cwdContains,omitempty"` + CwdHasPrefix *string `json:"cwdHasPrefix,omitempty"` + CwdHasSuffix *string `json:"cwdHasSuffix,omitempty"` + CwdIsNil bool `json:"cwdIsNil,omitempty"` + CwdNotNil bool `json:"cwdNotNil,omitempty"` + CwdEqualFold *string `json:"cwdEqualFold,omitempty"` + CwdContainsFold *string `json:"cwdContainsFold,omitempty"` + + // "status" field predicates. + Status *c2pb.Process_Status `json:"status,omitempty"` + StatusNEQ *c2pb.Process_Status `json:"statusNEQ,omitempty"` + StatusIn []c2pb.Process_Status `json:"statusIn,omitempty"` + StatusNotIn []c2pb.Process_Status `json:"statusNotIn,omitempty"` + // "host" edge predicates. HasHost *bool `json:"hasHost,omitempty"` HasHostWith []*HostWhereInput `json:"hasHostWith,omitempty"` @@ -1510,18 +2190,18 @@ type ProcessWhereInput struct { } // AddPredicates adds custom predicates to the where input to be used during the filtering phase. -func (i *ProcessWhereInput) AddPredicates(predicates ...predicate.Process) { +func (i *HostProcessWhereInput) AddPredicates(predicates ...predicate.HostProcess) { i.Predicates = append(i.Predicates, predicates...) } -// Filter applies the ProcessWhereInput filter on the ProcessQuery builder. -func (i *ProcessWhereInput) Filter(q *ProcessQuery) (*ProcessQuery, error) { +// Filter applies the HostProcessWhereInput filter on the HostProcessQuery builder. +func (i *HostProcessWhereInput) Filter(q *HostProcessQuery) (*HostProcessQuery, error) { if i == nil { return q, nil } p, err := i.P() if err != nil { - if err == ErrEmptyProcessWhereInput { + if err == ErrEmptyHostProcessWhereInput { return q, nil } return nil, err @@ -1529,19 +2209,19 @@ func (i *ProcessWhereInput) Filter(q *ProcessQuery) (*ProcessQuery, error) { return q.Where(p), nil } -// ErrEmptyProcessWhereInput is returned in case the ProcessWhereInput is empty. -var ErrEmptyProcessWhereInput = errors.New("ent: empty predicate ProcessWhereInput") +// ErrEmptyHostProcessWhereInput is returned in case the HostProcessWhereInput is empty. +var ErrEmptyHostProcessWhereInput = errors.New("ent: empty predicate HostProcessWhereInput") -// P returns a predicate for filtering processes. +// P returns a predicate for filtering hostprocesses. // An error is returned if the input is empty or invalid. -func (i *ProcessWhereInput) P() (predicate.Process, error) { - var predicates []predicate.Process +func (i *HostProcessWhereInput) P() (predicate.HostProcess, error) { + var predicates []predicate.HostProcess if i.Not != nil { p, err := i.Not.P() if err != nil { return nil, fmt.Errorf("%w: field 'not'", err) } - predicates = append(predicates, process.Not(p)) + predicates = append(predicates, hostprocess.Not(p)) } switch n := len(i.Or); { case n == 1: @@ -1551,7 +2231,7 @@ func (i *ProcessWhereInput) P() (predicate.Process, error) { } predicates = append(predicates, p) case n > 1: - or := make([]predicate.Process, 0, n) + or := make([]predicate.HostProcess, 0, n) for _, w := range i.Or { p, err := w.P() if err != nil { @@ -1559,7 +2239,7 @@ func (i *ProcessWhereInput) P() (predicate.Process, error) { } or = append(or, p) } - predicates = append(predicates, process.Or(or...)) + predicates = append(predicates, hostprocess.Or(or...)) } switch n := len(i.And); { case n == 1: @@ -1569,7 +2249,7 @@ func (i *ProcessWhereInput) P() (predicate.Process, error) { } predicates = append(predicates, p) case n > 1: - and := make([]predicate.Process, 0, n) + and := make([]predicate.HostProcess, 0, n) for _, w := range i.And { p, err := w.P() if err != nil { @@ -1577,188 +2257,404 @@ func (i *ProcessWhereInput) P() (predicate.Process, error) { } and = append(and, p) } - predicates = append(predicates, process.And(and...)) + predicates = append(predicates, hostprocess.And(and...)) } predicates = append(predicates, i.Predicates...) if i.ID != nil { - predicates = append(predicates, process.IDEQ(*i.ID)) + predicates = append(predicates, hostprocess.IDEQ(*i.ID)) } if i.IDNEQ != nil { - predicates = append(predicates, process.IDNEQ(*i.IDNEQ)) + predicates = append(predicates, hostprocess.IDNEQ(*i.IDNEQ)) } if len(i.IDIn) > 0 { - predicates = append(predicates, process.IDIn(i.IDIn...)) + predicates = append(predicates, hostprocess.IDIn(i.IDIn...)) } if len(i.IDNotIn) > 0 { - predicates = append(predicates, process.IDNotIn(i.IDNotIn...)) + predicates = append(predicates, hostprocess.IDNotIn(i.IDNotIn...)) } if i.IDGT != nil { - predicates = append(predicates, process.IDGT(*i.IDGT)) + predicates = append(predicates, hostprocess.IDGT(*i.IDGT)) } if i.IDGTE != nil { - predicates = append(predicates, process.IDGTE(*i.IDGTE)) + predicates = append(predicates, hostprocess.IDGTE(*i.IDGTE)) } if i.IDLT != nil { - predicates = append(predicates, process.IDLT(*i.IDLT)) + predicates = append(predicates, hostprocess.IDLT(*i.IDLT)) } if i.IDLTE != nil { - predicates = append(predicates, process.IDLTE(*i.IDLTE)) + predicates = append(predicates, hostprocess.IDLTE(*i.IDLTE)) } if i.CreatedAt != nil { - predicates = append(predicates, process.CreatedAtEQ(*i.CreatedAt)) + predicates = append(predicates, hostprocess.CreatedAtEQ(*i.CreatedAt)) } if i.CreatedAtNEQ != nil { - predicates = append(predicates, process.CreatedAtNEQ(*i.CreatedAtNEQ)) + predicates = append(predicates, hostprocess.CreatedAtNEQ(*i.CreatedAtNEQ)) } if len(i.CreatedAtIn) > 0 { - predicates = append(predicates, process.CreatedAtIn(i.CreatedAtIn...)) + predicates = append(predicates, hostprocess.CreatedAtIn(i.CreatedAtIn...)) } if len(i.CreatedAtNotIn) > 0 { - predicates = append(predicates, process.CreatedAtNotIn(i.CreatedAtNotIn...)) + predicates = append(predicates, hostprocess.CreatedAtNotIn(i.CreatedAtNotIn...)) } if i.CreatedAtGT != nil { - predicates = append(predicates, process.CreatedAtGT(*i.CreatedAtGT)) + predicates = append(predicates, hostprocess.CreatedAtGT(*i.CreatedAtGT)) } if i.CreatedAtGTE != nil { - predicates = append(predicates, process.CreatedAtGTE(*i.CreatedAtGTE)) + predicates = append(predicates, hostprocess.CreatedAtGTE(*i.CreatedAtGTE)) } if i.CreatedAtLT != nil { - predicates = append(predicates, process.CreatedAtLT(*i.CreatedAtLT)) + predicates = append(predicates, hostprocess.CreatedAtLT(*i.CreatedAtLT)) } if i.CreatedAtLTE != nil { - predicates = append(predicates, process.CreatedAtLTE(*i.CreatedAtLTE)) + predicates = append(predicates, hostprocess.CreatedAtLTE(*i.CreatedAtLTE)) } if i.LastModifiedAt != nil { - predicates = append(predicates, process.LastModifiedAtEQ(*i.LastModifiedAt)) + predicates = append(predicates, hostprocess.LastModifiedAtEQ(*i.LastModifiedAt)) } if i.LastModifiedAtNEQ != nil { - predicates = append(predicates, process.LastModifiedAtNEQ(*i.LastModifiedAtNEQ)) + predicates = append(predicates, hostprocess.LastModifiedAtNEQ(*i.LastModifiedAtNEQ)) } if len(i.LastModifiedAtIn) > 0 { - predicates = append(predicates, process.LastModifiedAtIn(i.LastModifiedAtIn...)) + predicates = append(predicates, hostprocess.LastModifiedAtIn(i.LastModifiedAtIn...)) } if len(i.LastModifiedAtNotIn) > 0 { - predicates = append(predicates, process.LastModifiedAtNotIn(i.LastModifiedAtNotIn...)) + predicates = append(predicates, hostprocess.LastModifiedAtNotIn(i.LastModifiedAtNotIn...)) } if i.LastModifiedAtGT != nil { - predicates = append(predicates, process.LastModifiedAtGT(*i.LastModifiedAtGT)) + predicates = append(predicates, hostprocess.LastModifiedAtGT(*i.LastModifiedAtGT)) } if i.LastModifiedAtGTE != nil { - predicates = append(predicates, process.LastModifiedAtGTE(*i.LastModifiedAtGTE)) + predicates = append(predicates, hostprocess.LastModifiedAtGTE(*i.LastModifiedAtGTE)) } if i.LastModifiedAtLT != nil { - predicates = append(predicates, process.LastModifiedAtLT(*i.LastModifiedAtLT)) + predicates = append(predicates, hostprocess.LastModifiedAtLT(*i.LastModifiedAtLT)) } if i.LastModifiedAtLTE != nil { - predicates = append(predicates, process.LastModifiedAtLTE(*i.LastModifiedAtLTE)) + predicates = append(predicates, hostprocess.LastModifiedAtLTE(*i.LastModifiedAtLTE)) } if i.Pid != nil { - predicates = append(predicates, process.PidEQ(*i.Pid)) + predicates = append(predicates, hostprocess.PidEQ(*i.Pid)) } if i.PidNEQ != nil { - predicates = append(predicates, process.PidNEQ(*i.PidNEQ)) + predicates = append(predicates, hostprocess.PidNEQ(*i.PidNEQ)) } if len(i.PidIn) > 0 { - predicates = append(predicates, process.PidIn(i.PidIn...)) + predicates = append(predicates, hostprocess.PidIn(i.PidIn...)) } if len(i.PidNotIn) > 0 { - predicates = append(predicates, process.PidNotIn(i.PidNotIn...)) + predicates = append(predicates, hostprocess.PidNotIn(i.PidNotIn...)) } if i.PidGT != nil { - predicates = append(predicates, process.PidGT(*i.PidGT)) + predicates = append(predicates, hostprocess.PidGT(*i.PidGT)) } if i.PidGTE != nil { - predicates = append(predicates, process.PidGTE(*i.PidGTE)) + predicates = append(predicates, hostprocess.PidGTE(*i.PidGTE)) } if i.PidLT != nil { - predicates = append(predicates, process.PidLT(*i.PidLT)) + predicates = append(predicates, hostprocess.PidLT(*i.PidLT)) } if i.PidLTE != nil { - predicates = append(predicates, process.PidLTE(*i.PidLTE)) + predicates = append(predicates, hostprocess.PidLTE(*i.PidLTE)) + } + if i.Ppid != nil { + predicates = append(predicates, hostprocess.PpidEQ(*i.Ppid)) + } + if i.PpidNEQ != nil { + predicates = append(predicates, hostprocess.PpidNEQ(*i.PpidNEQ)) + } + if len(i.PpidIn) > 0 { + predicates = append(predicates, hostprocess.PpidIn(i.PpidIn...)) + } + if len(i.PpidNotIn) > 0 { + predicates = append(predicates, hostprocess.PpidNotIn(i.PpidNotIn...)) + } + if i.PpidGT != nil { + predicates = append(predicates, hostprocess.PpidGT(*i.PpidGT)) + } + if i.PpidGTE != nil { + predicates = append(predicates, hostprocess.PpidGTE(*i.PpidGTE)) + } + if i.PpidLT != nil { + predicates = append(predicates, hostprocess.PpidLT(*i.PpidLT)) + } + if i.PpidLTE != nil { + predicates = append(predicates, hostprocess.PpidLTE(*i.PpidLTE)) } if i.Name != nil { - predicates = append(predicates, process.NameEQ(*i.Name)) + predicates = append(predicates, hostprocess.NameEQ(*i.Name)) } if i.NameNEQ != nil { - predicates = append(predicates, process.NameNEQ(*i.NameNEQ)) + predicates = append(predicates, hostprocess.NameNEQ(*i.NameNEQ)) } if len(i.NameIn) > 0 { - predicates = append(predicates, process.NameIn(i.NameIn...)) + predicates = append(predicates, hostprocess.NameIn(i.NameIn...)) } if len(i.NameNotIn) > 0 { - predicates = append(predicates, process.NameNotIn(i.NameNotIn...)) + predicates = append(predicates, hostprocess.NameNotIn(i.NameNotIn...)) } if i.NameGT != nil { - predicates = append(predicates, process.NameGT(*i.NameGT)) + predicates = append(predicates, hostprocess.NameGT(*i.NameGT)) } if i.NameGTE != nil { - predicates = append(predicates, process.NameGTE(*i.NameGTE)) + predicates = append(predicates, hostprocess.NameGTE(*i.NameGTE)) } if i.NameLT != nil { - predicates = append(predicates, process.NameLT(*i.NameLT)) + predicates = append(predicates, hostprocess.NameLT(*i.NameLT)) } if i.NameLTE != nil { - predicates = append(predicates, process.NameLTE(*i.NameLTE)) + predicates = append(predicates, hostprocess.NameLTE(*i.NameLTE)) } if i.NameContains != nil { - predicates = append(predicates, process.NameContains(*i.NameContains)) + predicates = append(predicates, hostprocess.NameContains(*i.NameContains)) } if i.NameHasPrefix != nil { - predicates = append(predicates, process.NameHasPrefix(*i.NameHasPrefix)) + predicates = append(predicates, hostprocess.NameHasPrefix(*i.NameHasPrefix)) } if i.NameHasSuffix != nil { - predicates = append(predicates, process.NameHasSuffix(*i.NameHasSuffix)) + predicates = append(predicates, hostprocess.NameHasSuffix(*i.NameHasSuffix)) } if i.NameEqualFold != nil { - predicates = append(predicates, process.NameEqualFold(*i.NameEqualFold)) + predicates = append(predicates, hostprocess.NameEqualFold(*i.NameEqualFold)) } if i.NameContainsFold != nil { - predicates = append(predicates, process.NameContainsFold(*i.NameContainsFold)) + predicates = append(predicates, hostprocess.NameContainsFold(*i.NameContainsFold)) } if i.Principal != nil { - predicates = append(predicates, process.PrincipalEQ(*i.Principal)) + predicates = append(predicates, hostprocess.PrincipalEQ(*i.Principal)) } if i.PrincipalNEQ != nil { - predicates = append(predicates, process.PrincipalNEQ(*i.PrincipalNEQ)) + predicates = append(predicates, hostprocess.PrincipalNEQ(*i.PrincipalNEQ)) } if len(i.PrincipalIn) > 0 { - predicates = append(predicates, process.PrincipalIn(i.PrincipalIn...)) + predicates = append(predicates, hostprocess.PrincipalIn(i.PrincipalIn...)) } if len(i.PrincipalNotIn) > 0 { - predicates = append(predicates, process.PrincipalNotIn(i.PrincipalNotIn...)) + predicates = append(predicates, hostprocess.PrincipalNotIn(i.PrincipalNotIn...)) } if i.PrincipalGT != nil { - predicates = append(predicates, process.PrincipalGT(*i.PrincipalGT)) + predicates = append(predicates, hostprocess.PrincipalGT(*i.PrincipalGT)) } if i.PrincipalGTE != nil { - predicates = append(predicates, process.PrincipalGTE(*i.PrincipalGTE)) + predicates = append(predicates, hostprocess.PrincipalGTE(*i.PrincipalGTE)) } if i.PrincipalLT != nil { - predicates = append(predicates, process.PrincipalLT(*i.PrincipalLT)) + predicates = append(predicates, hostprocess.PrincipalLT(*i.PrincipalLT)) } if i.PrincipalLTE != nil { - predicates = append(predicates, process.PrincipalLTE(*i.PrincipalLTE)) + predicates = append(predicates, hostprocess.PrincipalLTE(*i.PrincipalLTE)) } if i.PrincipalContains != nil { - predicates = append(predicates, process.PrincipalContains(*i.PrincipalContains)) + predicates = append(predicates, hostprocess.PrincipalContains(*i.PrincipalContains)) } if i.PrincipalHasPrefix != nil { - predicates = append(predicates, process.PrincipalHasPrefix(*i.PrincipalHasPrefix)) + predicates = append(predicates, hostprocess.PrincipalHasPrefix(*i.PrincipalHasPrefix)) } if i.PrincipalHasSuffix != nil { - predicates = append(predicates, process.PrincipalHasSuffix(*i.PrincipalHasSuffix)) + predicates = append(predicates, hostprocess.PrincipalHasSuffix(*i.PrincipalHasSuffix)) } if i.PrincipalEqualFold != nil { - predicates = append(predicates, process.PrincipalEqualFold(*i.PrincipalEqualFold)) + predicates = append(predicates, hostprocess.PrincipalEqualFold(*i.PrincipalEqualFold)) } if i.PrincipalContainsFold != nil { - predicates = append(predicates, process.PrincipalContainsFold(*i.PrincipalContainsFold)) + predicates = append(predicates, hostprocess.PrincipalContainsFold(*i.PrincipalContainsFold)) + } + if i.Path != nil { + predicates = append(predicates, hostprocess.PathEQ(*i.Path)) + } + if i.PathNEQ != nil { + predicates = append(predicates, hostprocess.PathNEQ(*i.PathNEQ)) + } + if len(i.PathIn) > 0 { + predicates = append(predicates, hostprocess.PathIn(i.PathIn...)) + } + if len(i.PathNotIn) > 0 { + predicates = append(predicates, hostprocess.PathNotIn(i.PathNotIn...)) + } + if i.PathGT != nil { + predicates = append(predicates, hostprocess.PathGT(*i.PathGT)) + } + if i.PathGTE != nil { + predicates = append(predicates, hostprocess.PathGTE(*i.PathGTE)) + } + if i.PathLT != nil { + predicates = append(predicates, hostprocess.PathLT(*i.PathLT)) + } + if i.PathLTE != nil { + predicates = append(predicates, hostprocess.PathLTE(*i.PathLTE)) + } + if i.PathContains != nil { + predicates = append(predicates, hostprocess.PathContains(*i.PathContains)) + } + if i.PathHasPrefix != nil { + predicates = append(predicates, hostprocess.PathHasPrefix(*i.PathHasPrefix)) + } + if i.PathHasSuffix != nil { + predicates = append(predicates, hostprocess.PathHasSuffix(*i.PathHasSuffix)) + } + if i.PathIsNil { + predicates = append(predicates, hostprocess.PathIsNil()) + } + if i.PathNotNil { + predicates = append(predicates, hostprocess.PathNotNil()) + } + if i.PathEqualFold != nil { + predicates = append(predicates, hostprocess.PathEqualFold(*i.PathEqualFold)) + } + if i.PathContainsFold != nil { + predicates = append(predicates, hostprocess.PathContainsFold(*i.PathContainsFold)) + } + if i.Cmd != nil { + predicates = append(predicates, hostprocess.CmdEQ(*i.Cmd)) + } + if i.CmdNEQ != nil { + predicates = append(predicates, hostprocess.CmdNEQ(*i.CmdNEQ)) + } + if len(i.CmdIn) > 0 { + predicates = append(predicates, hostprocess.CmdIn(i.CmdIn...)) + } + if len(i.CmdNotIn) > 0 { + predicates = append(predicates, hostprocess.CmdNotIn(i.CmdNotIn...)) + } + if i.CmdGT != nil { + predicates = append(predicates, hostprocess.CmdGT(*i.CmdGT)) + } + if i.CmdGTE != nil { + predicates = append(predicates, hostprocess.CmdGTE(*i.CmdGTE)) + } + if i.CmdLT != nil { + predicates = append(predicates, hostprocess.CmdLT(*i.CmdLT)) + } + if i.CmdLTE != nil { + predicates = append(predicates, hostprocess.CmdLTE(*i.CmdLTE)) + } + if i.CmdContains != nil { + predicates = append(predicates, hostprocess.CmdContains(*i.CmdContains)) + } + if i.CmdHasPrefix != nil { + predicates = append(predicates, hostprocess.CmdHasPrefix(*i.CmdHasPrefix)) + } + if i.CmdHasSuffix != nil { + predicates = append(predicates, hostprocess.CmdHasSuffix(*i.CmdHasSuffix)) + } + if i.CmdIsNil { + predicates = append(predicates, hostprocess.CmdIsNil()) + } + if i.CmdNotNil { + predicates = append(predicates, hostprocess.CmdNotNil()) + } + if i.CmdEqualFold != nil { + predicates = append(predicates, hostprocess.CmdEqualFold(*i.CmdEqualFold)) + } + if i.CmdContainsFold != nil { + predicates = append(predicates, hostprocess.CmdContainsFold(*i.CmdContainsFold)) + } + if i.Env != nil { + predicates = append(predicates, hostprocess.EnvEQ(*i.Env)) + } + if i.EnvNEQ != nil { + predicates = append(predicates, hostprocess.EnvNEQ(*i.EnvNEQ)) + } + if len(i.EnvIn) > 0 { + predicates = append(predicates, hostprocess.EnvIn(i.EnvIn...)) + } + if len(i.EnvNotIn) > 0 { + predicates = append(predicates, hostprocess.EnvNotIn(i.EnvNotIn...)) + } + if i.EnvGT != nil { + predicates = append(predicates, hostprocess.EnvGT(*i.EnvGT)) + } + if i.EnvGTE != nil { + predicates = append(predicates, hostprocess.EnvGTE(*i.EnvGTE)) + } + if i.EnvLT != nil { + predicates = append(predicates, hostprocess.EnvLT(*i.EnvLT)) + } + if i.EnvLTE != nil { + predicates = append(predicates, hostprocess.EnvLTE(*i.EnvLTE)) + } + if i.EnvContains != nil { + predicates = append(predicates, hostprocess.EnvContains(*i.EnvContains)) + } + if i.EnvHasPrefix != nil { + predicates = append(predicates, hostprocess.EnvHasPrefix(*i.EnvHasPrefix)) + } + if i.EnvHasSuffix != nil { + predicates = append(predicates, hostprocess.EnvHasSuffix(*i.EnvHasSuffix)) + } + if i.EnvIsNil { + predicates = append(predicates, hostprocess.EnvIsNil()) + } + if i.EnvNotNil { + predicates = append(predicates, hostprocess.EnvNotNil()) + } + if i.EnvEqualFold != nil { + predicates = append(predicates, hostprocess.EnvEqualFold(*i.EnvEqualFold)) + } + if i.EnvContainsFold != nil { + predicates = append(predicates, hostprocess.EnvContainsFold(*i.EnvContainsFold)) + } + if i.Cwd != nil { + predicates = append(predicates, hostprocess.CwdEQ(*i.Cwd)) + } + if i.CwdNEQ != nil { + predicates = append(predicates, hostprocess.CwdNEQ(*i.CwdNEQ)) + } + if len(i.CwdIn) > 0 { + predicates = append(predicates, hostprocess.CwdIn(i.CwdIn...)) + } + if len(i.CwdNotIn) > 0 { + predicates = append(predicates, hostprocess.CwdNotIn(i.CwdNotIn...)) + } + if i.CwdGT != nil { + predicates = append(predicates, hostprocess.CwdGT(*i.CwdGT)) + } + if i.CwdGTE != nil { + predicates = append(predicates, hostprocess.CwdGTE(*i.CwdGTE)) + } + if i.CwdLT != nil { + predicates = append(predicates, hostprocess.CwdLT(*i.CwdLT)) + } + if i.CwdLTE != nil { + predicates = append(predicates, hostprocess.CwdLTE(*i.CwdLTE)) + } + if i.CwdContains != nil { + predicates = append(predicates, hostprocess.CwdContains(*i.CwdContains)) + } + if i.CwdHasPrefix != nil { + predicates = append(predicates, hostprocess.CwdHasPrefix(*i.CwdHasPrefix)) + } + if i.CwdHasSuffix != nil { + predicates = append(predicates, hostprocess.CwdHasSuffix(*i.CwdHasSuffix)) + } + if i.CwdIsNil { + predicates = append(predicates, hostprocess.CwdIsNil()) + } + if i.CwdNotNil { + predicates = append(predicates, hostprocess.CwdNotNil()) + } + if i.CwdEqualFold != nil { + predicates = append(predicates, hostprocess.CwdEqualFold(*i.CwdEqualFold)) + } + if i.CwdContainsFold != nil { + predicates = append(predicates, hostprocess.CwdContainsFold(*i.CwdContainsFold)) + } + if i.Status != nil { + predicates = append(predicates, hostprocess.StatusEQ(*i.Status)) + } + if i.StatusNEQ != nil { + predicates = append(predicates, hostprocess.StatusNEQ(*i.StatusNEQ)) + } + if len(i.StatusIn) > 0 { + predicates = append(predicates, hostprocess.StatusIn(i.StatusIn...)) + } + if len(i.StatusNotIn) > 0 { + predicates = append(predicates, hostprocess.StatusNotIn(i.StatusNotIn...)) } if i.HasHost != nil { - p := process.HasHost() + p := hostprocess.HasHost() if !*i.HasHost { - p = process.Not(p) + p = hostprocess.Not(p) } predicates = append(predicates, p) } @@ -1771,12 +2667,12 @@ func (i *ProcessWhereInput) P() (predicate.Process, error) { } with = append(with, p) } - predicates = append(predicates, process.HasHostWith(with...)) + predicates = append(predicates, hostprocess.HasHostWith(with...)) } if i.HasTask != nil { - p := process.HasTask() + p := hostprocess.HasTask() if !*i.HasTask { - p = process.Not(p) + p = hostprocess.Not(p) } predicates = append(predicates, p) } @@ -1789,15 +2685,15 @@ func (i *ProcessWhereInput) P() (predicate.Process, error) { } with = append(with, p) } - predicates = append(predicates, process.HasTaskWith(with...)) + predicates = append(predicates, hostprocess.HasTaskWith(with...)) } switch len(predicates) { case 0: - return nil, ErrEmptyProcessWhereInput + return nil, ErrEmptyHostProcessWhereInput case 1: return predicates[0], nil default: - return process.And(predicates...), nil + return hostprocess.And(predicates...), nil } } @@ -2540,9 +3436,13 @@ type TaskWhereInput struct { HasBeacon *bool `json:"hasBeacon,omitempty"` HasBeaconWith []*BeaconWhereInput `json:"hasBeaconWith,omitempty"` + // "reported_files" edge predicates. + HasReportedFiles *bool `json:"hasReportedFiles,omitempty"` + HasReportedFilesWith []*HostFileWhereInput `json:"hasReportedFilesWith,omitempty"` + // "reported_processes" edge predicates. - HasReportedProcesses *bool `json:"hasReportedProcesses,omitempty"` - HasReportedProcessesWith []*ProcessWhereInput `json:"hasReportedProcessesWith,omitempty"` + HasReportedProcesses *bool `json:"hasReportedProcesses,omitempty"` + HasReportedProcessesWith []*HostProcessWhereInput `json:"hasReportedProcessesWith,omitempty"` } // AddPredicates adds custom predicates to the where input to be used during the filtering phase. @@ -2929,6 +3829,24 @@ func (i *TaskWhereInput) P() (predicate.Task, error) { } predicates = append(predicates, task.HasBeaconWith(with...)) } + if i.HasReportedFiles != nil { + p := task.HasReportedFiles() + if !*i.HasReportedFiles { + p = task.Not(p) + } + predicates = append(predicates, p) + } + if len(i.HasReportedFilesWith) > 0 { + with := make([]predicate.HostFile, 0, len(i.HasReportedFilesWith)) + for _, w := range i.HasReportedFilesWith { + p, err := w.P() + if err != nil { + return nil, fmt.Errorf("%w: field 'HasReportedFilesWith'", err) + } + with = append(with, p) + } + predicates = append(predicates, task.HasReportedFilesWith(with...)) + } if i.HasReportedProcesses != nil { p := task.HasReportedProcesses() if !*i.HasReportedProcesses { @@ -2937,7 +3855,7 @@ func (i *TaskWhereInput) P() (predicate.Task, error) { predicates = append(predicates, p) } if len(i.HasReportedProcessesWith) > 0 { - with := make([]predicate.Process, 0, len(i.HasReportedProcessesWith)) + with := make([]predicate.HostProcess, 0, len(i.HasReportedProcessesWith)) for _, w := range i.HasReportedProcessesWith { p, err := w.P() if err != nil { diff --git a/tavern/internal/ent/hook/hook.go b/tavern/internal/ent/hook/hook.go index 78bbb85ea..95797dab8 100644 --- a/tavern/internal/ent/hook/hook.go +++ b/tavern/internal/ent/hook/hook.go @@ -45,16 +45,28 @@ func (f HostFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.HostMutation", m) } -// The ProcessFunc type is an adapter to allow the use of ordinary -// function as Process mutator. -type ProcessFunc func(context.Context, *ent.ProcessMutation) (ent.Value, error) +// The HostFileFunc type is an adapter to allow the use of ordinary +// function as HostFile mutator. +type HostFileFunc func(context.Context, *ent.HostFileMutation) (ent.Value, error) // Mutate calls f(ctx, m). -func (f ProcessFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { - if mv, ok := m.(*ent.ProcessMutation); ok { +func (f HostFileFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { + if mv, ok := m.(*ent.HostFileMutation); ok { return f(ctx, mv) } - return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.ProcessMutation", m) + return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.HostFileMutation", m) +} + +// The HostProcessFunc type is an adapter to allow the use of ordinary +// function as HostProcess mutator. +type HostProcessFunc func(context.Context, *ent.HostProcessMutation) (ent.Value, error) + +// Mutate calls f(ctx, m). +func (f HostProcessFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { + if mv, ok := m.(*ent.HostProcessMutation); ok { + return f(ctx, mv) + } + return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.HostProcessMutation", m) } // The QuestFunc type is an adapter to allow the use of ordinary diff --git a/tavern/internal/ent/host.go b/tavern/internal/ent/host.go index 2ed68e284..2876f52e5 100644 --- a/tavern/internal/ent/host.go +++ b/tavern/internal/ent/host.go @@ -9,6 +9,7 @@ import ( "entgo.io/ent" "entgo.io/ent/dialect/sql" + "realm.pub/tavern/internal/c2/c2pb" "realm.pub/tavern/internal/ent/host" ) @@ -28,7 +29,7 @@ type Host struct { // Primary interface IP address reported by the agent. PrimaryIP string `json:"primary_ip,omitempty"` // Platform the agent is operating on. - Platform host.Platform `json:"platform,omitempty"` + Platform c2pb.Host_Platform `json:"platform,omitempty"` // Timestamp of when a task was last claimed or updated for the host. LastSeenAt time.Time `json:"last_seen_at,omitempty"` // Edges holds the relations/edges for other nodes in the graph. @@ -43,17 +44,20 @@ type HostEdges struct { Tags []*Tag `json:"tags,omitempty"` // Beacons that are present on this host system. Beacons []*Beacon `json:"beacons,omitempty"` + // Files reported on this host system. + Files []*HostFile `json:"files,omitempty"` // Processes reported as running on this host system. - Processes []*Process `json:"processes,omitempty"` + Processes []*HostProcess `json:"processes,omitempty"` // loadedTypes holds the information for reporting if a // type was loaded (or requested) in eager-loading or not. - loadedTypes [3]bool + loadedTypes [4]bool // totalCount holds the count of the edges above. - totalCount [3]map[string]int + totalCount [4]map[string]int namedTags map[string][]*Tag namedBeacons map[string][]*Beacon - namedProcesses map[string][]*Process + namedFiles map[string][]*HostFile + namedProcesses map[string][]*HostProcess } // TagsOrErr returns the Tags value or an error if the edge @@ -74,10 +78,19 @@ func (e HostEdges) BeaconsOrErr() ([]*Beacon, error) { return nil, &NotLoadedError{edge: "beacons"} } -// ProcessesOrErr returns the Processes value or an error if the edge +// FilesOrErr returns the Files value or an error if the edge // was not loaded in eager-loading. -func (e HostEdges) ProcessesOrErr() ([]*Process, error) { +func (e HostEdges) FilesOrErr() ([]*HostFile, error) { if e.loadedTypes[2] { + return e.Files, nil + } + return nil, &NotLoadedError{edge: "files"} +} + +// ProcessesOrErr returns the Processes value or an error if the edge +// was not loaded in eager-loading. +func (e HostEdges) ProcessesOrErr() ([]*HostProcess, error) { + if e.loadedTypes[3] { return e.Processes, nil } return nil, &NotLoadedError{edge: "processes"} @@ -88,9 +101,11 @@ func (*Host) scanValues(columns []string) ([]any, error) { values := make([]any, len(columns)) for i := range columns { switch columns[i] { + case host.FieldPlatform: + values[i] = new(c2pb.Host_Platform) case host.FieldID: values[i] = new(sql.NullInt64) - case host.FieldIdentifier, host.FieldName, host.FieldPrimaryIP, host.FieldPlatform: + case host.FieldIdentifier, host.FieldName, host.FieldPrimaryIP: values[i] = new(sql.NullString) case host.FieldCreatedAt, host.FieldLastModifiedAt, host.FieldLastSeenAt: values[i] = new(sql.NullTime) @@ -146,10 +161,10 @@ func (h *Host) assignValues(columns []string, values []any) error { h.PrimaryIP = value.String } case host.FieldPlatform: - if value, ok := values[i].(*sql.NullString); !ok { + if value, ok := values[i].(*c2pb.Host_Platform); !ok { return fmt.Errorf("unexpected type %T for field platform", values[i]) - } else if value.Valid { - h.Platform = host.Platform(value.String) + } else if value != nil { + h.Platform = *value } case host.FieldLastSeenAt: if value, ok := values[i].(*sql.NullTime); !ok { @@ -180,8 +195,13 @@ func (h *Host) QueryBeacons() *BeaconQuery { return NewHostClient(h.config).QueryBeacons(h) } +// QueryFiles queries the "files" edge of the Host entity. +func (h *Host) QueryFiles() *HostFileQuery { + return NewHostClient(h.config).QueryFiles(h) +} + // QueryProcesses queries the "processes" edge of the Host entity. -func (h *Host) QueryProcesses() *ProcessQuery { +func (h *Host) QueryProcesses() *HostProcessQuery { return NewHostClient(h.config).QueryProcesses(h) } @@ -280,9 +300,33 @@ func (h *Host) appendNamedBeacons(name string, edges ...*Beacon) { } } +// NamedFiles returns the Files named value or an error if the edge was not +// loaded in eager-loading with this name. +func (h *Host) NamedFiles(name string) ([]*HostFile, error) { + if h.Edges.namedFiles == nil { + return nil, &NotLoadedError{edge: name} + } + nodes, ok := h.Edges.namedFiles[name] + if !ok { + return nil, &NotLoadedError{edge: name} + } + return nodes, nil +} + +func (h *Host) appendNamedFiles(name string, edges ...*HostFile) { + if h.Edges.namedFiles == nil { + h.Edges.namedFiles = make(map[string][]*HostFile) + } + if len(edges) == 0 { + h.Edges.namedFiles[name] = []*HostFile{} + } else { + h.Edges.namedFiles[name] = append(h.Edges.namedFiles[name], edges...) + } +} + // NamedProcesses returns the Processes named value or an error if the edge was not // loaded in eager-loading with this name. -func (h *Host) NamedProcesses(name string) ([]*Process, error) { +func (h *Host) NamedProcesses(name string) ([]*HostProcess, error) { if h.Edges.namedProcesses == nil { return nil, &NotLoadedError{edge: name} } @@ -293,12 +337,12 @@ func (h *Host) NamedProcesses(name string) ([]*Process, error) { return nodes, nil } -func (h *Host) appendNamedProcesses(name string, edges ...*Process) { +func (h *Host) appendNamedProcesses(name string, edges ...*HostProcess) { if h.Edges.namedProcesses == nil { - h.Edges.namedProcesses = make(map[string][]*Process) + h.Edges.namedProcesses = make(map[string][]*HostProcess) } if len(edges) == 0 { - h.Edges.namedProcesses[name] = []*Process{} + h.Edges.namedProcesses[name] = []*HostProcess{} } else { h.Edges.namedProcesses[name] = append(h.Edges.namedProcesses[name], edges...) } diff --git a/tavern/internal/ent/host/host.go b/tavern/internal/ent/host/host.go index 17854a752..1887e910d 100644 --- a/tavern/internal/ent/host/host.go +++ b/tavern/internal/ent/host/host.go @@ -4,12 +4,12 @@ package host import ( "fmt" - "io" - "strconv" "time" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" + "github.com/99designs/gqlgen/graphql" + "realm.pub/tavern/internal/c2/c2pb" ) const ( @@ -35,6 +35,8 @@ const ( EdgeTags = "tags" // EdgeBeacons holds the string denoting the beacons edge name in mutations. EdgeBeacons = "beacons" + // EdgeFiles holds the string denoting the files edge name in mutations. + EdgeFiles = "files" // EdgeProcesses holds the string denoting the processes edge name in mutations. EdgeProcesses = "processes" // Table holds the table name of the host in the database. @@ -51,11 +53,18 @@ const ( BeaconsInverseTable = "beacons" // BeaconsColumn is the table column denoting the beacons relation/edge. BeaconsColumn = "beacon_host" + // FilesTable is the table that holds the files relation/edge. + FilesTable = "host_files" + // FilesInverseTable is the table name for the HostFile entity. + // It exists in this package in order to avoid circular dependency with the "hostfile" package. + FilesInverseTable = "host_files" + // FilesColumn is the table column denoting the files relation/edge. + FilesColumn = "host_files" // ProcessesTable is the table that holds the processes relation/edge. - ProcessesTable = "processes" - // ProcessesInverseTable is the table name for the Process entity. - // It exists in this package in order to avoid circular dependency with the "process" package. - ProcessesInverseTable = "processes" + ProcessesTable = "host_processes" + // ProcessesInverseTable is the table name for the HostProcess entity. + // It exists in this package in order to avoid circular dependency with the "hostprocess" package. + ProcessesInverseTable = "host_processes" // ProcessesColumn is the table column denoting the processes relation/edge. ProcessesColumn = "host_processes" ) @@ -101,29 +110,10 @@ var ( NameValidator func(string) error ) -// Platform defines the type for the "platform" enum field. -type Platform string - -// PlatformUnknown is the default value of the Platform enum. -const DefaultPlatform = PlatformUnknown - -// Platform values. -const ( - PlatformWindows Platform = "Windows" - PlatformLinux Platform = "Linux" - PlatformMacOS Platform = "MacOS" - PlatformBSD Platform = "BSD" - PlatformUnknown Platform = "Unknown" -) - -func (pl Platform) String() string { - return string(pl) -} - // PlatformValidator is a validator for the "platform" field enum values. It is called by the builders before save. -func PlatformValidator(pl Platform) error { - switch pl { - case PlatformWindows, PlatformLinux, PlatformMacOS, PlatformBSD, PlatformUnknown: +func PlatformValidator(pl c2pb.Host_Platform) error { + switch pl.String() { + case "PLATFORM_BSD", "PLATFORM_UNSPECIFIED", "PLATFORM_WINDOWS", "PLATFORM_LINUX", "PLATFORM_MACOS": return nil default: return fmt.Errorf("host: invalid enum value for platform field: %q", pl) @@ -201,6 +191,20 @@ func ByBeacons(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { } } +// ByFilesCount orders the results by files count. +func ByFilesCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newFilesStep(), opts...) + } +} + +// ByFiles orders the results by files terms. +func ByFiles(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newFilesStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} + // ByProcessesCount orders the results by processes count. func ByProcessesCount(opts ...sql.OrderTermOption) OrderOption { return func(s *sql.Selector) { @@ -228,6 +232,13 @@ func newBeaconsStep() *sqlgraph.Step { sqlgraph.Edge(sqlgraph.O2M, true, BeaconsTable, BeaconsColumn), ) } +func newFilesStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(FilesInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, FilesTable, FilesColumn), + ) +} func newProcessesStep() *sqlgraph.Step { return sqlgraph.NewStep( sqlgraph.From(Table, FieldID), @@ -236,20 +247,9 @@ func newProcessesStep() *sqlgraph.Step { ) } -// MarshalGQL implements graphql.Marshaler interface. -func (e Platform) MarshalGQL(w io.Writer) { - io.WriteString(w, strconv.Quote(e.String())) -} - -// UnmarshalGQL implements graphql.Unmarshaler interface. -func (e *Platform) UnmarshalGQL(val interface{}) error { - str, ok := val.(string) - if !ok { - return fmt.Errorf("enum %T must be a string", val) - } - *e = Platform(str) - if err := PlatformValidator(*e); err != nil { - return fmt.Errorf("%s is not a valid Platform", str) - } - return nil -} +var ( + // c2pb.Host_Platform must implement graphql.Marshaler. + _ graphql.Marshaler = (*c2pb.Host_Platform)(nil) + // c2pb.Host_Platform must implement graphql.Unmarshaler. + _ graphql.Unmarshaler = (*c2pb.Host_Platform)(nil) +) diff --git a/tavern/internal/ent/host/where.go b/tavern/internal/ent/host/where.go index 942bfb85a..efec97819 100644 --- a/tavern/internal/ent/host/where.go +++ b/tavern/internal/ent/host/where.go @@ -7,6 +7,7 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" + "realm.pub/tavern/internal/c2/c2pb" "realm.pub/tavern/internal/ent/predicate" ) @@ -381,22 +382,22 @@ func PrimaryIPContainsFold(v string) predicate.Host { } // PlatformEQ applies the EQ predicate on the "platform" field. -func PlatformEQ(v Platform) predicate.Host { +func PlatformEQ(v c2pb.Host_Platform) predicate.Host { return predicate.Host(sql.FieldEQ(FieldPlatform, v)) } // PlatformNEQ applies the NEQ predicate on the "platform" field. -func PlatformNEQ(v Platform) predicate.Host { +func PlatformNEQ(v c2pb.Host_Platform) predicate.Host { return predicate.Host(sql.FieldNEQ(FieldPlatform, v)) } // PlatformIn applies the In predicate on the "platform" field. -func PlatformIn(vs ...Platform) predicate.Host { +func PlatformIn(vs ...c2pb.Host_Platform) predicate.Host { return predicate.Host(sql.FieldIn(FieldPlatform, vs...)) } // PlatformNotIn applies the NotIn predicate on the "platform" field. -func PlatformNotIn(vs ...Platform) predicate.Host { +func PlatformNotIn(vs ...c2pb.Host_Platform) predicate.Host { return predicate.Host(sql.FieldNotIn(FieldPlatform, vs...)) } @@ -496,6 +497,29 @@ func HasBeaconsWith(preds ...predicate.Beacon) predicate.Host { }) } +// HasFiles applies the HasEdge predicate on the "files" edge. +func HasFiles() predicate.Host { + return predicate.Host(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, FilesTable, FilesColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasFilesWith applies the HasEdge predicate on the "files" edge with a given conditions (other predicates). +func HasFilesWith(preds ...predicate.HostFile) predicate.Host { + return predicate.Host(func(s *sql.Selector) { + step := newFilesStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + // HasProcesses applies the HasEdge predicate on the "processes" edge. func HasProcesses() predicate.Host { return predicate.Host(func(s *sql.Selector) { @@ -508,7 +532,7 @@ func HasProcesses() predicate.Host { } // HasProcessesWith applies the HasEdge predicate on the "processes" edge with a given conditions (other predicates). -func HasProcessesWith(preds ...predicate.Process) predicate.Host { +func HasProcessesWith(preds ...predicate.HostProcess) predicate.Host { return predicate.Host(func(s *sql.Selector) { step := newProcessesStep() sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { diff --git a/tavern/internal/ent/host_create.go b/tavern/internal/ent/host_create.go index 461ed3593..f3dd26e2f 100644 --- a/tavern/internal/ent/host_create.go +++ b/tavern/internal/ent/host_create.go @@ -11,9 +11,11 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" + "realm.pub/tavern/internal/c2/c2pb" "realm.pub/tavern/internal/ent/beacon" "realm.pub/tavern/internal/ent/host" - "realm.pub/tavern/internal/ent/process" + "realm.pub/tavern/internal/ent/hostfile" + "realm.pub/tavern/internal/ent/hostprocess" "realm.pub/tavern/internal/ent/tag" ) @@ -88,16 +90,8 @@ func (hc *HostCreate) SetNillablePrimaryIP(s *string) *HostCreate { } // SetPlatform sets the "platform" field. -func (hc *HostCreate) SetPlatform(h host.Platform) *HostCreate { - hc.mutation.SetPlatform(h) - return hc -} - -// SetNillablePlatform sets the "platform" field if the given value is not nil. -func (hc *HostCreate) SetNillablePlatform(h *host.Platform) *HostCreate { - if h != nil { - hc.SetPlatform(*h) - } +func (hc *HostCreate) SetPlatform(cp c2pb.Host_Platform) *HostCreate { + hc.mutation.SetPlatform(cp) return hc } @@ -145,17 +139,32 @@ func (hc *HostCreate) AddBeacons(b ...*Beacon) *HostCreate { return hc.AddBeaconIDs(ids...) } -// AddProcessIDs adds the "processes" edge to the Process entity by IDs. +// AddFileIDs adds the "files" edge to the HostFile entity by IDs. +func (hc *HostCreate) AddFileIDs(ids ...int) *HostCreate { + hc.mutation.AddFileIDs(ids...) + return hc +} + +// AddFiles adds the "files" edges to the HostFile entity. +func (hc *HostCreate) AddFiles(h ...*HostFile) *HostCreate { + ids := make([]int, len(h)) + for i := range h { + ids[i] = h[i].ID + } + return hc.AddFileIDs(ids...) +} + +// AddProcessIDs adds the "processes" edge to the HostProcess entity by IDs. func (hc *HostCreate) AddProcessIDs(ids ...int) *HostCreate { hc.mutation.AddProcessIDs(ids...) return hc } -// AddProcesses adds the "processes" edges to the Process entity. -func (hc *HostCreate) AddProcesses(p ...*Process) *HostCreate { - ids := make([]int, len(p)) - for i := range p { - ids[i] = p[i].ID +// AddProcesses adds the "processes" edges to the HostProcess entity. +func (hc *HostCreate) AddProcesses(h ...*HostProcess) *HostCreate { + ids := make([]int, len(h)) + for i := range h { + ids[i] = h[i].ID } return hc.AddProcessIDs(ids...) } @@ -203,10 +212,6 @@ func (hc *HostCreate) defaults() { v := host.DefaultLastModifiedAt() hc.mutation.SetLastModifiedAt(v) } - if _, ok := hc.mutation.Platform(); !ok { - v := host.DefaultPlatform - hc.mutation.SetPlatform(v) - } } // check runs all checks and user-defined validators on the builder. @@ -325,6 +330,22 @@ func (hc *HostCreate) createSpec() (*Host, *sqlgraph.CreateSpec) { } _spec.Edges = append(_spec.Edges, edge) } + if nodes := hc.mutation.FilesIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: host.FilesTable, + Columns: []string{host.FilesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(hostfile.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges = append(_spec.Edges, edge) + } if nodes := hc.mutation.ProcessesIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, @@ -333,7 +354,7 @@ func (hc *HostCreate) createSpec() (*Host, *sqlgraph.CreateSpec) { Columns: []string{host.ProcessesColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(process.FieldID, field.TypeInt), + IDSpec: sqlgraph.NewFieldSpec(hostprocess.FieldID, field.TypeInt), }, } for _, k := range nodes { @@ -454,7 +475,7 @@ func (u *HostUpsert) ClearPrimaryIP() *HostUpsert { } // SetPlatform sets the "platform" field. -func (u *HostUpsert) SetPlatform(v host.Platform) *HostUpsert { +func (u *HostUpsert) SetPlatform(v c2pb.Host_Platform) *HostUpsert { u.Set(host.FieldPlatform, v) return u } @@ -599,7 +620,7 @@ func (u *HostUpsertOne) ClearPrimaryIP() *HostUpsertOne { } // SetPlatform sets the "platform" field. -func (u *HostUpsertOne) SetPlatform(v host.Platform) *HostUpsertOne { +func (u *HostUpsertOne) SetPlatform(v c2pb.Host_Platform) *HostUpsertOne { return u.Update(func(s *HostUpsert) { s.SetPlatform(v) }) @@ -915,7 +936,7 @@ func (u *HostUpsertBulk) ClearPrimaryIP() *HostUpsertBulk { } // SetPlatform sets the "platform" field. -func (u *HostUpsertBulk) SetPlatform(v host.Platform) *HostUpsertBulk { +func (u *HostUpsertBulk) SetPlatform(v c2pb.Host_Platform) *HostUpsertBulk { return u.Update(func(s *HostUpsert) { s.SetPlatform(v) }) diff --git a/tavern/internal/ent/host_query.go b/tavern/internal/ent/host_query.go index f2f07a0c3..eb58bee60 100644 --- a/tavern/internal/ent/host_query.go +++ b/tavern/internal/ent/host_query.go @@ -13,8 +13,9 @@ import ( "entgo.io/ent/schema/field" "realm.pub/tavern/internal/ent/beacon" "realm.pub/tavern/internal/ent/host" + "realm.pub/tavern/internal/ent/hostfile" + "realm.pub/tavern/internal/ent/hostprocess" "realm.pub/tavern/internal/ent/predicate" - "realm.pub/tavern/internal/ent/process" "realm.pub/tavern/internal/ent/tag" ) @@ -27,12 +28,14 @@ type HostQuery struct { predicates []predicate.Host withTags *TagQuery withBeacons *BeaconQuery - withProcesses *ProcessQuery + withFiles *HostFileQuery + withProcesses *HostProcessQuery modifiers []func(*sql.Selector) loadTotal []func(context.Context, []*Host) error withNamedTags map[string]*TagQuery withNamedBeacons map[string]*BeaconQuery - withNamedProcesses map[string]*ProcessQuery + withNamedFiles map[string]*HostFileQuery + withNamedProcesses map[string]*HostProcessQuery // intermediate query (i.e. traversal path). sql *sql.Selector path func(context.Context) (*sql.Selector, error) @@ -113,9 +116,31 @@ func (hq *HostQuery) QueryBeacons() *BeaconQuery { return query } +// QueryFiles chains the current query on the "files" edge. +func (hq *HostQuery) QueryFiles() *HostFileQuery { + query := (&HostFileClient{config: hq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := hq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := hq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(host.Table, host.FieldID, selector), + sqlgraph.To(hostfile.Table, hostfile.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, host.FilesTable, host.FilesColumn), + ) + fromU = sqlgraph.SetNeighbors(hq.driver.Dialect(), step) + return fromU, nil + } + return query +} + // QueryProcesses chains the current query on the "processes" edge. -func (hq *HostQuery) QueryProcesses() *ProcessQuery { - query := (&ProcessClient{config: hq.config}).Query() +func (hq *HostQuery) QueryProcesses() *HostProcessQuery { + query := (&HostProcessClient{config: hq.config}).Query() query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { if err := hq.prepareQuery(ctx); err != nil { return nil, err @@ -126,7 +151,7 @@ func (hq *HostQuery) QueryProcesses() *ProcessQuery { } step := sqlgraph.NewStep( sqlgraph.From(host.Table, host.FieldID, selector), - sqlgraph.To(process.Table, process.FieldID), + sqlgraph.To(hostprocess.Table, hostprocess.FieldID), sqlgraph.Edge(sqlgraph.O2M, false, host.ProcessesTable, host.ProcessesColumn), ) fromU = sqlgraph.SetNeighbors(hq.driver.Dialect(), step) @@ -329,6 +354,7 @@ func (hq *HostQuery) Clone() *HostQuery { predicates: append([]predicate.Host{}, hq.predicates...), withTags: hq.withTags.Clone(), withBeacons: hq.withBeacons.Clone(), + withFiles: hq.withFiles.Clone(), withProcesses: hq.withProcesses.Clone(), // clone intermediate query. sql: hq.sql.Clone(), @@ -358,10 +384,21 @@ func (hq *HostQuery) WithBeacons(opts ...func(*BeaconQuery)) *HostQuery { return hq } +// WithFiles tells the query-builder to eager-load the nodes that are connected to +// the "files" edge. The optional arguments are used to configure the query builder of the edge. +func (hq *HostQuery) WithFiles(opts ...func(*HostFileQuery)) *HostQuery { + query := (&HostFileClient{config: hq.config}).Query() + for _, opt := range opts { + opt(query) + } + hq.withFiles = query + return hq +} + // WithProcesses tells the query-builder to eager-load the nodes that are connected to // the "processes" edge. The optional arguments are used to configure the query builder of the edge. -func (hq *HostQuery) WithProcesses(opts ...func(*ProcessQuery)) *HostQuery { - query := (&ProcessClient{config: hq.config}).Query() +func (hq *HostQuery) WithProcesses(opts ...func(*HostProcessQuery)) *HostQuery { + query := (&HostProcessClient{config: hq.config}).Query() for _, opt := range opts { opt(query) } @@ -447,9 +484,10 @@ func (hq *HostQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Host, e var ( nodes = []*Host{} _spec = hq.querySpec() - loadedTypes = [3]bool{ + loadedTypes = [4]bool{ hq.withTags != nil, hq.withBeacons != nil, + hq.withFiles != nil, hq.withProcesses != nil, } ) @@ -488,10 +526,17 @@ func (hq *HostQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Host, e return nil, err } } + if query := hq.withFiles; query != nil { + if err := hq.loadFiles(ctx, query, nodes, + func(n *Host) { n.Edges.Files = []*HostFile{} }, + func(n *Host, e *HostFile) { n.Edges.Files = append(n.Edges.Files, e) }); err != nil { + return nil, err + } + } if query := hq.withProcesses; query != nil { if err := hq.loadProcesses(ctx, query, nodes, - func(n *Host) { n.Edges.Processes = []*Process{} }, - func(n *Host, e *Process) { n.Edges.Processes = append(n.Edges.Processes, e) }); err != nil { + func(n *Host) { n.Edges.Processes = []*HostProcess{} }, + func(n *Host, e *HostProcess) { n.Edges.Processes = append(n.Edges.Processes, e) }); err != nil { return nil, err } } @@ -509,10 +554,17 @@ func (hq *HostQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Host, e return nil, err } } + for name, query := range hq.withNamedFiles { + if err := hq.loadFiles(ctx, query, nodes, + func(n *Host) { n.appendNamedFiles(name) }, + func(n *Host, e *HostFile) { n.appendNamedFiles(name, e) }); err != nil { + return nil, err + } + } for name, query := range hq.withNamedProcesses { if err := hq.loadProcesses(ctx, query, nodes, func(n *Host) { n.appendNamedProcesses(name) }, - func(n *Host, e *Process) { n.appendNamedProcesses(name, e) }); err != nil { + func(n *Host, e *HostProcess) { n.appendNamedProcesses(name, e) }); err != nil { return nil, err } } @@ -616,7 +668,38 @@ func (hq *HostQuery) loadBeacons(ctx context.Context, query *BeaconQuery, nodes } return nil } -func (hq *HostQuery) loadProcesses(ctx context.Context, query *ProcessQuery, nodes []*Host, init func(*Host), assign func(*Host, *Process)) error { +func (hq *HostQuery) loadFiles(ctx context.Context, query *HostFileQuery, nodes []*Host, init func(*Host), assign func(*Host, *HostFile)) error { + fks := make([]driver.Value, 0, len(nodes)) + nodeids := make(map[int]*Host) + for i := range nodes { + fks = append(fks, nodes[i].ID) + nodeids[nodes[i].ID] = nodes[i] + if init != nil { + init(nodes[i]) + } + } + query.withFKs = true + query.Where(predicate.HostFile(func(s *sql.Selector) { + s.Where(sql.InValues(s.C(host.FilesColumn), fks...)) + })) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + fk := n.host_files + if fk == nil { + return fmt.Errorf(`foreign-key "host_files" is nil for node %v`, n.ID) + } + node, ok := nodeids[*fk] + if !ok { + return fmt.Errorf(`unexpected referenced foreign-key "host_files" returned %v for node %v`, *fk, n.ID) + } + assign(node, n) + } + return nil +} +func (hq *HostQuery) loadProcesses(ctx context.Context, query *HostProcessQuery, nodes []*Host, init func(*Host), assign func(*Host, *HostProcess)) error { fks := make([]driver.Value, 0, len(nodes)) nodeids := make(map[int]*Host) for i := range nodes { @@ -627,7 +710,7 @@ func (hq *HostQuery) loadProcesses(ctx context.Context, query *ProcessQuery, nod } } query.withFKs = true - query.Where(predicate.Process(func(s *sql.Selector) { + query.Where(predicate.HostProcess(func(s *sql.Selector) { s.Where(sql.InValues(s.C(host.ProcessesColumn), fks...)) })) neighbors, err := query.All(ctx) @@ -760,15 +843,29 @@ func (hq *HostQuery) WithNamedBeacons(name string, opts ...func(*BeaconQuery)) * return hq } +// WithNamedFiles tells the query-builder to eager-load the nodes that are connected to the "files" +// edge with the given name. The optional arguments are used to configure the query builder of the edge. +func (hq *HostQuery) WithNamedFiles(name string, opts ...func(*HostFileQuery)) *HostQuery { + query := (&HostFileClient{config: hq.config}).Query() + for _, opt := range opts { + opt(query) + } + if hq.withNamedFiles == nil { + hq.withNamedFiles = make(map[string]*HostFileQuery) + } + hq.withNamedFiles[name] = query + return hq +} + // WithNamedProcesses tells the query-builder to eager-load the nodes that are connected to the "processes" // edge with the given name. The optional arguments are used to configure the query builder of the edge. -func (hq *HostQuery) WithNamedProcesses(name string, opts ...func(*ProcessQuery)) *HostQuery { - query := (&ProcessClient{config: hq.config}).Query() +func (hq *HostQuery) WithNamedProcesses(name string, opts ...func(*HostProcessQuery)) *HostQuery { + query := (&HostProcessClient{config: hq.config}).Query() for _, opt := range opts { opt(query) } if hq.withNamedProcesses == nil { - hq.withNamedProcesses = make(map[string]*ProcessQuery) + hq.withNamedProcesses = make(map[string]*HostProcessQuery) } hq.withNamedProcesses[name] = query return hq diff --git a/tavern/internal/ent/host_update.go b/tavern/internal/ent/host_update.go index 974fd0d59..45386bc7f 100644 --- a/tavern/internal/ent/host_update.go +++ b/tavern/internal/ent/host_update.go @@ -11,10 +11,12 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" + "realm.pub/tavern/internal/c2/c2pb" "realm.pub/tavern/internal/ent/beacon" "realm.pub/tavern/internal/ent/host" + "realm.pub/tavern/internal/ent/hostfile" + "realm.pub/tavern/internal/ent/hostprocess" "realm.pub/tavern/internal/ent/predicate" - "realm.pub/tavern/internal/ent/process" "realm.pub/tavern/internal/ent/tag" ) @@ -84,16 +86,8 @@ func (hu *HostUpdate) ClearPrimaryIP() *HostUpdate { } // SetPlatform sets the "platform" field. -func (hu *HostUpdate) SetPlatform(h host.Platform) *HostUpdate { - hu.mutation.SetPlatform(h) - return hu -} - -// SetNillablePlatform sets the "platform" field if the given value is not nil. -func (hu *HostUpdate) SetNillablePlatform(h *host.Platform) *HostUpdate { - if h != nil { - hu.SetPlatform(*h) - } +func (hu *HostUpdate) SetPlatform(cp c2pb.Host_Platform) *HostUpdate { + hu.mutation.SetPlatform(cp) return hu } @@ -147,17 +141,32 @@ func (hu *HostUpdate) AddBeacons(b ...*Beacon) *HostUpdate { return hu.AddBeaconIDs(ids...) } -// AddProcessIDs adds the "processes" edge to the Process entity by IDs. +// AddFileIDs adds the "files" edge to the HostFile entity by IDs. +func (hu *HostUpdate) AddFileIDs(ids ...int) *HostUpdate { + hu.mutation.AddFileIDs(ids...) + return hu +} + +// AddFiles adds the "files" edges to the HostFile entity. +func (hu *HostUpdate) AddFiles(h ...*HostFile) *HostUpdate { + ids := make([]int, len(h)) + for i := range h { + ids[i] = h[i].ID + } + return hu.AddFileIDs(ids...) +} + +// AddProcessIDs adds the "processes" edge to the HostProcess entity by IDs. func (hu *HostUpdate) AddProcessIDs(ids ...int) *HostUpdate { hu.mutation.AddProcessIDs(ids...) return hu } -// AddProcesses adds the "processes" edges to the Process entity. -func (hu *HostUpdate) AddProcesses(p ...*Process) *HostUpdate { - ids := make([]int, len(p)) - for i := range p { - ids[i] = p[i].ID +// AddProcesses adds the "processes" edges to the HostProcess entity. +func (hu *HostUpdate) AddProcesses(h ...*HostProcess) *HostUpdate { + ids := make([]int, len(h)) + for i := range h { + ids[i] = h[i].ID } return hu.AddProcessIDs(ids...) } @@ -209,23 +218,44 @@ func (hu *HostUpdate) RemoveBeacons(b ...*Beacon) *HostUpdate { return hu.RemoveBeaconIDs(ids...) } -// ClearProcesses clears all "processes" edges to the Process entity. +// ClearFiles clears all "files" edges to the HostFile entity. +func (hu *HostUpdate) ClearFiles() *HostUpdate { + hu.mutation.ClearFiles() + return hu +} + +// RemoveFileIDs removes the "files" edge to HostFile entities by IDs. +func (hu *HostUpdate) RemoveFileIDs(ids ...int) *HostUpdate { + hu.mutation.RemoveFileIDs(ids...) + return hu +} + +// RemoveFiles removes "files" edges to HostFile entities. +func (hu *HostUpdate) RemoveFiles(h ...*HostFile) *HostUpdate { + ids := make([]int, len(h)) + for i := range h { + ids[i] = h[i].ID + } + return hu.RemoveFileIDs(ids...) +} + +// ClearProcesses clears all "processes" edges to the HostProcess entity. func (hu *HostUpdate) ClearProcesses() *HostUpdate { hu.mutation.ClearProcesses() return hu } -// RemoveProcessIDs removes the "processes" edge to Process entities by IDs. +// RemoveProcessIDs removes the "processes" edge to HostProcess entities by IDs. func (hu *HostUpdate) RemoveProcessIDs(ids ...int) *HostUpdate { hu.mutation.RemoveProcessIDs(ids...) return hu } -// RemoveProcesses removes "processes" edges to Process entities. -func (hu *HostUpdate) RemoveProcesses(p ...*Process) *HostUpdate { - ids := make([]int, len(p)) - for i := range p { - ids[i] = p[i].ID +// RemoveProcesses removes "processes" edges to HostProcess entities. +func (hu *HostUpdate) RemoveProcesses(h ...*HostProcess) *HostUpdate { + ids := make([]int, len(h)) + for i := range h { + ids[i] = h[i].ID } return hu.RemoveProcessIDs(ids...) } @@ -415,6 +445,51 @@ func (hu *HostUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Add = append(_spec.Edges.Add, edge) } + if hu.mutation.FilesCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: host.FilesTable, + Columns: []string{host.FilesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(hostfile.FieldID, field.TypeInt), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := hu.mutation.RemovedFilesIDs(); len(nodes) > 0 && !hu.mutation.FilesCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: host.FilesTable, + Columns: []string{host.FilesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(hostfile.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := hu.mutation.FilesIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: host.FilesTable, + Columns: []string{host.FilesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(hostfile.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } if hu.mutation.ProcessesCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, @@ -423,7 +498,7 @@ func (hu *HostUpdate) sqlSave(ctx context.Context) (n int, err error) { Columns: []string{host.ProcessesColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(process.FieldID, field.TypeInt), + IDSpec: sqlgraph.NewFieldSpec(hostprocess.FieldID, field.TypeInt), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) @@ -436,7 +511,7 @@ func (hu *HostUpdate) sqlSave(ctx context.Context) (n int, err error) { Columns: []string{host.ProcessesColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(process.FieldID, field.TypeInt), + IDSpec: sqlgraph.NewFieldSpec(hostprocess.FieldID, field.TypeInt), }, } for _, k := range nodes { @@ -452,7 +527,7 @@ func (hu *HostUpdate) sqlSave(ctx context.Context) (n int, err error) { Columns: []string{host.ProcessesColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(process.FieldID, field.TypeInt), + IDSpec: sqlgraph.NewFieldSpec(hostprocess.FieldID, field.TypeInt), }, } for _, k := range nodes { @@ -533,16 +608,8 @@ func (huo *HostUpdateOne) ClearPrimaryIP() *HostUpdateOne { } // SetPlatform sets the "platform" field. -func (huo *HostUpdateOne) SetPlatform(h host.Platform) *HostUpdateOne { - huo.mutation.SetPlatform(h) - return huo -} - -// SetNillablePlatform sets the "platform" field if the given value is not nil. -func (huo *HostUpdateOne) SetNillablePlatform(h *host.Platform) *HostUpdateOne { - if h != nil { - huo.SetPlatform(*h) - } +func (huo *HostUpdateOne) SetPlatform(cp c2pb.Host_Platform) *HostUpdateOne { + huo.mutation.SetPlatform(cp) return huo } @@ -596,17 +663,32 @@ func (huo *HostUpdateOne) AddBeacons(b ...*Beacon) *HostUpdateOne { return huo.AddBeaconIDs(ids...) } -// AddProcessIDs adds the "processes" edge to the Process entity by IDs. +// AddFileIDs adds the "files" edge to the HostFile entity by IDs. +func (huo *HostUpdateOne) AddFileIDs(ids ...int) *HostUpdateOne { + huo.mutation.AddFileIDs(ids...) + return huo +} + +// AddFiles adds the "files" edges to the HostFile entity. +func (huo *HostUpdateOne) AddFiles(h ...*HostFile) *HostUpdateOne { + ids := make([]int, len(h)) + for i := range h { + ids[i] = h[i].ID + } + return huo.AddFileIDs(ids...) +} + +// AddProcessIDs adds the "processes" edge to the HostProcess entity by IDs. func (huo *HostUpdateOne) AddProcessIDs(ids ...int) *HostUpdateOne { huo.mutation.AddProcessIDs(ids...) return huo } -// AddProcesses adds the "processes" edges to the Process entity. -func (huo *HostUpdateOne) AddProcesses(p ...*Process) *HostUpdateOne { - ids := make([]int, len(p)) - for i := range p { - ids[i] = p[i].ID +// AddProcesses adds the "processes" edges to the HostProcess entity. +func (huo *HostUpdateOne) AddProcesses(h ...*HostProcess) *HostUpdateOne { + ids := make([]int, len(h)) + for i := range h { + ids[i] = h[i].ID } return huo.AddProcessIDs(ids...) } @@ -658,23 +740,44 @@ func (huo *HostUpdateOne) RemoveBeacons(b ...*Beacon) *HostUpdateOne { return huo.RemoveBeaconIDs(ids...) } -// ClearProcesses clears all "processes" edges to the Process entity. +// ClearFiles clears all "files" edges to the HostFile entity. +func (huo *HostUpdateOne) ClearFiles() *HostUpdateOne { + huo.mutation.ClearFiles() + return huo +} + +// RemoveFileIDs removes the "files" edge to HostFile entities by IDs. +func (huo *HostUpdateOne) RemoveFileIDs(ids ...int) *HostUpdateOne { + huo.mutation.RemoveFileIDs(ids...) + return huo +} + +// RemoveFiles removes "files" edges to HostFile entities. +func (huo *HostUpdateOne) RemoveFiles(h ...*HostFile) *HostUpdateOne { + ids := make([]int, len(h)) + for i := range h { + ids[i] = h[i].ID + } + return huo.RemoveFileIDs(ids...) +} + +// ClearProcesses clears all "processes" edges to the HostProcess entity. func (huo *HostUpdateOne) ClearProcesses() *HostUpdateOne { huo.mutation.ClearProcesses() return huo } -// RemoveProcessIDs removes the "processes" edge to Process entities by IDs. +// RemoveProcessIDs removes the "processes" edge to HostProcess entities by IDs. func (huo *HostUpdateOne) RemoveProcessIDs(ids ...int) *HostUpdateOne { huo.mutation.RemoveProcessIDs(ids...) return huo } -// RemoveProcesses removes "processes" edges to Process entities. -func (huo *HostUpdateOne) RemoveProcesses(p ...*Process) *HostUpdateOne { - ids := make([]int, len(p)) - for i := range p { - ids[i] = p[i].ID +// RemoveProcesses removes "processes" edges to HostProcess entities. +func (huo *HostUpdateOne) RemoveProcesses(h ...*HostProcess) *HostUpdateOne { + ids := make([]int, len(h)) + for i := range h { + ids[i] = h[i].ID } return huo.RemoveProcessIDs(ids...) } @@ -894,6 +997,51 @@ func (huo *HostUpdateOne) sqlSave(ctx context.Context) (_node *Host, err error) } _spec.Edges.Add = append(_spec.Edges.Add, edge) } + if huo.mutation.FilesCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: host.FilesTable, + Columns: []string{host.FilesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(hostfile.FieldID, field.TypeInt), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := huo.mutation.RemovedFilesIDs(); len(nodes) > 0 && !huo.mutation.FilesCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: host.FilesTable, + Columns: []string{host.FilesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(hostfile.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := huo.mutation.FilesIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: host.FilesTable, + Columns: []string{host.FilesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(hostfile.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } if huo.mutation.ProcessesCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, @@ -902,7 +1050,7 @@ func (huo *HostUpdateOne) sqlSave(ctx context.Context) (_node *Host, err error) Columns: []string{host.ProcessesColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(process.FieldID, field.TypeInt), + IDSpec: sqlgraph.NewFieldSpec(hostprocess.FieldID, field.TypeInt), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) @@ -915,7 +1063,7 @@ func (huo *HostUpdateOne) sqlSave(ctx context.Context) (_node *Host, err error) Columns: []string{host.ProcessesColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(process.FieldID, field.TypeInt), + IDSpec: sqlgraph.NewFieldSpec(hostprocess.FieldID, field.TypeInt), }, } for _, k := range nodes { @@ -931,7 +1079,7 @@ func (huo *HostUpdateOne) sqlSave(ctx context.Context) (_node *Host, err error) Columns: []string{host.ProcessesColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(process.FieldID, field.TypeInt), + IDSpec: sqlgraph.NewFieldSpec(hostprocess.FieldID, field.TypeInt), }, } for _, k := range nodes { diff --git a/tavern/internal/ent/hostfile.go b/tavern/internal/ent/hostfile.go new file mode 100644 index 000000000..4eda82450 --- /dev/null +++ b/tavern/internal/ent/hostfile.go @@ -0,0 +1,280 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "fmt" + "strings" + "time" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" + "realm.pub/tavern/internal/ent/host" + "realm.pub/tavern/internal/ent/hostfile" + "realm.pub/tavern/internal/ent/task" +) + +// HostFile is the model entity for the HostFile schema. +type HostFile struct { + config `json:"-"` + // ID of the ent. + ID int `json:"id,omitempty"` + // Timestamp of when this ent was created + CreatedAt time.Time `json:"created_at,omitempty"` + // Timestamp of when this ent was last updated + LastModifiedAt time.Time `json:"last_modified_at,omitempty"` + // Path to the file on the host system. + Path string `json:"path,omitempty"` + // User who owns the file on the host system. + Owner string `json:"owner,omitempty"` + // Group who owns the file on the host system. + Group string `json:"group,omitempty"` + // Permissions for the file on the host system. + Permissions string `json:"permissions,omitempty"` + // The size of the file in bytes + Size int `json:"size,omitempty"` + // A SHA3-256 digest of the content field + Hash string `json:"hash,omitempty"` + // The content of the file + Content []byte `json:"content,omitempty"` + // Edges holds the relations/edges for other nodes in the graph. + // The values are being populated by the HostFileQuery when eager-loading is set. + Edges HostFileEdges `json:"edges"` + host_files *int + host_file_host *int + task_reported_files *int + selectValues sql.SelectValues +} + +// HostFileEdges holds the relations/edges for other nodes in the graph. +type HostFileEdges struct { + // Host the file was reported on. + Host *Host `json:"host,omitempty"` + // Task that reported this file. + Task *Task `json:"task,omitempty"` + // loadedTypes holds the information for reporting if a + // type was loaded (or requested) in eager-loading or not. + loadedTypes [2]bool + // totalCount holds the count of the edges above. + totalCount [2]map[string]int +} + +// HostOrErr returns the Host value or an error if the edge +// was not loaded in eager-loading, or loaded but was not found. +func (e HostFileEdges) HostOrErr() (*Host, error) { + if e.loadedTypes[0] { + if e.Host == nil { + // Edge was loaded but was not found. + return nil, &NotFoundError{label: host.Label} + } + return e.Host, nil + } + return nil, &NotLoadedError{edge: "host"} +} + +// TaskOrErr returns the Task value or an error if the edge +// was not loaded in eager-loading, or loaded but was not found. +func (e HostFileEdges) TaskOrErr() (*Task, error) { + if e.loadedTypes[1] { + if e.Task == nil { + // Edge was loaded but was not found. + return nil, &NotFoundError{label: task.Label} + } + return e.Task, nil + } + return nil, &NotLoadedError{edge: "task"} +} + +// scanValues returns the types for scanning values from sql.Rows. +func (*HostFile) scanValues(columns []string) ([]any, error) { + values := make([]any, len(columns)) + for i := range columns { + switch columns[i] { + case hostfile.FieldContent: + values[i] = new([]byte) + case hostfile.FieldID, hostfile.FieldSize: + values[i] = new(sql.NullInt64) + case hostfile.FieldPath, hostfile.FieldOwner, hostfile.FieldGroup, hostfile.FieldPermissions, hostfile.FieldHash: + values[i] = new(sql.NullString) + case hostfile.FieldCreatedAt, hostfile.FieldLastModifiedAt: + values[i] = new(sql.NullTime) + case hostfile.ForeignKeys[0]: // host_files + values[i] = new(sql.NullInt64) + case hostfile.ForeignKeys[1]: // host_file_host + values[i] = new(sql.NullInt64) + case hostfile.ForeignKeys[2]: // task_reported_files + values[i] = new(sql.NullInt64) + default: + values[i] = new(sql.UnknownType) + } + } + return values, nil +} + +// assignValues assigns the values that were returned from sql.Rows (after scanning) +// to the HostFile fields. +func (hf *HostFile) assignValues(columns []string, values []any) error { + if m, n := len(values), len(columns); m < n { + return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) + } + for i := range columns { + switch columns[i] { + case hostfile.FieldID: + value, ok := values[i].(*sql.NullInt64) + if !ok { + return fmt.Errorf("unexpected type %T for field id", value) + } + hf.ID = int(value.Int64) + case hostfile.FieldCreatedAt: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field created_at", values[i]) + } else if value.Valid { + hf.CreatedAt = value.Time + } + case hostfile.FieldLastModifiedAt: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field last_modified_at", values[i]) + } else if value.Valid { + hf.LastModifiedAt = value.Time + } + case hostfile.FieldPath: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field path", values[i]) + } else if value.Valid { + hf.Path = value.String + } + case hostfile.FieldOwner: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field owner", values[i]) + } else if value.Valid { + hf.Owner = value.String + } + case hostfile.FieldGroup: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field group", values[i]) + } else if value.Valid { + hf.Group = value.String + } + case hostfile.FieldPermissions: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field permissions", values[i]) + } else if value.Valid { + hf.Permissions = value.String + } + case hostfile.FieldSize: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field size", values[i]) + } else if value.Valid { + hf.Size = int(value.Int64) + } + case hostfile.FieldHash: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field hash", values[i]) + } else if value.Valid { + hf.Hash = value.String + } + case hostfile.FieldContent: + if value, ok := values[i].(*[]byte); !ok { + return fmt.Errorf("unexpected type %T for field content", values[i]) + } else if value != nil { + hf.Content = *value + } + case hostfile.ForeignKeys[0]: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for edge-field host_files", value) + } else if value.Valid { + hf.host_files = new(int) + *hf.host_files = int(value.Int64) + } + case hostfile.ForeignKeys[1]: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for edge-field host_file_host", value) + } else if value.Valid { + hf.host_file_host = new(int) + *hf.host_file_host = int(value.Int64) + } + case hostfile.ForeignKeys[2]: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for edge-field task_reported_files", value) + } else if value.Valid { + hf.task_reported_files = new(int) + *hf.task_reported_files = int(value.Int64) + } + default: + hf.selectValues.Set(columns[i], values[i]) + } + } + return nil +} + +// Value returns the ent.Value that was dynamically selected and assigned to the HostFile. +// This includes values selected through modifiers, order, etc. +func (hf *HostFile) Value(name string) (ent.Value, error) { + return hf.selectValues.Get(name) +} + +// QueryHost queries the "host" edge of the HostFile entity. +func (hf *HostFile) QueryHost() *HostQuery { + return NewHostFileClient(hf.config).QueryHost(hf) +} + +// QueryTask queries the "task" edge of the HostFile entity. +func (hf *HostFile) QueryTask() *TaskQuery { + return NewHostFileClient(hf.config).QueryTask(hf) +} + +// Update returns a builder for updating this HostFile. +// Note that you need to call HostFile.Unwrap() before calling this method if this HostFile +// was returned from a transaction, and the transaction was committed or rolled back. +func (hf *HostFile) Update() *HostFileUpdateOne { + return NewHostFileClient(hf.config).UpdateOne(hf) +} + +// Unwrap unwraps the HostFile entity that was returned from a transaction after it was closed, +// so that all future queries will be executed through the driver which created the transaction. +func (hf *HostFile) Unwrap() *HostFile { + _tx, ok := hf.config.driver.(*txDriver) + if !ok { + panic("ent: HostFile is not a transactional entity") + } + hf.config.driver = _tx.drv + return hf +} + +// String implements the fmt.Stringer. +func (hf *HostFile) String() string { + var builder strings.Builder + builder.WriteString("HostFile(") + builder.WriteString(fmt.Sprintf("id=%v, ", hf.ID)) + builder.WriteString("created_at=") + builder.WriteString(hf.CreatedAt.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("last_modified_at=") + builder.WriteString(hf.LastModifiedAt.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("path=") + builder.WriteString(hf.Path) + builder.WriteString(", ") + builder.WriteString("owner=") + builder.WriteString(hf.Owner) + builder.WriteString(", ") + builder.WriteString("group=") + builder.WriteString(hf.Group) + builder.WriteString(", ") + builder.WriteString("permissions=") + builder.WriteString(hf.Permissions) + builder.WriteString(", ") + builder.WriteString("size=") + builder.WriteString(fmt.Sprintf("%v", hf.Size)) + builder.WriteString(", ") + builder.WriteString("hash=") + builder.WriteString(hf.Hash) + builder.WriteString(", ") + builder.WriteString("content=") + builder.WriteString(fmt.Sprintf("%v", hf.Content)) + builder.WriteByte(')') + return builder.String() +} + +// HostFiles is a parsable slice of HostFile. +type HostFiles []*HostFile diff --git a/tavern/internal/ent/hostfile/hostfile.go b/tavern/internal/ent/hostfile/hostfile.go new file mode 100644 index 000000000..e4e64eb48 --- /dev/null +++ b/tavern/internal/ent/hostfile/hostfile.go @@ -0,0 +1,192 @@ +// Code generated by ent, DO NOT EDIT. + +package hostfile + +import ( + "time" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" +) + +const ( + // Label holds the string label denoting the hostfile type in the database. + Label = "host_file" + // FieldID holds the string denoting the id field in the database. + FieldID = "id" + // FieldCreatedAt holds the string denoting the created_at field in the database. + FieldCreatedAt = "created_at" + // FieldLastModifiedAt holds the string denoting the last_modified_at field in the database. + FieldLastModifiedAt = "last_modified_at" + // FieldPath holds the string denoting the path field in the database. + FieldPath = "path" + // FieldOwner holds the string denoting the owner field in the database. + FieldOwner = "owner" + // FieldGroup holds the string denoting the group field in the database. + FieldGroup = "group" + // FieldPermissions holds the string denoting the permissions field in the database. + FieldPermissions = "permissions" + // FieldSize holds the string denoting the size field in the database. + FieldSize = "size" + // FieldHash holds the string denoting the hash field in the database. + FieldHash = "hash" + // FieldContent holds the string denoting the content field in the database. + FieldContent = "content" + // EdgeHost holds the string denoting the host edge name in mutations. + EdgeHost = "host" + // EdgeTask holds the string denoting the task edge name in mutations. + EdgeTask = "task" + // Table holds the table name of the hostfile in the database. + Table = "host_files" + // HostTable is the table that holds the host relation/edge. + HostTable = "host_files" + // HostInverseTable is the table name for the Host entity. + // It exists in this package in order to avoid circular dependency with the "host" package. + HostInverseTable = "hosts" + // HostColumn is the table column denoting the host relation/edge. + HostColumn = "host_file_host" + // TaskTable is the table that holds the task relation/edge. + TaskTable = "host_files" + // TaskInverseTable is the table name for the Task entity. + // It exists in this package in order to avoid circular dependency with the "task" package. + TaskInverseTable = "tasks" + // TaskColumn is the table column denoting the task relation/edge. + TaskColumn = "task_reported_files" +) + +// Columns holds all SQL columns for hostfile fields. +var Columns = []string{ + FieldID, + FieldCreatedAt, + FieldLastModifiedAt, + FieldPath, + FieldOwner, + FieldGroup, + FieldPermissions, + FieldSize, + FieldHash, + FieldContent, +} + +// ForeignKeys holds the SQL foreign-keys that are owned by the "host_files" +// table and are not defined as standalone fields in the schema. +var ForeignKeys = []string{ + "host_files", + "host_file_host", + "task_reported_files", +} + +// ValidColumn reports if the column name is valid (part of the table columns). +func ValidColumn(column string) bool { + for i := range Columns { + if column == Columns[i] { + return true + } + } + for i := range ForeignKeys { + if column == ForeignKeys[i] { + return true + } + } + return false +} + +// Note that the variables below are initialized by the runtime +// package on the initialization of the application. Therefore, +// it should be imported in the main as follows: +// +// import _ "realm.pub/tavern/internal/ent/runtime" +var ( + Hooks [1]ent.Hook + // DefaultCreatedAt holds the default value on creation for the "created_at" field. + DefaultCreatedAt func() time.Time + // DefaultLastModifiedAt holds the default value on creation for the "last_modified_at" field. + DefaultLastModifiedAt func() time.Time + // UpdateDefaultLastModifiedAt holds the default value on update for the "last_modified_at" field. + UpdateDefaultLastModifiedAt func() time.Time + // PathValidator is a validator for the "path" field. It is called by the builders before save. + PathValidator func(string) error + // DefaultSize holds the default value on creation for the "size" field. + DefaultSize int + // SizeValidator is a validator for the "size" field. It is called by the builders before save. + SizeValidator func(int) error + // HashValidator is a validator for the "hash" field. It is called by the builders before save. + HashValidator func(string) error +) + +// OrderOption defines the ordering options for the HostFile queries. +type OrderOption func(*sql.Selector) + +// ByID orders the results by the id field. +func ByID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldID, opts...).ToFunc() +} + +// ByCreatedAt orders the results by the created_at field. +func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldCreatedAt, opts...).ToFunc() +} + +// ByLastModifiedAt orders the results by the last_modified_at field. +func ByLastModifiedAt(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldLastModifiedAt, opts...).ToFunc() +} + +// ByPath orders the results by the path field. +func ByPath(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldPath, opts...).ToFunc() +} + +// ByOwner orders the results by the owner field. +func ByOwner(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldOwner, opts...).ToFunc() +} + +// ByGroup orders the results by the group field. +func ByGroup(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldGroup, opts...).ToFunc() +} + +// ByPermissions orders the results by the permissions field. +func ByPermissions(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldPermissions, opts...).ToFunc() +} + +// BySize orders the results by the size field. +func BySize(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldSize, opts...).ToFunc() +} + +// ByHash orders the results by the hash field. +func ByHash(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldHash, opts...).ToFunc() +} + +// ByHostField orders the results by host field. +func ByHostField(field string, opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newHostStep(), sql.OrderByField(field, opts...)) + } +} + +// ByTaskField orders the results by task field. +func ByTaskField(field string, opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newTaskStep(), sql.OrderByField(field, opts...)) + } +} +func newHostStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(HostInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, HostTable, HostColumn), + ) +} +func newTaskStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(TaskInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, TaskTable, TaskColumn), + ) +} diff --git a/tavern/internal/ent/hostfile/where.go b/tavern/internal/ent/hostfile/where.go new file mode 100644 index 000000000..00e70e6c3 --- /dev/null +++ b/tavern/internal/ent/hostfile/where.go @@ -0,0 +1,697 @@ +// Code generated by ent, DO NOT EDIT. + +package hostfile + +import ( + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "realm.pub/tavern/internal/ent/predicate" +) + +// ID filters vertices based on their ID field. +func ID(id int) predicate.HostFile { + return predicate.HostFile(sql.FieldEQ(FieldID, id)) +} + +// IDEQ applies the EQ predicate on the ID field. +func IDEQ(id int) predicate.HostFile { + return predicate.HostFile(sql.FieldEQ(FieldID, id)) +} + +// IDNEQ applies the NEQ predicate on the ID field. +func IDNEQ(id int) predicate.HostFile { + return predicate.HostFile(sql.FieldNEQ(FieldID, id)) +} + +// IDIn applies the In predicate on the ID field. +func IDIn(ids ...int) predicate.HostFile { + return predicate.HostFile(sql.FieldIn(FieldID, ids...)) +} + +// IDNotIn applies the NotIn predicate on the ID field. +func IDNotIn(ids ...int) predicate.HostFile { + return predicate.HostFile(sql.FieldNotIn(FieldID, ids...)) +} + +// IDGT applies the GT predicate on the ID field. +func IDGT(id int) predicate.HostFile { + return predicate.HostFile(sql.FieldGT(FieldID, id)) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id int) predicate.HostFile { + return predicate.HostFile(sql.FieldGTE(FieldID, id)) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id int) predicate.HostFile { + return predicate.HostFile(sql.FieldLT(FieldID, id)) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id int) predicate.HostFile { + return predicate.HostFile(sql.FieldLTE(FieldID, id)) +} + +// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ. +func CreatedAt(v time.Time) predicate.HostFile { + return predicate.HostFile(sql.FieldEQ(FieldCreatedAt, v)) +} + +// LastModifiedAt applies equality check predicate on the "last_modified_at" field. It's identical to LastModifiedAtEQ. +func LastModifiedAt(v time.Time) predicate.HostFile { + return predicate.HostFile(sql.FieldEQ(FieldLastModifiedAt, v)) +} + +// Path applies equality check predicate on the "path" field. It's identical to PathEQ. +func Path(v string) predicate.HostFile { + return predicate.HostFile(sql.FieldEQ(FieldPath, v)) +} + +// Owner applies equality check predicate on the "owner" field. It's identical to OwnerEQ. +func Owner(v string) predicate.HostFile { + return predicate.HostFile(sql.FieldEQ(FieldOwner, v)) +} + +// Group applies equality check predicate on the "group" field. It's identical to GroupEQ. +func Group(v string) predicate.HostFile { + return predicate.HostFile(sql.FieldEQ(FieldGroup, v)) +} + +// Permissions applies equality check predicate on the "permissions" field. It's identical to PermissionsEQ. +func Permissions(v string) predicate.HostFile { + return predicate.HostFile(sql.FieldEQ(FieldPermissions, v)) +} + +// Size applies equality check predicate on the "size" field. It's identical to SizeEQ. +func Size(v int) predicate.HostFile { + return predicate.HostFile(sql.FieldEQ(FieldSize, v)) +} + +// Hash applies equality check predicate on the "hash" field. It's identical to HashEQ. +func Hash(v string) predicate.HostFile { + return predicate.HostFile(sql.FieldEQ(FieldHash, v)) +} + +// Content applies equality check predicate on the "content" field. It's identical to ContentEQ. +func Content(v []byte) predicate.HostFile { + return predicate.HostFile(sql.FieldEQ(FieldContent, v)) +} + +// CreatedAtEQ applies the EQ predicate on the "created_at" field. +func CreatedAtEQ(v time.Time) predicate.HostFile { + return predicate.HostFile(sql.FieldEQ(FieldCreatedAt, v)) +} + +// CreatedAtNEQ applies the NEQ predicate on the "created_at" field. +func CreatedAtNEQ(v time.Time) predicate.HostFile { + return predicate.HostFile(sql.FieldNEQ(FieldCreatedAt, v)) +} + +// CreatedAtIn applies the In predicate on the "created_at" field. +func CreatedAtIn(vs ...time.Time) predicate.HostFile { + return predicate.HostFile(sql.FieldIn(FieldCreatedAt, vs...)) +} + +// CreatedAtNotIn applies the NotIn predicate on the "created_at" field. +func CreatedAtNotIn(vs ...time.Time) predicate.HostFile { + return predicate.HostFile(sql.FieldNotIn(FieldCreatedAt, vs...)) +} + +// CreatedAtGT applies the GT predicate on the "created_at" field. +func CreatedAtGT(v time.Time) predicate.HostFile { + return predicate.HostFile(sql.FieldGT(FieldCreatedAt, v)) +} + +// CreatedAtGTE applies the GTE predicate on the "created_at" field. +func CreatedAtGTE(v time.Time) predicate.HostFile { + return predicate.HostFile(sql.FieldGTE(FieldCreatedAt, v)) +} + +// CreatedAtLT applies the LT predicate on the "created_at" field. +func CreatedAtLT(v time.Time) predicate.HostFile { + return predicate.HostFile(sql.FieldLT(FieldCreatedAt, v)) +} + +// CreatedAtLTE applies the LTE predicate on the "created_at" field. +func CreatedAtLTE(v time.Time) predicate.HostFile { + return predicate.HostFile(sql.FieldLTE(FieldCreatedAt, v)) +} + +// LastModifiedAtEQ applies the EQ predicate on the "last_modified_at" field. +func LastModifiedAtEQ(v time.Time) predicate.HostFile { + return predicate.HostFile(sql.FieldEQ(FieldLastModifiedAt, v)) +} + +// LastModifiedAtNEQ applies the NEQ predicate on the "last_modified_at" field. +func LastModifiedAtNEQ(v time.Time) predicate.HostFile { + return predicate.HostFile(sql.FieldNEQ(FieldLastModifiedAt, v)) +} + +// LastModifiedAtIn applies the In predicate on the "last_modified_at" field. +func LastModifiedAtIn(vs ...time.Time) predicate.HostFile { + return predicate.HostFile(sql.FieldIn(FieldLastModifiedAt, vs...)) +} + +// LastModifiedAtNotIn applies the NotIn predicate on the "last_modified_at" field. +func LastModifiedAtNotIn(vs ...time.Time) predicate.HostFile { + return predicate.HostFile(sql.FieldNotIn(FieldLastModifiedAt, vs...)) +} + +// LastModifiedAtGT applies the GT predicate on the "last_modified_at" field. +func LastModifiedAtGT(v time.Time) predicate.HostFile { + return predicate.HostFile(sql.FieldGT(FieldLastModifiedAt, v)) +} + +// LastModifiedAtGTE applies the GTE predicate on the "last_modified_at" field. +func LastModifiedAtGTE(v time.Time) predicate.HostFile { + return predicate.HostFile(sql.FieldGTE(FieldLastModifiedAt, v)) +} + +// LastModifiedAtLT applies the LT predicate on the "last_modified_at" field. +func LastModifiedAtLT(v time.Time) predicate.HostFile { + return predicate.HostFile(sql.FieldLT(FieldLastModifiedAt, v)) +} + +// LastModifiedAtLTE applies the LTE predicate on the "last_modified_at" field. +func LastModifiedAtLTE(v time.Time) predicate.HostFile { + return predicate.HostFile(sql.FieldLTE(FieldLastModifiedAt, v)) +} + +// PathEQ applies the EQ predicate on the "path" field. +func PathEQ(v string) predicate.HostFile { + return predicate.HostFile(sql.FieldEQ(FieldPath, v)) +} + +// PathNEQ applies the NEQ predicate on the "path" field. +func PathNEQ(v string) predicate.HostFile { + return predicate.HostFile(sql.FieldNEQ(FieldPath, v)) +} + +// PathIn applies the In predicate on the "path" field. +func PathIn(vs ...string) predicate.HostFile { + return predicate.HostFile(sql.FieldIn(FieldPath, vs...)) +} + +// PathNotIn applies the NotIn predicate on the "path" field. +func PathNotIn(vs ...string) predicate.HostFile { + return predicate.HostFile(sql.FieldNotIn(FieldPath, vs...)) +} + +// PathGT applies the GT predicate on the "path" field. +func PathGT(v string) predicate.HostFile { + return predicate.HostFile(sql.FieldGT(FieldPath, v)) +} + +// PathGTE applies the GTE predicate on the "path" field. +func PathGTE(v string) predicate.HostFile { + return predicate.HostFile(sql.FieldGTE(FieldPath, v)) +} + +// PathLT applies the LT predicate on the "path" field. +func PathLT(v string) predicate.HostFile { + return predicate.HostFile(sql.FieldLT(FieldPath, v)) +} + +// PathLTE applies the LTE predicate on the "path" field. +func PathLTE(v string) predicate.HostFile { + return predicate.HostFile(sql.FieldLTE(FieldPath, v)) +} + +// PathContains applies the Contains predicate on the "path" field. +func PathContains(v string) predicate.HostFile { + return predicate.HostFile(sql.FieldContains(FieldPath, v)) +} + +// PathHasPrefix applies the HasPrefix predicate on the "path" field. +func PathHasPrefix(v string) predicate.HostFile { + return predicate.HostFile(sql.FieldHasPrefix(FieldPath, v)) +} + +// PathHasSuffix applies the HasSuffix predicate on the "path" field. +func PathHasSuffix(v string) predicate.HostFile { + return predicate.HostFile(sql.FieldHasSuffix(FieldPath, v)) +} + +// PathEqualFold applies the EqualFold predicate on the "path" field. +func PathEqualFold(v string) predicate.HostFile { + return predicate.HostFile(sql.FieldEqualFold(FieldPath, v)) +} + +// PathContainsFold applies the ContainsFold predicate on the "path" field. +func PathContainsFold(v string) predicate.HostFile { + return predicate.HostFile(sql.FieldContainsFold(FieldPath, v)) +} + +// OwnerEQ applies the EQ predicate on the "owner" field. +func OwnerEQ(v string) predicate.HostFile { + return predicate.HostFile(sql.FieldEQ(FieldOwner, v)) +} + +// OwnerNEQ applies the NEQ predicate on the "owner" field. +func OwnerNEQ(v string) predicate.HostFile { + return predicate.HostFile(sql.FieldNEQ(FieldOwner, v)) +} + +// OwnerIn applies the In predicate on the "owner" field. +func OwnerIn(vs ...string) predicate.HostFile { + return predicate.HostFile(sql.FieldIn(FieldOwner, vs...)) +} + +// OwnerNotIn applies the NotIn predicate on the "owner" field. +func OwnerNotIn(vs ...string) predicate.HostFile { + return predicate.HostFile(sql.FieldNotIn(FieldOwner, vs...)) +} + +// OwnerGT applies the GT predicate on the "owner" field. +func OwnerGT(v string) predicate.HostFile { + return predicate.HostFile(sql.FieldGT(FieldOwner, v)) +} + +// OwnerGTE applies the GTE predicate on the "owner" field. +func OwnerGTE(v string) predicate.HostFile { + return predicate.HostFile(sql.FieldGTE(FieldOwner, v)) +} + +// OwnerLT applies the LT predicate on the "owner" field. +func OwnerLT(v string) predicate.HostFile { + return predicate.HostFile(sql.FieldLT(FieldOwner, v)) +} + +// OwnerLTE applies the LTE predicate on the "owner" field. +func OwnerLTE(v string) predicate.HostFile { + return predicate.HostFile(sql.FieldLTE(FieldOwner, v)) +} + +// OwnerContains applies the Contains predicate on the "owner" field. +func OwnerContains(v string) predicate.HostFile { + return predicate.HostFile(sql.FieldContains(FieldOwner, v)) +} + +// OwnerHasPrefix applies the HasPrefix predicate on the "owner" field. +func OwnerHasPrefix(v string) predicate.HostFile { + return predicate.HostFile(sql.FieldHasPrefix(FieldOwner, v)) +} + +// OwnerHasSuffix applies the HasSuffix predicate on the "owner" field. +func OwnerHasSuffix(v string) predicate.HostFile { + return predicate.HostFile(sql.FieldHasSuffix(FieldOwner, v)) +} + +// OwnerIsNil applies the IsNil predicate on the "owner" field. +func OwnerIsNil() predicate.HostFile { + return predicate.HostFile(sql.FieldIsNull(FieldOwner)) +} + +// OwnerNotNil applies the NotNil predicate on the "owner" field. +func OwnerNotNil() predicate.HostFile { + return predicate.HostFile(sql.FieldNotNull(FieldOwner)) +} + +// OwnerEqualFold applies the EqualFold predicate on the "owner" field. +func OwnerEqualFold(v string) predicate.HostFile { + return predicate.HostFile(sql.FieldEqualFold(FieldOwner, v)) +} + +// OwnerContainsFold applies the ContainsFold predicate on the "owner" field. +func OwnerContainsFold(v string) predicate.HostFile { + return predicate.HostFile(sql.FieldContainsFold(FieldOwner, v)) +} + +// GroupEQ applies the EQ predicate on the "group" field. +func GroupEQ(v string) predicate.HostFile { + return predicate.HostFile(sql.FieldEQ(FieldGroup, v)) +} + +// GroupNEQ applies the NEQ predicate on the "group" field. +func GroupNEQ(v string) predicate.HostFile { + return predicate.HostFile(sql.FieldNEQ(FieldGroup, v)) +} + +// GroupIn applies the In predicate on the "group" field. +func GroupIn(vs ...string) predicate.HostFile { + return predicate.HostFile(sql.FieldIn(FieldGroup, vs...)) +} + +// GroupNotIn applies the NotIn predicate on the "group" field. +func GroupNotIn(vs ...string) predicate.HostFile { + return predicate.HostFile(sql.FieldNotIn(FieldGroup, vs...)) +} + +// GroupGT applies the GT predicate on the "group" field. +func GroupGT(v string) predicate.HostFile { + return predicate.HostFile(sql.FieldGT(FieldGroup, v)) +} + +// GroupGTE applies the GTE predicate on the "group" field. +func GroupGTE(v string) predicate.HostFile { + return predicate.HostFile(sql.FieldGTE(FieldGroup, v)) +} + +// GroupLT applies the LT predicate on the "group" field. +func GroupLT(v string) predicate.HostFile { + return predicate.HostFile(sql.FieldLT(FieldGroup, v)) +} + +// GroupLTE applies the LTE predicate on the "group" field. +func GroupLTE(v string) predicate.HostFile { + return predicate.HostFile(sql.FieldLTE(FieldGroup, v)) +} + +// GroupContains applies the Contains predicate on the "group" field. +func GroupContains(v string) predicate.HostFile { + return predicate.HostFile(sql.FieldContains(FieldGroup, v)) +} + +// GroupHasPrefix applies the HasPrefix predicate on the "group" field. +func GroupHasPrefix(v string) predicate.HostFile { + return predicate.HostFile(sql.FieldHasPrefix(FieldGroup, v)) +} + +// GroupHasSuffix applies the HasSuffix predicate on the "group" field. +func GroupHasSuffix(v string) predicate.HostFile { + return predicate.HostFile(sql.FieldHasSuffix(FieldGroup, v)) +} + +// GroupIsNil applies the IsNil predicate on the "group" field. +func GroupIsNil() predicate.HostFile { + return predicate.HostFile(sql.FieldIsNull(FieldGroup)) +} + +// GroupNotNil applies the NotNil predicate on the "group" field. +func GroupNotNil() predicate.HostFile { + return predicate.HostFile(sql.FieldNotNull(FieldGroup)) +} + +// GroupEqualFold applies the EqualFold predicate on the "group" field. +func GroupEqualFold(v string) predicate.HostFile { + return predicate.HostFile(sql.FieldEqualFold(FieldGroup, v)) +} + +// GroupContainsFold applies the ContainsFold predicate on the "group" field. +func GroupContainsFold(v string) predicate.HostFile { + return predicate.HostFile(sql.FieldContainsFold(FieldGroup, v)) +} + +// PermissionsEQ applies the EQ predicate on the "permissions" field. +func PermissionsEQ(v string) predicate.HostFile { + return predicate.HostFile(sql.FieldEQ(FieldPermissions, v)) +} + +// PermissionsNEQ applies the NEQ predicate on the "permissions" field. +func PermissionsNEQ(v string) predicate.HostFile { + return predicate.HostFile(sql.FieldNEQ(FieldPermissions, v)) +} + +// PermissionsIn applies the In predicate on the "permissions" field. +func PermissionsIn(vs ...string) predicate.HostFile { + return predicate.HostFile(sql.FieldIn(FieldPermissions, vs...)) +} + +// PermissionsNotIn applies the NotIn predicate on the "permissions" field. +func PermissionsNotIn(vs ...string) predicate.HostFile { + return predicate.HostFile(sql.FieldNotIn(FieldPermissions, vs...)) +} + +// PermissionsGT applies the GT predicate on the "permissions" field. +func PermissionsGT(v string) predicate.HostFile { + return predicate.HostFile(sql.FieldGT(FieldPermissions, v)) +} + +// PermissionsGTE applies the GTE predicate on the "permissions" field. +func PermissionsGTE(v string) predicate.HostFile { + return predicate.HostFile(sql.FieldGTE(FieldPermissions, v)) +} + +// PermissionsLT applies the LT predicate on the "permissions" field. +func PermissionsLT(v string) predicate.HostFile { + return predicate.HostFile(sql.FieldLT(FieldPermissions, v)) +} + +// PermissionsLTE applies the LTE predicate on the "permissions" field. +func PermissionsLTE(v string) predicate.HostFile { + return predicate.HostFile(sql.FieldLTE(FieldPermissions, v)) +} + +// PermissionsContains applies the Contains predicate on the "permissions" field. +func PermissionsContains(v string) predicate.HostFile { + return predicate.HostFile(sql.FieldContains(FieldPermissions, v)) +} + +// PermissionsHasPrefix applies the HasPrefix predicate on the "permissions" field. +func PermissionsHasPrefix(v string) predicate.HostFile { + return predicate.HostFile(sql.FieldHasPrefix(FieldPermissions, v)) +} + +// PermissionsHasSuffix applies the HasSuffix predicate on the "permissions" field. +func PermissionsHasSuffix(v string) predicate.HostFile { + return predicate.HostFile(sql.FieldHasSuffix(FieldPermissions, v)) +} + +// PermissionsIsNil applies the IsNil predicate on the "permissions" field. +func PermissionsIsNil() predicate.HostFile { + return predicate.HostFile(sql.FieldIsNull(FieldPermissions)) +} + +// PermissionsNotNil applies the NotNil predicate on the "permissions" field. +func PermissionsNotNil() predicate.HostFile { + return predicate.HostFile(sql.FieldNotNull(FieldPermissions)) +} + +// PermissionsEqualFold applies the EqualFold predicate on the "permissions" field. +func PermissionsEqualFold(v string) predicate.HostFile { + return predicate.HostFile(sql.FieldEqualFold(FieldPermissions, v)) +} + +// PermissionsContainsFold applies the ContainsFold predicate on the "permissions" field. +func PermissionsContainsFold(v string) predicate.HostFile { + return predicate.HostFile(sql.FieldContainsFold(FieldPermissions, v)) +} + +// SizeEQ applies the EQ predicate on the "size" field. +func SizeEQ(v int) predicate.HostFile { + return predicate.HostFile(sql.FieldEQ(FieldSize, v)) +} + +// SizeNEQ applies the NEQ predicate on the "size" field. +func SizeNEQ(v int) predicate.HostFile { + return predicate.HostFile(sql.FieldNEQ(FieldSize, v)) +} + +// SizeIn applies the In predicate on the "size" field. +func SizeIn(vs ...int) predicate.HostFile { + return predicate.HostFile(sql.FieldIn(FieldSize, vs...)) +} + +// SizeNotIn applies the NotIn predicate on the "size" field. +func SizeNotIn(vs ...int) predicate.HostFile { + return predicate.HostFile(sql.FieldNotIn(FieldSize, vs...)) +} + +// SizeGT applies the GT predicate on the "size" field. +func SizeGT(v int) predicate.HostFile { + return predicate.HostFile(sql.FieldGT(FieldSize, v)) +} + +// SizeGTE applies the GTE predicate on the "size" field. +func SizeGTE(v int) predicate.HostFile { + return predicate.HostFile(sql.FieldGTE(FieldSize, v)) +} + +// SizeLT applies the LT predicate on the "size" field. +func SizeLT(v int) predicate.HostFile { + return predicate.HostFile(sql.FieldLT(FieldSize, v)) +} + +// SizeLTE applies the LTE predicate on the "size" field. +func SizeLTE(v int) predicate.HostFile { + return predicate.HostFile(sql.FieldLTE(FieldSize, v)) +} + +// HashEQ applies the EQ predicate on the "hash" field. +func HashEQ(v string) predicate.HostFile { + return predicate.HostFile(sql.FieldEQ(FieldHash, v)) +} + +// HashNEQ applies the NEQ predicate on the "hash" field. +func HashNEQ(v string) predicate.HostFile { + return predicate.HostFile(sql.FieldNEQ(FieldHash, v)) +} + +// HashIn applies the In predicate on the "hash" field. +func HashIn(vs ...string) predicate.HostFile { + return predicate.HostFile(sql.FieldIn(FieldHash, vs...)) +} + +// HashNotIn applies the NotIn predicate on the "hash" field. +func HashNotIn(vs ...string) predicate.HostFile { + return predicate.HostFile(sql.FieldNotIn(FieldHash, vs...)) +} + +// HashGT applies the GT predicate on the "hash" field. +func HashGT(v string) predicate.HostFile { + return predicate.HostFile(sql.FieldGT(FieldHash, v)) +} + +// HashGTE applies the GTE predicate on the "hash" field. +func HashGTE(v string) predicate.HostFile { + return predicate.HostFile(sql.FieldGTE(FieldHash, v)) +} + +// HashLT applies the LT predicate on the "hash" field. +func HashLT(v string) predicate.HostFile { + return predicate.HostFile(sql.FieldLT(FieldHash, v)) +} + +// HashLTE applies the LTE predicate on the "hash" field. +func HashLTE(v string) predicate.HostFile { + return predicate.HostFile(sql.FieldLTE(FieldHash, v)) +} + +// HashContains applies the Contains predicate on the "hash" field. +func HashContains(v string) predicate.HostFile { + return predicate.HostFile(sql.FieldContains(FieldHash, v)) +} + +// HashHasPrefix applies the HasPrefix predicate on the "hash" field. +func HashHasPrefix(v string) predicate.HostFile { + return predicate.HostFile(sql.FieldHasPrefix(FieldHash, v)) +} + +// HashHasSuffix applies the HasSuffix predicate on the "hash" field. +func HashHasSuffix(v string) predicate.HostFile { + return predicate.HostFile(sql.FieldHasSuffix(FieldHash, v)) +} + +// HashIsNil applies the IsNil predicate on the "hash" field. +func HashIsNil() predicate.HostFile { + return predicate.HostFile(sql.FieldIsNull(FieldHash)) +} + +// HashNotNil applies the NotNil predicate on the "hash" field. +func HashNotNil() predicate.HostFile { + return predicate.HostFile(sql.FieldNotNull(FieldHash)) +} + +// HashEqualFold applies the EqualFold predicate on the "hash" field. +func HashEqualFold(v string) predicate.HostFile { + return predicate.HostFile(sql.FieldEqualFold(FieldHash, v)) +} + +// HashContainsFold applies the ContainsFold predicate on the "hash" field. +func HashContainsFold(v string) predicate.HostFile { + return predicate.HostFile(sql.FieldContainsFold(FieldHash, v)) +} + +// ContentEQ applies the EQ predicate on the "content" field. +func ContentEQ(v []byte) predicate.HostFile { + return predicate.HostFile(sql.FieldEQ(FieldContent, v)) +} + +// ContentNEQ applies the NEQ predicate on the "content" field. +func ContentNEQ(v []byte) predicate.HostFile { + return predicate.HostFile(sql.FieldNEQ(FieldContent, v)) +} + +// ContentIn applies the In predicate on the "content" field. +func ContentIn(vs ...[]byte) predicate.HostFile { + return predicate.HostFile(sql.FieldIn(FieldContent, vs...)) +} + +// ContentNotIn applies the NotIn predicate on the "content" field. +func ContentNotIn(vs ...[]byte) predicate.HostFile { + return predicate.HostFile(sql.FieldNotIn(FieldContent, vs...)) +} + +// ContentGT applies the GT predicate on the "content" field. +func ContentGT(v []byte) predicate.HostFile { + return predicate.HostFile(sql.FieldGT(FieldContent, v)) +} + +// ContentGTE applies the GTE predicate on the "content" field. +func ContentGTE(v []byte) predicate.HostFile { + return predicate.HostFile(sql.FieldGTE(FieldContent, v)) +} + +// ContentLT applies the LT predicate on the "content" field. +func ContentLT(v []byte) predicate.HostFile { + return predicate.HostFile(sql.FieldLT(FieldContent, v)) +} + +// ContentLTE applies the LTE predicate on the "content" field. +func ContentLTE(v []byte) predicate.HostFile { + return predicate.HostFile(sql.FieldLTE(FieldContent, v)) +} + +// ContentIsNil applies the IsNil predicate on the "content" field. +func ContentIsNil() predicate.HostFile { + return predicate.HostFile(sql.FieldIsNull(FieldContent)) +} + +// ContentNotNil applies the NotNil predicate on the "content" field. +func ContentNotNil() predicate.HostFile { + return predicate.HostFile(sql.FieldNotNull(FieldContent)) +} + +// HasHost applies the HasEdge predicate on the "host" edge. +func HasHost() predicate.HostFile { + return predicate.HostFile(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, HostTable, HostColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasHostWith applies the HasEdge predicate on the "host" edge with a given conditions (other predicates). +func HasHostWith(preds ...predicate.Host) predicate.HostFile { + return predicate.HostFile(func(s *sql.Selector) { + step := newHostStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// HasTask applies the HasEdge predicate on the "task" edge. +func HasTask() predicate.HostFile { + return predicate.HostFile(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, TaskTable, TaskColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasTaskWith applies the HasEdge predicate on the "task" edge with a given conditions (other predicates). +func HasTaskWith(preds ...predicate.Task) predicate.HostFile { + return predicate.HostFile(func(s *sql.Selector) { + step := newTaskStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// And groups predicates with the AND operator between them. +func And(predicates ...predicate.HostFile) predicate.HostFile { + return predicate.HostFile(sql.AndPredicates(predicates...)) +} + +// Or groups predicates with the OR operator between them. +func Or(predicates ...predicate.HostFile) predicate.HostFile { + return predicate.HostFile(sql.OrPredicates(predicates...)) +} + +// Not applies the not operator on the given predicate. +func Not(p predicate.HostFile) predicate.HostFile { + return predicate.HostFile(sql.NotPredicates(p)) +} diff --git a/tavern/internal/ent/hostfile_create.go b/tavern/internal/ent/hostfile_create.go new file mode 100644 index 000000000..a4ed40f9f --- /dev/null +++ b/tavern/internal/ent/hostfile_create.go @@ -0,0 +1,1118 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "realm.pub/tavern/internal/ent/host" + "realm.pub/tavern/internal/ent/hostfile" + "realm.pub/tavern/internal/ent/task" +) + +// HostFileCreate is the builder for creating a HostFile entity. +type HostFileCreate struct { + config + mutation *HostFileMutation + hooks []Hook + conflict []sql.ConflictOption +} + +// SetCreatedAt sets the "created_at" field. +func (hfc *HostFileCreate) SetCreatedAt(t time.Time) *HostFileCreate { + hfc.mutation.SetCreatedAt(t) + return hfc +} + +// SetNillableCreatedAt sets the "created_at" field if the given value is not nil. +func (hfc *HostFileCreate) SetNillableCreatedAt(t *time.Time) *HostFileCreate { + if t != nil { + hfc.SetCreatedAt(*t) + } + return hfc +} + +// SetLastModifiedAt sets the "last_modified_at" field. +func (hfc *HostFileCreate) SetLastModifiedAt(t time.Time) *HostFileCreate { + hfc.mutation.SetLastModifiedAt(t) + return hfc +} + +// SetNillableLastModifiedAt sets the "last_modified_at" field if the given value is not nil. +func (hfc *HostFileCreate) SetNillableLastModifiedAt(t *time.Time) *HostFileCreate { + if t != nil { + hfc.SetLastModifiedAt(*t) + } + return hfc +} + +// SetPath sets the "path" field. +func (hfc *HostFileCreate) SetPath(s string) *HostFileCreate { + hfc.mutation.SetPath(s) + return hfc +} + +// SetOwner sets the "owner" field. +func (hfc *HostFileCreate) SetOwner(s string) *HostFileCreate { + hfc.mutation.SetOwner(s) + return hfc +} + +// SetNillableOwner sets the "owner" field if the given value is not nil. +func (hfc *HostFileCreate) SetNillableOwner(s *string) *HostFileCreate { + if s != nil { + hfc.SetOwner(*s) + } + return hfc +} + +// SetGroup sets the "group" field. +func (hfc *HostFileCreate) SetGroup(s string) *HostFileCreate { + hfc.mutation.SetGroup(s) + return hfc +} + +// SetNillableGroup sets the "group" field if the given value is not nil. +func (hfc *HostFileCreate) SetNillableGroup(s *string) *HostFileCreate { + if s != nil { + hfc.SetGroup(*s) + } + return hfc +} + +// SetPermissions sets the "permissions" field. +func (hfc *HostFileCreate) SetPermissions(s string) *HostFileCreate { + hfc.mutation.SetPermissions(s) + return hfc +} + +// SetNillablePermissions sets the "permissions" field if the given value is not nil. +func (hfc *HostFileCreate) SetNillablePermissions(s *string) *HostFileCreate { + if s != nil { + hfc.SetPermissions(*s) + } + return hfc +} + +// SetSize sets the "size" field. +func (hfc *HostFileCreate) SetSize(i int) *HostFileCreate { + hfc.mutation.SetSize(i) + return hfc +} + +// SetNillableSize sets the "size" field if the given value is not nil. +func (hfc *HostFileCreate) SetNillableSize(i *int) *HostFileCreate { + if i != nil { + hfc.SetSize(*i) + } + return hfc +} + +// SetHash sets the "hash" field. +func (hfc *HostFileCreate) SetHash(s string) *HostFileCreate { + hfc.mutation.SetHash(s) + return hfc +} + +// SetNillableHash sets the "hash" field if the given value is not nil. +func (hfc *HostFileCreate) SetNillableHash(s *string) *HostFileCreate { + if s != nil { + hfc.SetHash(*s) + } + return hfc +} + +// SetContent sets the "content" field. +func (hfc *HostFileCreate) SetContent(b []byte) *HostFileCreate { + hfc.mutation.SetContent(b) + return hfc +} + +// SetHostID sets the "host" edge to the Host entity by ID. +func (hfc *HostFileCreate) SetHostID(id int) *HostFileCreate { + hfc.mutation.SetHostID(id) + return hfc +} + +// SetHost sets the "host" edge to the Host entity. +func (hfc *HostFileCreate) SetHost(h *Host) *HostFileCreate { + return hfc.SetHostID(h.ID) +} + +// SetTaskID sets the "task" edge to the Task entity by ID. +func (hfc *HostFileCreate) SetTaskID(id int) *HostFileCreate { + hfc.mutation.SetTaskID(id) + return hfc +} + +// SetTask sets the "task" edge to the Task entity. +func (hfc *HostFileCreate) SetTask(t *Task) *HostFileCreate { + return hfc.SetTaskID(t.ID) +} + +// Mutation returns the HostFileMutation object of the builder. +func (hfc *HostFileCreate) Mutation() *HostFileMutation { + return hfc.mutation +} + +// Save creates the HostFile in the database. +func (hfc *HostFileCreate) Save(ctx context.Context) (*HostFile, error) { + if err := hfc.defaults(); err != nil { + return nil, err + } + return withHooks(ctx, hfc.sqlSave, hfc.mutation, hfc.hooks) +} + +// SaveX calls Save and panics if Save returns an error. +func (hfc *HostFileCreate) SaveX(ctx context.Context) *HostFile { + v, err := hfc.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (hfc *HostFileCreate) Exec(ctx context.Context) error { + _, err := hfc.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (hfc *HostFileCreate) ExecX(ctx context.Context) { + if err := hfc.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (hfc *HostFileCreate) defaults() error { + if _, ok := hfc.mutation.CreatedAt(); !ok { + if hostfile.DefaultCreatedAt == nil { + return fmt.Errorf("ent: uninitialized hostfile.DefaultCreatedAt (forgotten import ent/runtime?)") + } + v := hostfile.DefaultCreatedAt() + hfc.mutation.SetCreatedAt(v) + } + if _, ok := hfc.mutation.LastModifiedAt(); !ok { + if hostfile.DefaultLastModifiedAt == nil { + return fmt.Errorf("ent: uninitialized hostfile.DefaultLastModifiedAt (forgotten import ent/runtime?)") + } + v := hostfile.DefaultLastModifiedAt() + hfc.mutation.SetLastModifiedAt(v) + } + if _, ok := hfc.mutation.Size(); !ok { + v := hostfile.DefaultSize + hfc.mutation.SetSize(v) + } + return nil +} + +// check runs all checks and user-defined validators on the builder. +func (hfc *HostFileCreate) check() error { + if _, ok := hfc.mutation.CreatedAt(); !ok { + return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "HostFile.created_at"`)} + } + if _, ok := hfc.mutation.LastModifiedAt(); !ok { + return &ValidationError{Name: "last_modified_at", err: errors.New(`ent: missing required field "HostFile.last_modified_at"`)} + } + if _, ok := hfc.mutation.Path(); !ok { + return &ValidationError{Name: "path", err: errors.New(`ent: missing required field "HostFile.path"`)} + } + if v, ok := hfc.mutation.Path(); ok { + if err := hostfile.PathValidator(v); err != nil { + return &ValidationError{Name: "path", err: fmt.Errorf(`ent: validator failed for field "HostFile.path": %w`, err)} + } + } + if _, ok := hfc.mutation.Size(); !ok { + return &ValidationError{Name: "size", err: errors.New(`ent: missing required field "HostFile.size"`)} + } + if v, ok := hfc.mutation.Size(); ok { + if err := hostfile.SizeValidator(v); err != nil { + return &ValidationError{Name: "size", err: fmt.Errorf(`ent: validator failed for field "HostFile.size": %w`, err)} + } + } + if v, ok := hfc.mutation.Hash(); ok { + if err := hostfile.HashValidator(v); err != nil { + return &ValidationError{Name: "hash", err: fmt.Errorf(`ent: validator failed for field "HostFile.hash": %w`, err)} + } + } + if _, ok := hfc.mutation.HostID(); !ok { + return &ValidationError{Name: "host", err: errors.New(`ent: missing required edge "HostFile.host"`)} + } + if _, ok := hfc.mutation.TaskID(); !ok { + return &ValidationError{Name: "task", err: errors.New(`ent: missing required edge "HostFile.task"`)} + } + return nil +} + +func (hfc *HostFileCreate) sqlSave(ctx context.Context) (*HostFile, error) { + if err := hfc.check(); err != nil { + return nil, err + } + _node, _spec := hfc.createSpec() + if err := sqlgraph.CreateNode(ctx, hfc.driver, _spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + id := _spec.ID.Value.(int64) + _node.ID = int(id) + hfc.mutation.id = &_node.ID + hfc.mutation.done = true + return _node, nil +} + +func (hfc *HostFileCreate) createSpec() (*HostFile, *sqlgraph.CreateSpec) { + var ( + _node = &HostFile{config: hfc.config} + _spec = sqlgraph.NewCreateSpec(hostfile.Table, sqlgraph.NewFieldSpec(hostfile.FieldID, field.TypeInt)) + ) + _spec.OnConflict = hfc.conflict + if value, ok := hfc.mutation.CreatedAt(); ok { + _spec.SetField(hostfile.FieldCreatedAt, field.TypeTime, value) + _node.CreatedAt = value + } + if value, ok := hfc.mutation.LastModifiedAt(); ok { + _spec.SetField(hostfile.FieldLastModifiedAt, field.TypeTime, value) + _node.LastModifiedAt = value + } + if value, ok := hfc.mutation.Path(); ok { + _spec.SetField(hostfile.FieldPath, field.TypeString, value) + _node.Path = value + } + if value, ok := hfc.mutation.Owner(); ok { + _spec.SetField(hostfile.FieldOwner, field.TypeString, value) + _node.Owner = value + } + if value, ok := hfc.mutation.Group(); ok { + _spec.SetField(hostfile.FieldGroup, field.TypeString, value) + _node.Group = value + } + if value, ok := hfc.mutation.Permissions(); ok { + _spec.SetField(hostfile.FieldPermissions, field.TypeString, value) + _node.Permissions = value + } + if value, ok := hfc.mutation.Size(); ok { + _spec.SetField(hostfile.FieldSize, field.TypeInt, value) + _node.Size = value + } + if value, ok := hfc.mutation.Hash(); ok { + _spec.SetField(hostfile.FieldHash, field.TypeString, value) + _node.Hash = value + } + if value, ok := hfc.mutation.Content(); ok { + _spec.SetField(hostfile.FieldContent, field.TypeBytes, value) + _node.Content = value + } + if nodes := hfc.mutation.HostIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: hostfile.HostTable, + Columns: []string{hostfile.HostColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(host.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _node.host_file_host = &nodes[0] + _spec.Edges = append(_spec.Edges, edge) + } + if nodes := hfc.mutation.TaskIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: hostfile.TaskTable, + Columns: []string{hostfile.TaskColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(task.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _node.task_reported_files = &nodes[0] + _spec.Edges = append(_spec.Edges, edge) + } + return _node, _spec +} + +// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause +// of the `INSERT` statement. For example: +// +// client.HostFile.Create(). +// SetCreatedAt(v). +// OnConflict( +// // Update the row with the new values +// // the was proposed for insertion. +// sql.ResolveWithNewValues(), +// ). +// // Override some of the fields with custom +// // update values. +// Update(func(u *ent.HostFileUpsert) { +// SetCreatedAt(v+v). +// }). +// Exec(ctx) +func (hfc *HostFileCreate) OnConflict(opts ...sql.ConflictOption) *HostFileUpsertOne { + hfc.conflict = opts + return &HostFileUpsertOne{ + create: hfc, + } +} + +// OnConflictColumns calls `OnConflict` and configures the columns +// as conflict target. Using this option is equivalent to using: +// +// client.HostFile.Create(). +// OnConflict(sql.ConflictColumns(columns...)). +// Exec(ctx) +func (hfc *HostFileCreate) OnConflictColumns(columns ...string) *HostFileUpsertOne { + hfc.conflict = append(hfc.conflict, sql.ConflictColumns(columns...)) + return &HostFileUpsertOne{ + create: hfc, + } +} + +type ( + // HostFileUpsertOne is the builder for "upsert"-ing + // one HostFile node. + HostFileUpsertOne struct { + create *HostFileCreate + } + + // HostFileUpsert is the "OnConflict" setter. + HostFileUpsert struct { + *sql.UpdateSet + } +) + +// SetLastModifiedAt sets the "last_modified_at" field. +func (u *HostFileUpsert) SetLastModifiedAt(v time.Time) *HostFileUpsert { + u.Set(hostfile.FieldLastModifiedAt, v) + return u +} + +// UpdateLastModifiedAt sets the "last_modified_at" field to the value that was provided on create. +func (u *HostFileUpsert) UpdateLastModifiedAt() *HostFileUpsert { + u.SetExcluded(hostfile.FieldLastModifiedAt) + return u +} + +// SetPath sets the "path" field. +func (u *HostFileUpsert) SetPath(v string) *HostFileUpsert { + u.Set(hostfile.FieldPath, v) + return u +} + +// UpdatePath sets the "path" field to the value that was provided on create. +func (u *HostFileUpsert) UpdatePath() *HostFileUpsert { + u.SetExcluded(hostfile.FieldPath) + return u +} + +// SetOwner sets the "owner" field. +func (u *HostFileUpsert) SetOwner(v string) *HostFileUpsert { + u.Set(hostfile.FieldOwner, v) + return u +} + +// UpdateOwner sets the "owner" field to the value that was provided on create. +func (u *HostFileUpsert) UpdateOwner() *HostFileUpsert { + u.SetExcluded(hostfile.FieldOwner) + return u +} + +// ClearOwner clears the value of the "owner" field. +func (u *HostFileUpsert) ClearOwner() *HostFileUpsert { + u.SetNull(hostfile.FieldOwner) + return u +} + +// SetGroup sets the "group" field. +func (u *HostFileUpsert) SetGroup(v string) *HostFileUpsert { + u.Set(hostfile.FieldGroup, v) + return u +} + +// UpdateGroup sets the "group" field to the value that was provided on create. +func (u *HostFileUpsert) UpdateGroup() *HostFileUpsert { + u.SetExcluded(hostfile.FieldGroup) + return u +} + +// ClearGroup clears the value of the "group" field. +func (u *HostFileUpsert) ClearGroup() *HostFileUpsert { + u.SetNull(hostfile.FieldGroup) + return u +} + +// SetPermissions sets the "permissions" field. +func (u *HostFileUpsert) SetPermissions(v string) *HostFileUpsert { + u.Set(hostfile.FieldPermissions, v) + return u +} + +// UpdatePermissions sets the "permissions" field to the value that was provided on create. +func (u *HostFileUpsert) UpdatePermissions() *HostFileUpsert { + u.SetExcluded(hostfile.FieldPermissions) + return u +} + +// ClearPermissions clears the value of the "permissions" field. +func (u *HostFileUpsert) ClearPermissions() *HostFileUpsert { + u.SetNull(hostfile.FieldPermissions) + return u +} + +// SetSize sets the "size" field. +func (u *HostFileUpsert) SetSize(v int) *HostFileUpsert { + u.Set(hostfile.FieldSize, v) + return u +} + +// UpdateSize sets the "size" field to the value that was provided on create. +func (u *HostFileUpsert) UpdateSize() *HostFileUpsert { + u.SetExcluded(hostfile.FieldSize) + return u +} + +// AddSize adds v to the "size" field. +func (u *HostFileUpsert) AddSize(v int) *HostFileUpsert { + u.Add(hostfile.FieldSize, v) + return u +} + +// SetHash sets the "hash" field. +func (u *HostFileUpsert) SetHash(v string) *HostFileUpsert { + u.Set(hostfile.FieldHash, v) + return u +} + +// UpdateHash sets the "hash" field to the value that was provided on create. +func (u *HostFileUpsert) UpdateHash() *HostFileUpsert { + u.SetExcluded(hostfile.FieldHash) + return u +} + +// ClearHash clears the value of the "hash" field. +func (u *HostFileUpsert) ClearHash() *HostFileUpsert { + u.SetNull(hostfile.FieldHash) + return u +} + +// SetContent sets the "content" field. +func (u *HostFileUpsert) SetContent(v []byte) *HostFileUpsert { + u.Set(hostfile.FieldContent, v) + return u +} + +// UpdateContent sets the "content" field to the value that was provided on create. +func (u *HostFileUpsert) UpdateContent() *HostFileUpsert { + u.SetExcluded(hostfile.FieldContent) + return u +} + +// ClearContent clears the value of the "content" field. +func (u *HostFileUpsert) ClearContent() *HostFileUpsert { + u.SetNull(hostfile.FieldContent) + return u +} + +// UpdateNewValues updates the mutable fields using the new values that were set on create. +// Using this option is equivalent to using: +// +// client.HostFile.Create(). +// OnConflict( +// sql.ResolveWithNewValues(), +// ). +// Exec(ctx) +func (u *HostFileUpsertOne) UpdateNewValues() *HostFileUpsertOne { + u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues()) + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) { + if _, exists := u.create.mutation.CreatedAt(); exists { + s.SetIgnore(hostfile.FieldCreatedAt) + } + })) + return u +} + +// Ignore sets each column to itself in case of conflict. +// Using this option is equivalent to using: +// +// client.HostFile.Create(). +// OnConflict(sql.ResolveWithIgnore()). +// Exec(ctx) +func (u *HostFileUpsertOne) Ignore() *HostFileUpsertOne { + u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore()) + return u +} + +// DoNothing configures the conflict_action to `DO NOTHING`. +// Supported only by SQLite and PostgreSQL. +func (u *HostFileUpsertOne) DoNothing() *HostFileUpsertOne { + u.create.conflict = append(u.create.conflict, sql.DoNothing()) + return u +} + +// Update allows overriding fields `UPDATE` values. See the HostFileCreate.OnConflict +// documentation for more info. +func (u *HostFileUpsertOne) Update(set func(*HostFileUpsert)) *HostFileUpsertOne { + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { + set(&HostFileUpsert{UpdateSet: update}) + })) + return u +} + +// SetLastModifiedAt sets the "last_modified_at" field. +func (u *HostFileUpsertOne) SetLastModifiedAt(v time.Time) *HostFileUpsertOne { + return u.Update(func(s *HostFileUpsert) { + s.SetLastModifiedAt(v) + }) +} + +// UpdateLastModifiedAt sets the "last_modified_at" field to the value that was provided on create. +func (u *HostFileUpsertOne) UpdateLastModifiedAt() *HostFileUpsertOne { + return u.Update(func(s *HostFileUpsert) { + s.UpdateLastModifiedAt() + }) +} + +// SetPath sets the "path" field. +func (u *HostFileUpsertOne) SetPath(v string) *HostFileUpsertOne { + return u.Update(func(s *HostFileUpsert) { + s.SetPath(v) + }) +} + +// UpdatePath sets the "path" field to the value that was provided on create. +func (u *HostFileUpsertOne) UpdatePath() *HostFileUpsertOne { + return u.Update(func(s *HostFileUpsert) { + s.UpdatePath() + }) +} + +// SetOwner sets the "owner" field. +func (u *HostFileUpsertOne) SetOwner(v string) *HostFileUpsertOne { + return u.Update(func(s *HostFileUpsert) { + s.SetOwner(v) + }) +} + +// UpdateOwner sets the "owner" field to the value that was provided on create. +func (u *HostFileUpsertOne) UpdateOwner() *HostFileUpsertOne { + return u.Update(func(s *HostFileUpsert) { + s.UpdateOwner() + }) +} + +// ClearOwner clears the value of the "owner" field. +func (u *HostFileUpsertOne) ClearOwner() *HostFileUpsertOne { + return u.Update(func(s *HostFileUpsert) { + s.ClearOwner() + }) +} + +// SetGroup sets the "group" field. +func (u *HostFileUpsertOne) SetGroup(v string) *HostFileUpsertOne { + return u.Update(func(s *HostFileUpsert) { + s.SetGroup(v) + }) +} + +// UpdateGroup sets the "group" field to the value that was provided on create. +func (u *HostFileUpsertOne) UpdateGroup() *HostFileUpsertOne { + return u.Update(func(s *HostFileUpsert) { + s.UpdateGroup() + }) +} + +// ClearGroup clears the value of the "group" field. +func (u *HostFileUpsertOne) ClearGroup() *HostFileUpsertOne { + return u.Update(func(s *HostFileUpsert) { + s.ClearGroup() + }) +} + +// SetPermissions sets the "permissions" field. +func (u *HostFileUpsertOne) SetPermissions(v string) *HostFileUpsertOne { + return u.Update(func(s *HostFileUpsert) { + s.SetPermissions(v) + }) +} + +// UpdatePermissions sets the "permissions" field to the value that was provided on create. +func (u *HostFileUpsertOne) UpdatePermissions() *HostFileUpsertOne { + return u.Update(func(s *HostFileUpsert) { + s.UpdatePermissions() + }) +} + +// ClearPermissions clears the value of the "permissions" field. +func (u *HostFileUpsertOne) ClearPermissions() *HostFileUpsertOne { + return u.Update(func(s *HostFileUpsert) { + s.ClearPermissions() + }) +} + +// SetSize sets the "size" field. +func (u *HostFileUpsertOne) SetSize(v int) *HostFileUpsertOne { + return u.Update(func(s *HostFileUpsert) { + s.SetSize(v) + }) +} + +// AddSize adds v to the "size" field. +func (u *HostFileUpsertOne) AddSize(v int) *HostFileUpsertOne { + return u.Update(func(s *HostFileUpsert) { + s.AddSize(v) + }) +} + +// UpdateSize sets the "size" field to the value that was provided on create. +func (u *HostFileUpsertOne) UpdateSize() *HostFileUpsertOne { + return u.Update(func(s *HostFileUpsert) { + s.UpdateSize() + }) +} + +// SetHash sets the "hash" field. +func (u *HostFileUpsertOne) SetHash(v string) *HostFileUpsertOne { + return u.Update(func(s *HostFileUpsert) { + s.SetHash(v) + }) +} + +// UpdateHash sets the "hash" field to the value that was provided on create. +func (u *HostFileUpsertOne) UpdateHash() *HostFileUpsertOne { + return u.Update(func(s *HostFileUpsert) { + s.UpdateHash() + }) +} + +// ClearHash clears the value of the "hash" field. +func (u *HostFileUpsertOne) ClearHash() *HostFileUpsertOne { + return u.Update(func(s *HostFileUpsert) { + s.ClearHash() + }) +} + +// SetContent sets the "content" field. +func (u *HostFileUpsertOne) SetContent(v []byte) *HostFileUpsertOne { + return u.Update(func(s *HostFileUpsert) { + s.SetContent(v) + }) +} + +// UpdateContent sets the "content" field to the value that was provided on create. +func (u *HostFileUpsertOne) UpdateContent() *HostFileUpsertOne { + return u.Update(func(s *HostFileUpsert) { + s.UpdateContent() + }) +} + +// ClearContent clears the value of the "content" field. +func (u *HostFileUpsertOne) ClearContent() *HostFileUpsertOne { + return u.Update(func(s *HostFileUpsert) { + s.ClearContent() + }) +} + +// Exec executes the query. +func (u *HostFileUpsertOne) Exec(ctx context.Context) error { + if len(u.create.conflict) == 0 { + return errors.New("ent: missing options for HostFileCreate.OnConflict") + } + return u.create.Exec(ctx) +} + +// ExecX is like Exec, but panics if an error occurs. +func (u *HostFileUpsertOne) ExecX(ctx context.Context) { + if err := u.create.Exec(ctx); err != nil { + panic(err) + } +} + +// Exec executes the UPSERT query and returns the inserted/updated ID. +func (u *HostFileUpsertOne) ID(ctx context.Context) (id int, err error) { + node, err := u.create.Save(ctx) + if err != nil { + return id, err + } + return node.ID, nil +} + +// IDX is like ID, but panics if an error occurs. +func (u *HostFileUpsertOne) IDX(ctx context.Context) int { + id, err := u.ID(ctx) + if err != nil { + panic(err) + } + return id +} + +// HostFileCreateBulk is the builder for creating many HostFile entities in bulk. +type HostFileCreateBulk struct { + config + err error + builders []*HostFileCreate + conflict []sql.ConflictOption +} + +// Save creates the HostFile entities in the database. +func (hfcb *HostFileCreateBulk) Save(ctx context.Context) ([]*HostFile, error) { + if hfcb.err != nil { + return nil, hfcb.err + } + specs := make([]*sqlgraph.CreateSpec, len(hfcb.builders)) + nodes := make([]*HostFile, len(hfcb.builders)) + mutators := make([]Mutator, len(hfcb.builders)) + for i := range hfcb.builders { + func(i int, root context.Context) { + builder := hfcb.builders[i] + builder.defaults() + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*HostFileMutation) + if !ok { + return nil, fmt.Errorf("unexpected mutation type %T", m) + } + if err := builder.check(); err != nil { + return nil, err + } + builder.mutation = mutation + var err error + nodes[i], specs[i] = builder.createSpec() + if i < len(mutators)-1 { + _, err = mutators[i+1].Mutate(root, hfcb.builders[i+1].mutation) + } else { + spec := &sqlgraph.BatchCreateSpec{Nodes: specs} + spec.OnConflict = hfcb.conflict + // Invoke the actual operation on the latest mutation in the chain. + if err = sqlgraph.BatchCreate(ctx, hfcb.driver, spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + } + } + if err != nil { + return nil, err + } + mutation.id = &nodes[i].ID + if specs[i].ID.Value != nil { + id := specs[i].ID.Value.(int64) + nodes[i].ID = int(id) + } + mutation.done = true + return nodes[i], nil + }) + for i := len(builder.hooks) - 1; i >= 0; i-- { + mut = builder.hooks[i](mut) + } + mutators[i] = mut + }(i, ctx) + } + if len(mutators) > 0 { + if _, err := mutators[0].Mutate(ctx, hfcb.builders[0].mutation); err != nil { + return nil, err + } + } + return nodes, nil +} + +// SaveX is like Save, but panics if an error occurs. +func (hfcb *HostFileCreateBulk) SaveX(ctx context.Context) []*HostFile { + v, err := hfcb.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (hfcb *HostFileCreateBulk) Exec(ctx context.Context) error { + _, err := hfcb.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (hfcb *HostFileCreateBulk) ExecX(ctx context.Context) { + if err := hfcb.Exec(ctx); err != nil { + panic(err) + } +} + +// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause +// of the `INSERT` statement. For example: +// +// client.HostFile.CreateBulk(builders...). +// OnConflict( +// // Update the row with the new values +// // the was proposed for insertion. +// sql.ResolveWithNewValues(), +// ). +// // Override some of the fields with custom +// // update values. +// Update(func(u *ent.HostFileUpsert) { +// SetCreatedAt(v+v). +// }). +// Exec(ctx) +func (hfcb *HostFileCreateBulk) OnConflict(opts ...sql.ConflictOption) *HostFileUpsertBulk { + hfcb.conflict = opts + return &HostFileUpsertBulk{ + create: hfcb, + } +} + +// OnConflictColumns calls `OnConflict` and configures the columns +// as conflict target. Using this option is equivalent to using: +// +// client.HostFile.Create(). +// OnConflict(sql.ConflictColumns(columns...)). +// Exec(ctx) +func (hfcb *HostFileCreateBulk) OnConflictColumns(columns ...string) *HostFileUpsertBulk { + hfcb.conflict = append(hfcb.conflict, sql.ConflictColumns(columns...)) + return &HostFileUpsertBulk{ + create: hfcb, + } +} + +// HostFileUpsertBulk is the builder for "upsert"-ing +// a bulk of HostFile nodes. +type HostFileUpsertBulk struct { + create *HostFileCreateBulk +} + +// UpdateNewValues updates the mutable fields using the new values that +// were set on create. Using this option is equivalent to using: +// +// client.HostFile.Create(). +// OnConflict( +// sql.ResolveWithNewValues(), +// ). +// Exec(ctx) +func (u *HostFileUpsertBulk) UpdateNewValues() *HostFileUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues()) + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) { + for _, b := range u.create.builders { + if _, exists := b.mutation.CreatedAt(); exists { + s.SetIgnore(hostfile.FieldCreatedAt) + } + } + })) + return u +} + +// Ignore sets each column to itself in case of conflict. +// Using this option is equivalent to using: +// +// client.HostFile.Create(). +// OnConflict(sql.ResolveWithIgnore()). +// Exec(ctx) +func (u *HostFileUpsertBulk) Ignore() *HostFileUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore()) + return u +} + +// DoNothing configures the conflict_action to `DO NOTHING`. +// Supported only by SQLite and PostgreSQL. +func (u *HostFileUpsertBulk) DoNothing() *HostFileUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.DoNothing()) + return u +} + +// Update allows overriding fields `UPDATE` values. See the HostFileCreateBulk.OnConflict +// documentation for more info. +func (u *HostFileUpsertBulk) Update(set func(*HostFileUpsert)) *HostFileUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { + set(&HostFileUpsert{UpdateSet: update}) + })) + return u +} + +// SetLastModifiedAt sets the "last_modified_at" field. +func (u *HostFileUpsertBulk) SetLastModifiedAt(v time.Time) *HostFileUpsertBulk { + return u.Update(func(s *HostFileUpsert) { + s.SetLastModifiedAt(v) + }) +} + +// UpdateLastModifiedAt sets the "last_modified_at" field to the value that was provided on create. +func (u *HostFileUpsertBulk) UpdateLastModifiedAt() *HostFileUpsertBulk { + return u.Update(func(s *HostFileUpsert) { + s.UpdateLastModifiedAt() + }) +} + +// SetPath sets the "path" field. +func (u *HostFileUpsertBulk) SetPath(v string) *HostFileUpsertBulk { + return u.Update(func(s *HostFileUpsert) { + s.SetPath(v) + }) +} + +// UpdatePath sets the "path" field to the value that was provided on create. +func (u *HostFileUpsertBulk) UpdatePath() *HostFileUpsertBulk { + return u.Update(func(s *HostFileUpsert) { + s.UpdatePath() + }) +} + +// SetOwner sets the "owner" field. +func (u *HostFileUpsertBulk) SetOwner(v string) *HostFileUpsertBulk { + return u.Update(func(s *HostFileUpsert) { + s.SetOwner(v) + }) +} + +// UpdateOwner sets the "owner" field to the value that was provided on create. +func (u *HostFileUpsertBulk) UpdateOwner() *HostFileUpsertBulk { + return u.Update(func(s *HostFileUpsert) { + s.UpdateOwner() + }) +} + +// ClearOwner clears the value of the "owner" field. +func (u *HostFileUpsertBulk) ClearOwner() *HostFileUpsertBulk { + return u.Update(func(s *HostFileUpsert) { + s.ClearOwner() + }) +} + +// SetGroup sets the "group" field. +func (u *HostFileUpsertBulk) SetGroup(v string) *HostFileUpsertBulk { + return u.Update(func(s *HostFileUpsert) { + s.SetGroup(v) + }) +} + +// UpdateGroup sets the "group" field to the value that was provided on create. +func (u *HostFileUpsertBulk) UpdateGroup() *HostFileUpsertBulk { + return u.Update(func(s *HostFileUpsert) { + s.UpdateGroup() + }) +} + +// ClearGroup clears the value of the "group" field. +func (u *HostFileUpsertBulk) ClearGroup() *HostFileUpsertBulk { + return u.Update(func(s *HostFileUpsert) { + s.ClearGroup() + }) +} + +// SetPermissions sets the "permissions" field. +func (u *HostFileUpsertBulk) SetPermissions(v string) *HostFileUpsertBulk { + return u.Update(func(s *HostFileUpsert) { + s.SetPermissions(v) + }) +} + +// UpdatePermissions sets the "permissions" field to the value that was provided on create. +func (u *HostFileUpsertBulk) UpdatePermissions() *HostFileUpsertBulk { + return u.Update(func(s *HostFileUpsert) { + s.UpdatePermissions() + }) +} + +// ClearPermissions clears the value of the "permissions" field. +func (u *HostFileUpsertBulk) ClearPermissions() *HostFileUpsertBulk { + return u.Update(func(s *HostFileUpsert) { + s.ClearPermissions() + }) +} + +// SetSize sets the "size" field. +func (u *HostFileUpsertBulk) SetSize(v int) *HostFileUpsertBulk { + return u.Update(func(s *HostFileUpsert) { + s.SetSize(v) + }) +} + +// AddSize adds v to the "size" field. +func (u *HostFileUpsertBulk) AddSize(v int) *HostFileUpsertBulk { + return u.Update(func(s *HostFileUpsert) { + s.AddSize(v) + }) +} + +// UpdateSize sets the "size" field to the value that was provided on create. +func (u *HostFileUpsertBulk) UpdateSize() *HostFileUpsertBulk { + return u.Update(func(s *HostFileUpsert) { + s.UpdateSize() + }) +} + +// SetHash sets the "hash" field. +func (u *HostFileUpsertBulk) SetHash(v string) *HostFileUpsertBulk { + return u.Update(func(s *HostFileUpsert) { + s.SetHash(v) + }) +} + +// UpdateHash sets the "hash" field to the value that was provided on create. +func (u *HostFileUpsertBulk) UpdateHash() *HostFileUpsertBulk { + return u.Update(func(s *HostFileUpsert) { + s.UpdateHash() + }) +} + +// ClearHash clears the value of the "hash" field. +func (u *HostFileUpsertBulk) ClearHash() *HostFileUpsertBulk { + return u.Update(func(s *HostFileUpsert) { + s.ClearHash() + }) +} + +// SetContent sets the "content" field. +func (u *HostFileUpsertBulk) SetContent(v []byte) *HostFileUpsertBulk { + return u.Update(func(s *HostFileUpsert) { + s.SetContent(v) + }) +} + +// UpdateContent sets the "content" field to the value that was provided on create. +func (u *HostFileUpsertBulk) UpdateContent() *HostFileUpsertBulk { + return u.Update(func(s *HostFileUpsert) { + s.UpdateContent() + }) +} + +// ClearContent clears the value of the "content" field. +func (u *HostFileUpsertBulk) ClearContent() *HostFileUpsertBulk { + return u.Update(func(s *HostFileUpsert) { + s.ClearContent() + }) +} + +// Exec executes the query. +func (u *HostFileUpsertBulk) Exec(ctx context.Context) error { + if u.create.err != nil { + return u.create.err + } + for i, b := range u.create.builders { + if len(b.conflict) != 0 { + return fmt.Errorf("ent: OnConflict was set for builder %d. Set it on the HostFileCreateBulk instead", i) + } + } + if len(u.create.conflict) == 0 { + return errors.New("ent: missing options for HostFileCreateBulk.OnConflict") + } + return u.create.Exec(ctx) +} + +// ExecX is like Exec, but panics if an error occurs. +func (u *HostFileUpsertBulk) ExecX(ctx context.Context) { + if err := u.create.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/tavern/internal/ent/hostfile_delete.go b/tavern/internal/ent/hostfile_delete.go new file mode 100644 index 000000000..e2c318b28 --- /dev/null +++ b/tavern/internal/ent/hostfile_delete.go @@ -0,0 +1,88 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "realm.pub/tavern/internal/ent/hostfile" + "realm.pub/tavern/internal/ent/predicate" +) + +// HostFileDelete is the builder for deleting a HostFile entity. +type HostFileDelete struct { + config + hooks []Hook + mutation *HostFileMutation +} + +// Where appends a list predicates to the HostFileDelete builder. +func (hfd *HostFileDelete) Where(ps ...predicate.HostFile) *HostFileDelete { + hfd.mutation.Where(ps...) + return hfd +} + +// Exec executes the deletion query and returns how many vertices were deleted. +func (hfd *HostFileDelete) Exec(ctx context.Context) (int, error) { + return withHooks(ctx, hfd.sqlExec, hfd.mutation, hfd.hooks) +} + +// ExecX is like Exec, but panics if an error occurs. +func (hfd *HostFileDelete) ExecX(ctx context.Context) int { + n, err := hfd.Exec(ctx) + if err != nil { + panic(err) + } + return n +} + +func (hfd *HostFileDelete) sqlExec(ctx context.Context) (int, error) { + _spec := sqlgraph.NewDeleteSpec(hostfile.Table, sqlgraph.NewFieldSpec(hostfile.FieldID, field.TypeInt)) + if ps := hfd.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + affected, err := sqlgraph.DeleteNodes(ctx, hfd.driver, _spec) + if err != nil && sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + hfd.mutation.done = true + return affected, err +} + +// HostFileDeleteOne is the builder for deleting a single HostFile entity. +type HostFileDeleteOne struct { + hfd *HostFileDelete +} + +// Where appends a list predicates to the HostFileDelete builder. +func (hfdo *HostFileDeleteOne) Where(ps ...predicate.HostFile) *HostFileDeleteOne { + hfdo.hfd.mutation.Where(ps...) + return hfdo +} + +// Exec executes the deletion query. +func (hfdo *HostFileDeleteOne) Exec(ctx context.Context) error { + n, err := hfdo.hfd.Exec(ctx) + switch { + case err != nil: + return err + case n == 0: + return &NotFoundError{hostfile.Label} + default: + return nil + } +} + +// ExecX is like Exec, but panics if an error occurs. +func (hfdo *HostFileDeleteOne) ExecX(ctx context.Context) { + if err := hfdo.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/tavern/internal/ent/hostfile_query.go b/tavern/internal/ent/hostfile_query.go new file mode 100644 index 000000000..b3ff371bd --- /dev/null +++ b/tavern/internal/ent/hostfile_query.go @@ -0,0 +1,701 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "fmt" + "math" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "realm.pub/tavern/internal/ent/host" + "realm.pub/tavern/internal/ent/hostfile" + "realm.pub/tavern/internal/ent/predicate" + "realm.pub/tavern/internal/ent/task" +) + +// HostFileQuery is the builder for querying HostFile entities. +type HostFileQuery struct { + config + ctx *QueryContext + order []hostfile.OrderOption + inters []Interceptor + predicates []predicate.HostFile + withHost *HostQuery + withTask *TaskQuery + withFKs bool + modifiers []func(*sql.Selector) + loadTotal []func(context.Context, []*HostFile) error + // intermediate query (i.e. traversal path). + sql *sql.Selector + path func(context.Context) (*sql.Selector, error) +} + +// Where adds a new predicate for the HostFileQuery builder. +func (hfq *HostFileQuery) Where(ps ...predicate.HostFile) *HostFileQuery { + hfq.predicates = append(hfq.predicates, ps...) + return hfq +} + +// Limit the number of records to be returned by this query. +func (hfq *HostFileQuery) Limit(limit int) *HostFileQuery { + hfq.ctx.Limit = &limit + return hfq +} + +// Offset to start from. +func (hfq *HostFileQuery) Offset(offset int) *HostFileQuery { + hfq.ctx.Offset = &offset + return hfq +} + +// Unique configures the query builder to filter duplicate records on query. +// By default, unique is set to true, and can be disabled using this method. +func (hfq *HostFileQuery) Unique(unique bool) *HostFileQuery { + hfq.ctx.Unique = &unique + return hfq +} + +// Order specifies how the records should be ordered. +func (hfq *HostFileQuery) Order(o ...hostfile.OrderOption) *HostFileQuery { + hfq.order = append(hfq.order, o...) + return hfq +} + +// QueryHost chains the current query on the "host" edge. +func (hfq *HostFileQuery) QueryHost() *HostQuery { + query := (&HostClient{config: hfq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := hfq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := hfq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(hostfile.Table, hostfile.FieldID, selector), + sqlgraph.To(host.Table, host.FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, hostfile.HostTable, hostfile.HostColumn), + ) + fromU = sqlgraph.SetNeighbors(hfq.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// QueryTask chains the current query on the "task" edge. +func (hfq *HostFileQuery) QueryTask() *TaskQuery { + query := (&TaskClient{config: hfq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := hfq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := hfq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(hostfile.Table, hostfile.FieldID, selector), + sqlgraph.To(task.Table, task.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, hostfile.TaskTable, hostfile.TaskColumn), + ) + fromU = sqlgraph.SetNeighbors(hfq.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// First returns the first HostFile entity from the query. +// Returns a *NotFoundError when no HostFile was found. +func (hfq *HostFileQuery) First(ctx context.Context) (*HostFile, error) { + nodes, err := hfq.Limit(1).All(setContextOp(ctx, hfq.ctx, "First")) + if err != nil { + return nil, err + } + if len(nodes) == 0 { + return nil, &NotFoundError{hostfile.Label} + } + return nodes[0], nil +} + +// FirstX is like First, but panics if an error occurs. +func (hfq *HostFileQuery) FirstX(ctx context.Context) *HostFile { + node, err := hfq.First(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return node +} + +// FirstID returns the first HostFile ID from the query. +// Returns a *NotFoundError when no HostFile ID was found. +func (hfq *HostFileQuery) FirstID(ctx context.Context) (id int, err error) { + var ids []int + if ids, err = hfq.Limit(1).IDs(setContextOp(ctx, hfq.ctx, "FirstID")); err != nil { + return + } + if len(ids) == 0 { + err = &NotFoundError{hostfile.Label} + return + } + return ids[0], nil +} + +// FirstIDX is like FirstID, but panics if an error occurs. +func (hfq *HostFileQuery) FirstIDX(ctx context.Context) int { + id, err := hfq.FirstID(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return id +} + +// Only returns a single HostFile entity found by the query, ensuring it only returns one. +// Returns a *NotSingularError when more than one HostFile entity is found. +// Returns a *NotFoundError when no HostFile entities are found. +func (hfq *HostFileQuery) Only(ctx context.Context) (*HostFile, error) { + nodes, err := hfq.Limit(2).All(setContextOp(ctx, hfq.ctx, "Only")) + if err != nil { + return nil, err + } + switch len(nodes) { + case 1: + return nodes[0], nil + case 0: + return nil, &NotFoundError{hostfile.Label} + default: + return nil, &NotSingularError{hostfile.Label} + } +} + +// OnlyX is like Only, but panics if an error occurs. +func (hfq *HostFileQuery) OnlyX(ctx context.Context) *HostFile { + node, err := hfq.Only(ctx) + if err != nil { + panic(err) + } + return node +} + +// OnlyID is like Only, but returns the only HostFile ID in the query. +// Returns a *NotSingularError when more than one HostFile ID is found. +// Returns a *NotFoundError when no entities are found. +func (hfq *HostFileQuery) OnlyID(ctx context.Context) (id int, err error) { + var ids []int + if ids, err = hfq.Limit(2).IDs(setContextOp(ctx, hfq.ctx, "OnlyID")); err != nil { + return + } + switch len(ids) { + case 1: + id = ids[0] + case 0: + err = &NotFoundError{hostfile.Label} + default: + err = &NotSingularError{hostfile.Label} + } + return +} + +// OnlyIDX is like OnlyID, but panics if an error occurs. +func (hfq *HostFileQuery) OnlyIDX(ctx context.Context) int { + id, err := hfq.OnlyID(ctx) + if err != nil { + panic(err) + } + return id +} + +// All executes the query and returns a list of HostFiles. +func (hfq *HostFileQuery) All(ctx context.Context) ([]*HostFile, error) { + ctx = setContextOp(ctx, hfq.ctx, "All") + if err := hfq.prepareQuery(ctx); err != nil { + return nil, err + } + qr := querierAll[[]*HostFile, *HostFileQuery]() + return withInterceptors[[]*HostFile](ctx, hfq, qr, hfq.inters) +} + +// AllX is like All, but panics if an error occurs. +func (hfq *HostFileQuery) AllX(ctx context.Context) []*HostFile { + nodes, err := hfq.All(ctx) + if err != nil { + panic(err) + } + return nodes +} + +// IDs executes the query and returns a list of HostFile IDs. +func (hfq *HostFileQuery) IDs(ctx context.Context) (ids []int, err error) { + if hfq.ctx.Unique == nil && hfq.path != nil { + hfq.Unique(true) + } + ctx = setContextOp(ctx, hfq.ctx, "IDs") + if err = hfq.Select(hostfile.FieldID).Scan(ctx, &ids); err != nil { + return nil, err + } + return ids, nil +} + +// IDsX is like IDs, but panics if an error occurs. +func (hfq *HostFileQuery) IDsX(ctx context.Context) []int { + ids, err := hfq.IDs(ctx) + if err != nil { + panic(err) + } + return ids +} + +// Count returns the count of the given query. +func (hfq *HostFileQuery) Count(ctx context.Context) (int, error) { + ctx = setContextOp(ctx, hfq.ctx, "Count") + if err := hfq.prepareQuery(ctx); err != nil { + return 0, err + } + return withInterceptors[int](ctx, hfq, querierCount[*HostFileQuery](), hfq.inters) +} + +// CountX is like Count, but panics if an error occurs. +func (hfq *HostFileQuery) CountX(ctx context.Context) int { + count, err := hfq.Count(ctx) + if err != nil { + panic(err) + } + return count +} + +// Exist returns true if the query has elements in the graph. +func (hfq *HostFileQuery) Exist(ctx context.Context) (bool, error) { + ctx = setContextOp(ctx, hfq.ctx, "Exist") + switch _, err := hfq.FirstID(ctx); { + case IsNotFound(err): + return false, nil + case err != nil: + return false, fmt.Errorf("ent: check existence: %w", err) + default: + return true, nil + } +} + +// ExistX is like Exist, but panics if an error occurs. +func (hfq *HostFileQuery) ExistX(ctx context.Context) bool { + exist, err := hfq.Exist(ctx) + if err != nil { + panic(err) + } + return exist +} + +// Clone returns a duplicate of the HostFileQuery builder, including all associated steps. It can be +// used to prepare common query builders and use them differently after the clone is made. +func (hfq *HostFileQuery) Clone() *HostFileQuery { + if hfq == nil { + return nil + } + return &HostFileQuery{ + config: hfq.config, + ctx: hfq.ctx.Clone(), + order: append([]hostfile.OrderOption{}, hfq.order...), + inters: append([]Interceptor{}, hfq.inters...), + predicates: append([]predicate.HostFile{}, hfq.predicates...), + withHost: hfq.withHost.Clone(), + withTask: hfq.withTask.Clone(), + // clone intermediate query. + sql: hfq.sql.Clone(), + path: hfq.path, + } +} + +// WithHost tells the query-builder to eager-load the nodes that are connected to +// the "host" edge. The optional arguments are used to configure the query builder of the edge. +func (hfq *HostFileQuery) WithHost(opts ...func(*HostQuery)) *HostFileQuery { + query := (&HostClient{config: hfq.config}).Query() + for _, opt := range opts { + opt(query) + } + hfq.withHost = query + return hfq +} + +// WithTask tells the query-builder to eager-load the nodes that are connected to +// the "task" edge. The optional arguments are used to configure the query builder of the edge. +func (hfq *HostFileQuery) WithTask(opts ...func(*TaskQuery)) *HostFileQuery { + query := (&TaskClient{config: hfq.config}).Query() + for _, opt := range opts { + opt(query) + } + hfq.withTask = query + return hfq +} + +// GroupBy is used to group vertices by one or more fields/columns. +// It is often used with aggregate functions, like: count, max, mean, min, sum. +// +// Example: +// +// var v []struct { +// CreatedAt time.Time `json:"created_at,omitempty"` +// Count int `json:"count,omitempty"` +// } +// +// client.HostFile.Query(). +// GroupBy(hostfile.FieldCreatedAt). +// Aggregate(ent.Count()). +// Scan(ctx, &v) +func (hfq *HostFileQuery) GroupBy(field string, fields ...string) *HostFileGroupBy { + hfq.ctx.Fields = append([]string{field}, fields...) + grbuild := &HostFileGroupBy{build: hfq} + grbuild.flds = &hfq.ctx.Fields + grbuild.label = hostfile.Label + grbuild.scan = grbuild.Scan + return grbuild +} + +// Select allows the selection one or more fields/columns for the given query, +// instead of selecting all fields in the entity. +// +// Example: +// +// var v []struct { +// CreatedAt time.Time `json:"created_at,omitempty"` +// } +// +// client.HostFile.Query(). +// Select(hostfile.FieldCreatedAt). +// Scan(ctx, &v) +func (hfq *HostFileQuery) Select(fields ...string) *HostFileSelect { + hfq.ctx.Fields = append(hfq.ctx.Fields, fields...) + sbuild := &HostFileSelect{HostFileQuery: hfq} + sbuild.label = hostfile.Label + sbuild.flds, sbuild.scan = &hfq.ctx.Fields, sbuild.Scan + return sbuild +} + +// Aggregate returns a HostFileSelect configured with the given aggregations. +func (hfq *HostFileQuery) Aggregate(fns ...AggregateFunc) *HostFileSelect { + return hfq.Select().Aggregate(fns...) +} + +func (hfq *HostFileQuery) prepareQuery(ctx context.Context) error { + for _, inter := range hfq.inters { + if inter == nil { + return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)") + } + if trv, ok := inter.(Traverser); ok { + if err := trv.Traverse(ctx, hfq); err != nil { + return err + } + } + } + for _, f := range hfq.ctx.Fields { + if !hostfile.ValidColumn(f) { + return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + } + if hfq.path != nil { + prev, err := hfq.path(ctx) + if err != nil { + return err + } + hfq.sql = prev + } + return nil +} + +func (hfq *HostFileQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*HostFile, error) { + var ( + nodes = []*HostFile{} + withFKs = hfq.withFKs + _spec = hfq.querySpec() + loadedTypes = [2]bool{ + hfq.withHost != nil, + hfq.withTask != nil, + } + ) + if hfq.withHost != nil || hfq.withTask != nil { + withFKs = true + } + if withFKs { + _spec.Node.Columns = append(_spec.Node.Columns, hostfile.ForeignKeys...) + } + _spec.ScanValues = func(columns []string) ([]any, error) { + return (*HostFile).scanValues(nil, columns) + } + _spec.Assign = func(columns []string, values []any) error { + node := &HostFile{config: hfq.config} + nodes = append(nodes, node) + node.Edges.loadedTypes = loadedTypes + return node.assignValues(columns, values) + } + if len(hfq.modifiers) > 0 { + _spec.Modifiers = hfq.modifiers + } + for i := range hooks { + hooks[i](ctx, _spec) + } + if err := sqlgraph.QueryNodes(ctx, hfq.driver, _spec); err != nil { + return nil, err + } + if len(nodes) == 0 { + return nodes, nil + } + if query := hfq.withHost; query != nil { + if err := hfq.loadHost(ctx, query, nodes, nil, + func(n *HostFile, e *Host) { n.Edges.Host = e }); err != nil { + return nil, err + } + } + if query := hfq.withTask; query != nil { + if err := hfq.loadTask(ctx, query, nodes, nil, + func(n *HostFile, e *Task) { n.Edges.Task = e }); err != nil { + return nil, err + } + } + for i := range hfq.loadTotal { + if err := hfq.loadTotal[i](ctx, nodes); err != nil { + return nil, err + } + } + return nodes, nil +} + +func (hfq *HostFileQuery) loadHost(ctx context.Context, query *HostQuery, nodes []*HostFile, init func(*HostFile), assign func(*HostFile, *Host)) error { + ids := make([]int, 0, len(nodes)) + nodeids := make(map[int][]*HostFile) + for i := range nodes { + if nodes[i].host_file_host == nil { + continue + } + fk := *nodes[i].host_file_host + if _, ok := nodeids[fk]; !ok { + ids = append(ids, fk) + } + nodeids[fk] = append(nodeids[fk], nodes[i]) + } + if len(ids) == 0 { + return nil + } + query.Where(host.IDIn(ids...)) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + nodes, ok := nodeids[n.ID] + if !ok { + return fmt.Errorf(`unexpected foreign-key "host_file_host" returned %v`, n.ID) + } + for i := range nodes { + assign(nodes[i], n) + } + } + return nil +} +func (hfq *HostFileQuery) loadTask(ctx context.Context, query *TaskQuery, nodes []*HostFile, init func(*HostFile), assign func(*HostFile, *Task)) error { + ids := make([]int, 0, len(nodes)) + nodeids := make(map[int][]*HostFile) + for i := range nodes { + if nodes[i].task_reported_files == nil { + continue + } + fk := *nodes[i].task_reported_files + if _, ok := nodeids[fk]; !ok { + ids = append(ids, fk) + } + nodeids[fk] = append(nodeids[fk], nodes[i]) + } + if len(ids) == 0 { + return nil + } + query.Where(task.IDIn(ids...)) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + nodes, ok := nodeids[n.ID] + if !ok { + return fmt.Errorf(`unexpected foreign-key "task_reported_files" returned %v`, n.ID) + } + for i := range nodes { + assign(nodes[i], n) + } + } + return nil +} + +func (hfq *HostFileQuery) sqlCount(ctx context.Context) (int, error) { + _spec := hfq.querySpec() + if len(hfq.modifiers) > 0 { + _spec.Modifiers = hfq.modifiers + } + _spec.Node.Columns = hfq.ctx.Fields + if len(hfq.ctx.Fields) > 0 { + _spec.Unique = hfq.ctx.Unique != nil && *hfq.ctx.Unique + } + return sqlgraph.CountNodes(ctx, hfq.driver, _spec) +} + +func (hfq *HostFileQuery) querySpec() *sqlgraph.QuerySpec { + _spec := sqlgraph.NewQuerySpec(hostfile.Table, hostfile.Columns, sqlgraph.NewFieldSpec(hostfile.FieldID, field.TypeInt)) + _spec.From = hfq.sql + if unique := hfq.ctx.Unique; unique != nil { + _spec.Unique = *unique + } else if hfq.path != nil { + _spec.Unique = true + } + if fields := hfq.ctx.Fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, hostfile.FieldID) + for i := range fields { + if fields[i] != hostfile.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) + } + } + } + if ps := hfq.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if limit := hfq.ctx.Limit; limit != nil { + _spec.Limit = *limit + } + if offset := hfq.ctx.Offset; offset != nil { + _spec.Offset = *offset + } + if ps := hfq.order; len(ps) > 0 { + _spec.Order = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + return _spec +} + +func (hfq *HostFileQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(hfq.driver.Dialect()) + t1 := builder.Table(hostfile.Table) + columns := hfq.ctx.Fields + if len(columns) == 0 { + columns = hostfile.Columns + } + selector := builder.Select(t1.Columns(columns...)...).From(t1) + if hfq.sql != nil { + selector = hfq.sql + selector.Select(selector.Columns(columns...)...) + } + if hfq.ctx.Unique != nil && *hfq.ctx.Unique { + selector.Distinct() + } + for _, p := range hfq.predicates { + p(selector) + } + for _, p := range hfq.order { + p(selector) + } + if offset := hfq.ctx.Offset; offset != nil { + // limit is mandatory for offset clause. We start + // with default value, and override it below if needed. + selector.Offset(*offset).Limit(math.MaxInt32) + } + if limit := hfq.ctx.Limit; limit != nil { + selector.Limit(*limit) + } + return selector +} + +// HostFileGroupBy is the group-by builder for HostFile entities. +type HostFileGroupBy struct { + selector + build *HostFileQuery +} + +// Aggregate adds the given aggregation functions to the group-by query. +func (hfgb *HostFileGroupBy) Aggregate(fns ...AggregateFunc) *HostFileGroupBy { + hfgb.fns = append(hfgb.fns, fns...) + return hfgb +} + +// Scan applies the selector query and scans the result into the given value. +func (hfgb *HostFileGroupBy) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, hfgb.build.ctx, "GroupBy") + if err := hfgb.build.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*HostFileQuery, *HostFileGroupBy](ctx, hfgb.build, hfgb, hfgb.build.inters, v) +} + +func (hfgb *HostFileGroupBy) sqlScan(ctx context.Context, root *HostFileQuery, v any) error { + selector := root.sqlQuery(ctx).Select() + aggregation := make([]string, 0, len(hfgb.fns)) + for _, fn := range hfgb.fns { + aggregation = append(aggregation, fn(selector)) + } + if len(selector.SelectedColumns()) == 0 { + columns := make([]string, 0, len(*hfgb.flds)+len(hfgb.fns)) + for _, f := range *hfgb.flds { + columns = append(columns, selector.C(f)) + } + columns = append(columns, aggregation...) + selector.Select(columns...) + } + selector.GroupBy(selector.Columns(*hfgb.flds...)...) + if err := selector.Err(); err != nil { + return err + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := hfgb.build.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// HostFileSelect is the builder for selecting fields of HostFile entities. +type HostFileSelect struct { + *HostFileQuery + selector +} + +// Aggregate adds the given aggregation functions to the selector query. +func (hfs *HostFileSelect) Aggregate(fns ...AggregateFunc) *HostFileSelect { + hfs.fns = append(hfs.fns, fns...) + return hfs +} + +// Scan applies the selector query and scans the result into the given value. +func (hfs *HostFileSelect) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, hfs.ctx, "Select") + if err := hfs.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*HostFileQuery, *HostFileSelect](ctx, hfs.HostFileQuery, hfs, hfs.inters, v) +} + +func (hfs *HostFileSelect) sqlScan(ctx context.Context, root *HostFileQuery, v any) error { + selector := root.sqlQuery(ctx) + aggregation := make([]string, 0, len(hfs.fns)) + for _, fn := range hfs.fns { + aggregation = append(aggregation, fn(selector)) + } + switch n := len(*hfs.selector.flds); { + case n == 0 && len(aggregation) > 0: + selector.Select(aggregation...) + case n != 0 && len(aggregation) > 0: + selector.AppendSelect(aggregation...) + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := hfs.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} diff --git a/tavern/internal/ent/hostfile_update.go b/tavern/internal/ent/hostfile_update.go new file mode 100644 index 000000000..fba264e69 --- /dev/null +++ b/tavern/internal/ent/hostfile_update.go @@ -0,0 +1,784 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "realm.pub/tavern/internal/ent/host" + "realm.pub/tavern/internal/ent/hostfile" + "realm.pub/tavern/internal/ent/predicate" + "realm.pub/tavern/internal/ent/task" +) + +// HostFileUpdate is the builder for updating HostFile entities. +type HostFileUpdate struct { + config + hooks []Hook + mutation *HostFileMutation +} + +// Where appends a list predicates to the HostFileUpdate builder. +func (hfu *HostFileUpdate) Where(ps ...predicate.HostFile) *HostFileUpdate { + hfu.mutation.Where(ps...) + return hfu +} + +// SetLastModifiedAt sets the "last_modified_at" field. +func (hfu *HostFileUpdate) SetLastModifiedAt(t time.Time) *HostFileUpdate { + hfu.mutation.SetLastModifiedAt(t) + return hfu +} + +// SetPath sets the "path" field. +func (hfu *HostFileUpdate) SetPath(s string) *HostFileUpdate { + hfu.mutation.SetPath(s) + return hfu +} + +// SetOwner sets the "owner" field. +func (hfu *HostFileUpdate) SetOwner(s string) *HostFileUpdate { + hfu.mutation.SetOwner(s) + return hfu +} + +// SetNillableOwner sets the "owner" field if the given value is not nil. +func (hfu *HostFileUpdate) SetNillableOwner(s *string) *HostFileUpdate { + if s != nil { + hfu.SetOwner(*s) + } + return hfu +} + +// ClearOwner clears the value of the "owner" field. +func (hfu *HostFileUpdate) ClearOwner() *HostFileUpdate { + hfu.mutation.ClearOwner() + return hfu +} + +// SetGroup sets the "group" field. +func (hfu *HostFileUpdate) SetGroup(s string) *HostFileUpdate { + hfu.mutation.SetGroup(s) + return hfu +} + +// SetNillableGroup sets the "group" field if the given value is not nil. +func (hfu *HostFileUpdate) SetNillableGroup(s *string) *HostFileUpdate { + if s != nil { + hfu.SetGroup(*s) + } + return hfu +} + +// ClearGroup clears the value of the "group" field. +func (hfu *HostFileUpdate) ClearGroup() *HostFileUpdate { + hfu.mutation.ClearGroup() + return hfu +} + +// SetPermissions sets the "permissions" field. +func (hfu *HostFileUpdate) SetPermissions(s string) *HostFileUpdate { + hfu.mutation.SetPermissions(s) + return hfu +} + +// SetNillablePermissions sets the "permissions" field if the given value is not nil. +func (hfu *HostFileUpdate) SetNillablePermissions(s *string) *HostFileUpdate { + if s != nil { + hfu.SetPermissions(*s) + } + return hfu +} + +// ClearPermissions clears the value of the "permissions" field. +func (hfu *HostFileUpdate) ClearPermissions() *HostFileUpdate { + hfu.mutation.ClearPermissions() + return hfu +} + +// SetSize sets the "size" field. +func (hfu *HostFileUpdate) SetSize(i int) *HostFileUpdate { + hfu.mutation.ResetSize() + hfu.mutation.SetSize(i) + return hfu +} + +// SetNillableSize sets the "size" field if the given value is not nil. +func (hfu *HostFileUpdate) SetNillableSize(i *int) *HostFileUpdate { + if i != nil { + hfu.SetSize(*i) + } + return hfu +} + +// AddSize adds i to the "size" field. +func (hfu *HostFileUpdate) AddSize(i int) *HostFileUpdate { + hfu.mutation.AddSize(i) + return hfu +} + +// SetHash sets the "hash" field. +func (hfu *HostFileUpdate) SetHash(s string) *HostFileUpdate { + hfu.mutation.SetHash(s) + return hfu +} + +// SetNillableHash sets the "hash" field if the given value is not nil. +func (hfu *HostFileUpdate) SetNillableHash(s *string) *HostFileUpdate { + if s != nil { + hfu.SetHash(*s) + } + return hfu +} + +// ClearHash clears the value of the "hash" field. +func (hfu *HostFileUpdate) ClearHash() *HostFileUpdate { + hfu.mutation.ClearHash() + return hfu +} + +// SetContent sets the "content" field. +func (hfu *HostFileUpdate) SetContent(b []byte) *HostFileUpdate { + hfu.mutation.SetContent(b) + return hfu +} + +// ClearContent clears the value of the "content" field. +func (hfu *HostFileUpdate) ClearContent() *HostFileUpdate { + hfu.mutation.ClearContent() + return hfu +} + +// SetHostID sets the "host" edge to the Host entity by ID. +func (hfu *HostFileUpdate) SetHostID(id int) *HostFileUpdate { + hfu.mutation.SetHostID(id) + return hfu +} + +// SetHost sets the "host" edge to the Host entity. +func (hfu *HostFileUpdate) SetHost(h *Host) *HostFileUpdate { + return hfu.SetHostID(h.ID) +} + +// SetTaskID sets the "task" edge to the Task entity by ID. +func (hfu *HostFileUpdate) SetTaskID(id int) *HostFileUpdate { + hfu.mutation.SetTaskID(id) + return hfu +} + +// SetTask sets the "task" edge to the Task entity. +func (hfu *HostFileUpdate) SetTask(t *Task) *HostFileUpdate { + return hfu.SetTaskID(t.ID) +} + +// Mutation returns the HostFileMutation object of the builder. +func (hfu *HostFileUpdate) Mutation() *HostFileMutation { + return hfu.mutation +} + +// ClearHost clears the "host" edge to the Host entity. +func (hfu *HostFileUpdate) ClearHost() *HostFileUpdate { + hfu.mutation.ClearHost() + return hfu +} + +// ClearTask clears the "task" edge to the Task entity. +func (hfu *HostFileUpdate) ClearTask() *HostFileUpdate { + hfu.mutation.ClearTask() + return hfu +} + +// Save executes the query and returns the number of nodes affected by the update operation. +func (hfu *HostFileUpdate) Save(ctx context.Context) (int, error) { + if err := hfu.defaults(); err != nil { + return 0, err + } + return withHooks(ctx, hfu.sqlSave, hfu.mutation, hfu.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (hfu *HostFileUpdate) SaveX(ctx context.Context) int { + affected, err := hfu.Save(ctx) + if err != nil { + panic(err) + } + return affected +} + +// Exec executes the query. +func (hfu *HostFileUpdate) Exec(ctx context.Context) error { + _, err := hfu.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (hfu *HostFileUpdate) ExecX(ctx context.Context) { + if err := hfu.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (hfu *HostFileUpdate) defaults() error { + if _, ok := hfu.mutation.LastModifiedAt(); !ok { + if hostfile.UpdateDefaultLastModifiedAt == nil { + return fmt.Errorf("ent: uninitialized hostfile.UpdateDefaultLastModifiedAt (forgotten import ent/runtime?)") + } + v := hostfile.UpdateDefaultLastModifiedAt() + hfu.mutation.SetLastModifiedAt(v) + } + return nil +} + +// check runs all checks and user-defined validators on the builder. +func (hfu *HostFileUpdate) check() error { + if v, ok := hfu.mutation.Path(); ok { + if err := hostfile.PathValidator(v); err != nil { + return &ValidationError{Name: "path", err: fmt.Errorf(`ent: validator failed for field "HostFile.path": %w`, err)} + } + } + if v, ok := hfu.mutation.Size(); ok { + if err := hostfile.SizeValidator(v); err != nil { + return &ValidationError{Name: "size", err: fmt.Errorf(`ent: validator failed for field "HostFile.size": %w`, err)} + } + } + if v, ok := hfu.mutation.Hash(); ok { + if err := hostfile.HashValidator(v); err != nil { + return &ValidationError{Name: "hash", err: fmt.Errorf(`ent: validator failed for field "HostFile.hash": %w`, err)} + } + } + if _, ok := hfu.mutation.HostID(); hfu.mutation.HostCleared() && !ok { + return errors.New(`ent: clearing a required unique edge "HostFile.host"`) + } + if _, ok := hfu.mutation.TaskID(); hfu.mutation.TaskCleared() && !ok { + return errors.New(`ent: clearing a required unique edge "HostFile.task"`) + } + return nil +} + +func (hfu *HostFileUpdate) sqlSave(ctx context.Context) (n int, err error) { + if err := hfu.check(); err != nil { + return n, err + } + _spec := sqlgraph.NewUpdateSpec(hostfile.Table, hostfile.Columns, sqlgraph.NewFieldSpec(hostfile.FieldID, field.TypeInt)) + if ps := hfu.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := hfu.mutation.LastModifiedAt(); ok { + _spec.SetField(hostfile.FieldLastModifiedAt, field.TypeTime, value) + } + if value, ok := hfu.mutation.Path(); ok { + _spec.SetField(hostfile.FieldPath, field.TypeString, value) + } + if value, ok := hfu.mutation.Owner(); ok { + _spec.SetField(hostfile.FieldOwner, field.TypeString, value) + } + if hfu.mutation.OwnerCleared() { + _spec.ClearField(hostfile.FieldOwner, field.TypeString) + } + if value, ok := hfu.mutation.Group(); ok { + _spec.SetField(hostfile.FieldGroup, field.TypeString, value) + } + if hfu.mutation.GroupCleared() { + _spec.ClearField(hostfile.FieldGroup, field.TypeString) + } + if value, ok := hfu.mutation.Permissions(); ok { + _spec.SetField(hostfile.FieldPermissions, field.TypeString, value) + } + if hfu.mutation.PermissionsCleared() { + _spec.ClearField(hostfile.FieldPermissions, field.TypeString) + } + if value, ok := hfu.mutation.Size(); ok { + _spec.SetField(hostfile.FieldSize, field.TypeInt, value) + } + if value, ok := hfu.mutation.AddedSize(); ok { + _spec.AddField(hostfile.FieldSize, field.TypeInt, value) + } + if value, ok := hfu.mutation.Hash(); ok { + _spec.SetField(hostfile.FieldHash, field.TypeString, value) + } + if hfu.mutation.HashCleared() { + _spec.ClearField(hostfile.FieldHash, field.TypeString) + } + if value, ok := hfu.mutation.Content(); ok { + _spec.SetField(hostfile.FieldContent, field.TypeBytes, value) + } + if hfu.mutation.ContentCleared() { + _spec.ClearField(hostfile.FieldContent, field.TypeBytes) + } + if hfu.mutation.HostCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: hostfile.HostTable, + Columns: []string{hostfile.HostColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(host.FieldID, field.TypeInt), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := hfu.mutation.HostIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: hostfile.HostTable, + Columns: []string{hostfile.HostColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(host.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if hfu.mutation.TaskCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: hostfile.TaskTable, + Columns: []string{hostfile.TaskColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(task.FieldID, field.TypeInt), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := hfu.mutation.TaskIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: hostfile.TaskTable, + Columns: []string{hostfile.TaskColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(task.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if n, err = sqlgraph.UpdateNodes(ctx, hfu.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{hostfile.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return 0, err + } + hfu.mutation.done = true + return n, nil +} + +// HostFileUpdateOne is the builder for updating a single HostFile entity. +type HostFileUpdateOne struct { + config + fields []string + hooks []Hook + mutation *HostFileMutation +} + +// SetLastModifiedAt sets the "last_modified_at" field. +func (hfuo *HostFileUpdateOne) SetLastModifiedAt(t time.Time) *HostFileUpdateOne { + hfuo.mutation.SetLastModifiedAt(t) + return hfuo +} + +// SetPath sets the "path" field. +func (hfuo *HostFileUpdateOne) SetPath(s string) *HostFileUpdateOne { + hfuo.mutation.SetPath(s) + return hfuo +} + +// SetOwner sets the "owner" field. +func (hfuo *HostFileUpdateOne) SetOwner(s string) *HostFileUpdateOne { + hfuo.mutation.SetOwner(s) + return hfuo +} + +// SetNillableOwner sets the "owner" field if the given value is not nil. +func (hfuo *HostFileUpdateOne) SetNillableOwner(s *string) *HostFileUpdateOne { + if s != nil { + hfuo.SetOwner(*s) + } + return hfuo +} + +// ClearOwner clears the value of the "owner" field. +func (hfuo *HostFileUpdateOne) ClearOwner() *HostFileUpdateOne { + hfuo.mutation.ClearOwner() + return hfuo +} + +// SetGroup sets the "group" field. +func (hfuo *HostFileUpdateOne) SetGroup(s string) *HostFileUpdateOne { + hfuo.mutation.SetGroup(s) + return hfuo +} + +// SetNillableGroup sets the "group" field if the given value is not nil. +func (hfuo *HostFileUpdateOne) SetNillableGroup(s *string) *HostFileUpdateOne { + if s != nil { + hfuo.SetGroup(*s) + } + return hfuo +} + +// ClearGroup clears the value of the "group" field. +func (hfuo *HostFileUpdateOne) ClearGroup() *HostFileUpdateOne { + hfuo.mutation.ClearGroup() + return hfuo +} + +// SetPermissions sets the "permissions" field. +func (hfuo *HostFileUpdateOne) SetPermissions(s string) *HostFileUpdateOne { + hfuo.mutation.SetPermissions(s) + return hfuo +} + +// SetNillablePermissions sets the "permissions" field if the given value is not nil. +func (hfuo *HostFileUpdateOne) SetNillablePermissions(s *string) *HostFileUpdateOne { + if s != nil { + hfuo.SetPermissions(*s) + } + return hfuo +} + +// ClearPermissions clears the value of the "permissions" field. +func (hfuo *HostFileUpdateOne) ClearPermissions() *HostFileUpdateOne { + hfuo.mutation.ClearPermissions() + return hfuo +} + +// SetSize sets the "size" field. +func (hfuo *HostFileUpdateOne) SetSize(i int) *HostFileUpdateOne { + hfuo.mutation.ResetSize() + hfuo.mutation.SetSize(i) + return hfuo +} + +// SetNillableSize sets the "size" field if the given value is not nil. +func (hfuo *HostFileUpdateOne) SetNillableSize(i *int) *HostFileUpdateOne { + if i != nil { + hfuo.SetSize(*i) + } + return hfuo +} + +// AddSize adds i to the "size" field. +func (hfuo *HostFileUpdateOne) AddSize(i int) *HostFileUpdateOne { + hfuo.mutation.AddSize(i) + return hfuo +} + +// SetHash sets the "hash" field. +func (hfuo *HostFileUpdateOne) SetHash(s string) *HostFileUpdateOne { + hfuo.mutation.SetHash(s) + return hfuo +} + +// SetNillableHash sets the "hash" field if the given value is not nil. +func (hfuo *HostFileUpdateOne) SetNillableHash(s *string) *HostFileUpdateOne { + if s != nil { + hfuo.SetHash(*s) + } + return hfuo +} + +// ClearHash clears the value of the "hash" field. +func (hfuo *HostFileUpdateOne) ClearHash() *HostFileUpdateOne { + hfuo.mutation.ClearHash() + return hfuo +} + +// SetContent sets the "content" field. +func (hfuo *HostFileUpdateOne) SetContent(b []byte) *HostFileUpdateOne { + hfuo.mutation.SetContent(b) + return hfuo +} + +// ClearContent clears the value of the "content" field. +func (hfuo *HostFileUpdateOne) ClearContent() *HostFileUpdateOne { + hfuo.mutation.ClearContent() + return hfuo +} + +// SetHostID sets the "host" edge to the Host entity by ID. +func (hfuo *HostFileUpdateOne) SetHostID(id int) *HostFileUpdateOne { + hfuo.mutation.SetHostID(id) + return hfuo +} + +// SetHost sets the "host" edge to the Host entity. +func (hfuo *HostFileUpdateOne) SetHost(h *Host) *HostFileUpdateOne { + return hfuo.SetHostID(h.ID) +} + +// SetTaskID sets the "task" edge to the Task entity by ID. +func (hfuo *HostFileUpdateOne) SetTaskID(id int) *HostFileUpdateOne { + hfuo.mutation.SetTaskID(id) + return hfuo +} + +// SetTask sets the "task" edge to the Task entity. +func (hfuo *HostFileUpdateOne) SetTask(t *Task) *HostFileUpdateOne { + return hfuo.SetTaskID(t.ID) +} + +// Mutation returns the HostFileMutation object of the builder. +func (hfuo *HostFileUpdateOne) Mutation() *HostFileMutation { + return hfuo.mutation +} + +// ClearHost clears the "host" edge to the Host entity. +func (hfuo *HostFileUpdateOne) ClearHost() *HostFileUpdateOne { + hfuo.mutation.ClearHost() + return hfuo +} + +// ClearTask clears the "task" edge to the Task entity. +func (hfuo *HostFileUpdateOne) ClearTask() *HostFileUpdateOne { + hfuo.mutation.ClearTask() + return hfuo +} + +// Where appends a list predicates to the HostFileUpdate builder. +func (hfuo *HostFileUpdateOne) Where(ps ...predicate.HostFile) *HostFileUpdateOne { + hfuo.mutation.Where(ps...) + return hfuo +} + +// Select allows selecting one or more fields (columns) of the returned entity. +// The default is selecting all fields defined in the entity schema. +func (hfuo *HostFileUpdateOne) Select(field string, fields ...string) *HostFileUpdateOne { + hfuo.fields = append([]string{field}, fields...) + return hfuo +} + +// Save executes the query and returns the updated HostFile entity. +func (hfuo *HostFileUpdateOne) Save(ctx context.Context) (*HostFile, error) { + if err := hfuo.defaults(); err != nil { + return nil, err + } + return withHooks(ctx, hfuo.sqlSave, hfuo.mutation, hfuo.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (hfuo *HostFileUpdateOne) SaveX(ctx context.Context) *HostFile { + node, err := hfuo.Save(ctx) + if err != nil { + panic(err) + } + return node +} + +// Exec executes the query on the entity. +func (hfuo *HostFileUpdateOne) Exec(ctx context.Context) error { + _, err := hfuo.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (hfuo *HostFileUpdateOne) ExecX(ctx context.Context) { + if err := hfuo.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (hfuo *HostFileUpdateOne) defaults() error { + if _, ok := hfuo.mutation.LastModifiedAt(); !ok { + if hostfile.UpdateDefaultLastModifiedAt == nil { + return fmt.Errorf("ent: uninitialized hostfile.UpdateDefaultLastModifiedAt (forgotten import ent/runtime?)") + } + v := hostfile.UpdateDefaultLastModifiedAt() + hfuo.mutation.SetLastModifiedAt(v) + } + return nil +} + +// check runs all checks and user-defined validators on the builder. +func (hfuo *HostFileUpdateOne) check() error { + if v, ok := hfuo.mutation.Path(); ok { + if err := hostfile.PathValidator(v); err != nil { + return &ValidationError{Name: "path", err: fmt.Errorf(`ent: validator failed for field "HostFile.path": %w`, err)} + } + } + if v, ok := hfuo.mutation.Size(); ok { + if err := hostfile.SizeValidator(v); err != nil { + return &ValidationError{Name: "size", err: fmt.Errorf(`ent: validator failed for field "HostFile.size": %w`, err)} + } + } + if v, ok := hfuo.mutation.Hash(); ok { + if err := hostfile.HashValidator(v); err != nil { + return &ValidationError{Name: "hash", err: fmt.Errorf(`ent: validator failed for field "HostFile.hash": %w`, err)} + } + } + if _, ok := hfuo.mutation.HostID(); hfuo.mutation.HostCleared() && !ok { + return errors.New(`ent: clearing a required unique edge "HostFile.host"`) + } + if _, ok := hfuo.mutation.TaskID(); hfuo.mutation.TaskCleared() && !ok { + return errors.New(`ent: clearing a required unique edge "HostFile.task"`) + } + return nil +} + +func (hfuo *HostFileUpdateOne) sqlSave(ctx context.Context) (_node *HostFile, err error) { + if err := hfuo.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(hostfile.Table, hostfile.Columns, sqlgraph.NewFieldSpec(hostfile.FieldID, field.TypeInt)) + id, ok := hfuo.mutation.ID() + if !ok { + return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "HostFile.id" for update`)} + } + _spec.Node.ID.Value = id + if fields := hfuo.fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, hostfile.FieldID) + for _, f := range fields { + if !hostfile.ValidColumn(f) { + return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + if f != hostfile.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, f) + } + } + } + if ps := hfuo.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := hfuo.mutation.LastModifiedAt(); ok { + _spec.SetField(hostfile.FieldLastModifiedAt, field.TypeTime, value) + } + if value, ok := hfuo.mutation.Path(); ok { + _spec.SetField(hostfile.FieldPath, field.TypeString, value) + } + if value, ok := hfuo.mutation.Owner(); ok { + _spec.SetField(hostfile.FieldOwner, field.TypeString, value) + } + if hfuo.mutation.OwnerCleared() { + _spec.ClearField(hostfile.FieldOwner, field.TypeString) + } + if value, ok := hfuo.mutation.Group(); ok { + _spec.SetField(hostfile.FieldGroup, field.TypeString, value) + } + if hfuo.mutation.GroupCleared() { + _spec.ClearField(hostfile.FieldGroup, field.TypeString) + } + if value, ok := hfuo.mutation.Permissions(); ok { + _spec.SetField(hostfile.FieldPermissions, field.TypeString, value) + } + if hfuo.mutation.PermissionsCleared() { + _spec.ClearField(hostfile.FieldPermissions, field.TypeString) + } + if value, ok := hfuo.mutation.Size(); ok { + _spec.SetField(hostfile.FieldSize, field.TypeInt, value) + } + if value, ok := hfuo.mutation.AddedSize(); ok { + _spec.AddField(hostfile.FieldSize, field.TypeInt, value) + } + if value, ok := hfuo.mutation.Hash(); ok { + _spec.SetField(hostfile.FieldHash, field.TypeString, value) + } + if hfuo.mutation.HashCleared() { + _spec.ClearField(hostfile.FieldHash, field.TypeString) + } + if value, ok := hfuo.mutation.Content(); ok { + _spec.SetField(hostfile.FieldContent, field.TypeBytes, value) + } + if hfuo.mutation.ContentCleared() { + _spec.ClearField(hostfile.FieldContent, field.TypeBytes) + } + if hfuo.mutation.HostCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: hostfile.HostTable, + Columns: []string{hostfile.HostColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(host.FieldID, field.TypeInt), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := hfuo.mutation.HostIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: hostfile.HostTable, + Columns: []string{hostfile.HostColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(host.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if hfuo.mutation.TaskCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: hostfile.TaskTable, + Columns: []string{hostfile.TaskColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(task.FieldID, field.TypeInt), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := hfuo.mutation.TaskIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: hostfile.TaskTable, + Columns: []string{hostfile.TaskColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(task.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + _node = &HostFile{config: hfuo.config} + _spec.Assign = _node.assignValues + _spec.ScanValues = _node.scanValues + if err = sqlgraph.UpdateNode(ctx, hfuo.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{hostfile.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + hfuo.mutation.done = true + return _node, nil +} diff --git a/tavern/internal/ent/hostprocess.go b/tavern/internal/ent/hostprocess.go new file mode 100644 index 000000000..4897df7ef --- /dev/null +++ b/tavern/internal/ent/hostprocess.go @@ -0,0 +1,303 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "fmt" + "strings" + "time" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" + "realm.pub/tavern/internal/c2/c2pb" + "realm.pub/tavern/internal/ent/host" + "realm.pub/tavern/internal/ent/hostprocess" + "realm.pub/tavern/internal/ent/task" +) + +// HostProcess is the model entity for the HostProcess schema. +type HostProcess struct { + config `json:"-"` + // ID of the ent. + ID int `json:"id,omitempty"` + // Timestamp of when this ent was created + CreatedAt time.Time `json:"created_at,omitempty"` + // Timestamp of when this ent was last updated + LastModifiedAt time.Time `json:"last_modified_at,omitempty"` + // ID of the process. + Pid uint64 `json:"pid,omitempty"` + // ID of the parent process. + Ppid uint64 `json:"ppid,omitempty"` + // The name of the process. + Name string `json:"name,omitempty"` + // The user the process is running as. + Principal string `json:"principal,omitempty"` + // The path to the process executable. + Path string `json:"path,omitempty"` + // The command used to execute the process. + Cmd string `json:"cmd,omitempty"` + // The environment variables set for the process. + Env string `json:"env,omitempty"` + // The current working directory for the process. + Cwd string `json:"cwd,omitempty"` + // Current process status. + Status c2pb.Process_Status `json:"status,omitempty"` + // Edges holds the relations/edges for other nodes in the graph. + // The values are being populated by the HostProcessQuery when eager-loading is set. + Edges HostProcessEdges `json:"edges"` + host_processes *int + host_process_host *int + task_reported_processes *int + selectValues sql.SelectValues +} + +// HostProcessEdges holds the relations/edges for other nodes in the graph. +type HostProcessEdges struct { + // Host the process was reported on. + Host *Host `json:"host,omitempty"` + // Task that reported this process. + Task *Task `json:"task,omitempty"` + // loadedTypes holds the information for reporting if a + // type was loaded (or requested) in eager-loading or not. + loadedTypes [2]bool + // totalCount holds the count of the edges above. + totalCount [2]map[string]int +} + +// HostOrErr returns the Host value or an error if the edge +// was not loaded in eager-loading, or loaded but was not found. +func (e HostProcessEdges) HostOrErr() (*Host, error) { + if e.loadedTypes[0] { + if e.Host == nil { + // Edge was loaded but was not found. + return nil, &NotFoundError{label: host.Label} + } + return e.Host, nil + } + return nil, &NotLoadedError{edge: "host"} +} + +// TaskOrErr returns the Task value or an error if the edge +// was not loaded in eager-loading, or loaded but was not found. +func (e HostProcessEdges) TaskOrErr() (*Task, error) { + if e.loadedTypes[1] { + if e.Task == nil { + // Edge was loaded but was not found. + return nil, &NotFoundError{label: task.Label} + } + return e.Task, nil + } + return nil, &NotLoadedError{edge: "task"} +} + +// scanValues returns the types for scanning values from sql.Rows. +func (*HostProcess) scanValues(columns []string) ([]any, error) { + values := make([]any, len(columns)) + for i := range columns { + switch columns[i] { + case hostprocess.FieldStatus: + values[i] = new(c2pb.Process_Status) + case hostprocess.FieldID, hostprocess.FieldPid, hostprocess.FieldPpid: + values[i] = new(sql.NullInt64) + case hostprocess.FieldName, hostprocess.FieldPrincipal, hostprocess.FieldPath, hostprocess.FieldCmd, hostprocess.FieldEnv, hostprocess.FieldCwd: + values[i] = new(sql.NullString) + case hostprocess.FieldCreatedAt, hostprocess.FieldLastModifiedAt: + values[i] = new(sql.NullTime) + case hostprocess.ForeignKeys[0]: // host_processes + values[i] = new(sql.NullInt64) + case hostprocess.ForeignKeys[1]: // host_process_host + values[i] = new(sql.NullInt64) + case hostprocess.ForeignKeys[2]: // task_reported_processes + values[i] = new(sql.NullInt64) + default: + values[i] = new(sql.UnknownType) + } + } + return values, nil +} + +// assignValues assigns the values that were returned from sql.Rows (after scanning) +// to the HostProcess fields. +func (hp *HostProcess) assignValues(columns []string, values []any) error { + if m, n := len(values), len(columns); m < n { + return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) + } + for i := range columns { + switch columns[i] { + case hostprocess.FieldID: + value, ok := values[i].(*sql.NullInt64) + if !ok { + return fmt.Errorf("unexpected type %T for field id", value) + } + hp.ID = int(value.Int64) + case hostprocess.FieldCreatedAt: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field created_at", values[i]) + } else if value.Valid { + hp.CreatedAt = value.Time + } + case hostprocess.FieldLastModifiedAt: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field last_modified_at", values[i]) + } else if value.Valid { + hp.LastModifiedAt = value.Time + } + case hostprocess.FieldPid: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field pid", values[i]) + } else if value.Valid { + hp.Pid = uint64(value.Int64) + } + case hostprocess.FieldPpid: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field ppid", values[i]) + } else if value.Valid { + hp.Ppid = uint64(value.Int64) + } + case hostprocess.FieldName: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field name", values[i]) + } else if value.Valid { + hp.Name = value.String + } + case hostprocess.FieldPrincipal: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field principal", values[i]) + } else if value.Valid { + hp.Principal = value.String + } + case hostprocess.FieldPath: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field path", values[i]) + } else if value.Valid { + hp.Path = value.String + } + case hostprocess.FieldCmd: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field cmd", values[i]) + } else if value.Valid { + hp.Cmd = value.String + } + case hostprocess.FieldEnv: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field env", values[i]) + } else if value.Valid { + hp.Env = value.String + } + case hostprocess.FieldCwd: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field cwd", values[i]) + } else if value.Valid { + hp.Cwd = value.String + } + case hostprocess.FieldStatus: + if value, ok := values[i].(*c2pb.Process_Status); !ok { + return fmt.Errorf("unexpected type %T for field status", values[i]) + } else if value != nil { + hp.Status = *value + } + case hostprocess.ForeignKeys[0]: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for edge-field host_processes", value) + } else if value.Valid { + hp.host_processes = new(int) + *hp.host_processes = int(value.Int64) + } + case hostprocess.ForeignKeys[1]: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for edge-field host_process_host", value) + } else if value.Valid { + hp.host_process_host = new(int) + *hp.host_process_host = int(value.Int64) + } + case hostprocess.ForeignKeys[2]: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for edge-field task_reported_processes", value) + } else if value.Valid { + hp.task_reported_processes = new(int) + *hp.task_reported_processes = int(value.Int64) + } + default: + hp.selectValues.Set(columns[i], values[i]) + } + } + return nil +} + +// Value returns the ent.Value that was dynamically selected and assigned to the HostProcess. +// This includes values selected through modifiers, order, etc. +func (hp *HostProcess) Value(name string) (ent.Value, error) { + return hp.selectValues.Get(name) +} + +// QueryHost queries the "host" edge of the HostProcess entity. +func (hp *HostProcess) QueryHost() *HostQuery { + return NewHostProcessClient(hp.config).QueryHost(hp) +} + +// QueryTask queries the "task" edge of the HostProcess entity. +func (hp *HostProcess) QueryTask() *TaskQuery { + return NewHostProcessClient(hp.config).QueryTask(hp) +} + +// Update returns a builder for updating this HostProcess. +// Note that you need to call HostProcess.Unwrap() before calling this method if this HostProcess +// was returned from a transaction, and the transaction was committed or rolled back. +func (hp *HostProcess) Update() *HostProcessUpdateOne { + return NewHostProcessClient(hp.config).UpdateOne(hp) +} + +// Unwrap unwraps the HostProcess entity that was returned from a transaction after it was closed, +// so that all future queries will be executed through the driver which created the transaction. +func (hp *HostProcess) Unwrap() *HostProcess { + _tx, ok := hp.config.driver.(*txDriver) + if !ok { + panic("ent: HostProcess is not a transactional entity") + } + hp.config.driver = _tx.drv + return hp +} + +// String implements the fmt.Stringer. +func (hp *HostProcess) String() string { + var builder strings.Builder + builder.WriteString("HostProcess(") + builder.WriteString(fmt.Sprintf("id=%v, ", hp.ID)) + builder.WriteString("created_at=") + builder.WriteString(hp.CreatedAt.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("last_modified_at=") + builder.WriteString(hp.LastModifiedAt.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("pid=") + builder.WriteString(fmt.Sprintf("%v", hp.Pid)) + builder.WriteString(", ") + builder.WriteString("ppid=") + builder.WriteString(fmt.Sprintf("%v", hp.Ppid)) + builder.WriteString(", ") + builder.WriteString("name=") + builder.WriteString(hp.Name) + builder.WriteString(", ") + builder.WriteString("principal=") + builder.WriteString(hp.Principal) + builder.WriteString(", ") + builder.WriteString("path=") + builder.WriteString(hp.Path) + builder.WriteString(", ") + builder.WriteString("cmd=") + builder.WriteString(hp.Cmd) + builder.WriteString(", ") + builder.WriteString("env=") + builder.WriteString(hp.Env) + builder.WriteString(", ") + builder.WriteString("cwd=") + builder.WriteString(hp.Cwd) + builder.WriteString(", ") + builder.WriteString("status=") + builder.WriteString(fmt.Sprintf("%v", hp.Status)) + builder.WriteByte(')') + return builder.String() +} + +// HostProcesses is a parsable slice of HostProcess. +type HostProcesses []*HostProcess diff --git a/tavern/internal/ent/process/process.go b/tavern/internal/ent/hostprocess/hostprocess.go similarity index 61% rename from tavern/internal/ent/process/process.go rename to tavern/internal/ent/hostprocess/hostprocess.go index 59a30eb16..c16a644cb 100644 --- a/tavern/internal/ent/process/process.go +++ b/tavern/internal/ent/hostprocess/hostprocess.go @@ -1,17 +1,20 @@ // Code generated by ent, DO NOT EDIT. -package process +package hostprocess import ( + "fmt" "time" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" + "github.com/99designs/gqlgen/graphql" + "realm.pub/tavern/internal/c2/c2pb" ) const ( - // Label holds the string label denoting the process type in the database. - Label = "process" + // Label holds the string label denoting the hostprocess type in the database. + Label = "host_process" // FieldID holds the string denoting the id field in the database. FieldID = "id" // FieldCreatedAt holds the string denoting the created_at field in the database. @@ -20,25 +23,37 @@ const ( FieldLastModifiedAt = "last_modified_at" // FieldPid holds the string denoting the pid field in the database. FieldPid = "pid" + // FieldPpid holds the string denoting the ppid field in the database. + FieldPpid = "ppid" // FieldName holds the string denoting the name field in the database. FieldName = "name" // FieldPrincipal holds the string denoting the principal field in the database. FieldPrincipal = "principal" + // FieldPath holds the string denoting the path field in the database. + FieldPath = "path" + // FieldCmd holds the string denoting the cmd field in the database. + FieldCmd = "cmd" + // FieldEnv holds the string denoting the env field in the database. + FieldEnv = "env" + // FieldCwd holds the string denoting the cwd field in the database. + FieldCwd = "cwd" + // FieldStatus holds the string denoting the status field in the database. + FieldStatus = "status" // EdgeHost holds the string denoting the host edge name in mutations. EdgeHost = "host" // EdgeTask holds the string denoting the task edge name in mutations. EdgeTask = "task" - // Table holds the table name of the process in the database. - Table = "processes" + // Table holds the table name of the hostprocess in the database. + Table = "host_processes" // HostTable is the table that holds the host relation/edge. - HostTable = "processes" + HostTable = "host_processes" // HostInverseTable is the table name for the Host entity. // It exists in this package in order to avoid circular dependency with the "host" package. HostInverseTable = "hosts" // HostColumn is the table column denoting the host relation/edge. - HostColumn = "process_host" + HostColumn = "host_process_host" // TaskTable is the table that holds the task relation/edge. - TaskTable = "processes" + TaskTable = "host_processes" // TaskInverseTable is the table name for the Task entity. // It exists in this package in order to avoid circular dependency with the "task" package. TaskInverseTable = "tasks" @@ -46,21 +61,27 @@ const ( TaskColumn = "task_reported_processes" ) -// Columns holds all SQL columns for process fields. +// Columns holds all SQL columns for hostprocess fields. var Columns = []string{ FieldID, FieldCreatedAt, FieldLastModifiedAt, FieldPid, + FieldPpid, FieldName, FieldPrincipal, + FieldPath, + FieldCmd, + FieldEnv, + FieldCwd, + FieldStatus, } -// ForeignKeys holds the SQL foreign-keys that are owned by the "processes" +// ForeignKeys holds the SQL foreign-keys that are owned by the "host_processes" // table and are not defined as standalone fields in the schema. var ForeignKeys = []string{ "host_processes", - "process_host", + "host_process_host", "task_reported_processes", } @@ -90,7 +111,17 @@ var ( PrincipalValidator func(string) error ) -// OrderOption defines the ordering options for the Process queries. +// StatusValidator is a validator for the "status" field enum values. It is called by the builders before save. +func StatusValidator(s c2pb.Process_Status) error { + switch s.String() { + case "STATUS_STOP", "STATUS_TRACING", "STATUS_WAKE_KILL", "STATUS_UNKNOWN", "STATUS_IDLE", "STATUS_SLEEP", "STATUS_WAKING", "STATUS_UNSPECIFIED", "STATUS_PARKED", "STATUS_LOCK_BLOCKED", "STATUS_DEAD", "STATUS_ZOMBIE", "STATUS_UNINTERUPTIBLE_DISK_SLEEP", "STATUS_RUN": + return nil + default: + return fmt.Errorf("hostprocess: invalid enum value for status field: %q", s) + } +} + +// OrderOption defines the ordering options for the HostProcess queries. type OrderOption func(*sql.Selector) // ByID orders the results by the id field. @@ -113,6 +144,11 @@ func ByPid(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldPid, opts...).ToFunc() } +// ByPpid orders the results by the ppid field. +func ByPpid(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldPpid, opts...).ToFunc() +} + // ByName orders the results by the name field. func ByName(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldName, opts...).ToFunc() @@ -123,6 +159,31 @@ func ByPrincipal(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldPrincipal, opts...).ToFunc() } +// ByPath orders the results by the path field. +func ByPath(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldPath, opts...).ToFunc() +} + +// ByCmd orders the results by the cmd field. +func ByCmd(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldCmd, opts...).ToFunc() +} + +// ByEnv orders the results by the env field. +func ByEnv(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldEnv, opts...).ToFunc() +} + +// ByCwd orders the results by the cwd field. +func ByCwd(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldCwd, opts...).ToFunc() +} + +// ByStatus orders the results by the status field. +func ByStatus(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldStatus, opts...).ToFunc() +} + // ByHostField orders the results by host field. func ByHostField(field string, opts ...sql.OrderTermOption) OrderOption { return func(s *sql.Selector) { @@ -150,3 +211,10 @@ func newTaskStep() *sqlgraph.Step { sqlgraph.Edge(sqlgraph.M2O, true, TaskTable, TaskColumn), ) } + +var ( + // c2pb.Process_Status must implement graphql.Marshaler. + _ graphql.Marshaler = (*c2pb.Process_Status)(nil) + // c2pb.Process_Status must implement graphql.Unmarshaler. + _ graphql.Unmarshaler = (*c2pb.Process_Status)(nil) +) diff --git a/tavern/internal/ent/hostprocess/where.go b/tavern/internal/ent/hostprocess/where.go new file mode 100644 index 000000000..1700050f4 --- /dev/null +++ b/tavern/internal/ent/hostprocess/where.go @@ -0,0 +1,778 @@ +// Code generated by ent, DO NOT EDIT. + +package hostprocess + +import ( + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "realm.pub/tavern/internal/c2/c2pb" + "realm.pub/tavern/internal/ent/predicate" +) + +// ID filters vertices based on their ID field. +func ID(id int) predicate.HostProcess { + return predicate.HostProcess(sql.FieldEQ(FieldID, id)) +} + +// IDEQ applies the EQ predicate on the ID field. +func IDEQ(id int) predicate.HostProcess { + return predicate.HostProcess(sql.FieldEQ(FieldID, id)) +} + +// IDNEQ applies the NEQ predicate on the ID field. +func IDNEQ(id int) predicate.HostProcess { + return predicate.HostProcess(sql.FieldNEQ(FieldID, id)) +} + +// IDIn applies the In predicate on the ID field. +func IDIn(ids ...int) predicate.HostProcess { + return predicate.HostProcess(sql.FieldIn(FieldID, ids...)) +} + +// IDNotIn applies the NotIn predicate on the ID field. +func IDNotIn(ids ...int) predicate.HostProcess { + return predicate.HostProcess(sql.FieldNotIn(FieldID, ids...)) +} + +// IDGT applies the GT predicate on the ID field. +func IDGT(id int) predicate.HostProcess { + return predicate.HostProcess(sql.FieldGT(FieldID, id)) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id int) predicate.HostProcess { + return predicate.HostProcess(sql.FieldGTE(FieldID, id)) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id int) predicate.HostProcess { + return predicate.HostProcess(sql.FieldLT(FieldID, id)) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id int) predicate.HostProcess { + return predicate.HostProcess(sql.FieldLTE(FieldID, id)) +} + +// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ. +func CreatedAt(v time.Time) predicate.HostProcess { + return predicate.HostProcess(sql.FieldEQ(FieldCreatedAt, v)) +} + +// LastModifiedAt applies equality check predicate on the "last_modified_at" field. It's identical to LastModifiedAtEQ. +func LastModifiedAt(v time.Time) predicate.HostProcess { + return predicate.HostProcess(sql.FieldEQ(FieldLastModifiedAt, v)) +} + +// Pid applies equality check predicate on the "pid" field. It's identical to PidEQ. +func Pid(v uint64) predicate.HostProcess { + return predicate.HostProcess(sql.FieldEQ(FieldPid, v)) +} + +// Ppid applies equality check predicate on the "ppid" field. It's identical to PpidEQ. +func Ppid(v uint64) predicate.HostProcess { + return predicate.HostProcess(sql.FieldEQ(FieldPpid, v)) +} + +// Name applies equality check predicate on the "name" field. It's identical to NameEQ. +func Name(v string) predicate.HostProcess { + return predicate.HostProcess(sql.FieldEQ(FieldName, v)) +} + +// Principal applies equality check predicate on the "principal" field. It's identical to PrincipalEQ. +func Principal(v string) predicate.HostProcess { + return predicate.HostProcess(sql.FieldEQ(FieldPrincipal, v)) +} + +// Path applies equality check predicate on the "path" field. It's identical to PathEQ. +func Path(v string) predicate.HostProcess { + return predicate.HostProcess(sql.FieldEQ(FieldPath, v)) +} + +// Cmd applies equality check predicate on the "cmd" field. It's identical to CmdEQ. +func Cmd(v string) predicate.HostProcess { + return predicate.HostProcess(sql.FieldEQ(FieldCmd, v)) +} + +// Env applies equality check predicate on the "env" field. It's identical to EnvEQ. +func Env(v string) predicate.HostProcess { + return predicate.HostProcess(sql.FieldEQ(FieldEnv, v)) +} + +// Cwd applies equality check predicate on the "cwd" field. It's identical to CwdEQ. +func Cwd(v string) predicate.HostProcess { + return predicate.HostProcess(sql.FieldEQ(FieldCwd, v)) +} + +// CreatedAtEQ applies the EQ predicate on the "created_at" field. +func CreatedAtEQ(v time.Time) predicate.HostProcess { + return predicate.HostProcess(sql.FieldEQ(FieldCreatedAt, v)) +} + +// CreatedAtNEQ applies the NEQ predicate on the "created_at" field. +func CreatedAtNEQ(v time.Time) predicate.HostProcess { + return predicate.HostProcess(sql.FieldNEQ(FieldCreatedAt, v)) +} + +// CreatedAtIn applies the In predicate on the "created_at" field. +func CreatedAtIn(vs ...time.Time) predicate.HostProcess { + return predicate.HostProcess(sql.FieldIn(FieldCreatedAt, vs...)) +} + +// CreatedAtNotIn applies the NotIn predicate on the "created_at" field. +func CreatedAtNotIn(vs ...time.Time) predicate.HostProcess { + return predicate.HostProcess(sql.FieldNotIn(FieldCreatedAt, vs...)) +} + +// CreatedAtGT applies the GT predicate on the "created_at" field. +func CreatedAtGT(v time.Time) predicate.HostProcess { + return predicate.HostProcess(sql.FieldGT(FieldCreatedAt, v)) +} + +// CreatedAtGTE applies the GTE predicate on the "created_at" field. +func CreatedAtGTE(v time.Time) predicate.HostProcess { + return predicate.HostProcess(sql.FieldGTE(FieldCreatedAt, v)) +} + +// CreatedAtLT applies the LT predicate on the "created_at" field. +func CreatedAtLT(v time.Time) predicate.HostProcess { + return predicate.HostProcess(sql.FieldLT(FieldCreatedAt, v)) +} + +// CreatedAtLTE applies the LTE predicate on the "created_at" field. +func CreatedAtLTE(v time.Time) predicate.HostProcess { + return predicate.HostProcess(sql.FieldLTE(FieldCreatedAt, v)) +} + +// LastModifiedAtEQ applies the EQ predicate on the "last_modified_at" field. +func LastModifiedAtEQ(v time.Time) predicate.HostProcess { + return predicate.HostProcess(sql.FieldEQ(FieldLastModifiedAt, v)) +} + +// LastModifiedAtNEQ applies the NEQ predicate on the "last_modified_at" field. +func LastModifiedAtNEQ(v time.Time) predicate.HostProcess { + return predicate.HostProcess(sql.FieldNEQ(FieldLastModifiedAt, v)) +} + +// LastModifiedAtIn applies the In predicate on the "last_modified_at" field. +func LastModifiedAtIn(vs ...time.Time) predicate.HostProcess { + return predicate.HostProcess(sql.FieldIn(FieldLastModifiedAt, vs...)) +} + +// LastModifiedAtNotIn applies the NotIn predicate on the "last_modified_at" field. +func LastModifiedAtNotIn(vs ...time.Time) predicate.HostProcess { + return predicate.HostProcess(sql.FieldNotIn(FieldLastModifiedAt, vs...)) +} + +// LastModifiedAtGT applies the GT predicate on the "last_modified_at" field. +func LastModifiedAtGT(v time.Time) predicate.HostProcess { + return predicate.HostProcess(sql.FieldGT(FieldLastModifiedAt, v)) +} + +// LastModifiedAtGTE applies the GTE predicate on the "last_modified_at" field. +func LastModifiedAtGTE(v time.Time) predicate.HostProcess { + return predicate.HostProcess(sql.FieldGTE(FieldLastModifiedAt, v)) +} + +// LastModifiedAtLT applies the LT predicate on the "last_modified_at" field. +func LastModifiedAtLT(v time.Time) predicate.HostProcess { + return predicate.HostProcess(sql.FieldLT(FieldLastModifiedAt, v)) +} + +// LastModifiedAtLTE applies the LTE predicate on the "last_modified_at" field. +func LastModifiedAtLTE(v time.Time) predicate.HostProcess { + return predicate.HostProcess(sql.FieldLTE(FieldLastModifiedAt, v)) +} + +// PidEQ applies the EQ predicate on the "pid" field. +func PidEQ(v uint64) predicate.HostProcess { + return predicate.HostProcess(sql.FieldEQ(FieldPid, v)) +} + +// PidNEQ applies the NEQ predicate on the "pid" field. +func PidNEQ(v uint64) predicate.HostProcess { + return predicate.HostProcess(sql.FieldNEQ(FieldPid, v)) +} + +// PidIn applies the In predicate on the "pid" field. +func PidIn(vs ...uint64) predicate.HostProcess { + return predicate.HostProcess(sql.FieldIn(FieldPid, vs...)) +} + +// PidNotIn applies the NotIn predicate on the "pid" field. +func PidNotIn(vs ...uint64) predicate.HostProcess { + return predicate.HostProcess(sql.FieldNotIn(FieldPid, vs...)) +} + +// PidGT applies the GT predicate on the "pid" field. +func PidGT(v uint64) predicate.HostProcess { + return predicate.HostProcess(sql.FieldGT(FieldPid, v)) +} + +// PidGTE applies the GTE predicate on the "pid" field. +func PidGTE(v uint64) predicate.HostProcess { + return predicate.HostProcess(sql.FieldGTE(FieldPid, v)) +} + +// PidLT applies the LT predicate on the "pid" field. +func PidLT(v uint64) predicate.HostProcess { + return predicate.HostProcess(sql.FieldLT(FieldPid, v)) +} + +// PidLTE applies the LTE predicate on the "pid" field. +func PidLTE(v uint64) predicate.HostProcess { + return predicate.HostProcess(sql.FieldLTE(FieldPid, v)) +} + +// PpidEQ applies the EQ predicate on the "ppid" field. +func PpidEQ(v uint64) predicate.HostProcess { + return predicate.HostProcess(sql.FieldEQ(FieldPpid, v)) +} + +// PpidNEQ applies the NEQ predicate on the "ppid" field. +func PpidNEQ(v uint64) predicate.HostProcess { + return predicate.HostProcess(sql.FieldNEQ(FieldPpid, v)) +} + +// PpidIn applies the In predicate on the "ppid" field. +func PpidIn(vs ...uint64) predicate.HostProcess { + return predicate.HostProcess(sql.FieldIn(FieldPpid, vs...)) +} + +// PpidNotIn applies the NotIn predicate on the "ppid" field. +func PpidNotIn(vs ...uint64) predicate.HostProcess { + return predicate.HostProcess(sql.FieldNotIn(FieldPpid, vs...)) +} + +// PpidGT applies the GT predicate on the "ppid" field. +func PpidGT(v uint64) predicate.HostProcess { + return predicate.HostProcess(sql.FieldGT(FieldPpid, v)) +} + +// PpidGTE applies the GTE predicate on the "ppid" field. +func PpidGTE(v uint64) predicate.HostProcess { + return predicate.HostProcess(sql.FieldGTE(FieldPpid, v)) +} + +// PpidLT applies the LT predicate on the "ppid" field. +func PpidLT(v uint64) predicate.HostProcess { + return predicate.HostProcess(sql.FieldLT(FieldPpid, v)) +} + +// PpidLTE applies the LTE predicate on the "ppid" field. +func PpidLTE(v uint64) predicate.HostProcess { + return predicate.HostProcess(sql.FieldLTE(FieldPpid, v)) +} + +// NameEQ applies the EQ predicate on the "name" field. +func NameEQ(v string) predicate.HostProcess { + return predicate.HostProcess(sql.FieldEQ(FieldName, v)) +} + +// NameNEQ applies the NEQ predicate on the "name" field. +func NameNEQ(v string) predicate.HostProcess { + return predicate.HostProcess(sql.FieldNEQ(FieldName, v)) +} + +// NameIn applies the In predicate on the "name" field. +func NameIn(vs ...string) predicate.HostProcess { + return predicate.HostProcess(sql.FieldIn(FieldName, vs...)) +} + +// NameNotIn applies the NotIn predicate on the "name" field. +func NameNotIn(vs ...string) predicate.HostProcess { + return predicate.HostProcess(sql.FieldNotIn(FieldName, vs...)) +} + +// NameGT applies the GT predicate on the "name" field. +func NameGT(v string) predicate.HostProcess { + return predicate.HostProcess(sql.FieldGT(FieldName, v)) +} + +// NameGTE applies the GTE predicate on the "name" field. +func NameGTE(v string) predicate.HostProcess { + return predicate.HostProcess(sql.FieldGTE(FieldName, v)) +} + +// NameLT applies the LT predicate on the "name" field. +func NameLT(v string) predicate.HostProcess { + return predicate.HostProcess(sql.FieldLT(FieldName, v)) +} + +// NameLTE applies the LTE predicate on the "name" field. +func NameLTE(v string) predicate.HostProcess { + return predicate.HostProcess(sql.FieldLTE(FieldName, v)) +} + +// NameContains applies the Contains predicate on the "name" field. +func NameContains(v string) predicate.HostProcess { + return predicate.HostProcess(sql.FieldContains(FieldName, v)) +} + +// NameHasPrefix applies the HasPrefix predicate on the "name" field. +func NameHasPrefix(v string) predicate.HostProcess { + return predicate.HostProcess(sql.FieldHasPrefix(FieldName, v)) +} + +// NameHasSuffix applies the HasSuffix predicate on the "name" field. +func NameHasSuffix(v string) predicate.HostProcess { + return predicate.HostProcess(sql.FieldHasSuffix(FieldName, v)) +} + +// NameEqualFold applies the EqualFold predicate on the "name" field. +func NameEqualFold(v string) predicate.HostProcess { + return predicate.HostProcess(sql.FieldEqualFold(FieldName, v)) +} + +// NameContainsFold applies the ContainsFold predicate on the "name" field. +func NameContainsFold(v string) predicate.HostProcess { + return predicate.HostProcess(sql.FieldContainsFold(FieldName, v)) +} + +// PrincipalEQ applies the EQ predicate on the "principal" field. +func PrincipalEQ(v string) predicate.HostProcess { + return predicate.HostProcess(sql.FieldEQ(FieldPrincipal, v)) +} + +// PrincipalNEQ applies the NEQ predicate on the "principal" field. +func PrincipalNEQ(v string) predicate.HostProcess { + return predicate.HostProcess(sql.FieldNEQ(FieldPrincipal, v)) +} + +// PrincipalIn applies the In predicate on the "principal" field. +func PrincipalIn(vs ...string) predicate.HostProcess { + return predicate.HostProcess(sql.FieldIn(FieldPrincipal, vs...)) +} + +// PrincipalNotIn applies the NotIn predicate on the "principal" field. +func PrincipalNotIn(vs ...string) predicate.HostProcess { + return predicate.HostProcess(sql.FieldNotIn(FieldPrincipal, vs...)) +} + +// PrincipalGT applies the GT predicate on the "principal" field. +func PrincipalGT(v string) predicate.HostProcess { + return predicate.HostProcess(sql.FieldGT(FieldPrincipal, v)) +} + +// PrincipalGTE applies the GTE predicate on the "principal" field. +func PrincipalGTE(v string) predicate.HostProcess { + return predicate.HostProcess(sql.FieldGTE(FieldPrincipal, v)) +} + +// PrincipalLT applies the LT predicate on the "principal" field. +func PrincipalLT(v string) predicate.HostProcess { + return predicate.HostProcess(sql.FieldLT(FieldPrincipal, v)) +} + +// PrincipalLTE applies the LTE predicate on the "principal" field. +func PrincipalLTE(v string) predicate.HostProcess { + return predicate.HostProcess(sql.FieldLTE(FieldPrincipal, v)) +} + +// PrincipalContains applies the Contains predicate on the "principal" field. +func PrincipalContains(v string) predicate.HostProcess { + return predicate.HostProcess(sql.FieldContains(FieldPrincipal, v)) +} + +// PrincipalHasPrefix applies the HasPrefix predicate on the "principal" field. +func PrincipalHasPrefix(v string) predicate.HostProcess { + return predicate.HostProcess(sql.FieldHasPrefix(FieldPrincipal, v)) +} + +// PrincipalHasSuffix applies the HasSuffix predicate on the "principal" field. +func PrincipalHasSuffix(v string) predicate.HostProcess { + return predicate.HostProcess(sql.FieldHasSuffix(FieldPrincipal, v)) +} + +// PrincipalEqualFold applies the EqualFold predicate on the "principal" field. +func PrincipalEqualFold(v string) predicate.HostProcess { + return predicate.HostProcess(sql.FieldEqualFold(FieldPrincipal, v)) +} + +// PrincipalContainsFold applies the ContainsFold predicate on the "principal" field. +func PrincipalContainsFold(v string) predicate.HostProcess { + return predicate.HostProcess(sql.FieldContainsFold(FieldPrincipal, v)) +} + +// PathEQ applies the EQ predicate on the "path" field. +func PathEQ(v string) predicate.HostProcess { + return predicate.HostProcess(sql.FieldEQ(FieldPath, v)) +} + +// PathNEQ applies the NEQ predicate on the "path" field. +func PathNEQ(v string) predicate.HostProcess { + return predicate.HostProcess(sql.FieldNEQ(FieldPath, v)) +} + +// PathIn applies the In predicate on the "path" field. +func PathIn(vs ...string) predicate.HostProcess { + return predicate.HostProcess(sql.FieldIn(FieldPath, vs...)) +} + +// PathNotIn applies the NotIn predicate on the "path" field. +func PathNotIn(vs ...string) predicate.HostProcess { + return predicate.HostProcess(sql.FieldNotIn(FieldPath, vs...)) +} + +// PathGT applies the GT predicate on the "path" field. +func PathGT(v string) predicate.HostProcess { + return predicate.HostProcess(sql.FieldGT(FieldPath, v)) +} + +// PathGTE applies the GTE predicate on the "path" field. +func PathGTE(v string) predicate.HostProcess { + return predicate.HostProcess(sql.FieldGTE(FieldPath, v)) +} + +// PathLT applies the LT predicate on the "path" field. +func PathLT(v string) predicate.HostProcess { + return predicate.HostProcess(sql.FieldLT(FieldPath, v)) +} + +// PathLTE applies the LTE predicate on the "path" field. +func PathLTE(v string) predicate.HostProcess { + return predicate.HostProcess(sql.FieldLTE(FieldPath, v)) +} + +// PathContains applies the Contains predicate on the "path" field. +func PathContains(v string) predicate.HostProcess { + return predicate.HostProcess(sql.FieldContains(FieldPath, v)) +} + +// PathHasPrefix applies the HasPrefix predicate on the "path" field. +func PathHasPrefix(v string) predicate.HostProcess { + return predicate.HostProcess(sql.FieldHasPrefix(FieldPath, v)) +} + +// PathHasSuffix applies the HasSuffix predicate on the "path" field. +func PathHasSuffix(v string) predicate.HostProcess { + return predicate.HostProcess(sql.FieldHasSuffix(FieldPath, v)) +} + +// PathIsNil applies the IsNil predicate on the "path" field. +func PathIsNil() predicate.HostProcess { + return predicate.HostProcess(sql.FieldIsNull(FieldPath)) +} + +// PathNotNil applies the NotNil predicate on the "path" field. +func PathNotNil() predicate.HostProcess { + return predicate.HostProcess(sql.FieldNotNull(FieldPath)) +} + +// PathEqualFold applies the EqualFold predicate on the "path" field. +func PathEqualFold(v string) predicate.HostProcess { + return predicate.HostProcess(sql.FieldEqualFold(FieldPath, v)) +} + +// PathContainsFold applies the ContainsFold predicate on the "path" field. +func PathContainsFold(v string) predicate.HostProcess { + return predicate.HostProcess(sql.FieldContainsFold(FieldPath, v)) +} + +// CmdEQ applies the EQ predicate on the "cmd" field. +func CmdEQ(v string) predicate.HostProcess { + return predicate.HostProcess(sql.FieldEQ(FieldCmd, v)) +} + +// CmdNEQ applies the NEQ predicate on the "cmd" field. +func CmdNEQ(v string) predicate.HostProcess { + return predicate.HostProcess(sql.FieldNEQ(FieldCmd, v)) +} + +// CmdIn applies the In predicate on the "cmd" field. +func CmdIn(vs ...string) predicate.HostProcess { + return predicate.HostProcess(sql.FieldIn(FieldCmd, vs...)) +} + +// CmdNotIn applies the NotIn predicate on the "cmd" field. +func CmdNotIn(vs ...string) predicate.HostProcess { + return predicate.HostProcess(sql.FieldNotIn(FieldCmd, vs...)) +} + +// CmdGT applies the GT predicate on the "cmd" field. +func CmdGT(v string) predicate.HostProcess { + return predicate.HostProcess(sql.FieldGT(FieldCmd, v)) +} + +// CmdGTE applies the GTE predicate on the "cmd" field. +func CmdGTE(v string) predicate.HostProcess { + return predicate.HostProcess(sql.FieldGTE(FieldCmd, v)) +} + +// CmdLT applies the LT predicate on the "cmd" field. +func CmdLT(v string) predicate.HostProcess { + return predicate.HostProcess(sql.FieldLT(FieldCmd, v)) +} + +// CmdLTE applies the LTE predicate on the "cmd" field. +func CmdLTE(v string) predicate.HostProcess { + return predicate.HostProcess(sql.FieldLTE(FieldCmd, v)) +} + +// CmdContains applies the Contains predicate on the "cmd" field. +func CmdContains(v string) predicate.HostProcess { + return predicate.HostProcess(sql.FieldContains(FieldCmd, v)) +} + +// CmdHasPrefix applies the HasPrefix predicate on the "cmd" field. +func CmdHasPrefix(v string) predicate.HostProcess { + return predicate.HostProcess(sql.FieldHasPrefix(FieldCmd, v)) +} + +// CmdHasSuffix applies the HasSuffix predicate on the "cmd" field. +func CmdHasSuffix(v string) predicate.HostProcess { + return predicate.HostProcess(sql.FieldHasSuffix(FieldCmd, v)) +} + +// CmdIsNil applies the IsNil predicate on the "cmd" field. +func CmdIsNil() predicate.HostProcess { + return predicate.HostProcess(sql.FieldIsNull(FieldCmd)) +} + +// CmdNotNil applies the NotNil predicate on the "cmd" field. +func CmdNotNil() predicate.HostProcess { + return predicate.HostProcess(sql.FieldNotNull(FieldCmd)) +} + +// CmdEqualFold applies the EqualFold predicate on the "cmd" field. +func CmdEqualFold(v string) predicate.HostProcess { + return predicate.HostProcess(sql.FieldEqualFold(FieldCmd, v)) +} + +// CmdContainsFold applies the ContainsFold predicate on the "cmd" field. +func CmdContainsFold(v string) predicate.HostProcess { + return predicate.HostProcess(sql.FieldContainsFold(FieldCmd, v)) +} + +// EnvEQ applies the EQ predicate on the "env" field. +func EnvEQ(v string) predicate.HostProcess { + return predicate.HostProcess(sql.FieldEQ(FieldEnv, v)) +} + +// EnvNEQ applies the NEQ predicate on the "env" field. +func EnvNEQ(v string) predicate.HostProcess { + return predicate.HostProcess(sql.FieldNEQ(FieldEnv, v)) +} + +// EnvIn applies the In predicate on the "env" field. +func EnvIn(vs ...string) predicate.HostProcess { + return predicate.HostProcess(sql.FieldIn(FieldEnv, vs...)) +} + +// EnvNotIn applies the NotIn predicate on the "env" field. +func EnvNotIn(vs ...string) predicate.HostProcess { + return predicate.HostProcess(sql.FieldNotIn(FieldEnv, vs...)) +} + +// EnvGT applies the GT predicate on the "env" field. +func EnvGT(v string) predicate.HostProcess { + return predicate.HostProcess(sql.FieldGT(FieldEnv, v)) +} + +// EnvGTE applies the GTE predicate on the "env" field. +func EnvGTE(v string) predicate.HostProcess { + return predicate.HostProcess(sql.FieldGTE(FieldEnv, v)) +} + +// EnvLT applies the LT predicate on the "env" field. +func EnvLT(v string) predicate.HostProcess { + return predicate.HostProcess(sql.FieldLT(FieldEnv, v)) +} + +// EnvLTE applies the LTE predicate on the "env" field. +func EnvLTE(v string) predicate.HostProcess { + return predicate.HostProcess(sql.FieldLTE(FieldEnv, v)) +} + +// EnvContains applies the Contains predicate on the "env" field. +func EnvContains(v string) predicate.HostProcess { + return predicate.HostProcess(sql.FieldContains(FieldEnv, v)) +} + +// EnvHasPrefix applies the HasPrefix predicate on the "env" field. +func EnvHasPrefix(v string) predicate.HostProcess { + return predicate.HostProcess(sql.FieldHasPrefix(FieldEnv, v)) +} + +// EnvHasSuffix applies the HasSuffix predicate on the "env" field. +func EnvHasSuffix(v string) predicate.HostProcess { + return predicate.HostProcess(sql.FieldHasSuffix(FieldEnv, v)) +} + +// EnvIsNil applies the IsNil predicate on the "env" field. +func EnvIsNil() predicate.HostProcess { + return predicate.HostProcess(sql.FieldIsNull(FieldEnv)) +} + +// EnvNotNil applies the NotNil predicate on the "env" field. +func EnvNotNil() predicate.HostProcess { + return predicate.HostProcess(sql.FieldNotNull(FieldEnv)) +} + +// EnvEqualFold applies the EqualFold predicate on the "env" field. +func EnvEqualFold(v string) predicate.HostProcess { + return predicate.HostProcess(sql.FieldEqualFold(FieldEnv, v)) +} + +// EnvContainsFold applies the ContainsFold predicate on the "env" field. +func EnvContainsFold(v string) predicate.HostProcess { + return predicate.HostProcess(sql.FieldContainsFold(FieldEnv, v)) +} + +// CwdEQ applies the EQ predicate on the "cwd" field. +func CwdEQ(v string) predicate.HostProcess { + return predicate.HostProcess(sql.FieldEQ(FieldCwd, v)) +} + +// CwdNEQ applies the NEQ predicate on the "cwd" field. +func CwdNEQ(v string) predicate.HostProcess { + return predicate.HostProcess(sql.FieldNEQ(FieldCwd, v)) +} + +// CwdIn applies the In predicate on the "cwd" field. +func CwdIn(vs ...string) predicate.HostProcess { + return predicate.HostProcess(sql.FieldIn(FieldCwd, vs...)) +} + +// CwdNotIn applies the NotIn predicate on the "cwd" field. +func CwdNotIn(vs ...string) predicate.HostProcess { + return predicate.HostProcess(sql.FieldNotIn(FieldCwd, vs...)) +} + +// CwdGT applies the GT predicate on the "cwd" field. +func CwdGT(v string) predicate.HostProcess { + return predicate.HostProcess(sql.FieldGT(FieldCwd, v)) +} + +// CwdGTE applies the GTE predicate on the "cwd" field. +func CwdGTE(v string) predicate.HostProcess { + return predicate.HostProcess(sql.FieldGTE(FieldCwd, v)) +} + +// CwdLT applies the LT predicate on the "cwd" field. +func CwdLT(v string) predicate.HostProcess { + return predicate.HostProcess(sql.FieldLT(FieldCwd, v)) +} + +// CwdLTE applies the LTE predicate on the "cwd" field. +func CwdLTE(v string) predicate.HostProcess { + return predicate.HostProcess(sql.FieldLTE(FieldCwd, v)) +} + +// CwdContains applies the Contains predicate on the "cwd" field. +func CwdContains(v string) predicate.HostProcess { + return predicate.HostProcess(sql.FieldContains(FieldCwd, v)) +} + +// CwdHasPrefix applies the HasPrefix predicate on the "cwd" field. +func CwdHasPrefix(v string) predicate.HostProcess { + return predicate.HostProcess(sql.FieldHasPrefix(FieldCwd, v)) +} + +// CwdHasSuffix applies the HasSuffix predicate on the "cwd" field. +func CwdHasSuffix(v string) predicate.HostProcess { + return predicate.HostProcess(sql.FieldHasSuffix(FieldCwd, v)) +} + +// CwdIsNil applies the IsNil predicate on the "cwd" field. +func CwdIsNil() predicate.HostProcess { + return predicate.HostProcess(sql.FieldIsNull(FieldCwd)) +} + +// CwdNotNil applies the NotNil predicate on the "cwd" field. +func CwdNotNil() predicate.HostProcess { + return predicate.HostProcess(sql.FieldNotNull(FieldCwd)) +} + +// CwdEqualFold applies the EqualFold predicate on the "cwd" field. +func CwdEqualFold(v string) predicate.HostProcess { + return predicate.HostProcess(sql.FieldEqualFold(FieldCwd, v)) +} + +// CwdContainsFold applies the ContainsFold predicate on the "cwd" field. +func CwdContainsFold(v string) predicate.HostProcess { + return predicate.HostProcess(sql.FieldContainsFold(FieldCwd, v)) +} + +// StatusEQ applies the EQ predicate on the "status" field. +func StatusEQ(v c2pb.Process_Status) predicate.HostProcess { + return predicate.HostProcess(sql.FieldEQ(FieldStatus, v)) +} + +// StatusNEQ applies the NEQ predicate on the "status" field. +func StatusNEQ(v c2pb.Process_Status) predicate.HostProcess { + return predicate.HostProcess(sql.FieldNEQ(FieldStatus, v)) +} + +// StatusIn applies the In predicate on the "status" field. +func StatusIn(vs ...c2pb.Process_Status) predicate.HostProcess { + return predicate.HostProcess(sql.FieldIn(FieldStatus, vs...)) +} + +// StatusNotIn applies the NotIn predicate on the "status" field. +func StatusNotIn(vs ...c2pb.Process_Status) predicate.HostProcess { + return predicate.HostProcess(sql.FieldNotIn(FieldStatus, vs...)) +} + +// HasHost applies the HasEdge predicate on the "host" edge. +func HasHost() predicate.HostProcess { + return predicate.HostProcess(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, HostTable, HostColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasHostWith applies the HasEdge predicate on the "host" edge with a given conditions (other predicates). +func HasHostWith(preds ...predicate.Host) predicate.HostProcess { + return predicate.HostProcess(func(s *sql.Selector) { + step := newHostStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// HasTask applies the HasEdge predicate on the "task" edge. +func HasTask() predicate.HostProcess { + return predicate.HostProcess(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, TaskTable, TaskColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasTaskWith applies the HasEdge predicate on the "task" edge with a given conditions (other predicates). +func HasTaskWith(preds ...predicate.Task) predicate.HostProcess { + return predicate.HostProcess(func(s *sql.Selector) { + step := newTaskStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// And groups predicates with the AND operator between them. +func And(predicates ...predicate.HostProcess) predicate.HostProcess { + return predicate.HostProcess(sql.AndPredicates(predicates...)) +} + +// Or groups predicates with the OR operator between them. +func Or(predicates ...predicate.HostProcess) predicate.HostProcess { + return predicate.HostProcess(sql.OrPredicates(predicates...)) +} + +// Not applies the not operator on the given predicate. +func Not(p predicate.HostProcess) predicate.HostProcess { + return predicate.HostProcess(sql.NotPredicates(p)) +} diff --git a/tavern/internal/ent/hostprocess_create.go b/tavern/internal/ent/hostprocess_create.go new file mode 100644 index 000000000..7fda213d8 --- /dev/null +++ b/tavern/internal/ent/hostprocess_create.go @@ -0,0 +1,1202 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "realm.pub/tavern/internal/c2/c2pb" + "realm.pub/tavern/internal/ent/host" + "realm.pub/tavern/internal/ent/hostprocess" + "realm.pub/tavern/internal/ent/task" +) + +// HostProcessCreate is the builder for creating a HostProcess entity. +type HostProcessCreate struct { + config + mutation *HostProcessMutation + hooks []Hook + conflict []sql.ConflictOption +} + +// SetCreatedAt sets the "created_at" field. +func (hpc *HostProcessCreate) SetCreatedAt(t time.Time) *HostProcessCreate { + hpc.mutation.SetCreatedAt(t) + return hpc +} + +// SetNillableCreatedAt sets the "created_at" field if the given value is not nil. +func (hpc *HostProcessCreate) SetNillableCreatedAt(t *time.Time) *HostProcessCreate { + if t != nil { + hpc.SetCreatedAt(*t) + } + return hpc +} + +// SetLastModifiedAt sets the "last_modified_at" field. +func (hpc *HostProcessCreate) SetLastModifiedAt(t time.Time) *HostProcessCreate { + hpc.mutation.SetLastModifiedAt(t) + return hpc +} + +// SetNillableLastModifiedAt sets the "last_modified_at" field if the given value is not nil. +func (hpc *HostProcessCreate) SetNillableLastModifiedAt(t *time.Time) *HostProcessCreate { + if t != nil { + hpc.SetLastModifiedAt(*t) + } + return hpc +} + +// SetPid sets the "pid" field. +func (hpc *HostProcessCreate) SetPid(u uint64) *HostProcessCreate { + hpc.mutation.SetPid(u) + return hpc +} + +// SetPpid sets the "ppid" field. +func (hpc *HostProcessCreate) SetPpid(u uint64) *HostProcessCreate { + hpc.mutation.SetPpid(u) + return hpc +} + +// SetName sets the "name" field. +func (hpc *HostProcessCreate) SetName(s string) *HostProcessCreate { + hpc.mutation.SetName(s) + return hpc +} + +// SetPrincipal sets the "principal" field. +func (hpc *HostProcessCreate) SetPrincipal(s string) *HostProcessCreate { + hpc.mutation.SetPrincipal(s) + return hpc +} + +// SetPath sets the "path" field. +func (hpc *HostProcessCreate) SetPath(s string) *HostProcessCreate { + hpc.mutation.SetPath(s) + return hpc +} + +// SetNillablePath sets the "path" field if the given value is not nil. +func (hpc *HostProcessCreate) SetNillablePath(s *string) *HostProcessCreate { + if s != nil { + hpc.SetPath(*s) + } + return hpc +} + +// SetCmd sets the "cmd" field. +func (hpc *HostProcessCreate) SetCmd(s string) *HostProcessCreate { + hpc.mutation.SetCmd(s) + return hpc +} + +// SetNillableCmd sets the "cmd" field if the given value is not nil. +func (hpc *HostProcessCreate) SetNillableCmd(s *string) *HostProcessCreate { + if s != nil { + hpc.SetCmd(*s) + } + return hpc +} + +// SetEnv sets the "env" field. +func (hpc *HostProcessCreate) SetEnv(s string) *HostProcessCreate { + hpc.mutation.SetEnv(s) + return hpc +} + +// SetNillableEnv sets the "env" field if the given value is not nil. +func (hpc *HostProcessCreate) SetNillableEnv(s *string) *HostProcessCreate { + if s != nil { + hpc.SetEnv(*s) + } + return hpc +} + +// SetCwd sets the "cwd" field. +func (hpc *HostProcessCreate) SetCwd(s string) *HostProcessCreate { + hpc.mutation.SetCwd(s) + return hpc +} + +// SetNillableCwd sets the "cwd" field if the given value is not nil. +func (hpc *HostProcessCreate) SetNillableCwd(s *string) *HostProcessCreate { + if s != nil { + hpc.SetCwd(*s) + } + return hpc +} + +// SetStatus sets the "status" field. +func (hpc *HostProcessCreate) SetStatus(cs c2pb.Process_Status) *HostProcessCreate { + hpc.mutation.SetStatus(cs) + return hpc +} + +// SetHostID sets the "host" edge to the Host entity by ID. +func (hpc *HostProcessCreate) SetHostID(id int) *HostProcessCreate { + hpc.mutation.SetHostID(id) + return hpc +} + +// SetHost sets the "host" edge to the Host entity. +func (hpc *HostProcessCreate) SetHost(h *Host) *HostProcessCreate { + return hpc.SetHostID(h.ID) +} + +// SetTaskID sets the "task" edge to the Task entity by ID. +func (hpc *HostProcessCreate) SetTaskID(id int) *HostProcessCreate { + hpc.mutation.SetTaskID(id) + return hpc +} + +// SetTask sets the "task" edge to the Task entity. +func (hpc *HostProcessCreate) SetTask(t *Task) *HostProcessCreate { + return hpc.SetTaskID(t.ID) +} + +// Mutation returns the HostProcessMutation object of the builder. +func (hpc *HostProcessCreate) Mutation() *HostProcessMutation { + return hpc.mutation +} + +// Save creates the HostProcess in the database. +func (hpc *HostProcessCreate) Save(ctx context.Context) (*HostProcess, error) { + hpc.defaults() + return withHooks(ctx, hpc.sqlSave, hpc.mutation, hpc.hooks) +} + +// SaveX calls Save and panics if Save returns an error. +func (hpc *HostProcessCreate) SaveX(ctx context.Context) *HostProcess { + v, err := hpc.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (hpc *HostProcessCreate) Exec(ctx context.Context) error { + _, err := hpc.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (hpc *HostProcessCreate) ExecX(ctx context.Context) { + if err := hpc.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (hpc *HostProcessCreate) defaults() { + if _, ok := hpc.mutation.CreatedAt(); !ok { + v := hostprocess.DefaultCreatedAt() + hpc.mutation.SetCreatedAt(v) + } + if _, ok := hpc.mutation.LastModifiedAt(); !ok { + v := hostprocess.DefaultLastModifiedAt() + hpc.mutation.SetLastModifiedAt(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (hpc *HostProcessCreate) check() error { + if _, ok := hpc.mutation.CreatedAt(); !ok { + return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "HostProcess.created_at"`)} + } + if _, ok := hpc.mutation.LastModifiedAt(); !ok { + return &ValidationError{Name: "last_modified_at", err: errors.New(`ent: missing required field "HostProcess.last_modified_at"`)} + } + if _, ok := hpc.mutation.Pid(); !ok { + return &ValidationError{Name: "pid", err: errors.New(`ent: missing required field "HostProcess.pid"`)} + } + if _, ok := hpc.mutation.Ppid(); !ok { + return &ValidationError{Name: "ppid", err: errors.New(`ent: missing required field "HostProcess.ppid"`)} + } + if _, ok := hpc.mutation.Name(); !ok { + return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "HostProcess.name"`)} + } + if _, ok := hpc.mutation.Principal(); !ok { + return &ValidationError{Name: "principal", err: errors.New(`ent: missing required field "HostProcess.principal"`)} + } + if v, ok := hpc.mutation.Principal(); ok { + if err := hostprocess.PrincipalValidator(v); err != nil { + return &ValidationError{Name: "principal", err: fmt.Errorf(`ent: validator failed for field "HostProcess.principal": %w`, err)} + } + } + if _, ok := hpc.mutation.Status(); !ok { + return &ValidationError{Name: "status", err: errors.New(`ent: missing required field "HostProcess.status"`)} + } + if v, ok := hpc.mutation.Status(); ok { + if err := hostprocess.StatusValidator(v); err != nil { + return &ValidationError{Name: "status", err: fmt.Errorf(`ent: validator failed for field "HostProcess.status": %w`, err)} + } + } + if _, ok := hpc.mutation.HostID(); !ok { + return &ValidationError{Name: "host", err: errors.New(`ent: missing required edge "HostProcess.host"`)} + } + if _, ok := hpc.mutation.TaskID(); !ok { + return &ValidationError{Name: "task", err: errors.New(`ent: missing required edge "HostProcess.task"`)} + } + return nil +} + +func (hpc *HostProcessCreate) sqlSave(ctx context.Context) (*HostProcess, error) { + if err := hpc.check(); err != nil { + return nil, err + } + _node, _spec := hpc.createSpec() + if err := sqlgraph.CreateNode(ctx, hpc.driver, _spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + id := _spec.ID.Value.(int64) + _node.ID = int(id) + hpc.mutation.id = &_node.ID + hpc.mutation.done = true + return _node, nil +} + +func (hpc *HostProcessCreate) createSpec() (*HostProcess, *sqlgraph.CreateSpec) { + var ( + _node = &HostProcess{config: hpc.config} + _spec = sqlgraph.NewCreateSpec(hostprocess.Table, sqlgraph.NewFieldSpec(hostprocess.FieldID, field.TypeInt)) + ) + _spec.OnConflict = hpc.conflict + if value, ok := hpc.mutation.CreatedAt(); ok { + _spec.SetField(hostprocess.FieldCreatedAt, field.TypeTime, value) + _node.CreatedAt = value + } + if value, ok := hpc.mutation.LastModifiedAt(); ok { + _spec.SetField(hostprocess.FieldLastModifiedAt, field.TypeTime, value) + _node.LastModifiedAt = value + } + if value, ok := hpc.mutation.Pid(); ok { + _spec.SetField(hostprocess.FieldPid, field.TypeUint64, value) + _node.Pid = value + } + if value, ok := hpc.mutation.Ppid(); ok { + _spec.SetField(hostprocess.FieldPpid, field.TypeUint64, value) + _node.Ppid = value + } + if value, ok := hpc.mutation.Name(); ok { + _spec.SetField(hostprocess.FieldName, field.TypeString, value) + _node.Name = value + } + if value, ok := hpc.mutation.Principal(); ok { + _spec.SetField(hostprocess.FieldPrincipal, field.TypeString, value) + _node.Principal = value + } + if value, ok := hpc.mutation.Path(); ok { + _spec.SetField(hostprocess.FieldPath, field.TypeString, value) + _node.Path = value + } + if value, ok := hpc.mutation.Cmd(); ok { + _spec.SetField(hostprocess.FieldCmd, field.TypeString, value) + _node.Cmd = value + } + if value, ok := hpc.mutation.Env(); ok { + _spec.SetField(hostprocess.FieldEnv, field.TypeString, value) + _node.Env = value + } + if value, ok := hpc.mutation.Cwd(); ok { + _spec.SetField(hostprocess.FieldCwd, field.TypeString, value) + _node.Cwd = value + } + if value, ok := hpc.mutation.Status(); ok { + _spec.SetField(hostprocess.FieldStatus, field.TypeEnum, value) + _node.Status = value + } + if nodes := hpc.mutation.HostIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: hostprocess.HostTable, + Columns: []string{hostprocess.HostColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(host.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _node.host_process_host = &nodes[0] + _spec.Edges = append(_spec.Edges, edge) + } + if nodes := hpc.mutation.TaskIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: hostprocess.TaskTable, + Columns: []string{hostprocess.TaskColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(task.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _node.task_reported_processes = &nodes[0] + _spec.Edges = append(_spec.Edges, edge) + } + return _node, _spec +} + +// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause +// of the `INSERT` statement. For example: +// +// client.HostProcess.Create(). +// SetCreatedAt(v). +// OnConflict( +// // Update the row with the new values +// // the was proposed for insertion. +// sql.ResolveWithNewValues(), +// ). +// // Override some of the fields with custom +// // update values. +// Update(func(u *ent.HostProcessUpsert) { +// SetCreatedAt(v+v). +// }). +// Exec(ctx) +func (hpc *HostProcessCreate) OnConflict(opts ...sql.ConflictOption) *HostProcessUpsertOne { + hpc.conflict = opts + return &HostProcessUpsertOne{ + create: hpc, + } +} + +// OnConflictColumns calls `OnConflict` and configures the columns +// as conflict target. Using this option is equivalent to using: +// +// client.HostProcess.Create(). +// OnConflict(sql.ConflictColumns(columns...)). +// Exec(ctx) +func (hpc *HostProcessCreate) OnConflictColumns(columns ...string) *HostProcessUpsertOne { + hpc.conflict = append(hpc.conflict, sql.ConflictColumns(columns...)) + return &HostProcessUpsertOne{ + create: hpc, + } +} + +type ( + // HostProcessUpsertOne is the builder for "upsert"-ing + // one HostProcess node. + HostProcessUpsertOne struct { + create *HostProcessCreate + } + + // HostProcessUpsert is the "OnConflict" setter. + HostProcessUpsert struct { + *sql.UpdateSet + } +) + +// SetLastModifiedAt sets the "last_modified_at" field. +func (u *HostProcessUpsert) SetLastModifiedAt(v time.Time) *HostProcessUpsert { + u.Set(hostprocess.FieldLastModifiedAt, v) + return u +} + +// UpdateLastModifiedAt sets the "last_modified_at" field to the value that was provided on create. +func (u *HostProcessUpsert) UpdateLastModifiedAt() *HostProcessUpsert { + u.SetExcluded(hostprocess.FieldLastModifiedAt) + return u +} + +// SetPid sets the "pid" field. +func (u *HostProcessUpsert) SetPid(v uint64) *HostProcessUpsert { + u.Set(hostprocess.FieldPid, v) + return u +} + +// UpdatePid sets the "pid" field to the value that was provided on create. +func (u *HostProcessUpsert) UpdatePid() *HostProcessUpsert { + u.SetExcluded(hostprocess.FieldPid) + return u +} + +// AddPid adds v to the "pid" field. +func (u *HostProcessUpsert) AddPid(v uint64) *HostProcessUpsert { + u.Add(hostprocess.FieldPid, v) + return u +} + +// SetPpid sets the "ppid" field. +func (u *HostProcessUpsert) SetPpid(v uint64) *HostProcessUpsert { + u.Set(hostprocess.FieldPpid, v) + return u +} + +// UpdatePpid sets the "ppid" field to the value that was provided on create. +func (u *HostProcessUpsert) UpdatePpid() *HostProcessUpsert { + u.SetExcluded(hostprocess.FieldPpid) + return u +} + +// AddPpid adds v to the "ppid" field. +func (u *HostProcessUpsert) AddPpid(v uint64) *HostProcessUpsert { + u.Add(hostprocess.FieldPpid, v) + return u +} + +// SetName sets the "name" field. +func (u *HostProcessUpsert) SetName(v string) *HostProcessUpsert { + u.Set(hostprocess.FieldName, v) + return u +} + +// UpdateName sets the "name" field to the value that was provided on create. +func (u *HostProcessUpsert) UpdateName() *HostProcessUpsert { + u.SetExcluded(hostprocess.FieldName) + return u +} + +// SetPrincipal sets the "principal" field. +func (u *HostProcessUpsert) SetPrincipal(v string) *HostProcessUpsert { + u.Set(hostprocess.FieldPrincipal, v) + return u +} + +// UpdatePrincipal sets the "principal" field to the value that was provided on create. +func (u *HostProcessUpsert) UpdatePrincipal() *HostProcessUpsert { + u.SetExcluded(hostprocess.FieldPrincipal) + return u +} + +// SetPath sets the "path" field. +func (u *HostProcessUpsert) SetPath(v string) *HostProcessUpsert { + u.Set(hostprocess.FieldPath, v) + return u +} + +// UpdatePath sets the "path" field to the value that was provided on create. +func (u *HostProcessUpsert) UpdatePath() *HostProcessUpsert { + u.SetExcluded(hostprocess.FieldPath) + return u +} + +// ClearPath clears the value of the "path" field. +func (u *HostProcessUpsert) ClearPath() *HostProcessUpsert { + u.SetNull(hostprocess.FieldPath) + return u +} + +// SetCmd sets the "cmd" field. +func (u *HostProcessUpsert) SetCmd(v string) *HostProcessUpsert { + u.Set(hostprocess.FieldCmd, v) + return u +} + +// UpdateCmd sets the "cmd" field to the value that was provided on create. +func (u *HostProcessUpsert) UpdateCmd() *HostProcessUpsert { + u.SetExcluded(hostprocess.FieldCmd) + return u +} + +// ClearCmd clears the value of the "cmd" field. +func (u *HostProcessUpsert) ClearCmd() *HostProcessUpsert { + u.SetNull(hostprocess.FieldCmd) + return u +} + +// SetEnv sets the "env" field. +func (u *HostProcessUpsert) SetEnv(v string) *HostProcessUpsert { + u.Set(hostprocess.FieldEnv, v) + return u +} + +// UpdateEnv sets the "env" field to the value that was provided on create. +func (u *HostProcessUpsert) UpdateEnv() *HostProcessUpsert { + u.SetExcluded(hostprocess.FieldEnv) + return u +} + +// ClearEnv clears the value of the "env" field. +func (u *HostProcessUpsert) ClearEnv() *HostProcessUpsert { + u.SetNull(hostprocess.FieldEnv) + return u +} + +// SetCwd sets the "cwd" field. +func (u *HostProcessUpsert) SetCwd(v string) *HostProcessUpsert { + u.Set(hostprocess.FieldCwd, v) + return u +} + +// UpdateCwd sets the "cwd" field to the value that was provided on create. +func (u *HostProcessUpsert) UpdateCwd() *HostProcessUpsert { + u.SetExcluded(hostprocess.FieldCwd) + return u +} + +// ClearCwd clears the value of the "cwd" field. +func (u *HostProcessUpsert) ClearCwd() *HostProcessUpsert { + u.SetNull(hostprocess.FieldCwd) + return u +} + +// SetStatus sets the "status" field. +func (u *HostProcessUpsert) SetStatus(v c2pb.Process_Status) *HostProcessUpsert { + u.Set(hostprocess.FieldStatus, v) + return u +} + +// UpdateStatus sets the "status" field to the value that was provided on create. +func (u *HostProcessUpsert) UpdateStatus() *HostProcessUpsert { + u.SetExcluded(hostprocess.FieldStatus) + return u +} + +// UpdateNewValues updates the mutable fields using the new values that were set on create. +// Using this option is equivalent to using: +// +// client.HostProcess.Create(). +// OnConflict( +// sql.ResolveWithNewValues(), +// ). +// Exec(ctx) +func (u *HostProcessUpsertOne) UpdateNewValues() *HostProcessUpsertOne { + u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues()) + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) { + if _, exists := u.create.mutation.CreatedAt(); exists { + s.SetIgnore(hostprocess.FieldCreatedAt) + } + })) + return u +} + +// Ignore sets each column to itself in case of conflict. +// Using this option is equivalent to using: +// +// client.HostProcess.Create(). +// OnConflict(sql.ResolveWithIgnore()). +// Exec(ctx) +func (u *HostProcessUpsertOne) Ignore() *HostProcessUpsertOne { + u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore()) + return u +} + +// DoNothing configures the conflict_action to `DO NOTHING`. +// Supported only by SQLite and PostgreSQL. +func (u *HostProcessUpsertOne) DoNothing() *HostProcessUpsertOne { + u.create.conflict = append(u.create.conflict, sql.DoNothing()) + return u +} + +// Update allows overriding fields `UPDATE` values. See the HostProcessCreate.OnConflict +// documentation for more info. +func (u *HostProcessUpsertOne) Update(set func(*HostProcessUpsert)) *HostProcessUpsertOne { + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { + set(&HostProcessUpsert{UpdateSet: update}) + })) + return u +} + +// SetLastModifiedAt sets the "last_modified_at" field. +func (u *HostProcessUpsertOne) SetLastModifiedAt(v time.Time) *HostProcessUpsertOne { + return u.Update(func(s *HostProcessUpsert) { + s.SetLastModifiedAt(v) + }) +} + +// UpdateLastModifiedAt sets the "last_modified_at" field to the value that was provided on create. +func (u *HostProcessUpsertOne) UpdateLastModifiedAt() *HostProcessUpsertOne { + return u.Update(func(s *HostProcessUpsert) { + s.UpdateLastModifiedAt() + }) +} + +// SetPid sets the "pid" field. +func (u *HostProcessUpsertOne) SetPid(v uint64) *HostProcessUpsertOne { + return u.Update(func(s *HostProcessUpsert) { + s.SetPid(v) + }) +} + +// AddPid adds v to the "pid" field. +func (u *HostProcessUpsertOne) AddPid(v uint64) *HostProcessUpsertOne { + return u.Update(func(s *HostProcessUpsert) { + s.AddPid(v) + }) +} + +// UpdatePid sets the "pid" field to the value that was provided on create. +func (u *HostProcessUpsertOne) UpdatePid() *HostProcessUpsertOne { + return u.Update(func(s *HostProcessUpsert) { + s.UpdatePid() + }) +} + +// SetPpid sets the "ppid" field. +func (u *HostProcessUpsertOne) SetPpid(v uint64) *HostProcessUpsertOne { + return u.Update(func(s *HostProcessUpsert) { + s.SetPpid(v) + }) +} + +// AddPpid adds v to the "ppid" field. +func (u *HostProcessUpsertOne) AddPpid(v uint64) *HostProcessUpsertOne { + return u.Update(func(s *HostProcessUpsert) { + s.AddPpid(v) + }) +} + +// UpdatePpid sets the "ppid" field to the value that was provided on create. +func (u *HostProcessUpsertOne) UpdatePpid() *HostProcessUpsertOne { + return u.Update(func(s *HostProcessUpsert) { + s.UpdatePpid() + }) +} + +// SetName sets the "name" field. +func (u *HostProcessUpsertOne) SetName(v string) *HostProcessUpsertOne { + return u.Update(func(s *HostProcessUpsert) { + s.SetName(v) + }) +} + +// UpdateName sets the "name" field to the value that was provided on create. +func (u *HostProcessUpsertOne) UpdateName() *HostProcessUpsertOne { + return u.Update(func(s *HostProcessUpsert) { + s.UpdateName() + }) +} + +// SetPrincipal sets the "principal" field. +func (u *HostProcessUpsertOne) SetPrincipal(v string) *HostProcessUpsertOne { + return u.Update(func(s *HostProcessUpsert) { + s.SetPrincipal(v) + }) +} + +// UpdatePrincipal sets the "principal" field to the value that was provided on create. +func (u *HostProcessUpsertOne) UpdatePrincipal() *HostProcessUpsertOne { + return u.Update(func(s *HostProcessUpsert) { + s.UpdatePrincipal() + }) +} + +// SetPath sets the "path" field. +func (u *HostProcessUpsertOne) SetPath(v string) *HostProcessUpsertOne { + return u.Update(func(s *HostProcessUpsert) { + s.SetPath(v) + }) +} + +// UpdatePath sets the "path" field to the value that was provided on create. +func (u *HostProcessUpsertOne) UpdatePath() *HostProcessUpsertOne { + return u.Update(func(s *HostProcessUpsert) { + s.UpdatePath() + }) +} + +// ClearPath clears the value of the "path" field. +func (u *HostProcessUpsertOne) ClearPath() *HostProcessUpsertOne { + return u.Update(func(s *HostProcessUpsert) { + s.ClearPath() + }) +} + +// SetCmd sets the "cmd" field. +func (u *HostProcessUpsertOne) SetCmd(v string) *HostProcessUpsertOne { + return u.Update(func(s *HostProcessUpsert) { + s.SetCmd(v) + }) +} + +// UpdateCmd sets the "cmd" field to the value that was provided on create. +func (u *HostProcessUpsertOne) UpdateCmd() *HostProcessUpsertOne { + return u.Update(func(s *HostProcessUpsert) { + s.UpdateCmd() + }) +} + +// ClearCmd clears the value of the "cmd" field. +func (u *HostProcessUpsertOne) ClearCmd() *HostProcessUpsertOne { + return u.Update(func(s *HostProcessUpsert) { + s.ClearCmd() + }) +} + +// SetEnv sets the "env" field. +func (u *HostProcessUpsertOne) SetEnv(v string) *HostProcessUpsertOne { + return u.Update(func(s *HostProcessUpsert) { + s.SetEnv(v) + }) +} + +// UpdateEnv sets the "env" field to the value that was provided on create. +func (u *HostProcessUpsertOne) UpdateEnv() *HostProcessUpsertOne { + return u.Update(func(s *HostProcessUpsert) { + s.UpdateEnv() + }) +} + +// ClearEnv clears the value of the "env" field. +func (u *HostProcessUpsertOne) ClearEnv() *HostProcessUpsertOne { + return u.Update(func(s *HostProcessUpsert) { + s.ClearEnv() + }) +} + +// SetCwd sets the "cwd" field. +func (u *HostProcessUpsertOne) SetCwd(v string) *HostProcessUpsertOne { + return u.Update(func(s *HostProcessUpsert) { + s.SetCwd(v) + }) +} + +// UpdateCwd sets the "cwd" field to the value that was provided on create. +func (u *HostProcessUpsertOne) UpdateCwd() *HostProcessUpsertOne { + return u.Update(func(s *HostProcessUpsert) { + s.UpdateCwd() + }) +} + +// ClearCwd clears the value of the "cwd" field. +func (u *HostProcessUpsertOne) ClearCwd() *HostProcessUpsertOne { + return u.Update(func(s *HostProcessUpsert) { + s.ClearCwd() + }) +} + +// SetStatus sets the "status" field. +func (u *HostProcessUpsertOne) SetStatus(v c2pb.Process_Status) *HostProcessUpsertOne { + return u.Update(func(s *HostProcessUpsert) { + s.SetStatus(v) + }) +} + +// UpdateStatus sets the "status" field to the value that was provided on create. +func (u *HostProcessUpsertOne) UpdateStatus() *HostProcessUpsertOne { + return u.Update(func(s *HostProcessUpsert) { + s.UpdateStatus() + }) +} + +// Exec executes the query. +func (u *HostProcessUpsertOne) Exec(ctx context.Context) error { + if len(u.create.conflict) == 0 { + return errors.New("ent: missing options for HostProcessCreate.OnConflict") + } + return u.create.Exec(ctx) +} + +// ExecX is like Exec, but panics if an error occurs. +func (u *HostProcessUpsertOne) ExecX(ctx context.Context) { + if err := u.create.Exec(ctx); err != nil { + panic(err) + } +} + +// Exec executes the UPSERT query and returns the inserted/updated ID. +func (u *HostProcessUpsertOne) ID(ctx context.Context) (id int, err error) { + node, err := u.create.Save(ctx) + if err != nil { + return id, err + } + return node.ID, nil +} + +// IDX is like ID, but panics if an error occurs. +func (u *HostProcessUpsertOne) IDX(ctx context.Context) int { + id, err := u.ID(ctx) + if err != nil { + panic(err) + } + return id +} + +// HostProcessCreateBulk is the builder for creating many HostProcess entities in bulk. +type HostProcessCreateBulk struct { + config + err error + builders []*HostProcessCreate + conflict []sql.ConflictOption +} + +// Save creates the HostProcess entities in the database. +func (hpcb *HostProcessCreateBulk) Save(ctx context.Context) ([]*HostProcess, error) { + if hpcb.err != nil { + return nil, hpcb.err + } + specs := make([]*sqlgraph.CreateSpec, len(hpcb.builders)) + nodes := make([]*HostProcess, len(hpcb.builders)) + mutators := make([]Mutator, len(hpcb.builders)) + for i := range hpcb.builders { + func(i int, root context.Context) { + builder := hpcb.builders[i] + builder.defaults() + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*HostProcessMutation) + if !ok { + return nil, fmt.Errorf("unexpected mutation type %T", m) + } + if err := builder.check(); err != nil { + return nil, err + } + builder.mutation = mutation + var err error + nodes[i], specs[i] = builder.createSpec() + if i < len(mutators)-1 { + _, err = mutators[i+1].Mutate(root, hpcb.builders[i+1].mutation) + } else { + spec := &sqlgraph.BatchCreateSpec{Nodes: specs} + spec.OnConflict = hpcb.conflict + // Invoke the actual operation on the latest mutation in the chain. + if err = sqlgraph.BatchCreate(ctx, hpcb.driver, spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + } + } + if err != nil { + return nil, err + } + mutation.id = &nodes[i].ID + if specs[i].ID.Value != nil { + id := specs[i].ID.Value.(int64) + nodes[i].ID = int(id) + } + mutation.done = true + return nodes[i], nil + }) + for i := len(builder.hooks) - 1; i >= 0; i-- { + mut = builder.hooks[i](mut) + } + mutators[i] = mut + }(i, ctx) + } + if len(mutators) > 0 { + if _, err := mutators[0].Mutate(ctx, hpcb.builders[0].mutation); err != nil { + return nil, err + } + } + return nodes, nil +} + +// SaveX is like Save, but panics if an error occurs. +func (hpcb *HostProcessCreateBulk) SaveX(ctx context.Context) []*HostProcess { + v, err := hpcb.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (hpcb *HostProcessCreateBulk) Exec(ctx context.Context) error { + _, err := hpcb.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (hpcb *HostProcessCreateBulk) ExecX(ctx context.Context) { + if err := hpcb.Exec(ctx); err != nil { + panic(err) + } +} + +// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause +// of the `INSERT` statement. For example: +// +// client.HostProcess.CreateBulk(builders...). +// OnConflict( +// // Update the row with the new values +// // the was proposed for insertion. +// sql.ResolveWithNewValues(), +// ). +// // Override some of the fields with custom +// // update values. +// Update(func(u *ent.HostProcessUpsert) { +// SetCreatedAt(v+v). +// }). +// Exec(ctx) +func (hpcb *HostProcessCreateBulk) OnConflict(opts ...sql.ConflictOption) *HostProcessUpsertBulk { + hpcb.conflict = opts + return &HostProcessUpsertBulk{ + create: hpcb, + } +} + +// OnConflictColumns calls `OnConflict` and configures the columns +// as conflict target. Using this option is equivalent to using: +// +// client.HostProcess.Create(). +// OnConflict(sql.ConflictColumns(columns...)). +// Exec(ctx) +func (hpcb *HostProcessCreateBulk) OnConflictColumns(columns ...string) *HostProcessUpsertBulk { + hpcb.conflict = append(hpcb.conflict, sql.ConflictColumns(columns...)) + return &HostProcessUpsertBulk{ + create: hpcb, + } +} + +// HostProcessUpsertBulk is the builder for "upsert"-ing +// a bulk of HostProcess nodes. +type HostProcessUpsertBulk struct { + create *HostProcessCreateBulk +} + +// UpdateNewValues updates the mutable fields using the new values that +// were set on create. Using this option is equivalent to using: +// +// client.HostProcess.Create(). +// OnConflict( +// sql.ResolveWithNewValues(), +// ). +// Exec(ctx) +func (u *HostProcessUpsertBulk) UpdateNewValues() *HostProcessUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues()) + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) { + for _, b := range u.create.builders { + if _, exists := b.mutation.CreatedAt(); exists { + s.SetIgnore(hostprocess.FieldCreatedAt) + } + } + })) + return u +} + +// Ignore sets each column to itself in case of conflict. +// Using this option is equivalent to using: +// +// client.HostProcess.Create(). +// OnConflict(sql.ResolveWithIgnore()). +// Exec(ctx) +func (u *HostProcessUpsertBulk) Ignore() *HostProcessUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore()) + return u +} + +// DoNothing configures the conflict_action to `DO NOTHING`. +// Supported only by SQLite and PostgreSQL. +func (u *HostProcessUpsertBulk) DoNothing() *HostProcessUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.DoNothing()) + return u +} + +// Update allows overriding fields `UPDATE` values. See the HostProcessCreateBulk.OnConflict +// documentation for more info. +func (u *HostProcessUpsertBulk) Update(set func(*HostProcessUpsert)) *HostProcessUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { + set(&HostProcessUpsert{UpdateSet: update}) + })) + return u +} + +// SetLastModifiedAt sets the "last_modified_at" field. +func (u *HostProcessUpsertBulk) SetLastModifiedAt(v time.Time) *HostProcessUpsertBulk { + return u.Update(func(s *HostProcessUpsert) { + s.SetLastModifiedAt(v) + }) +} + +// UpdateLastModifiedAt sets the "last_modified_at" field to the value that was provided on create. +func (u *HostProcessUpsertBulk) UpdateLastModifiedAt() *HostProcessUpsertBulk { + return u.Update(func(s *HostProcessUpsert) { + s.UpdateLastModifiedAt() + }) +} + +// SetPid sets the "pid" field. +func (u *HostProcessUpsertBulk) SetPid(v uint64) *HostProcessUpsertBulk { + return u.Update(func(s *HostProcessUpsert) { + s.SetPid(v) + }) +} + +// AddPid adds v to the "pid" field. +func (u *HostProcessUpsertBulk) AddPid(v uint64) *HostProcessUpsertBulk { + return u.Update(func(s *HostProcessUpsert) { + s.AddPid(v) + }) +} + +// UpdatePid sets the "pid" field to the value that was provided on create. +func (u *HostProcessUpsertBulk) UpdatePid() *HostProcessUpsertBulk { + return u.Update(func(s *HostProcessUpsert) { + s.UpdatePid() + }) +} + +// SetPpid sets the "ppid" field. +func (u *HostProcessUpsertBulk) SetPpid(v uint64) *HostProcessUpsertBulk { + return u.Update(func(s *HostProcessUpsert) { + s.SetPpid(v) + }) +} + +// AddPpid adds v to the "ppid" field. +func (u *HostProcessUpsertBulk) AddPpid(v uint64) *HostProcessUpsertBulk { + return u.Update(func(s *HostProcessUpsert) { + s.AddPpid(v) + }) +} + +// UpdatePpid sets the "ppid" field to the value that was provided on create. +func (u *HostProcessUpsertBulk) UpdatePpid() *HostProcessUpsertBulk { + return u.Update(func(s *HostProcessUpsert) { + s.UpdatePpid() + }) +} + +// SetName sets the "name" field. +func (u *HostProcessUpsertBulk) SetName(v string) *HostProcessUpsertBulk { + return u.Update(func(s *HostProcessUpsert) { + s.SetName(v) + }) +} + +// UpdateName sets the "name" field to the value that was provided on create. +func (u *HostProcessUpsertBulk) UpdateName() *HostProcessUpsertBulk { + return u.Update(func(s *HostProcessUpsert) { + s.UpdateName() + }) +} + +// SetPrincipal sets the "principal" field. +func (u *HostProcessUpsertBulk) SetPrincipal(v string) *HostProcessUpsertBulk { + return u.Update(func(s *HostProcessUpsert) { + s.SetPrincipal(v) + }) +} + +// UpdatePrincipal sets the "principal" field to the value that was provided on create. +func (u *HostProcessUpsertBulk) UpdatePrincipal() *HostProcessUpsertBulk { + return u.Update(func(s *HostProcessUpsert) { + s.UpdatePrincipal() + }) +} + +// SetPath sets the "path" field. +func (u *HostProcessUpsertBulk) SetPath(v string) *HostProcessUpsertBulk { + return u.Update(func(s *HostProcessUpsert) { + s.SetPath(v) + }) +} + +// UpdatePath sets the "path" field to the value that was provided on create. +func (u *HostProcessUpsertBulk) UpdatePath() *HostProcessUpsertBulk { + return u.Update(func(s *HostProcessUpsert) { + s.UpdatePath() + }) +} + +// ClearPath clears the value of the "path" field. +func (u *HostProcessUpsertBulk) ClearPath() *HostProcessUpsertBulk { + return u.Update(func(s *HostProcessUpsert) { + s.ClearPath() + }) +} + +// SetCmd sets the "cmd" field. +func (u *HostProcessUpsertBulk) SetCmd(v string) *HostProcessUpsertBulk { + return u.Update(func(s *HostProcessUpsert) { + s.SetCmd(v) + }) +} + +// UpdateCmd sets the "cmd" field to the value that was provided on create. +func (u *HostProcessUpsertBulk) UpdateCmd() *HostProcessUpsertBulk { + return u.Update(func(s *HostProcessUpsert) { + s.UpdateCmd() + }) +} + +// ClearCmd clears the value of the "cmd" field. +func (u *HostProcessUpsertBulk) ClearCmd() *HostProcessUpsertBulk { + return u.Update(func(s *HostProcessUpsert) { + s.ClearCmd() + }) +} + +// SetEnv sets the "env" field. +func (u *HostProcessUpsertBulk) SetEnv(v string) *HostProcessUpsertBulk { + return u.Update(func(s *HostProcessUpsert) { + s.SetEnv(v) + }) +} + +// UpdateEnv sets the "env" field to the value that was provided on create. +func (u *HostProcessUpsertBulk) UpdateEnv() *HostProcessUpsertBulk { + return u.Update(func(s *HostProcessUpsert) { + s.UpdateEnv() + }) +} + +// ClearEnv clears the value of the "env" field. +func (u *HostProcessUpsertBulk) ClearEnv() *HostProcessUpsertBulk { + return u.Update(func(s *HostProcessUpsert) { + s.ClearEnv() + }) +} + +// SetCwd sets the "cwd" field. +func (u *HostProcessUpsertBulk) SetCwd(v string) *HostProcessUpsertBulk { + return u.Update(func(s *HostProcessUpsert) { + s.SetCwd(v) + }) +} + +// UpdateCwd sets the "cwd" field to the value that was provided on create. +func (u *HostProcessUpsertBulk) UpdateCwd() *HostProcessUpsertBulk { + return u.Update(func(s *HostProcessUpsert) { + s.UpdateCwd() + }) +} + +// ClearCwd clears the value of the "cwd" field. +func (u *HostProcessUpsertBulk) ClearCwd() *HostProcessUpsertBulk { + return u.Update(func(s *HostProcessUpsert) { + s.ClearCwd() + }) +} + +// SetStatus sets the "status" field. +func (u *HostProcessUpsertBulk) SetStatus(v c2pb.Process_Status) *HostProcessUpsertBulk { + return u.Update(func(s *HostProcessUpsert) { + s.SetStatus(v) + }) +} + +// UpdateStatus sets the "status" field to the value that was provided on create. +func (u *HostProcessUpsertBulk) UpdateStatus() *HostProcessUpsertBulk { + return u.Update(func(s *HostProcessUpsert) { + s.UpdateStatus() + }) +} + +// Exec executes the query. +func (u *HostProcessUpsertBulk) Exec(ctx context.Context) error { + if u.create.err != nil { + return u.create.err + } + for i, b := range u.create.builders { + if len(b.conflict) != 0 { + return fmt.Errorf("ent: OnConflict was set for builder %d. Set it on the HostProcessCreateBulk instead", i) + } + } + if len(u.create.conflict) == 0 { + return errors.New("ent: missing options for HostProcessCreateBulk.OnConflict") + } + return u.create.Exec(ctx) +} + +// ExecX is like Exec, but panics if an error occurs. +func (u *HostProcessUpsertBulk) ExecX(ctx context.Context) { + if err := u.create.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/tavern/internal/ent/hostprocess_delete.go b/tavern/internal/ent/hostprocess_delete.go new file mode 100644 index 000000000..0af8f8ece --- /dev/null +++ b/tavern/internal/ent/hostprocess_delete.go @@ -0,0 +1,88 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "realm.pub/tavern/internal/ent/hostprocess" + "realm.pub/tavern/internal/ent/predicate" +) + +// HostProcessDelete is the builder for deleting a HostProcess entity. +type HostProcessDelete struct { + config + hooks []Hook + mutation *HostProcessMutation +} + +// Where appends a list predicates to the HostProcessDelete builder. +func (hpd *HostProcessDelete) Where(ps ...predicate.HostProcess) *HostProcessDelete { + hpd.mutation.Where(ps...) + return hpd +} + +// Exec executes the deletion query and returns how many vertices were deleted. +func (hpd *HostProcessDelete) Exec(ctx context.Context) (int, error) { + return withHooks(ctx, hpd.sqlExec, hpd.mutation, hpd.hooks) +} + +// ExecX is like Exec, but panics if an error occurs. +func (hpd *HostProcessDelete) ExecX(ctx context.Context) int { + n, err := hpd.Exec(ctx) + if err != nil { + panic(err) + } + return n +} + +func (hpd *HostProcessDelete) sqlExec(ctx context.Context) (int, error) { + _spec := sqlgraph.NewDeleteSpec(hostprocess.Table, sqlgraph.NewFieldSpec(hostprocess.FieldID, field.TypeInt)) + if ps := hpd.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + affected, err := sqlgraph.DeleteNodes(ctx, hpd.driver, _spec) + if err != nil && sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + hpd.mutation.done = true + return affected, err +} + +// HostProcessDeleteOne is the builder for deleting a single HostProcess entity. +type HostProcessDeleteOne struct { + hpd *HostProcessDelete +} + +// Where appends a list predicates to the HostProcessDelete builder. +func (hpdo *HostProcessDeleteOne) Where(ps ...predicate.HostProcess) *HostProcessDeleteOne { + hpdo.hpd.mutation.Where(ps...) + return hpdo +} + +// Exec executes the deletion query. +func (hpdo *HostProcessDeleteOne) Exec(ctx context.Context) error { + n, err := hpdo.hpd.Exec(ctx) + switch { + case err != nil: + return err + case n == 0: + return &NotFoundError{hostprocess.Label} + default: + return nil + } +} + +// ExecX is like Exec, but panics if an error occurs. +func (hpdo *HostProcessDeleteOne) ExecX(ctx context.Context) { + if err := hpdo.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/tavern/internal/ent/hostprocess_query.go b/tavern/internal/ent/hostprocess_query.go new file mode 100644 index 000000000..df40ae390 --- /dev/null +++ b/tavern/internal/ent/hostprocess_query.go @@ -0,0 +1,701 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "fmt" + "math" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "realm.pub/tavern/internal/ent/host" + "realm.pub/tavern/internal/ent/hostprocess" + "realm.pub/tavern/internal/ent/predicate" + "realm.pub/tavern/internal/ent/task" +) + +// HostProcessQuery is the builder for querying HostProcess entities. +type HostProcessQuery struct { + config + ctx *QueryContext + order []hostprocess.OrderOption + inters []Interceptor + predicates []predicate.HostProcess + withHost *HostQuery + withTask *TaskQuery + withFKs bool + modifiers []func(*sql.Selector) + loadTotal []func(context.Context, []*HostProcess) error + // intermediate query (i.e. traversal path). + sql *sql.Selector + path func(context.Context) (*sql.Selector, error) +} + +// Where adds a new predicate for the HostProcessQuery builder. +func (hpq *HostProcessQuery) Where(ps ...predicate.HostProcess) *HostProcessQuery { + hpq.predicates = append(hpq.predicates, ps...) + return hpq +} + +// Limit the number of records to be returned by this query. +func (hpq *HostProcessQuery) Limit(limit int) *HostProcessQuery { + hpq.ctx.Limit = &limit + return hpq +} + +// Offset to start from. +func (hpq *HostProcessQuery) Offset(offset int) *HostProcessQuery { + hpq.ctx.Offset = &offset + return hpq +} + +// Unique configures the query builder to filter duplicate records on query. +// By default, unique is set to true, and can be disabled using this method. +func (hpq *HostProcessQuery) Unique(unique bool) *HostProcessQuery { + hpq.ctx.Unique = &unique + return hpq +} + +// Order specifies how the records should be ordered. +func (hpq *HostProcessQuery) Order(o ...hostprocess.OrderOption) *HostProcessQuery { + hpq.order = append(hpq.order, o...) + return hpq +} + +// QueryHost chains the current query on the "host" edge. +func (hpq *HostProcessQuery) QueryHost() *HostQuery { + query := (&HostClient{config: hpq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := hpq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := hpq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(hostprocess.Table, hostprocess.FieldID, selector), + sqlgraph.To(host.Table, host.FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, hostprocess.HostTable, hostprocess.HostColumn), + ) + fromU = sqlgraph.SetNeighbors(hpq.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// QueryTask chains the current query on the "task" edge. +func (hpq *HostProcessQuery) QueryTask() *TaskQuery { + query := (&TaskClient{config: hpq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := hpq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := hpq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(hostprocess.Table, hostprocess.FieldID, selector), + sqlgraph.To(task.Table, task.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, hostprocess.TaskTable, hostprocess.TaskColumn), + ) + fromU = sqlgraph.SetNeighbors(hpq.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// First returns the first HostProcess entity from the query. +// Returns a *NotFoundError when no HostProcess was found. +func (hpq *HostProcessQuery) First(ctx context.Context) (*HostProcess, error) { + nodes, err := hpq.Limit(1).All(setContextOp(ctx, hpq.ctx, "First")) + if err != nil { + return nil, err + } + if len(nodes) == 0 { + return nil, &NotFoundError{hostprocess.Label} + } + return nodes[0], nil +} + +// FirstX is like First, but panics if an error occurs. +func (hpq *HostProcessQuery) FirstX(ctx context.Context) *HostProcess { + node, err := hpq.First(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return node +} + +// FirstID returns the first HostProcess ID from the query. +// Returns a *NotFoundError when no HostProcess ID was found. +func (hpq *HostProcessQuery) FirstID(ctx context.Context) (id int, err error) { + var ids []int + if ids, err = hpq.Limit(1).IDs(setContextOp(ctx, hpq.ctx, "FirstID")); err != nil { + return + } + if len(ids) == 0 { + err = &NotFoundError{hostprocess.Label} + return + } + return ids[0], nil +} + +// FirstIDX is like FirstID, but panics if an error occurs. +func (hpq *HostProcessQuery) FirstIDX(ctx context.Context) int { + id, err := hpq.FirstID(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return id +} + +// Only returns a single HostProcess entity found by the query, ensuring it only returns one. +// Returns a *NotSingularError when more than one HostProcess entity is found. +// Returns a *NotFoundError when no HostProcess entities are found. +func (hpq *HostProcessQuery) Only(ctx context.Context) (*HostProcess, error) { + nodes, err := hpq.Limit(2).All(setContextOp(ctx, hpq.ctx, "Only")) + if err != nil { + return nil, err + } + switch len(nodes) { + case 1: + return nodes[0], nil + case 0: + return nil, &NotFoundError{hostprocess.Label} + default: + return nil, &NotSingularError{hostprocess.Label} + } +} + +// OnlyX is like Only, but panics if an error occurs. +func (hpq *HostProcessQuery) OnlyX(ctx context.Context) *HostProcess { + node, err := hpq.Only(ctx) + if err != nil { + panic(err) + } + return node +} + +// OnlyID is like Only, but returns the only HostProcess ID in the query. +// Returns a *NotSingularError when more than one HostProcess ID is found. +// Returns a *NotFoundError when no entities are found. +func (hpq *HostProcessQuery) OnlyID(ctx context.Context) (id int, err error) { + var ids []int + if ids, err = hpq.Limit(2).IDs(setContextOp(ctx, hpq.ctx, "OnlyID")); err != nil { + return + } + switch len(ids) { + case 1: + id = ids[0] + case 0: + err = &NotFoundError{hostprocess.Label} + default: + err = &NotSingularError{hostprocess.Label} + } + return +} + +// OnlyIDX is like OnlyID, but panics if an error occurs. +func (hpq *HostProcessQuery) OnlyIDX(ctx context.Context) int { + id, err := hpq.OnlyID(ctx) + if err != nil { + panic(err) + } + return id +} + +// All executes the query and returns a list of HostProcesses. +func (hpq *HostProcessQuery) All(ctx context.Context) ([]*HostProcess, error) { + ctx = setContextOp(ctx, hpq.ctx, "All") + if err := hpq.prepareQuery(ctx); err != nil { + return nil, err + } + qr := querierAll[[]*HostProcess, *HostProcessQuery]() + return withInterceptors[[]*HostProcess](ctx, hpq, qr, hpq.inters) +} + +// AllX is like All, but panics if an error occurs. +func (hpq *HostProcessQuery) AllX(ctx context.Context) []*HostProcess { + nodes, err := hpq.All(ctx) + if err != nil { + panic(err) + } + return nodes +} + +// IDs executes the query and returns a list of HostProcess IDs. +func (hpq *HostProcessQuery) IDs(ctx context.Context) (ids []int, err error) { + if hpq.ctx.Unique == nil && hpq.path != nil { + hpq.Unique(true) + } + ctx = setContextOp(ctx, hpq.ctx, "IDs") + if err = hpq.Select(hostprocess.FieldID).Scan(ctx, &ids); err != nil { + return nil, err + } + return ids, nil +} + +// IDsX is like IDs, but panics if an error occurs. +func (hpq *HostProcessQuery) IDsX(ctx context.Context) []int { + ids, err := hpq.IDs(ctx) + if err != nil { + panic(err) + } + return ids +} + +// Count returns the count of the given query. +func (hpq *HostProcessQuery) Count(ctx context.Context) (int, error) { + ctx = setContextOp(ctx, hpq.ctx, "Count") + if err := hpq.prepareQuery(ctx); err != nil { + return 0, err + } + return withInterceptors[int](ctx, hpq, querierCount[*HostProcessQuery](), hpq.inters) +} + +// CountX is like Count, but panics if an error occurs. +func (hpq *HostProcessQuery) CountX(ctx context.Context) int { + count, err := hpq.Count(ctx) + if err != nil { + panic(err) + } + return count +} + +// Exist returns true if the query has elements in the graph. +func (hpq *HostProcessQuery) Exist(ctx context.Context) (bool, error) { + ctx = setContextOp(ctx, hpq.ctx, "Exist") + switch _, err := hpq.FirstID(ctx); { + case IsNotFound(err): + return false, nil + case err != nil: + return false, fmt.Errorf("ent: check existence: %w", err) + default: + return true, nil + } +} + +// ExistX is like Exist, but panics if an error occurs. +func (hpq *HostProcessQuery) ExistX(ctx context.Context) bool { + exist, err := hpq.Exist(ctx) + if err != nil { + panic(err) + } + return exist +} + +// Clone returns a duplicate of the HostProcessQuery builder, including all associated steps. It can be +// used to prepare common query builders and use them differently after the clone is made. +func (hpq *HostProcessQuery) Clone() *HostProcessQuery { + if hpq == nil { + return nil + } + return &HostProcessQuery{ + config: hpq.config, + ctx: hpq.ctx.Clone(), + order: append([]hostprocess.OrderOption{}, hpq.order...), + inters: append([]Interceptor{}, hpq.inters...), + predicates: append([]predicate.HostProcess{}, hpq.predicates...), + withHost: hpq.withHost.Clone(), + withTask: hpq.withTask.Clone(), + // clone intermediate query. + sql: hpq.sql.Clone(), + path: hpq.path, + } +} + +// WithHost tells the query-builder to eager-load the nodes that are connected to +// the "host" edge. The optional arguments are used to configure the query builder of the edge. +func (hpq *HostProcessQuery) WithHost(opts ...func(*HostQuery)) *HostProcessQuery { + query := (&HostClient{config: hpq.config}).Query() + for _, opt := range opts { + opt(query) + } + hpq.withHost = query + return hpq +} + +// WithTask tells the query-builder to eager-load the nodes that are connected to +// the "task" edge. The optional arguments are used to configure the query builder of the edge. +func (hpq *HostProcessQuery) WithTask(opts ...func(*TaskQuery)) *HostProcessQuery { + query := (&TaskClient{config: hpq.config}).Query() + for _, opt := range opts { + opt(query) + } + hpq.withTask = query + return hpq +} + +// GroupBy is used to group vertices by one or more fields/columns. +// It is often used with aggregate functions, like: count, max, mean, min, sum. +// +// Example: +// +// var v []struct { +// CreatedAt time.Time `json:"created_at,omitempty"` +// Count int `json:"count,omitempty"` +// } +// +// client.HostProcess.Query(). +// GroupBy(hostprocess.FieldCreatedAt). +// Aggregate(ent.Count()). +// Scan(ctx, &v) +func (hpq *HostProcessQuery) GroupBy(field string, fields ...string) *HostProcessGroupBy { + hpq.ctx.Fields = append([]string{field}, fields...) + grbuild := &HostProcessGroupBy{build: hpq} + grbuild.flds = &hpq.ctx.Fields + grbuild.label = hostprocess.Label + grbuild.scan = grbuild.Scan + return grbuild +} + +// Select allows the selection one or more fields/columns for the given query, +// instead of selecting all fields in the entity. +// +// Example: +// +// var v []struct { +// CreatedAt time.Time `json:"created_at,omitempty"` +// } +// +// client.HostProcess.Query(). +// Select(hostprocess.FieldCreatedAt). +// Scan(ctx, &v) +func (hpq *HostProcessQuery) Select(fields ...string) *HostProcessSelect { + hpq.ctx.Fields = append(hpq.ctx.Fields, fields...) + sbuild := &HostProcessSelect{HostProcessQuery: hpq} + sbuild.label = hostprocess.Label + sbuild.flds, sbuild.scan = &hpq.ctx.Fields, sbuild.Scan + return sbuild +} + +// Aggregate returns a HostProcessSelect configured with the given aggregations. +func (hpq *HostProcessQuery) Aggregate(fns ...AggregateFunc) *HostProcessSelect { + return hpq.Select().Aggregate(fns...) +} + +func (hpq *HostProcessQuery) prepareQuery(ctx context.Context) error { + for _, inter := range hpq.inters { + if inter == nil { + return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)") + } + if trv, ok := inter.(Traverser); ok { + if err := trv.Traverse(ctx, hpq); err != nil { + return err + } + } + } + for _, f := range hpq.ctx.Fields { + if !hostprocess.ValidColumn(f) { + return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + } + if hpq.path != nil { + prev, err := hpq.path(ctx) + if err != nil { + return err + } + hpq.sql = prev + } + return nil +} + +func (hpq *HostProcessQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*HostProcess, error) { + var ( + nodes = []*HostProcess{} + withFKs = hpq.withFKs + _spec = hpq.querySpec() + loadedTypes = [2]bool{ + hpq.withHost != nil, + hpq.withTask != nil, + } + ) + if hpq.withHost != nil || hpq.withTask != nil { + withFKs = true + } + if withFKs { + _spec.Node.Columns = append(_spec.Node.Columns, hostprocess.ForeignKeys...) + } + _spec.ScanValues = func(columns []string) ([]any, error) { + return (*HostProcess).scanValues(nil, columns) + } + _spec.Assign = func(columns []string, values []any) error { + node := &HostProcess{config: hpq.config} + nodes = append(nodes, node) + node.Edges.loadedTypes = loadedTypes + return node.assignValues(columns, values) + } + if len(hpq.modifiers) > 0 { + _spec.Modifiers = hpq.modifiers + } + for i := range hooks { + hooks[i](ctx, _spec) + } + if err := sqlgraph.QueryNodes(ctx, hpq.driver, _spec); err != nil { + return nil, err + } + if len(nodes) == 0 { + return nodes, nil + } + if query := hpq.withHost; query != nil { + if err := hpq.loadHost(ctx, query, nodes, nil, + func(n *HostProcess, e *Host) { n.Edges.Host = e }); err != nil { + return nil, err + } + } + if query := hpq.withTask; query != nil { + if err := hpq.loadTask(ctx, query, nodes, nil, + func(n *HostProcess, e *Task) { n.Edges.Task = e }); err != nil { + return nil, err + } + } + for i := range hpq.loadTotal { + if err := hpq.loadTotal[i](ctx, nodes); err != nil { + return nil, err + } + } + return nodes, nil +} + +func (hpq *HostProcessQuery) loadHost(ctx context.Context, query *HostQuery, nodes []*HostProcess, init func(*HostProcess), assign func(*HostProcess, *Host)) error { + ids := make([]int, 0, len(nodes)) + nodeids := make(map[int][]*HostProcess) + for i := range nodes { + if nodes[i].host_process_host == nil { + continue + } + fk := *nodes[i].host_process_host + if _, ok := nodeids[fk]; !ok { + ids = append(ids, fk) + } + nodeids[fk] = append(nodeids[fk], nodes[i]) + } + if len(ids) == 0 { + return nil + } + query.Where(host.IDIn(ids...)) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + nodes, ok := nodeids[n.ID] + if !ok { + return fmt.Errorf(`unexpected foreign-key "host_process_host" returned %v`, n.ID) + } + for i := range nodes { + assign(nodes[i], n) + } + } + return nil +} +func (hpq *HostProcessQuery) loadTask(ctx context.Context, query *TaskQuery, nodes []*HostProcess, init func(*HostProcess), assign func(*HostProcess, *Task)) error { + ids := make([]int, 0, len(nodes)) + nodeids := make(map[int][]*HostProcess) + for i := range nodes { + if nodes[i].task_reported_processes == nil { + continue + } + fk := *nodes[i].task_reported_processes + if _, ok := nodeids[fk]; !ok { + ids = append(ids, fk) + } + nodeids[fk] = append(nodeids[fk], nodes[i]) + } + if len(ids) == 0 { + return nil + } + query.Where(task.IDIn(ids...)) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + nodes, ok := nodeids[n.ID] + if !ok { + return fmt.Errorf(`unexpected foreign-key "task_reported_processes" returned %v`, n.ID) + } + for i := range nodes { + assign(nodes[i], n) + } + } + return nil +} + +func (hpq *HostProcessQuery) sqlCount(ctx context.Context) (int, error) { + _spec := hpq.querySpec() + if len(hpq.modifiers) > 0 { + _spec.Modifiers = hpq.modifiers + } + _spec.Node.Columns = hpq.ctx.Fields + if len(hpq.ctx.Fields) > 0 { + _spec.Unique = hpq.ctx.Unique != nil && *hpq.ctx.Unique + } + return sqlgraph.CountNodes(ctx, hpq.driver, _spec) +} + +func (hpq *HostProcessQuery) querySpec() *sqlgraph.QuerySpec { + _spec := sqlgraph.NewQuerySpec(hostprocess.Table, hostprocess.Columns, sqlgraph.NewFieldSpec(hostprocess.FieldID, field.TypeInt)) + _spec.From = hpq.sql + if unique := hpq.ctx.Unique; unique != nil { + _spec.Unique = *unique + } else if hpq.path != nil { + _spec.Unique = true + } + if fields := hpq.ctx.Fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, hostprocess.FieldID) + for i := range fields { + if fields[i] != hostprocess.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) + } + } + } + if ps := hpq.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if limit := hpq.ctx.Limit; limit != nil { + _spec.Limit = *limit + } + if offset := hpq.ctx.Offset; offset != nil { + _spec.Offset = *offset + } + if ps := hpq.order; len(ps) > 0 { + _spec.Order = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + return _spec +} + +func (hpq *HostProcessQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(hpq.driver.Dialect()) + t1 := builder.Table(hostprocess.Table) + columns := hpq.ctx.Fields + if len(columns) == 0 { + columns = hostprocess.Columns + } + selector := builder.Select(t1.Columns(columns...)...).From(t1) + if hpq.sql != nil { + selector = hpq.sql + selector.Select(selector.Columns(columns...)...) + } + if hpq.ctx.Unique != nil && *hpq.ctx.Unique { + selector.Distinct() + } + for _, p := range hpq.predicates { + p(selector) + } + for _, p := range hpq.order { + p(selector) + } + if offset := hpq.ctx.Offset; offset != nil { + // limit is mandatory for offset clause. We start + // with default value, and override it below if needed. + selector.Offset(*offset).Limit(math.MaxInt32) + } + if limit := hpq.ctx.Limit; limit != nil { + selector.Limit(*limit) + } + return selector +} + +// HostProcessGroupBy is the group-by builder for HostProcess entities. +type HostProcessGroupBy struct { + selector + build *HostProcessQuery +} + +// Aggregate adds the given aggregation functions to the group-by query. +func (hpgb *HostProcessGroupBy) Aggregate(fns ...AggregateFunc) *HostProcessGroupBy { + hpgb.fns = append(hpgb.fns, fns...) + return hpgb +} + +// Scan applies the selector query and scans the result into the given value. +func (hpgb *HostProcessGroupBy) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, hpgb.build.ctx, "GroupBy") + if err := hpgb.build.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*HostProcessQuery, *HostProcessGroupBy](ctx, hpgb.build, hpgb, hpgb.build.inters, v) +} + +func (hpgb *HostProcessGroupBy) sqlScan(ctx context.Context, root *HostProcessQuery, v any) error { + selector := root.sqlQuery(ctx).Select() + aggregation := make([]string, 0, len(hpgb.fns)) + for _, fn := range hpgb.fns { + aggregation = append(aggregation, fn(selector)) + } + if len(selector.SelectedColumns()) == 0 { + columns := make([]string, 0, len(*hpgb.flds)+len(hpgb.fns)) + for _, f := range *hpgb.flds { + columns = append(columns, selector.C(f)) + } + columns = append(columns, aggregation...) + selector.Select(columns...) + } + selector.GroupBy(selector.Columns(*hpgb.flds...)...) + if err := selector.Err(); err != nil { + return err + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := hpgb.build.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// HostProcessSelect is the builder for selecting fields of HostProcess entities. +type HostProcessSelect struct { + *HostProcessQuery + selector +} + +// Aggregate adds the given aggregation functions to the selector query. +func (hps *HostProcessSelect) Aggregate(fns ...AggregateFunc) *HostProcessSelect { + hps.fns = append(hps.fns, fns...) + return hps +} + +// Scan applies the selector query and scans the result into the given value. +func (hps *HostProcessSelect) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, hps.ctx, "Select") + if err := hps.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*HostProcessQuery, *HostProcessSelect](ctx, hps.HostProcessQuery, hps, hps.inters, v) +} + +func (hps *HostProcessSelect) sqlScan(ctx context.Context, root *HostProcessQuery, v any) error { + selector := root.sqlQuery(ctx) + aggregation := make([]string, 0, len(hps.fns)) + for _, fn := range hps.fns { + aggregation = append(aggregation, fn(selector)) + } + switch n := len(*hps.selector.flds); { + case n == 0 && len(aggregation) > 0: + selector.Select(aggregation...) + case n != 0 && len(aggregation) > 0: + selector.AppendSelect(aggregation...) + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := hps.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} diff --git a/tavern/internal/ent/hostprocess_update.go b/tavern/internal/ent/hostprocess_update.go new file mode 100644 index 000000000..ae271a9df --- /dev/null +++ b/tavern/internal/ent/hostprocess_update.go @@ -0,0 +1,785 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "realm.pub/tavern/internal/c2/c2pb" + "realm.pub/tavern/internal/ent/host" + "realm.pub/tavern/internal/ent/hostprocess" + "realm.pub/tavern/internal/ent/predicate" + "realm.pub/tavern/internal/ent/task" +) + +// HostProcessUpdate is the builder for updating HostProcess entities. +type HostProcessUpdate struct { + config + hooks []Hook + mutation *HostProcessMutation +} + +// Where appends a list predicates to the HostProcessUpdate builder. +func (hpu *HostProcessUpdate) Where(ps ...predicate.HostProcess) *HostProcessUpdate { + hpu.mutation.Where(ps...) + return hpu +} + +// SetLastModifiedAt sets the "last_modified_at" field. +func (hpu *HostProcessUpdate) SetLastModifiedAt(t time.Time) *HostProcessUpdate { + hpu.mutation.SetLastModifiedAt(t) + return hpu +} + +// SetPid sets the "pid" field. +func (hpu *HostProcessUpdate) SetPid(u uint64) *HostProcessUpdate { + hpu.mutation.ResetPid() + hpu.mutation.SetPid(u) + return hpu +} + +// AddPid adds u to the "pid" field. +func (hpu *HostProcessUpdate) AddPid(u int64) *HostProcessUpdate { + hpu.mutation.AddPid(u) + return hpu +} + +// SetPpid sets the "ppid" field. +func (hpu *HostProcessUpdate) SetPpid(u uint64) *HostProcessUpdate { + hpu.mutation.ResetPpid() + hpu.mutation.SetPpid(u) + return hpu +} + +// AddPpid adds u to the "ppid" field. +func (hpu *HostProcessUpdate) AddPpid(u int64) *HostProcessUpdate { + hpu.mutation.AddPpid(u) + return hpu +} + +// SetName sets the "name" field. +func (hpu *HostProcessUpdate) SetName(s string) *HostProcessUpdate { + hpu.mutation.SetName(s) + return hpu +} + +// SetPrincipal sets the "principal" field. +func (hpu *HostProcessUpdate) SetPrincipal(s string) *HostProcessUpdate { + hpu.mutation.SetPrincipal(s) + return hpu +} + +// SetPath sets the "path" field. +func (hpu *HostProcessUpdate) SetPath(s string) *HostProcessUpdate { + hpu.mutation.SetPath(s) + return hpu +} + +// SetNillablePath sets the "path" field if the given value is not nil. +func (hpu *HostProcessUpdate) SetNillablePath(s *string) *HostProcessUpdate { + if s != nil { + hpu.SetPath(*s) + } + return hpu +} + +// ClearPath clears the value of the "path" field. +func (hpu *HostProcessUpdate) ClearPath() *HostProcessUpdate { + hpu.mutation.ClearPath() + return hpu +} + +// SetCmd sets the "cmd" field. +func (hpu *HostProcessUpdate) SetCmd(s string) *HostProcessUpdate { + hpu.mutation.SetCmd(s) + return hpu +} + +// SetNillableCmd sets the "cmd" field if the given value is not nil. +func (hpu *HostProcessUpdate) SetNillableCmd(s *string) *HostProcessUpdate { + if s != nil { + hpu.SetCmd(*s) + } + return hpu +} + +// ClearCmd clears the value of the "cmd" field. +func (hpu *HostProcessUpdate) ClearCmd() *HostProcessUpdate { + hpu.mutation.ClearCmd() + return hpu +} + +// SetEnv sets the "env" field. +func (hpu *HostProcessUpdate) SetEnv(s string) *HostProcessUpdate { + hpu.mutation.SetEnv(s) + return hpu +} + +// SetNillableEnv sets the "env" field if the given value is not nil. +func (hpu *HostProcessUpdate) SetNillableEnv(s *string) *HostProcessUpdate { + if s != nil { + hpu.SetEnv(*s) + } + return hpu +} + +// ClearEnv clears the value of the "env" field. +func (hpu *HostProcessUpdate) ClearEnv() *HostProcessUpdate { + hpu.mutation.ClearEnv() + return hpu +} + +// SetCwd sets the "cwd" field. +func (hpu *HostProcessUpdate) SetCwd(s string) *HostProcessUpdate { + hpu.mutation.SetCwd(s) + return hpu +} + +// SetNillableCwd sets the "cwd" field if the given value is not nil. +func (hpu *HostProcessUpdate) SetNillableCwd(s *string) *HostProcessUpdate { + if s != nil { + hpu.SetCwd(*s) + } + return hpu +} + +// ClearCwd clears the value of the "cwd" field. +func (hpu *HostProcessUpdate) ClearCwd() *HostProcessUpdate { + hpu.mutation.ClearCwd() + return hpu +} + +// SetStatus sets the "status" field. +func (hpu *HostProcessUpdate) SetStatus(cs c2pb.Process_Status) *HostProcessUpdate { + hpu.mutation.SetStatus(cs) + return hpu +} + +// SetHostID sets the "host" edge to the Host entity by ID. +func (hpu *HostProcessUpdate) SetHostID(id int) *HostProcessUpdate { + hpu.mutation.SetHostID(id) + return hpu +} + +// SetHost sets the "host" edge to the Host entity. +func (hpu *HostProcessUpdate) SetHost(h *Host) *HostProcessUpdate { + return hpu.SetHostID(h.ID) +} + +// SetTaskID sets the "task" edge to the Task entity by ID. +func (hpu *HostProcessUpdate) SetTaskID(id int) *HostProcessUpdate { + hpu.mutation.SetTaskID(id) + return hpu +} + +// SetTask sets the "task" edge to the Task entity. +func (hpu *HostProcessUpdate) SetTask(t *Task) *HostProcessUpdate { + return hpu.SetTaskID(t.ID) +} + +// Mutation returns the HostProcessMutation object of the builder. +func (hpu *HostProcessUpdate) Mutation() *HostProcessMutation { + return hpu.mutation +} + +// ClearHost clears the "host" edge to the Host entity. +func (hpu *HostProcessUpdate) ClearHost() *HostProcessUpdate { + hpu.mutation.ClearHost() + return hpu +} + +// ClearTask clears the "task" edge to the Task entity. +func (hpu *HostProcessUpdate) ClearTask() *HostProcessUpdate { + hpu.mutation.ClearTask() + return hpu +} + +// Save executes the query and returns the number of nodes affected by the update operation. +func (hpu *HostProcessUpdate) Save(ctx context.Context) (int, error) { + hpu.defaults() + return withHooks(ctx, hpu.sqlSave, hpu.mutation, hpu.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (hpu *HostProcessUpdate) SaveX(ctx context.Context) int { + affected, err := hpu.Save(ctx) + if err != nil { + panic(err) + } + return affected +} + +// Exec executes the query. +func (hpu *HostProcessUpdate) Exec(ctx context.Context) error { + _, err := hpu.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (hpu *HostProcessUpdate) ExecX(ctx context.Context) { + if err := hpu.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (hpu *HostProcessUpdate) defaults() { + if _, ok := hpu.mutation.LastModifiedAt(); !ok { + v := hostprocess.UpdateDefaultLastModifiedAt() + hpu.mutation.SetLastModifiedAt(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (hpu *HostProcessUpdate) check() error { + if v, ok := hpu.mutation.Principal(); ok { + if err := hostprocess.PrincipalValidator(v); err != nil { + return &ValidationError{Name: "principal", err: fmt.Errorf(`ent: validator failed for field "HostProcess.principal": %w`, err)} + } + } + if v, ok := hpu.mutation.Status(); ok { + if err := hostprocess.StatusValidator(v); err != nil { + return &ValidationError{Name: "status", err: fmt.Errorf(`ent: validator failed for field "HostProcess.status": %w`, err)} + } + } + if _, ok := hpu.mutation.HostID(); hpu.mutation.HostCleared() && !ok { + return errors.New(`ent: clearing a required unique edge "HostProcess.host"`) + } + if _, ok := hpu.mutation.TaskID(); hpu.mutation.TaskCleared() && !ok { + return errors.New(`ent: clearing a required unique edge "HostProcess.task"`) + } + return nil +} + +func (hpu *HostProcessUpdate) sqlSave(ctx context.Context) (n int, err error) { + if err := hpu.check(); err != nil { + return n, err + } + _spec := sqlgraph.NewUpdateSpec(hostprocess.Table, hostprocess.Columns, sqlgraph.NewFieldSpec(hostprocess.FieldID, field.TypeInt)) + if ps := hpu.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := hpu.mutation.LastModifiedAt(); ok { + _spec.SetField(hostprocess.FieldLastModifiedAt, field.TypeTime, value) + } + if value, ok := hpu.mutation.Pid(); ok { + _spec.SetField(hostprocess.FieldPid, field.TypeUint64, value) + } + if value, ok := hpu.mutation.AddedPid(); ok { + _spec.AddField(hostprocess.FieldPid, field.TypeUint64, value) + } + if value, ok := hpu.mutation.Ppid(); ok { + _spec.SetField(hostprocess.FieldPpid, field.TypeUint64, value) + } + if value, ok := hpu.mutation.AddedPpid(); ok { + _spec.AddField(hostprocess.FieldPpid, field.TypeUint64, value) + } + if value, ok := hpu.mutation.Name(); ok { + _spec.SetField(hostprocess.FieldName, field.TypeString, value) + } + if value, ok := hpu.mutation.Principal(); ok { + _spec.SetField(hostprocess.FieldPrincipal, field.TypeString, value) + } + if value, ok := hpu.mutation.Path(); ok { + _spec.SetField(hostprocess.FieldPath, field.TypeString, value) + } + if hpu.mutation.PathCleared() { + _spec.ClearField(hostprocess.FieldPath, field.TypeString) + } + if value, ok := hpu.mutation.Cmd(); ok { + _spec.SetField(hostprocess.FieldCmd, field.TypeString, value) + } + if hpu.mutation.CmdCleared() { + _spec.ClearField(hostprocess.FieldCmd, field.TypeString) + } + if value, ok := hpu.mutation.Env(); ok { + _spec.SetField(hostprocess.FieldEnv, field.TypeString, value) + } + if hpu.mutation.EnvCleared() { + _spec.ClearField(hostprocess.FieldEnv, field.TypeString) + } + if value, ok := hpu.mutation.Cwd(); ok { + _spec.SetField(hostprocess.FieldCwd, field.TypeString, value) + } + if hpu.mutation.CwdCleared() { + _spec.ClearField(hostprocess.FieldCwd, field.TypeString) + } + if value, ok := hpu.mutation.Status(); ok { + _spec.SetField(hostprocess.FieldStatus, field.TypeEnum, value) + } + if hpu.mutation.HostCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: hostprocess.HostTable, + Columns: []string{hostprocess.HostColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(host.FieldID, field.TypeInt), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := hpu.mutation.HostIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: hostprocess.HostTable, + Columns: []string{hostprocess.HostColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(host.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if hpu.mutation.TaskCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: hostprocess.TaskTable, + Columns: []string{hostprocess.TaskColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(task.FieldID, field.TypeInt), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := hpu.mutation.TaskIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: hostprocess.TaskTable, + Columns: []string{hostprocess.TaskColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(task.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if n, err = sqlgraph.UpdateNodes(ctx, hpu.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{hostprocess.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return 0, err + } + hpu.mutation.done = true + return n, nil +} + +// HostProcessUpdateOne is the builder for updating a single HostProcess entity. +type HostProcessUpdateOne struct { + config + fields []string + hooks []Hook + mutation *HostProcessMutation +} + +// SetLastModifiedAt sets the "last_modified_at" field. +func (hpuo *HostProcessUpdateOne) SetLastModifiedAt(t time.Time) *HostProcessUpdateOne { + hpuo.mutation.SetLastModifiedAt(t) + return hpuo +} + +// SetPid sets the "pid" field. +func (hpuo *HostProcessUpdateOne) SetPid(u uint64) *HostProcessUpdateOne { + hpuo.mutation.ResetPid() + hpuo.mutation.SetPid(u) + return hpuo +} + +// AddPid adds u to the "pid" field. +func (hpuo *HostProcessUpdateOne) AddPid(u int64) *HostProcessUpdateOne { + hpuo.mutation.AddPid(u) + return hpuo +} + +// SetPpid sets the "ppid" field. +func (hpuo *HostProcessUpdateOne) SetPpid(u uint64) *HostProcessUpdateOne { + hpuo.mutation.ResetPpid() + hpuo.mutation.SetPpid(u) + return hpuo +} + +// AddPpid adds u to the "ppid" field. +func (hpuo *HostProcessUpdateOne) AddPpid(u int64) *HostProcessUpdateOne { + hpuo.mutation.AddPpid(u) + return hpuo +} + +// SetName sets the "name" field. +func (hpuo *HostProcessUpdateOne) SetName(s string) *HostProcessUpdateOne { + hpuo.mutation.SetName(s) + return hpuo +} + +// SetPrincipal sets the "principal" field. +func (hpuo *HostProcessUpdateOne) SetPrincipal(s string) *HostProcessUpdateOne { + hpuo.mutation.SetPrincipal(s) + return hpuo +} + +// SetPath sets the "path" field. +func (hpuo *HostProcessUpdateOne) SetPath(s string) *HostProcessUpdateOne { + hpuo.mutation.SetPath(s) + return hpuo +} + +// SetNillablePath sets the "path" field if the given value is not nil. +func (hpuo *HostProcessUpdateOne) SetNillablePath(s *string) *HostProcessUpdateOne { + if s != nil { + hpuo.SetPath(*s) + } + return hpuo +} + +// ClearPath clears the value of the "path" field. +func (hpuo *HostProcessUpdateOne) ClearPath() *HostProcessUpdateOne { + hpuo.mutation.ClearPath() + return hpuo +} + +// SetCmd sets the "cmd" field. +func (hpuo *HostProcessUpdateOne) SetCmd(s string) *HostProcessUpdateOne { + hpuo.mutation.SetCmd(s) + return hpuo +} + +// SetNillableCmd sets the "cmd" field if the given value is not nil. +func (hpuo *HostProcessUpdateOne) SetNillableCmd(s *string) *HostProcessUpdateOne { + if s != nil { + hpuo.SetCmd(*s) + } + return hpuo +} + +// ClearCmd clears the value of the "cmd" field. +func (hpuo *HostProcessUpdateOne) ClearCmd() *HostProcessUpdateOne { + hpuo.mutation.ClearCmd() + return hpuo +} + +// SetEnv sets the "env" field. +func (hpuo *HostProcessUpdateOne) SetEnv(s string) *HostProcessUpdateOne { + hpuo.mutation.SetEnv(s) + return hpuo +} + +// SetNillableEnv sets the "env" field if the given value is not nil. +func (hpuo *HostProcessUpdateOne) SetNillableEnv(s *string) *HostProcessUpdateOne { + if s != nil { + hpuo.SetEnv(*s) + } + return hpuo +} + +// ClearEnv clears the value of the "env" field. +func (hpuo *HostProcessUpdateOne) ClearEnv() *HostProcessUpdateOne { + hpuo.mutation.ClearEnv() + return hpuo +} + +// SetCwd sets the "cwd" field. +func (hpuo *HostProcessUpdateOne) SetCwd(s string) *HostProcessUpdateOne { + hpuo.mutation.SetCwd(s) + return hpuo +} + +// SetNillableCwd sets the "cwd" field if the given value is not nil. +func (hpuo *HostProcessUpdateOne) SetNillableCwd(s *string) *HostProcessUpdateOne { + if s != nil { + hpuo.SetCwd(*s) + } + return hpuo +} + +// ClearCwd clears the value of the "cwd" field. +func (hpuo *HostProcessUpdateOne) ClearCwd() *HostProcessUpdateOne { + hpuo.mutation.ClearCwd() + return hpuo +} + +// SetStatus sets the "status" field. +func (hpuo *HostProcessUpdateOne) SetStatus(cs c2pb.Process_Status) *HostProcessUpdateOne { + hpuo.mutation.SetStatus(cs) + return hpuo +} + +// SetHostID sets the "host" edge to the Host entity by ID. +func (hpuo *HostProcessUpdateOne) SetHostID(id int) *HostProcessUpdateOne { + hpuo.mutation.SetHostID(id) + return hpuo +} + +// SetHost sets the "host" edge to the Host entity. +func (hpuo *HostProcessUpdateOne) SetHost(h *Host) *HostProcessUpdateOne { + return hpuo.SetHostID(h.ID) +} + +// SetTaskID sets the "task" edge to the Task entity by ID. +func (hpuo *HostProcessUpdateOne) SetTaskID(id int) *HostProcessUpdateOne { + hpuo.mutation.SetTaskID(id) + return hpuo +} + +// SetTask sets the "task" edge to the Task entity. +func (hpuo *HostProcessUpdateOne) SetTask(t *Task) *HostProcessUpdateOne { + return hpuo.SetTaskID(t.ID) +} + +// Mutation returns the HostProcessMutation object of the builder. +func (hpuo *HostProcessUpdateOne) Mutation() *HostProcessMutation { + return hpuo.mutation +} + +// ClearHost clears the "host" edge to the Host entity. +func (hpuo *HostProcessUpdateOne) ClearHost() *HostProcessUpdateOne { + hpuo.mutation.ClearHost() + return hpuo +} + +// ClearTask clears the "task" edge to the Task entity. +func (hpuo *HostProcessUpdateOne) ClearTask() *HostProcessUpdateOne { + hpuo.mutation.ClearTask() + return hpuo +} + +// Where appends a list predicates to the HostProcessUpdate builder. +func (hpuo *HostProcessUpdateOne) Where(ps ...predicate.HostProcess) *HostProcessUpdateOne { + hpuo.mutation.Where(ps...) + return hpuo +} + +// Select allows selecting one or more fields (columns) of the returned entity. +// The default is selecting all fields defined in the entity schema. +func (hpuo *HostProcessUpdateOne) Select(field string, fields ...string) *HostProcessUpdateOne { + hpuo.fields = append([]string{field}, fields...) + return hpuo +} + +// Save executes the query and returns the updated HostProcess entity. +func (hpuo *HostProcessUpdateOne) Save(ctx context.Context) (*HostProcess, error) { + hpuo.defaults() + return withHooks(ctx, hpuo.sqlSave, hpuo.mutation, hpuo.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (hpuo *HostProcessUpdateOne) SaveX(ctx context.Context) *HostProcess { + node, err := hpuo.Save(ctx) + if err != nil { + panic(err) + } + return node +} + +// Exec executes the query on the entity. +func (hpuo *HostProcessUpdateOne) Exec(ctx context.Context) error { + _, err := hpuo.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (hpuo *HostProcessUpdateOne) ExecX(ctx context.Context) { + if err := hpuo.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (hpuo *HostProcessUpdateOne) defaults() { + if _, ok := hpuo.mutation.LastModifiedAt(); !ok { + v := hostprocess.UpdateDefaultLastModifiedAt() + hpuo.mutation.SetLastModifiedAt(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (hpuo *HostProcessUpdateOne) check() error { + if v, ok := hpuo.mutation.Principal(); ok { + if err := hostprocess.PrincipalValidator(v); err != nil { + return &ValidationError{Name: "principal", err: fmt.Errorf(`ent: validator failed for field "HostProcess.principal": %w`, err)} + } + } + if v, ok := hpuo.mutation.Status(); ok { + if err := hostprocess.StatusValidator(v); err != nil { + return &ValidationError{Name: "status", err: fmt.Errorf(`ent: validator failed for field "HostProcess.status": %w`, err)} + } + } + if _, ok := hpuo.mutation.HostID(); hpuo.mutation.HostCleared() && !ok { + return errors.New(`ent: clearing a required unique edge "HostProcess.host"`) + } + if _, ok := hpuo.mutation.TaskID(); hpuo.mutation.TaskCleared() && !ok { + return errors.New(`ent: clearing a required unique edge "HostProcess.task"`) + } + return nil +} + +func (hpuo *HostProcessUpdateOne) sqlSave(ctx context.Context) (_node *HostProcess, err error) { + if err := hpuo.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(hostprocess.Table, hostprocess.Columns, sqlgraph.NewFieldSpec(hostprocess.FieldID, field.TypeInt)) + id, ok := hpuo.mutation.ID() + if !ok { + return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "HostProcess.id" for update`)} + } + _spec.Node.ID.Value = id + if fields := hpuo.fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, hostprocess.FieldID) + for _, f := range fields { + if !hostprocess.ValidColumn(f) { + return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + if f != hostprocess.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, f) + } + } + } + if ps := hpuo.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := hpuo.mutation.LastModifiedAt(); ok { + _spec.SetField(hostprocess.FieldLastModifiedAt, field.TypeTime, value) + } + if value, ok := hpuo.mutation.Pid(); ok { + _spec.SetField(hostprocess.FieldPid, field.TypeUint64, value) + } + if value, ok := hpuo.mutation.AddedPid(); ok { + _spec.AddField(hostprocess.FieldPid, field.TypeUint64, value) + } + if value, ok := hpuo.mutation.Ppid(); ok { + _spec.SetField(hostprocess.FieldPpid, field.TypeUint64, value) + } + if value, ok := hpuo.mutation.AddedPpid(); ok { + _spec.AddField(hostprocess.FieldPpid, field.TypeUint64, value) + } + if value, ok := hpuo.mutation.Name(); ok { + _spec.SetField(hostprocess.FieldName, field.TypeString, value) + } + if value, ok := hpuo.mutation.Principal(); ok { + _spec.SetField(hostprocess.FieldPrincipal, field.TypeString, value) + } + if value, ok := hpuo.mutation.Path(); ok { + _spec.SetField(hostprocess.FieldPath, field.TypeString, value) + } + if hpuo.mutation.PathCleared() { + _spec.ClearField(hostprocess.FieldPath, field.TypeString) + } + if value, ok := hpuo.mutation.Cmd(); ok { + _spec.SetField(hostprocess.FieldCmd, field.TypeString, value) + } + if hpuo.mutation.CmdCleared() { + _spec.ClearField(hostprocess.FieldCmd, field.TypeString) + } + if value, ok := hpuo.mutation.Env(); ok { + _spec.SetField(hostprocess.FieldEnv, field.TypeString, value) + } + if hpuo.mutation.EnvCleared() { + _spec.ClearField(hostprocess.FieldEnv, field.TypeString) + } + if value, ok := hpuo.mutation.Cwd(); ok { + _spec.SetField(hostprocess.FieldCwd, field.TypeString, value) + } + if hpuo.mutation.CwdCleared() { + _spec.ClearField(hostprocess.FieldCwd, field.TypeString) + } + if value, ok := hpuo.mutation.Status(); ok { + _spec.SetField(hostprocess.FieldStatus, field.TypeEnum, value) + } + if hpuo.mutation.HostCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: hostprocess.HostTable, + Columns: []string{hostprocess.HostColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(host.FieldID, field.TypeInt), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := hpuo.mutation.HostIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: hostprocess.HostTable, + Columns: []string{hostprocess.HostColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(host.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if hpuo.mutation.TaskCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: hostprocess.TaskTable, + Columns: []string{hostprocess.TaskColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(task.FieldID, field.TypeInt), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := hpuo.mutation.TaskIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: hostprocess.TaskTable, + Columns: []string{hostprocess.TaskColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(task.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + _node = &HostProcess{config: hpuo.config} + _spec.Assign = _node.assignValues + _spec.ScanValues = _node.scanValues + if err = sqlgraph.UpdateNode(ctx, hpuo.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{hostprocess.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + hpuo.mutation.done = true + return _node, nil +} diff --git a/tavern/internal/ent/migrate/schema.go b/tavern/internal/ent/migrate/schema.go index 908e9b143..2134af139 100644 --- a/tavern/internal/ent/migrate/schema.go +++ b/tavern/internal/ent/migrate/schema.go @@ -59,7 +59,7 @@ var ( {Name: "identifier", Type: field.TypeString, Unique: true}, {Name: "name", Type: field.TypeString, Nullable: true}, {Name: "primary_ip", Type: field.TypeString, Nullable: true}, - {Name: "platform", Type: field.TypeEnum, Enums: []string{"Windows", "Linux", "MacOS", "BSD", "Unknown"}, Default: "Unknown"}, + {Name: "platform", Type: field.TypeEnum, Enums: []string{"PLATFORM_BSD", "PLATFORM_UNSPECIFIED", "PLATFORM_WINDOWS", "PLATFORM_LINUX", "PLATFORM_MACOS"}}, {Name: "last_seen_at", Type: field.TypeTime, Nullable: true}, } // HostsTable holds the schema information for the "hosts" table. @@ -68,39 +68,87 @@ var ( Columns: HostsColumns, PrimaryKey: []*schema.Column{HostsColumns[0]}, } - // ProcessesColumns holds the columns for the "processes" table. - ProcessesColumns = []*schema.Column{ + // HostFilesColumns holds the columns for the "host_files" table. + HostFilesColumns = []*schema.Column{ + {Name: "id", Type: field.TypeInt, Increment: true}, + {Name: "created_at", Type: field.TypeTime}, + {Name: "last_modified_at", Type: field.TypeTime}, + {Name: "path", Type: field.TypeString}, + {Name: "owner", Type: field.TypeString, Nullable: true}, + {Name: "group", Type: field.TypeString, Nullable: true}, + {Name: "permissions", Type: field.TypeString, Nullable: true}, + {Name: "size", Type: field.TypeInt, Default: 0}, + {Name: "hash", Type: field.TypeString, Nullable: true, Size: 100}, + {Name: "content", Type: field.TypeBytes, Nullable: true}, + {Name: "host_files", Type: field.TypeInt, Nullable: true}, + {Name: "host_file_host", Type: field.TypeInt}, + {Name: "task_reported_files", Type: field.TypeInt}, + } + // HostFilesTable holds the schema information for the "host_files" table. + HostFilesTable = &schema.Table{ + Name: "host_files", + Columns: HostFilesColumns, + PrimaryKey: []*schema.Column{HostFilesColumns[0]}, + ForeignKeys: []*schema.ForeignKey{ + { + Symbol: "host_files_hosts_files", + Columns: []*schema.Column{HostFilesColumns[10]}, + RefColumns: []*schema.Column{HostsColumns[0]}, + OnDelete: schema.SetNull, + }, + { + Symbol: "host_files_hosts_host", + Columns: []*schema.Column{HostFilesColumns[11]}, + RefColumns: []*schema.Column{HostsColumns[0]}, + OnDelete: schema.NoAction, + }, + { + Symbol: "host_files_tasks_reported_files", + Columns: []*schema.Column{HostFilesColumns[12]}, + RefColumns: []*schema.Column{TasksColumns[0]}, + OnDelete: schema.NoAction, + }, + }, + } + // HostProcessesColumns holds the columns for the "host_processes" table. + HostProcessesColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "created_at", Type: field.TypeTime}, {Name: "last_modified_at", Type: field.TypeTime}, {Name: "pid", Type: field.TypeUint64}, + {Name: "ppid", Type: field.TypeUint64}, {Name: "name", Type: field.TypeString}, {Name: "principal", Type: field.TypeString}, + {Name: "path", Type: field.TypeString, Nullable: true}, + {Name: "cmd", Type: field.TypeString, Nullable: true}, + {Name: "env", Type: field.TypeString, Nullable: true}, + {Name: "cwd", Type: field.TypeString, Nullable: true}, + {Name: "status", Type: field.TypeEnum, Enums: []string{"STATUS_STOP", "STATUS_TRACING", "STATUS_WAKE_KILL", "STATUS_UNKNOWN", "STATUS_IDLE", "STATUS_SLEEP", "STATUS_WAKING", "STATUS_UNSPECIFIED", "STATUS_PARKED", "STATUS_LOCK_BLOCKED", "STATUS_DEAD", "STATUS_ZOMBIE", "STATUS_UNINTERUPTIBLE_DISK_SLEEP", "STATUS_RUN"}}, {Name: "host_processes", Type: field.TypeInt, Nullable: true}, - {Name: "process_host", Type: field.TypeInt}, + {Name: "host_process_host", Type: field.TypeInt}, {Name: "task_reported_processes", Type: field.TypeInt}, } - // ProcessesTable holds the schema information for the "processes" table. - ProcessesTable = &schema.Table{ - Name: "processes", - Columns: ProcessesColumns, - PrimaryKey: []*schema.Column{ProcessesColumns[0]}, + // HostProcessesTable holds the schema information for the "host_processes" table. + HostProcessesTable = &schema.Table{ + Name: "host_processes", + Columns: HostProcessesColumns, + PrimaryKey: []*schema.Column{HostProcessesColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { - Symbol: "processes_hosts_processes", - Columns: []*schema.Column{ProcessesColumns[6]}, + Symbol: "host_processes_hosts_processes", + Columns: []*schema.Column{HostProcessesColumns[12]}, RefColumns: []*schema.Column{HostsColumns[0]}, OnDelete: schema.SetNull, }, { - Symbol: "processes_hosts_host", - Columns: []*schema.Column{ProcessesColumns[7]}, + Symbol: "host_processes_hosts_host", + Columns: []*schema.Column{HostProcessesColumns[13]}, RefColumns: []*schema.Column{HostsColumns[0]}, OnDelete: schema.NoAction, }, { - Symbol: "processes_tasks_reported_processes", - Columns: []*schema.Column{ProcessesColumns[8]}, + Symbol: "host_processes_tasks_reported_processes", + Columns: []*schema.Column{HostProcessesColumns[14]}, RefColumns: []*schema.Column{TasksColumns[0]}, OnDelete: schema.NoAction, }, @@ -289,7 +337,8 @@ var ( BeaconsTable, FilesTable, HostsTable, - ProcessesTable, + HostFilesTable, + HostProcessesTable, QuestsTable, TagsTable, TasksTable, @@ -302,9 +351,12 @@ var ( func init() { BeaconsTable.ForeignKeys[0].RefTable = HostsTable - ProcessesTable.ForeignKeys[0].RefTable = HostsTable - ProcessesTable.ForeignKeys[1].RefTable = HostsTable - ProcessesTable.ForeignKeys[2].RefTable = TasksTable + HostFilesTable.ForeignKeys[0].RefTable = HostsTable + HostFilesTable.ForeignKeys[1].RefTable = HostsTable + HostFilesTable.ForeignKeys[2].RefTable = TasksTable + HostProcessesTable.ForeignKeys[0].RefTable = HostsTable + HostProcessesTable.ForeignKeys[1].RefTable = HostsTable + HostProcessesTable.ForeignKeys[2].RefTable = TasksTable QuestsTable.ForeignKeys[0].RefTable = TomesTable QuestsTable.ForeignKeys[1].RefTable = FilesTable QuestsTable.ForeignKeys[2].RefTable = UsersTable diff --git a/tavern/internal/ent/mutation.go b/tavern/internal/ent/mutation.go index 7357e752d..fbd262586 100644 --- a/tavern/internal/ent/mutation.go +++ b/tavern/internal/ent/mutation.go @@ -11,11 +11,13 @@ import ( "entgo.io/ent" "entgo.io/ent/dialect/sql" + "realm.pub/tavern/internal/c2/c2pb" "realm.pub/tavern/internal/ent/beacon" "realm.pub/tavern/internal/ent/file" "realm.pub/tavern/internal/ent/host" + "realm.pub/tavern/internal/ent/hostfile" + "realm.pub/tavern/internal/ent/hostprocess" "realm.pub/tavern/internal/ent/predicate" - "realm.pub/tavern/internal/ent/process" "realm.pub/tavern/internal/ent/quest" "realm.pub/tavern/internal/ent/tag" "realm.pub/tavern/internal/ent/task" @@ -32,15 +34,16 @@ const ( OpUpdateOne = ent.OpUpdateOne // Node types. - TypeBeacon = "Beacon" - TypeFile = "File" - TypeHost = "Host" - TypeProcess = "Process" - TypeQuest = "Quest" - TypeTag = "Tag" - TypeTask = "Task" - TypeTome = "Tome" - TypeUser = "User" + TypeBeacon = "Beacon" + TypeFile = "File" + TypeHost = "Host" + TypeHostFile = "HostFile" + TypeHostProcess = "HostProcess" + TypeQuest = "Quest" + TypeTag = "Tag" + TypeTask = "Task" + TypeTome = "Tome" + TypeUser = "User" ) // BeaconMutation represents an operation that mutates the Beacon nodes in the graph. @@ -1751,7 +1754,7 @@ type HostMutation struct { identifier *string name *string primary_ip *string - platform *host.Platform + platform *c2pb.Host_Platform last_seen_at *time.Time clearedFields map[string]struct{} tags map[int]struct{} @@ -1760,6 +1763,9 @@ type HostMutation struct { beacons map[int]struct{} removedbeacons map[int]struct{} clearedbeacons bool + files map[int]struct{} + removedfiles map[int]struct{} + clearedfiles bool processes map[int]struct{} removedprocesses map[int]struct{} clearedprocesses bool @@ -2073,12 +2079,12 @@ func (m *HostMutation) ResetPrimaryIP() { } // SetPlatform sets the "platform" field. -func (m *HostMutation) SetPlatform(h host.Platform) { - m.platform = &h +func (m *HostMutation) SetPlatform(cp c2pb.Host_Platform) { + m.platform = &cp } // Platform returns the value of the "platform" field in the mutation. -func (m *HostMutation) Platform() (r host.Platform, exists bool) { +func (m *HostMutation) Platform() (r c2pb.Host_Platform, exists bool) { v := m.platform if v == nil { return @@ -2089,7 +2095,7 @@ func (m *HostMutation) Platform() (r host.Platform, exists bool) { // OldPlatform returns the old "platform" field's value of the Host entity. // If the Host object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *HostMutation) OldPlatform(ctx context.Context) (v host.Platform, err error) { +func (m *HostMutation) OldPlatform(ctx context.Context) (v c2pb.Host_Platform, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldPlatform is only allowed on UpdateOne operations") } @@ -2265,7 +2271,61 @@ func (m *HostMutation) ResetBeacons() { m.removedbeacons = nil } -// AddProcessIDs adds the "processes" edge to the Process entity by ids. +// AddFileIDs adds the "files" edge to the HostFile entity by ids. +func (m *HostMutation) AddFileIDs(ids ...int) { + if m.files == nil { + m.files = make(map[int]struct{}) + } + for i := range ids { + m.files[ids[i]] = struct{}{} + } +} + +// ClearFiles clears the "files" edge to the HostFile entity. +func (m *HostMutation) ClearFiles() { + m.clearedfiles = true +} + +// FilesCleared reports if the "files" edge to the HostFile entity was cleared. +func (m *HostMutation) FilesCleared() bool { + return m.clearedfiles +} + +// RemoveFileIDs removes the "files" edge to the HostFile entity by IDs. +func (m *HostMutation) RemoveFileIDs(ids ...int) { + if m.removedfiles == nil { + m.removedfiles = make(map[int]struct{}) + } + for i := range ids { + delete(m.files, ids[i]) + m.removedfiles[ids[i]] = struct{}{} + } +} + +// RemovedFiles returns the removed IDs of the "files" edge to the HostFile entity. +func (m *HostMutation) RemovedFilesIDs() (ids []int) { + for id := range m.removedfiles { + ids = append(ids, id) + } + return +} + +// FilesIDs returns the "files" edge IDs in the mutation. +func (m *HostMutation) FilesIDs() (ids []int) { + for id := range m.files { + ids = append(ids, id) + } + return +} + +// ResetFiles resets all changes to the "files" edge. +func (m *HostMutation) ResetFiles() { + m.files = nil + m.clearedfiles = false + m.removedfiles = nil +} + +// AddProcessIDs adds the "processes" edge to the HostProcess entity by ids. func (m *HostMutation) AddProcessIDs(ids ...int) { if m.processes == nil { m.processes = make(map[int]struct{}) @@ -2275,17 +2335,17 @@ func (m *HostMutation) AddProcessIDs(ids ...int) { } } -// ClearProcesses clears the "processes" edge to the Process entity. +// ClearProcesses clears the "processes" edge to the HostProcess entity. func (m *HostMutation) ClearProcesses() { m.clearedprocesses = true } -// ProcessesCleared reports if the "processes" edge to the Process entity was cleared. +// ProcessesCleared reports if the "processes" edge to the HostProcess entity was cleared. func (m *HostMutation) ProcessesCleared() bool { return m.clearedprocesses } -// RemoveProcessIDs removes the "processes" edge to the Process entity by IDs. +// RemoveProcessIDs removes the "processes" edge to the HostProcess entity by IDs. func (m *HostMutation) RemoveProcessIDs(ids ...int) { if m.removedprocesses == nil { m.removedprocesses = make(map[int]struct{}) @@ -2296,7 +2356,7 @@ func (m *HostMutation) RemoveProcessIDs(ids ...int) { } } -// RemovedProcesses returns the removed IDs of the "processes" edge to the Process entity. +// RemovedProcesses returns the removed IDs of the "processes" edge to the HostProcess entity. func (m *HostMutation) RemovedProcessesIDs() (ids []int) { for id := range m.removedprocesses { ids = append(ids, id) @@ -2465,7 +2525,7 @@ func (m *HostMutation) SetField(name string, value ent.Value) error { m.SetPrimaryIP(v) return nil case host.FieldPlatform: - v, ok := value.(host.Platform) + v, ok := value.(c2pb.Host_Platform) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } @@ -2575,13 +2635,16 @@ func (m *HostMutation) ResetField(name string) error { // AddedEdges returns all edge names that were set/added in this mutation. func (m *HostMutation) AddedEdges() []string { - edges := make([]string, 0, 3) + edges := make([]string, 0, 4) if m.tags != nil { edges = append(edges, host.EdgeTags) } if m.beacons != nil { edges = append(edges, host.EdgeBeacons) } + if m.files != nil { + edges = append(edges, host.EdgeFiles) + } if m.processes != nil { edges = append(edges, host.EdgeProcesses) } @@ -2604,6 +2667,12 @@ func (m *HostMutation) AddedIDs(name string) []ent.Value { ids = append(ids, id) } return ids + case host.EdgeFiles: + ids := make([]ent.Value, 0, len(m.files)) + for id := range m.files { + ids = append(ids, id) + } + return ids case host.EdgeProcesses: ids := make([]ent.Value, 0, len(m.processes)) for id := range m.processes { @@ -2616,13 +2685,16 @@ func (m *HostMutation) AddedIDs(name string) []ent.Value { // RemovedEdges returns all edge names that were removed in this mutation. func (m *HostMutation) RemovedEdges() []string { - edges := make([]string, 0, 3) + edges := make([]string, 0, 4) if m.removedtags != nil { edges = append(edges, host.EdgeTags) } if m.removedbeacons != nil { edges = append(edges, host.EdgeBeacons) } + if m.removedfiles != nil { + edges = append(edges, host.EdgeFiles) + } if m.removedprocesses != nil { edges = append(edges, host.EdgeProcesses) } @@ -2645,6 +2717,12 @@ func (m *HostMutation) RemovedIDs(name string) []ent.Value { ids = append(ids, id) } return ids + case host.EdgeFiles: + ids := make([]ent.Value, 0, len(m.removedfiles)) + for id := range m.removedfiles { + ids = append(ids, id) + } + return ids case host.EdgeProcesses: ids := make([]ent.Value, 0, len(m.removedprocesses)) for id := range m.removedprocesses { @@ -2657,13 +2735,16 @@ func (m *HostMutation) RemovedIDs(name string) []ent.Value { // ClearedEdges returns all edge names that were cleared in this mutation. func (m *HostMutation) ClearedEdges() []string { - edges := make([]string, 0, 3) + edges := make([]string, 0, 4) if m.clearedtags { edges = append(edges, host.EdgeTags) } if m.clearedbeacons { edges = append(edges, host.EdgeBeacons) } + if m.clearedfiles { + edges = append(edges, host.EdgeFiles) + } if m.clearedprocesses { edges = append(edges, host.EdgeProcesses) } @@ -2678,6 +2759,8 @@ func (m *HostMutation) EdgeCleared(name string) bool { return m.clearedtags case host.EdgeBeacons: return m.clearedbeacons + case host.EdgeFiles: + return m.clearedfiles case host.EdgeProcesses: return m.clearedprocesses } @@ -2702,15 +2785,1036 @@ func (m *HostMutation) ResetEdge(name string) error { case host.EdgeBeacons: m.ResetBeacons() return nil - case host.EdgeProcesses: - m.ResetProcesses() + case host.EdgeFiles: + m.ResetFiles() + return nil + case host.EdgeProcesses: + m.ResetProcesses() + return nil + } + return fmt.Errorf("unknown Host edge %s", name) +} + +// HostFileMutation represents an operation that mutates the HostFile nodes in the graph. +type HostFileMutation struct { + config + op Op + typ string + id *int + created_at *time.Time + last_modified_at *time.Time + _path *string + owner *string + group *string + permissions *string + size *int + addsize *int + hash *string + content *[]byte + clearedFields map[string]struct{} + host *int + clearedhost bool + task *int + clearedtask bool + done bool + oldValue func(context.Context) (*HostFile, error) + predicates []predicate.HostFile +} + +var _ ent.Mutation = (*HostFileMutation)(nil) + +// hostfileOption allows management of the mutation configuration using functional options. +type hostfileOption func(*HostFileMutation) + +// newHostFileMutation creates new mutation for the HostFile entity. +func newHostFileMutation(c config, op Op, opts ...hostfileOption) *HostFileMutation { + m := &HostFileMutation{ + config: c, + op: op, + typ: TypeHostFile, + clearedFields: make(map[string]struct{}), + } + for _, opt := range opts { + opt(m) + } + return m +} + +// withHostFileID sets the ID field of the mutation. +func withHostFileID(id int) hostfileOption { + return func(m *HostFileMutation) { + var ( + err error + once sync.Once + value *HostFile + ) + m.oldValue = func(ctx context.Context) (*HostFile, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().HostFile.Get(ctx, id) + } + }) + return value, err + } + m.id = &id + } +} + +// withHostFile sets the old HostFile of the mutation. +func withHostFile(node *HostFile) hostfileOption { + return func(m *HostFileMutation) { + m.oldValue = func(context.Context) (*HostFile, error) { + return node, nil + } + m.id = &node.ID + } +} + +// Client returns a new `ent.Client` from the mutation. If the mutation was +// executed in a transaction (ent.Tx), a transactional client is returned. +func (m HostFileMutation) Client() *Client { + client := &Client{config: m.config} + client.init() + return client +} + +// Tx returns an `ent.Tx` for mutations that were executed in transactions; +// it returns an error otherwise. +func (m HostFileMutation) Tx() (*Tx, error) { + if _, ok := m.driver.(*txDriver); !ok { + return nil, errors.New("ent: mutation is not running in a transaction") + } + tx := &Tx{config: m.config} + tx.init() + return tx, nil +} + +// ID returns the ID value in the mutation. Note that the ID is only available +// if it was provided to the builder or after it was returned from the database. +func (m *HostFileMutation) ID() (id int, exists bool) { + if m.id == nil { + return + } + return *m.id, true +} + +// IDs queries the database and returns the entity ids that match the mutation's predicate. +// That means, if the mutation is applied within a transaction with an isolation level such +// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated +// or updated by the mutation. +func (m *HostFileMutation) IDs(ctx context.Context) ([]int, error) { + switch { + case m.op.Is(OpUpdateOne | OpDeleteOne): + id, exists := m.ID() + if exists { + return []int{id}, nil + } + fallthrough + case m.op.Is(OpUpdate | OpDelete): + return m.Client().HostFile.Query().Where(m.predicates...).IDs(ctx) + default: + return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) + } +} + +// SetCreatedAt sets the "created_at" field. +func (m *HostFileMutation) SetCreatedAt(t time.Time) { + m.created_at = &t +} + +// CreatedAt returns the value of the "created_at" field in the mutation. +func (m *HostFileMutation) CreatedAt() (r time.Time, exists bool) { + v := m.created_at + if v == nil { + return + } + return *v, true +} + +// OldCreatedAt returns the old "created_at" field's value of the HostFile entity. +// If the HostFile object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *HostFileMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCreatedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err) + } + return oldValue.CreatedAt, nil +} + +// ResetCreatedAt resets all changes to the "created_at" field. +func (m *HostFileMutation) ResetCreatedAt() { + m.created_at = nil +} + +// SetLastModifiedAt sets the "last_modified_at" field. +func (m *HostFileMutation) SetLastModifiedAt(t time.Time) { + m.last_modified_at = &t +} + +// LastModifiedAt returns the value of the "last_modified_at" field in the mutation. +func (m *HostFileMutation) LastModifiedAt() (r time.Time, exists bool) { + v := m.last_modified_at + if v == nil { + return + } + return *v, true +} + +// OldLastModifiedAt returns the old "last_modified_at" field's value of the HostFile entity. +// If the HostFile object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *HostFileMutation) OldLastModifiedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldLastModifiedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldLastModifiedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldLastModifiedAt: %w", err) + } + return oldValue.LastModifiedAt, nil +} + +// ResetLastModifiedAt resets all changes to the "last_modified_at" field. +func (m *HostFileMutation) ResetLastModifiedAt() { + m.last_modified_at = nil +} + +// SetPath sets the "path" field. +func (m *HostFileMutation) SetPath(s string) { + m._path = &s +} + +// Path returns the value of the "path" field in the mutation. +func (m *HostFileMutation) Path() (r string, exists bool) { + v := m._path + if v == nil { + return + } + return *v, true +} + +// OldPath returns the old "path" field's value of the HostFile entity. +// If the HostFile object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *HostFileMutation) OldPath(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldPath is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldPath requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldPath: %w", err) + } + return oldValue.Path, nil +} + +// ResetPath resets all changes to the "path" field. +func (m *HostFileMutation) ResetPath() { + m._path = nil +} + +// SetOwner sets the "owner" field. +func (m *HostFileMutation) SetOwner(s string) { + m.owner = &s +} + +// Owner returns the value of the "owner" field in the mutation. +func (m *HostFileMutation) Owner() (r string, exists bool) { + v := m.owner + if v == nil { + return + } + return *v, true +} + +// OldOwner returns the old "owner" field's value of the HostFile entity. +// If the HostFile object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *HostFileMutation) OldOwner(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldOwner is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldOwner requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldOwner: %w", err) + } + return oldValue.Owner, nil +} + +// ClearOwner clears the value of the "owner" field. +func (m *HostFileMutation) ClearOwner() { + m.owner = nil + m.clearedFields[hostfile.FieldOwner] = struct{}{} +} + +// OwnerCleared returns if the "owner" field was cleared in this mutation. +func (m *HostFileMutation) OwnerCleared() bool { + _, ok := m.clearedFields[hostfile.FieldOwner] + return ok +} + +// ResetOwner resets all changes to the "owner" field. +func (m *HostFileMutation) ResetOwner() { + m.owner = nil + delete(m.clearedFields, hostfile.FieldOwner) +} + +// SetGroup sets the "group" field. +func (m *HostFileMutation) SetGroup(s string) { + m.group = &s +} + +// Group returns the value of the "group" field in the mutation. +func (m *HostFileMutation) Group() (r string, exists bool) { + v := m.group + if v == nil { + return + } + return *v, true +} + +// OldGroup returns the old "group" field's value of the HostFile entity. +// If the HostFile object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *HostFileMutation) OldGroup(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldGroup is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldGroup requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldGroup: %w", err) + } + return oldValue.Group, nil +} + +// ClearGroup clears the value of the "group" field. +func (m *HostFileMutation) ClearGroup() { + m.group = nil + m.clearedFields[hostfile.FieldGroup] = struct{}{} +} + +// GroupCleared returns if the "group" field was cleared in this mutation. +func (m *HostFileMutation) GroupCleared() bool { + _, ok := m.clearedFields[hostfile.FieldGroup] + return ok +} + +// ResetGroup resets all changes to the "group" field. +func (m *HostFileMutation) ResetGroup() { + m.group = nil + delete(m.clearedFields, hostfile.FieldGroup) +} + +// SetPermissions sets the "permissions" field. +func (m *HostFileMutation) SetPermissions(s string) { + m.permissions = &s +} + +// Permissions returns the value of the "permissions" field in the mutation. +func (m *HostFileMutation) Permissions() (r string, exists bool) { + v := m.permissions + if v == nil { + return + } + return *v, true +} + +// OldPermissions returns the old "permissions" field's value of the HostFile entity. +// If the HostFile object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *HostFileMutation) OldPermissions(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldPermissions is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldPermissions requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldPermissions: %w", err) + } + return oldValue.Permissions, nil +} + +// ClearPermissions clears the value of the "permissions" field. +func (m *HostFileMutation) ClearPermissions() { + m.permissions = nil + m.clearedFields[hostfile.FieldPermissions] = struct{}{} +} + +// PermissionsCleared returns if the "permissions" field was cleared in this mutation. +func (m *HostFileMutation) PermissionsCleared() bool { + _, ok := m.clearedFields[hostfile.FieldPermissions] + return ok +} + +// ResetPermissions resets all changes to the "permissions" field. +func (m *HostFileMutation) ResetPermissions() { + m.permissions = nil + delete(m.clearedFields, hostfile.FieldPermissions) +} + +// SetSize sets the "size" field. +func (m *HostFileMutation) SetSize(i int) { + m.size = &i + m.addsize = nil +} + +// Size returns the value of the "size" field in the mutation. +func (m *HostFileMutation) Size() (r int, exists bool) { + v := m.size + if v == nil { + return + } + return *v, true +} + +// OldSize returns the old "size" field's value of the HostFile entity. +// If the HostFile object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *HostFileMutation) OldSize(ctx context.Context) (v int, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldSize is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldSize requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldSize: %w", err) + } + return oldValue.Size, nil +} + +// AddSize adds i to the "size" field. +func (m *HostFileMutation) AddSize(i int) { + if m.addsize != nil { + *m.addsize += i + } else { + m.addsize = &i + } +} + +// AddedSize returns the value that was added to the "size" field in this mutation. +func (m *HostFileMutation) AddedSize() (r int, exists bool) { + v := m.addsize + if v == nil { + return + } + return *v, true +} + +// ResetSize resets all changes to the "size" field. +func (m *HostFileMutation) ResetSize() { + m.size = nil + m.addsize = nil +} + +// SetHash sets the "hash" field. +func (m *HostFileMutation) SetHash(s string) { + m.hash = &s +} + +// Hash returns the value of the "hash" field in the mutation. +func (m *HostFileMutation) Hash() (r string, exists bool) { + v := m.hash + if v == nil { + return + } + return *v, true +} + +// OldHash returns the old "hash" field's value of the HostFile entity. +// If the HostFile object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *HostFileMutation) OldHash(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldHash is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldHash requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldHash: %w", err) + } + return oldValue.Hash, nil +} + +// ClearHash clears the value of the "hash" field. +func (m *HostFileMutation) ClearHash() { + m.hash = nil + m.clearedFields[hostfile.FieldHash] = struct{}{} +} + +// HashCleared returns if the "hash" field was cleared in this mutation. +func (m *HostFileMutation) HashCleared() bool { + _, ok := m.clearedFields[hostfile.FieldHash] + return ok +} + +// ResetHash resets all changes to the "hash" field. +func (m *HostFileMutation) ResetHash() { + m.hash = nil + delete(m.clearedFields, hostfile.FieldHash) +} + +// SetContent sets the "content" field. +func (m *HostFileMutation) SetContent(b []byte) { + m.content = &b +} + +// Content returns the value of the "content" field in the mutation. +func (m *HostFileMutation) Content() (r []byte, exists bool) { + v := m.content + if v == nil { + return + } + return *v, true +} + +// OldContent returns the old "content" field's value of the HostFile entity. +// If the HostFile object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *HostFileMutation) OldContent(ctx context.Context) (v []byte, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldContent is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldContent requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldContent: %w", err) + } + return oldValue.Content, nil +} + +// ClearContent clears the value of the "content" field. +func (m *HostFileMutation) ClearContent() { + m.content = nil + m.clearedFields[hostfile.FieldContent] = struct{}{} +} + +// ContentCleared returns if the "content" field was cleared in this mutation. +func (m *HostFileMutation) ContentCleared() bool { + _, ok := m.clearedFields[hostfile.FieldContent] + return ok +} + +// ResetContent resets all changes to the "content" field. +func (m *HostFileMutation) ResetContent() { + m.content = nil + delete(m.clearedFields, hostfile.FieldContent) +} + +// SetHostID sets the "host" edge to the Host entity by id. +func (m *HostFileMutation) SetHostID(id int) { + m.host = &id +} + +// ClearHost clears the "host" edge to the Host entity. +func (m *HostFileMutation) ClearHost() { + m.clearedhost = true +} + +// HostCleared reports if the "host" edge to the Host entity was cleared. +func (m *HostFileMutation) HostCleared() bool { + return m.clearedhost +} + +// HostID returns the "host" edge ID in the mutation. +func (m *HostFileMutation) HostID() (id int, exists bool) { + if m.host != nil { + return *m.host, true + } + return +} + +// HostIDs returns the "host" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// HostID instead. It exists only for internal usage by the builders. +func (m *HostFileMutation) HostIDs() (ids []int) { + if id := m.host; id != nil { + ids = append(ids, *id) + } + return +} + +// ResetHost resets all changes to the "host" edge. +func (m *HostFileMutation) ResetHost() { + m.host = nil + m.clearedhost = false +} + +// SetTaskID sets the "task" edge to the Task entity by id. +func (m *HostFileMutation) SetTaskID(id int) { + m.task = &id +} + +// ClearTask clears the "task" edge to the Task entity. +func (m *HostFileMutation) ClearTask() { + m.clearedtask = true +} + +// TaskCleared reports if the "task" edge to the Task entity was cleared. +func (m *HostFileMutation) TaskCleared() bool { + return m.clearedtask +} + +// TaskID returns the "task" edge ID in the mutation. +func (m *HostFileMutation) TaskID() (id int, exists bool) { + if m.task != nil { + return *m.task, true + } + return +} + +// TaskIDs returns the "task" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// TaskID instead. It exists only for internal usage by the builders. +func (m *HostFileMutation) TaskIDs() (ids []int) { + if id := m.task; id != nil { + ids = append(ids, *id) + } + return +} + +// ResetTask resets all changes to the "task" edge. +func (m *HostFileMutation) ResetTask() { + m.task = nil + m.clearedtask = false +} + +// Where appends a list predicates to the HostFileMutation builder. +func (m *HostFileMutation) Where(ps ...predicate.HostFile) { + m.predicates = append(m.predicates, ps...) +} + +// WhereP appends storage-level predicates to the HostFileMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *HostFileMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.HostFile, len(ps)) + for i := range ps { + p[i] = ps[i] + } + m.Where(p...) +} + +// Op returns the operation name. +func (m *HostFileMutation) Op() Op { + return m.op +} + +// SetOp allows setting the mutation operation. +func (m *HostFileMutation) SetOp(op Op) { + m.op = op +} + +// Type returns the node type of this mutation (HostFile). +func (m *HostFileMutation) Type() string { + return m.typ +} + +// Fields returns all fields that were changed during this mutation. Note that in +// order to get all numeric fields that were incremented/decremented, call +// AddedFields(). +func (m *HostFileMutation) Fields() []string { + fields := make([]string, 0, 9) + if m.created_at != nil { + fields = append(fields, hostfile.FieldCreatedAt) + } + if m.last_modified_at != nil { + fields = append(fields, hostfile.FieldLastModifiedAt) + } + if m._path != nil { + fields = append(fields, hostfile.FieldPath) + } + if m.owner != nil { + fields = append(fields, hostfile.FieldOwner) + } + if m.group != nil { + fields = append(fields, hostfile.FieldGroup) + } + if m.permissions != nil { + fields = append(fields, hostfile.FieldPermissions) + } + if m.size != nil { + fields = append(fields, hostfile.FieldSize) + } + if m.hash != nil { + fields = append(fields, hostfile.FieldHash) + } + if m.content != nil { + fields = append(fields, hostfile.FieldContent) + } + return fields +} + +// Field returns the value of a field with the given name. The second boolean +// return value indicates that this field was not set, or was not defined in the +// schema. +func (m *HostFileMutation) Field(name string) (ent.Value, bool) { + switch name { + case hostfile.FieldCreatedAt: + return m.CreatedAt() + case hostfile.FieldLastModifiedAt: + return m.LastModifiedAt() + case hostfile.FieldPath: + return m.Path() + case hostfile.FieldOwner: + return m.Owner() + case hostfile.FieldGroup: + return m.Group() + case hostfile.FieldPermissions: + return m.Permissions() + case hostfile.FieldSize: + return m.Size() + case hostfile.FieldHash: + return m.Hash() + case hostfile.FieldContent: + return m.Content() + } + return nil, false +} + +// OldField returns the old value of the field from the database. An error is +// returned if the mutation operation is not UpdateOne, or the query to the +// database failed. +func (m *HostFileMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case hostfile.FieldCreatedAt: + return m.OldCreatedAt(ctx) + case hostfile.FieldLastModifiedAt: + return m.OldLastModifiedAt(ctx) + case hostfile.FieldPath: + return m.OldPath(ctx) + case hostfile.FieldOwner: + return m.OldOwner(ctx) + case hostfile.FieldGroup: + return m.OldGroup(ctx) + case hostfile.FieldPermissions: + return m.OldPermissions(ctx) + case hostfile.FieldSize: + return m.OldSize(ctx) + case hostfile.FieldHash: + return m.OldHash(ctx) + case hostfile.FieldContent: + return m.OldContent(ctx) + } + return nil, fmt.Errorf("unknown HostFile field %s", name) +} + +// SetField sets the value of a field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *HostFileMutation) SetField(name string, value ent.Value) error { + switch name { + case hostfile.FieldCreatedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCreatedAt(v) + return nil + case hostfile.FieldLastModifiedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetLastModifiedAt(v) + return nil + case hostfile.FieldPath: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetPath(v) + return nil + case hostfile.FieldOwner: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetOwner(v) + return nil + case hostfile.FieldGroup: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetGroup(v) + return nil + case hostfile.FieldPermissions: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetPermissions(v) + return nil + case hostfile.FieldSize: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetSize(v) + return nil + case hostfile.FieldHash: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetHash(v) + return nil + case hostfile.FieldContent: + v, ok := value.([]byte) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetContent(v) + return nil + } + return fmt.Errorf("unknown HostFile field %s", name) +} + +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *HostFileMutation) AddedFields() []string { + var fields []string + if m.addsize != nil { + fields = append(fields, hostfile.FieldSize) + } + return fields +} + +// AddedField returns the numeric value that was incremented/decremented on a field +// with the given name. The second boolean return value indicates that this field +// was not set, or was not defined in the schema. +func (m *HostFileMutation) AddedField(name string) (ent.Value, bool) { + switch name { + case hostfile.FieldSize: + return m.AddedSize() + } + return nil, false +} + +// AddField adds the value to the field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *HostFileMutation) AddField(name string, value ent.Value) error { + switch name { + case hostfile.FieldSize: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddSize(v) + return nil + } + return fmt.Errorf("unknown HostFile numeric field %s", name) +} + +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *HostFileMutation) ClearedFields() []string { + var fields []string + if m.FieldCleared(hostfile.FieldOwner) { + fields = append(fields, hostfile.FieldOwner) + } + if m.FieldCleared(hostfile.FieldGroup) { + fields = append(fields, hostfile.FieldGroup) + } + if m.FieldCleared(hostfile.FieldPermissions) { + fields = append(fields, hostfile.FieldPermissions) + } + if m.FieldCleared(hostfile.FieldHash) { + fields = append(fields, hostfile.FieldHash) + } + if m.FieldCleared(hostfile.FieldContent) { + fields = append(fields, hostfile.FieldContent) + } + return fields +} + +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *HostFileMutation) FieldCleared(name string) bool { + _, ok := m.clearedFields[name] + return ok +} + +// ClearField clears the value of the field with the given name. It returns an +// error if the field is not defined in the schema. +func (m *HostFileMutation) ClearField(name string) error { + switch name { + case hostfile.FieldOwner: + m.ClearOwner() + return nil + case hostfile.FieldGroup: + m.ClearGroup() + return nil + case hostfile.FieldPermissions: + m.ClearPermissions() + return nil + case hostfile.FieldHash: + m.ClearHash() + return nil + case hostfile.FieldContent: + m.ClearContent() + return nil + } + return fmt.Errorf("unknown HostFile nullable field %s", name) +} + +// ResetField resets all changes in the mutation for the field with the given name. +// It returns an error if the field is not defined in the schema. +func (m *HostFileMutation) ResetField(name string) error { + switch name { + case hostfile.FieldCreatedAt: + m.ResetCreatedAt() + return nil + case hostfile.FieldLastModifiedAt: + m.ResetLastModifiedAt() + return nil + case hostfile.FieldPath: + m.ResetPath() + return nil + case hostfile.FieldOwner: + m.ResetOwner() + return nil + case hostfile.FieldGroup: + m.ResetGroup() + return nil + case hostfile.FieldPermissions: + m.ResetPermissions() + return nil + case hostfile.FieldSize: + m.ResetSize() + return nil + case hostfile.FieldHash: + m.ResetHash() + return nil + case hostfile.FieldContent: + m.ResetContent() + return nil + } + return fmt.Errorf("unknown HostFile field %s", name) +} + +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *HostFileMutation) AddedEdges() []string { + edges := make([]string, 0, 2) + if m.host != nil { + edges = append(edges, hostfile.EdgeHost) + } + if m.task != nil { + edges = append(edges, hostfile.EdgeTask) + } + return edges +} + +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *HostFileMutation) AddedIDs(name string) []ent.Value { + switch name { + case hostfile.EdgeHost: + if id := m.host; id != nil { + return []ent.Value{*id} + } + case hostfile.EdgeTask: + if id := m.task; id != nil { + return []ent.Value{*id} + } + } + return nil +} + +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *HostFileMutation) RemovedEdges() []string { + edges := make([]string, 0, 2) + return edges +} + +// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with +// the given name in this mutation. +func (m *HostFileMutation) RemovedIDs(name string) []ent.Value { + return nil +} + +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *HostFileMutation) ClearedEdges() []string { + edges := make([]string, 0, 2) + if m.clearedhost { + edges = append(edges, hostfile.EdgeHost) + } + if m.clearedtask { + edges = append(edges, hostfile.EdgeTask) + } + return edges +} + +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *HostFileMutation) EdgeCleared(name string) bool { + switch name { + case hostfile.EdgeHost: + return m.clearedhost + case hostfile.EdgeTask: + return m.clearedtask + } + return false +} + +// ClearEdge clears the value of the edge with the given name. It returns an error +// if that edge is not defined in the schema. +func (m *HostFileMutation) ClearEdge(name string) error { + switch name { + case hostfile.EdgeHost: + m.ClearHost() + return nil + case hostfile.EdgeTask: + m.ClearTask() + return nil + } + return fmt.Errorf("unknown HostFile unique edge %s", name) +} + +// ResetEdge resets all changes to the edge with the given name in this mutation. +// It returns an error if the edge is not defined in the schema. +func (m *HostFileMutation) ResetEdge(name string) error { + switch name { + case hostfile.EdgeHost: + m.ResetHost() + return nil + case hostfile.EdgeTask: + m.ResetTask() return nil } - return fmt.Errorf("unknown Host edge %s", name) + return fmt.Errorf("unknown HostFile edge %s", name) } -// ProcessMutation represents an operation that mutates the Process nodes in the graph. -type ProcessMutation struct { +// HostProcessMutation represents an operation that mutates the HostProcess nodes in the graph. +type HostProcessMutation struct { config op Op typ string @@ -2719,29 +3823,36 @@ type ProcessMutation struct { last_modified_at *time.Time pid *uint64 addpid *int64 + ppid *uint64 + addppid *int64 name *string principal *string + _path *string + cmd *string + env *string + cwd *string + status *c2pb.Process_Status clearedFields map[string]struct{} host *int clearedhost bool task *int clearedtask bool done bool - oldValue func(context.Context) (*Process, error) - predicates []predicate.Process + oldValue func(context.Context) (*HostProcess, error) + predicates []predicate.HostProcess } -var _ ent.Mutation = (*ProcessMutation)(nil) +var _ ent.Mutation = (*HostProcessMutation)(nil) -// processOption allows management of the mutation configuration using functional options. -type processOption func(*ProcessMutation) +// hostprocessOption allows management of the mutation configuration using functional options. +type hostprocessOption func(*HostProcessMutation) -// newProcessMutation creates new mutation for the Process entity. -func newProcessMutation(c config, op Op, opts ...processOption) *ProcessMutation { - m := &ProcessMutation{ +// newHostProcessMutation creates new mutation for the HostProcess entity. +func newHostProcessMutation(c config, op Op, opts ...hostprocessOption) *HostProcessMutation { + m := &HostProcessMutation{ config: c, op: op, - typ: TypeProcess, + typ: TypeHostProcess, clearedFields: make(map[string]struct{}), } for _, opt := range opts { @@ -2750,20 +3861,20 @@ func newProcessMutation(c config, op Op, opts ...processOption) *ProcessMutation return m } -// withProcessID sets the ID field of the mutation. -func withProcessID(id int) processOption { - return func(m *ProcessMutation) { +// withHostProcessID sets the ID field of the mutation. +func withHostProcessID(id int) hostprocessOption { + return func(m *HostProcessMutation) { var ( err error once sync.Once - value *Process + value *HostProcess ) - m.oldValue = func(ctx context.Context) (*Process, error) { + m.oldValue = func(ctx context.Context) (*HostProcess, error) { once.Do(func() { if m.done { err = errors.New("querying old values post mutation is not allowed") } else { - value, err = m.Client().Process.Get(ctx, id) + value, err = m.Client().HostProcess.Get(ctx, id) } }) return value, err @@ -2772,10 +3883,10 @@ func withProcessID(id int) processOption { } } -// withProcess sets the old Process of the mutation. -func withProcess(node *Process) processOption { - return func(m *ProcessMutation) { - m.oldValue = func(context.Context) (*Process, error) { +// withHostProcess sets the old HostProcess of the mutation. +func withHostProcess(node *HostProcess) hostprocessOption { + return func(m *HostProcessMutation) { + m.oldValue = func(context.Context) (*HostProcess, error) { return node, nil } m.id = &node.ID @@ -2784,7 +3895,7 @@ func withProcess(node *Process) processOption { // Client returns a new `ent.Client` from the mutation. If the mutation was // executed in a transaction (ent.Tx), a transactional client is returned. -func (m ProcessMutation) Client() *Client { +func (m HostProcessMutation) Client() *Client { client := &Client{config: m.config} client.init() return client @@ -2792,7 +3903,7 @@ func (m ProcessMutation) Client() *Client { // Tx returns an `ent.Tx` for mutations that were executed in transactions; // it returns an error otherwise. -func (m ProcessMutation) Tx() (*Tx, error) { +func (m HostProcessMutation) Tx() (*Tx, error) { if _, ok := m.driver.(*txDriver); !ok { return nil, errors.New("ent: mutation is not running in a transaction") } @@ -2803,7 +3914,7 @@ func (m ProcessMutation) Tx() (*Tx, error) { // ID returns the ID value in the mutation. Note that the ID is only available // if it was provided to the builder or after it was returned from the database. -func (m *ProcessMutation) ID() (id int, exists bool) { +func (m *HostProcessMutation) ID() (id int, exists bool) { if m.id == nil { return } @@ -2814,7 +3925,7 @@ func (m *ProcessMutation) ID() (id int, exists bool) { // That means, if the mutation is applied within a transaction with an isolation level such // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated // or updated by the mutation. -func (m *ProcessMutation) IDs(ctx context.Context) ([]int, error) { +func (m *HostProcessMutation) IDs(ctx context.Context) ([]int, error) { switch { case m.op.Is(OpUpdateOne | OpDeleteOne): id, exists := m.ID() @@ -2823,19 +3934,19 @@ func (m *ProcessMutation) IDs(ctx context.Context) ([]int, error) { } fallthrough case m.op.Is(OpUpdate | OpDelete): - return m.Client().Process.Query().Where(m.predicates...).IDs(ctx) + return m.Client().HostProcess.Query().Where(m.predicates...).IDs(ctx) default: return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) } } // SetCreatedAt sets the "created_at" field. -func (m *ProcessMutation) SetCreatedAt(t time.Time) { +func (m *HostProcessMutation) SetCreatedAt(t time.Time) { m.created_at = &t } // CreatedAt returns the value of the "created_at" field in the mutation. -func (m *ProcessMutation) CreatedAt() (r time.Time, exists bool) { +func (m *HostProcessMutation) CreatedAt() (r time.Time, exists bool) { v := m.created_at if v == nil { return @@ -2843,10 +3954,10 @@ func (m *ProcessMutation) CreatedAt() (r time.Time, exists bool) { return *v, true } -// OldCreatedAt returns the old "created_at" field's value of the Process entity. -// If the Process object wasn't provided to the builder, the object is fetched from the database. +// OldCreatedAt returns the old "created_at" field's value of the HostProcess entity. +// If the HostProcess object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ProcessMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { +func (m *HostProcessMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") } @@ -2861,17 +3972,17 @@ func (m *ProcessMutation) OldCreatedAt(ctx context.Context) (v time.Time, err er } // ResetCreatedAt resets all changes to the "created_at" field. -func (m *ProcessMutation) ResetCreatedAt() { +func (m *HostProcessMutation) ResetCreatedAt() { m.created_at = nil } // SetLastModifiedAt sets the "last_modified_at" field. -func (m *ProcessMutation) SetLastModifiedAt(t time.Time) { +func (m *HostProcessMutation) SetLastModifiedAt(t time.Time) { m.last_modified_at = &t } // LastModifiedAt returns the value of the "last_modified_at" field in the mutation. -func (m *ProcessMutation) LastModifiedAt() (r time.Time, exists bool) { +func (m *HostProcessMutation) LastModifiedAt() (r time.Time, exists bool) { v := m.last_modified_at if v == nil { return @@ -2879,10 +3990,10 @@ func (m *ProcessMutation) LastModifiedAt() (r time.Time, exists bool) { return *v, true } -// OldLastModifiedAt returns the old "last_modified_at" field's value of the Process entity. -// If the Process object wasn't provided to the builder, the object is fetched from the database. +// OldLastModifiedAt returns the old "last_modified_at" field's value of the HostProcess entity. +// If the HostProcess object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ProcessMutation) OldLastModifiedAt(ctx context.Context) (v time.Time, err error) { +func (m *HostProcessMutation) OldLastModifiedAt(ctx context.Context) (v time.Time, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldLastModifiedAt is only allowed on UpdateOne operations") } @@ -2897,18 +4008,18 @@ func (m *ProcessMutation) OldLastModifiedAt(ctx context.Context) (v time.Time, e } // ResetLastModifiedAt resets all changes to the "last_modified_at" field. -func (m *ProcessMutation) ResetLastModifiedAt() { +func (m *HostProcessMutation) ResetLastModifiedAt() { m.last_modified_at = nil } // SetPid sets the "pid" field. -func (m *ProcessMutation) SetPid(u uint64) { +func (m *HostProcessMutation) SetPid(u uint64) { m.pid = &u m.addpid = nil } // Pid returns the value of the "pid" field in the mutation. -func (m *ProcessMutation) Pid() (r uint64, exists bool) { +func (m *HostProcessMutation) Pid() (r uint64, exists bool) { v := m.pid if v == nil { return @@ -2916,10 +4027,10 @@ func (m *ProcessMutation) Pid() (r uint64, exists bool) { return *v, true } -// OldPid returns the old "pid" field's value of the Process entity. -// If the Process object wasn't provided to the builder, the object is fetched from the database. +// OldPid returns the old "pid" field's value of the HostProcess entity. +// If the HostProcess object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ProcessMutation) OldPid(ctx context.Context) (v uint64, err error) { +func (m *HostProcessMutation) OldPid(ctx context.Context) (v uint64, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldPid is only allowed on UpdateOne operations") } @@ -2934,7 +4045,7 @@ func (m *ProcessMutation) OldPid(ctx context.Context) (v uint64, err error) { } // AddPid adds u to the "pid" field. -func (m *ProcessMutation) AddPid(u int64) { +func (m *HostProcessMutation) AddPid(u int64) { if m.addpid != nil { *m.addpid += u } else { @@ -2943,7 +4054,7 @@ func (m *ProcessMutation) AddPid(u int64) { } // AddedPid returns the value that was added to the "pid" field in this mutation. -func (m *ProcessMutation) AddedPid() (r int64, exists bool) { +func (m *HostProcessMutation) AddedPid() (r int64, exists bool) { v := m.addpid if v == nil { return @@ -2952,18 +4063,74 @@ func (m *ProcessMutation) AddedPid() (r int64, exists bool) { } // ResetPid resets all changes to the "pid" field. -func (m *ProcessMutation) ResetPid() { +func (m *HostProcessMutation) ResetPid() { m.pid = nil m.addpid = nil } +// SetPpid sets the "ppid" field. +func (m *HostProcessMutation) SetPpid(u uint64) { + m.ppid = &u + m.addppid = nil +} + +// Ppid returns the value of the "ppid" field in the mutation. +func (m *HostProcessMutation) Ppid() (r uint64, exists bool) { + v := m.ppid + if v == nil { + return + } + return *v, true +} + +// OldPpid returns the old "ppid" field's value of the HostProcess entity. +// If the HostProcess object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *HostProcessMutation) OldPpid(ctx context.Context) (v uint64, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldPpid is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldPpid requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldPpid: %w", err) + } + return oldValue.Ppid, nil +} + +// AddPpid adds u to the "ppid" field. +func (m *HostProcessMutation) AddPpid(u int64) { + if m.addppid != nil { + *m.addppid += u + } else { + m.addppid = &u + } +} + +// AddedPpid returns the value that was added to the "ppid" field in this mutation. +func (m *HostProcessMutation) AddedPpid() (r int64, exists bool) { + v := m.addppid + if v == nil { + return + } + return *v, true +} + +// ResetPpid resets all changes to the "ppid" field. +func (m *HostProcessMutation) ResetPpid() { + m.ppid = nil + m.addppid = nil +} + // SetName sets the "name" field. -func (m *ProcessMutation) SetName(s string) { +func (m *HostProcessMutation) SetName(s string) { m.name = &s } // Name returns the value of the "name" field in the mutation. -func (m *ProcessMutation) Name() (r string, exists bool) { +func (m *HostProcessMutation) Name() (r string, exists bool) { v := m.name if v == nil { return @@ -2971,10 +4138,10 @@ func (m *ProcessMutation) Name() (r string, exists bool) { return *v, true } -// OldName returns the old "name" field's value of the Process entity. -// If the Process object wasn't provided to the builder, the object is fetched from the database. +// OldName returns the old "name" field's value of the HostProcess entity. +// If the HostProcess object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ProcessMutation) OldName(ctx context.Context) (v string, err error) { +func (m *HostProcessMutation) OldName(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldName is only allowed on UpdateOne operations") } @@ -2989,17 +4156,17 @@ func (m *ProcessMutation) OldName(ctx context.Context) (v string, err error) { } // ResetName resets all changes to the "name" field. -func (m *ProcessMutation) ResetName() { +func (m *HostProcessMutation) ResetName() { m.name = nil } // SetPrincipal sets the "principal" field. -func (m *ProcessMutation) SetPrincipal(s string) { +func (m *HostProcessMutation) SetPrincipal(s string) { m.principal = &s } // Principal returns the value of the "principal" field in the mutation. -func (m *ProcessMutation) Principal() (r string, exists bool) { +func (m *HostProcessMutation) Principal() (r string, exists bool) { v := m.principal if v == nil { return @@ -3007,10 +4174,10 @@ func (m *ProcessMutation) Principal() (r string, exists bool) { return *v, true } -// OldPrincipal returns the old "principal" field's value of the Process entity. -// If the Process object wasn't provided to the builder, the object is fetched from the database. +// OldPrincipal returns the old "principal" field's value of the HostProcess entity. +// If the HostProcess object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ProcessMutation) OldPrincipal(ctx context.Context) (v string, err error) { +func (m *HostProcessMutation) OldPrincipal(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldPrincipal is only allowed on UpdateOne operations") } @@ -3025,27 +4192,259 @@ func (m *ProcessMutation) OldPrincipal(ctx context.Context) (v string, err error } // ResetPrincipal resets all changes to the "principal" field. -func (m *ProcessMutation) ResetPrincipal() { +func (m *HostProcessMutation) ResetPrincipal() { m.principal = nil } +// SetPath sets the "path" field. +func (m *HostProcessMutation) SetPath(s string) { + m._path = &s +} + +// Path returns the value of the "path" field in the mutation. +func (m *HostProcessMutation) Path() (r string, exists bool) { + v := m._path + if v == nil { + return + } + return *v, true +} + +// OldPath returns the old "path" field's value of the HostProcess entity. +// If the HostProcess object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *HostProcessMutation) OldPath(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldPath is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldPath requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldPath: %w", err) + } + return oldValue.Path, nil +} + +// ClearPath clears the value of the "path" field. +func (m *HostProcessMutation) ClearPath() { + m._path = nil + m.clearedFields[hostprocess.FieldPath] = struct{}{} +} + +// PathCleared returns if the "path" field was cleared in this mutation. +func (m *HostProcessMutation) PathCleared() bool { + _, ok := m.clearedFields[hostprocess.FieldPath] + return ok +} + +// ResetPath resets all changes to the "path" field. +func (m *HostProcessMutation) ResetPath() { + m._path = nil + delete(m.clearedFields, hostprocess.FieldPath) +} + +// SetCmd sets the "cmd" field. +func (m *HostProcessMutation) SetCmd(s string) { + m.cmd = &s +} + +// Cmd returns the value of the "cmd" field in the mutation. +func (m *HostProcessMutation) Cmd() (r string, exists bool) { + v := m.cmd + if v == nil { + return + } + return *v, true +} + +// OldCmd returns the old "cmd" field's value of the HostProcess entity. +// If the HostProcess object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *HostProcessMutation) OldCmd(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCmd is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCmd requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCmd: %w", err) + } + return oldValue.Cmd, nil +} + +// ClearCmd clears the value of the "cmd" field. +func (m *HostProcessMutation) ClearCmd() { + m.cmd = nil + m.clearedFields[hostprocess.FieldCmd] = struct{}{} +} + +// CmdCleared returns if the "cmd" field was cleared in this mutation. +func (m *HostProcessMutation) CmdCleared() bool { + _, ok := m.clearedFields[hostprocess.FieldCmd] + return ok +} + +// ResetCmd resets all changes to the "cmd" field. +func (m *HostProcessMutation) ResetCmd() { + m.cmd = nil + delete(m.clearedFields, hostprocess.FieldCmd) +} + +// SetEnv sets the "env" field. +func (m *HostProcessMutation) SetEnv(s string) { + m.env = &s +} + +// Env returns the value of the "env" field in the mutation. +func (m *HostProcessMutation) Env() (r string, exists bool) { + v := m.env + if v == nil { + return + } + return *v, true +} + +// OldEnv returns the old "env" field's value of the HostProcess entity. +// If the HostProcess object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *HostProcessMutation) OldEnv(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldEnv is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldEnv requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldEnv: %w", err) + } + return oldValue.Env, nil +} + +// ClearEnv clears the value of the "env" field. +func (m *HostProcessMutation) ClearEnv() { + m.env = nil + m.clearedFields[hostprocess.FieldEnv] = struct{}{} +} + +// EnvCleared returns if the "env" field was cleared in this mutation. +func (m *HostProcessMutation) EnvCleared() bool { + _, ok := m.clearedFields[hostprocess.FieldEnv] + return ok +} + +// ResetEnv resets all changes to the "env" field. +func (m *HostProcessMutation) ResetEnv() { + m.env = nil + delete(m.clearedFields, hostprocess.FieldEnv) +} + +// SetCwd sets the "cwd" field. +func (m *HostProcessMutation) SetCwd(s string) { + m.cwd = &s +} + +// Cwd returns the value of the "cwd" field in the mutation. +func (m *HostProcessMutation) Cwd() (r string, exists bool) { + v := m.cwd + if v == nil { + return + } + return *v, true +} + +// OldCwd returns the old "cwd" field's value of the HostProcess entity. +// If the HostProcess object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *HostProcessMutation) OldCwd(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCwd is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCwd requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCwd: %w", err) + } + return oldValue.Cwd, nil +} + +// ClearCwd clears the value of the "cwd" field. +func (m *HostProcessMutation) ClearCwd() { + m.cwd = nil + m.clearedFields[hostprocess.FieldCwd] = struct{}{} +} + +// CwdCleared returns if the "cwd" field was cleared in this mutation. +func (m *HostProcessMutation) CwdCleared() bool { + _, ok := m.clearedFields[hostprocess.FieldCwd] + return ok +} + +// ResetCwd resets all changes to the "cwd" field. +func (m *HostProcessMutation) ResetCwd() { + m.cwd = nil + delete(m.clearedFields, hostprocess.FieldCwd) +} + +// SetStatus sets the "status" field. +func (m *HostProcessMutation) SetStatus(cs c2pb.Process_Status) { + m.status = &cs +} + +// Status returns the value of the "status" field in the mutation. +func (m *HostProcessMutation) Status() (r c2pb.Process_Status, exists bool) { + v := m.status + if v == nil { + return + } + return *v, true +} + +// OldStatus returns the old "status" field's value of the HostProcess entity. +// If the HostProcess object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *HostProcessMutation) OldStatus(ctx context.Context) (v c2pb.Process_Status, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldStatus is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldStatus requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldStatus: %w", err) + } + return oldValue.Status, nil +} + +// ResetStatus resets all changes to the "status" field. +func (m *HostProcessMutation) ResetStatus() { + m.status = nil +} + // SetHostID sets the "host" edge to the Host entity by id. -func (m *ProcessMutation) SetHostID(id int) { +func (m *HostProcessMutation) SetHostID(id int) { m.host = &id } // ClearHost clears the "host" edge to the Host entity. -func (m *ProcessMutation) ClearHost() { +func (m *HostProcessMutation) ClearHost() { m.clearedhost = true } // HostCleared reports if the "host" edge to the Host entity was cleared. -func (m *ProcessMutation) HostCleared() bool { +func (m *HostProcessMutation) HostCleared() bool { return m.clearedhost } // HostID returns the "host" edge ID in the mutation. -func (m *ProcessMutation) HostID() (id int, exists bool) { +func (m *HostProcessMutation) HostID() (id int, exists bool) { if m.host != nil { return *m.host, true } @@ -3055,7 +4454,7 @@ func (m *ProcessMutation) HostID() (id int, exists bool) { // HostIDs returns the "host" edge IDs in the mutation. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use // HostID instead. It exists only for internal usage by the builders. -func (m *ProcessMutation) HostIDs() (ids []int) { +func (m *HostProcessMutation) HostIDs() (ids []int) { if id := m.host; id != nil { ids = append(ids, *id) } @@ -3063,28 +4462,28 @@ func (m *ProcessMutation) HostIDs() (ids []int) { } // ResetHost resets all changes to the "host" edge. -func (m *ProcessMutation) ResetHost() { +func (m *HostProcessMutation) ResetHost() { m.host = nil m.clearedhost = false } // SetTaskID sets the "task" edge to the Task entity by id. -func (m *ProcessMutation) SetTaskID(id int) { +func (m *HostProcessMutation) SetTaskID(id int) { m.task = &id } // ClearTask clears the "task" edge to the Task entity. -func (m *ProcessMutation) ClearTask() { +func (m *HostProcessMutation) ClearTask() { m.clearedtask = true } // TaskCleared reports if the "task" edge to the Task entity was cleared. -func (m *ProcessMutation) TaskCleared() bool { +func (m *HostProcessMutation) TaskCleared() bool { return m.clearedtask } // TaskID returns the "task" edge ID in the mutation. -func (m *ProcessMutation) TaskID() (id int, exists bool) { +func (m *HostProcessMutation) TaskID() (id int, exists bool) { if m.task != nil { return *m.task, true } @@ -3094,7 +4493,7 @@ func (m *ProcessMutation) TaskID() (id int, exists bool) { // TaskIDs returns the "task" edge IDs in the mutation. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use // TaskID instead. It exists only for internal usage by the builders. -func (m *ProcessMutation) TaskIDs() (ids []int) { +func (m *HostProcessMutation) TaskIDs() (ids []int) { if id := m.task; id != nil { ids = append(ids, *id) } @@ -3102,20 +4501,20 @@ func (m *ProcessMutation) TaskIDs() (ids []int) { } // ResetTask resets all changes to the "task" edge. -func (m *ProcessMutation) ResetTask() { +func (m *HostProcessMutation) ResetTask() { m.task = nil m.clearedtask = false } -// Where appends a list predicates to the ProcessMutation builder. -func (m *ProcessMutation) Where(ps ...predicate.Process) { +// Where appends a list predicates to the HostProcessMutation builder. +func (m *HostProcessMutation) Where(ps ...predicate.HostProcess) { m.predicates = append(m.predicates, ps...) } -// WhereP appends storage-level predicates to the ProcessMutation builder. Using this method, +// WhereP appends storage-level predicates to the HostProcessMutation builder. Using this method, // users can use type-assertion to append predicates that do not depend on any generated package. -func (m *ProcessMutation) WhereP(ps ...func(*sql.Selector)) { - p := make([]predicate.Process, len(ps)) +func (m *HostProcessMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.HostProcess, len(ps)) for i := range ps { p[i] = ps[i] } @@ -3123,39 +4522,57 @@ func (m *ProcessMutation) WhereP(ps ...func(*sql.Selector)) { } // Op returns the operation name. -func (m *ProcessMutation) Op() Op { +func (m *HostProcessMutation) Op() Op { return m.op } // SetOp allows setting the mutation operation. -func (m *ProcessMutation) SetOp(op Op) { +func (m *HostProcessMutation) SetOp(op Op) { m.op = op } -// Type returns the node type of this mutation (Process). -func (m *ProcessMutation) Type() string { +// Type returns the node type of this mutation (HostProcess). +func (m *HostProcessMutation) Type() string { return m.typ } // Fields returns all fields that were changed during this mutation. Note that in // order to get all numeric fields that were incremented/decremented, call // AddedFields(). -func (m *ProcessMutation) Fields() []string { - fields := make([]string, 0, 5) +func (m *HostProcessMutation) Fields() []string { + fields := make([]string, 0, 11) if m.created_at != nil { - fields = append(fields, process.FieldCreatedAt) + fields = append(fields, hostprocess.FieldCreatedAt) } if m.last_modified_at != nil { - fields = append(fields, process.FieldLastModifiedAt) + fields = append(fields, hostprocess.FieldLastModifiedAt) } if m.pid != nil { - fields = append(fields, process.FieldPid) + fields = append(fields, hostprocess.FieldPid) + } + if m.ppid != nil { + fields = append(fields, hostprocess.FieldPpid) } if m.name != nil { - fields = append(fields, process.FieldName) + fields = append(fields, hostprocess.FieldName) } if m.principal != nil { - fields = append(fields, process.FieldPrincipal) + fields = append(fields, hostprocess.FieldPrincipal) + } + if m._path != nil { + fields = append(fields, hostprocess.FieldPath) + } + if m.cmd != nil { + fields = append(fields, hostprocess.FieldCmd) + } + if m.env != nil { + fields = append(fields, hostprocess.FieldEnv) + } + if m.cwd != nil { + fields = append(fields, hostprocess.FieldCwd) + } + if m.status != nil { + fields = append(fields, hostprocess.FieldStatus) } return fields } @@ -3163,18 +4580,30 @@ func (m *ProcessMutation) Fields() []string { // Field returns the value of a field with the given name. The second boolean // return value indicates that this field was not set, or was not defined in the // schema. -func (m *ProcessMutation) Field(name string) (ent.Value, bool) { +func (m *HostProcessMutation) Field(name string) (ent.Value, bool) { switch name { - case process.FieldCreatedAt: + case hostprocess.FieldCreatedAt: return m.CreatedAt() - case process.FieldLastModifiedAt: + case hostprocess.FieldLastModifiedAt: return m.LastModifiedAt() - case process.FieldPid: + case hostprocess.FieldPid: return m.Pid() - case process.FieldName: + case hostprocess.FieldPpid: + return m.Ppid() + case hostprocess.FieldName: return m.Name() - case process.FieldPrincipal: + case hostprocess.FieldPrincipal: return m.Principal() + case hostprocess.FieldPath: + return m.Path() + case hostprocess.FieldCmd: + return m.Cmd() + case hostprocess.FieldEnv: + return m.Env() + case hostprocess.FieldCwd: + return m.Cwd() + case hostprocess.FieldStatus: + return m.Status() } return nil, false } @@ -3182,72 +4611,129 @@ func (m *ProcessMutation) Field(name string) (ent.Value, bool) { // OldField returns the old value of the field from the database. An error is // returned if the mutation operation is not UpdateOne, or the query to the // database failed. -func (m *ProcessMutation) OldField(ctx context.Context, name string) (ent.Value, error) { +func (m *HostProcessMutation) OldField(ctx context.Context, name string) (ent.Value, error) { switch name { - case process.FieldCreatedAt: + case hostprocess.FieldCreatedAt: return m.OldCreatedAt(ctx) - case process.FieldLastModifiedAt: + case hostprocess.FieldLastModifiedAt: return m.OldLastModifiedAt(ctx) - case process.FieldPid: + case hostprocess.FieldPid: return m.OldPid(ctx) - case process.FieldName: + case hostprocess.FieldPpid: + return m.OldPpid(ctx) + case hostprocess.FieldName: return m.OldName(ctx) - case process.FieldPrincipal: + case hostprocess.FieldPrincipal: return m.OldPrincipal(ctx) + case hostprocess.FieldPath: + return m.OldPath(ctx) + case hostprocess.FieldCmd: + return m.OldCmd(ctx) + case hostprocess.FieldEnv: + return m.OldEnv(ctx) + case hostprocess.FieldCwd: + return m.OldCwd(ctx) + case hostprocess.FieldStatus: + return m.OldStatus(ctx) } - return nil, fmt.Errorf("unknown Process field %s", name) + return nil, fmt.Errorf("unknown HostProcess field %s", name) } // SetField sets the value of a field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. -func (m *ProcessMutation) SetField(name string, value ent.Value) error { +func (m *HostProcessMutation) SetField(name string, value ent.Value) error { switch name { - case process.FieldCreatedAt: + case hostprocess.FieldCreatedAt: v, ok := value.(time.Time) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetCreatedAt(v) return nil - case process.FieldLastModifiedAt: + case hostprocess.FieldLastModifiedAt: v, ok := value.(time.Time) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetLastModifiedAt(v) return nil - case process.FieldPid: + case hostprocess.FieldPid: v, ok := value.(uint64) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetPid(v) return nil - case process.FieldName: + case hostprocess.FieldPpid: + v, ok := value.(uint64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetPpid(v) + return nil + case hostprocess.FieldName: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetName(v) return nil - case process.FieldPrincipal: + case hostprocess.FieldPrincipal: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetPrincipal(v) return nil + case hostprocess.FieldPath: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetPath(v) + return nil + case hostprocess.FieldCmd: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCmd(v) + return nil + case hostprocess.FieldEnv: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetEnv(v) + return nil + case hostprocess.FieldCwd: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCwd(v) + return nil + case hostprocess.FieldStatus: + v, ok := value.(c2pb.Process_Status) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetStatus(v) + return nil } - return fmt.Errorf("unknown Process field %s", name) + return fmt.Errorf("unknown HostProcess field %s", name) } // AddedFields returns all numeric fields that were incremented/decremented during // this mutation. -func (m *ProcessMutation) AddedFields() []string { +func (m *HostProcessMutation) AddedFields() []string { var fields []string if m.addpid != nil { - fields = append(fields, process.FieldPid) + fields = append(fields, hostprocess.FieldPid) + } + if m.addppid != nil { + fields = append(fields, hostprocess.FieldPpid) } return fields } @@ -3255,10 +4741,12 @@ func (m *ProcessMutation) AddedFields() []string { // AddedField returns the numeric value that was incremented/decremented on a field // with the given name. The second boolean return value indicates that this field // was not set, or was not defined in the schema. -func (m *ProcessMutation) AddedField(name string) (ent.Value, bool) { +func (m *HostProcessMutation) AddedField(name string) (ent.Value, bool) { switch name { - case process.FieldPid: + case hostprocess.FieldPid: return m.AddedPid() + case hostprocess.FieldPpid: + return m.AddedPpid() } return nil, false } @@ -3266,82 +4754,134 @@ func (m *ProcessMutation) AddedField(name string) (ent.Value, bool) { // AddField adds the value to the field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. -func (m *ProcessMutation) AddField(name string, value ent.Value) error { +func (m *HostProcessMutation) AddField(name string, value ent.Value) error { switch name { - case process.FieldPid: + case hostprocess.FieldPid: v, ok := value.(int64) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.AddPid(v) return nil + case hostprocess.FieldPpid: + v, ok := value.(int64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddPpid(v) + return nil } - return fmt.Errorf("unknown Process numeric field %s", name) + return fmt.Errorf("unknown HostProcess numeric field %s", name) } // ClearedFields returns all nullable fields that were cleared during this // mutation. -func (m *ProcessMutation) ClearedFields() []string { - return nil +func (m *HostProcessMutation) ClearedFields() []string { + var fields []string + if m.FieldCleared(hostprocess.FieldPath) { + fields = append(fields, hostprocess.FieldPath) + } + if m.FieldCleared(hostprocess.FieldCmd) { + fields = append(fields, hostprocess.FieldCmd) + } + if m.FieldCleared(hostprocess.FieldEnv) { + fields = append(fields, hostprocess.FieldEnv) + } + if m.FieldCleared(hostprocess.FieldCwd) { + fields = append(fields, hostprocess.FieldCwd) + } + return fields } // FieldCleared returns a boolean indicating if a field with the given name was // cleared in this mutation. -func (m *ProcessMutation) FieldCleared(name string) bool { +func (m *HostProcessMutation) FieldCleared(name string) bool { _, ok := m.clearedFields[name] return ok } // ClearField clears the value of the field with the given name. It returns an // error if the field is not defined in the schema. -func (m *ProcessMutation) ClearField(name string) error { - return fmt.Errorf("unknown Process nullable field %s", name) +func (m *HostProcessMutation) ClearField(name string) error { + switch name { + case hostprocess.FieldPath: + m.ClearPath() + return nil + case hostprocess.FieldCmd: + m.ClearCmd() + return nil + case hostprocess.FieldEnv: + m.ClearEnv() + return nil + case hostprocess.FieldCwd: + m.ClearCwd() + return nil + } + return fmt.Errorf("unknown HostProcess nullable field %s", name) } // ResetField resets all changes in the mutation for the field with the given name. // It returns an error if the field is not defined in the schema. -func (m *ProcessMutation) ResetField(name string) error { +func (m *HostProcessMutation) ResetField(name string) error { switch name { - case process.FieldCreatedAt: + case hostprocess.FieldCreatedAt: m.ResetCreatedAt() return nil - case process.FieldLastModifiedAt: + case hostprocess.FieldLastModifiedAt: m.ResetLastModifiedAt() return nil - case process.FieldPid: + case hostprocess.FieldPid: m.ResetPid() return nil - case process.FieldName: + case hostprocess.FieldPpid: + m.ResetPpid() + return nil + case hostprocess.FieldName: m.ResetName() return nil - case process.FieldPrincipal: + case hostprocess.FieldPrincipal: m.ResetPrincipal() return nil + case hostprocess.FieldPath: + m.ResetPath() + return nil + case hostprocess.FieldCmd: + m.ResetCmd() + return nil + case hostprocess.FieldEnv: + m.ResetEnv() + return nil + case hostprocess.FieldCwd: + m.ResetCwd() + return nil + case hostprocess.FieldStatus: + m.ResetStatus() + return nil } - return fmt.Errorf("unknown Process field %s", name) + return fmt.Errorf("unknown HostProcess field %s", name) } // AddedEdges returns all edge names that were set/added in this mutation. -func (m *ProcessMutation) AddedEdges() []string { +func (m *HostProcessMutation) AddedEdges() []string { edges := make([]string, 0, 2) if m.host != nil { - edges = append(edges, process.EdgeHost) + edges = append(edges, hostprocess.EdgeHost) } if m.task != nil { - edges = append(edges, process.EdgeTask) + edges = append(edges, hostprocess.EdgeTask) } return edges } // AddedIDs returns all IDs (to other nodes) that were added for the given edge // name in this mutation. -func (m *ProcessMutation) AddedIDs(name string) []ent.Value { +func (m *HostProcessMutation) AddedIDs(name string) []ent.Value { switch name { - case process.EdgeHost: + case hostprocess.EdgeHost: if id := m.host; id != nil { return []ent.Value{*id} } - case process.EdgeTask: + case hostprocess.EdgeTask: if id := m.task; id != nil { return []ent.Value{*id} } @@ -3350,36 +4890,36 @@ func (m *ProcessMutation) AddedIDs(name string) []ent.Value { } // RemovedEdges returns all edge names that were removed in this mutation. -func (m *ProcessMutation) RemovedEdges() []string { +func (m *HostProcessMutation) RemovedEdges() []string { edges := make([]string, 0, 2) return edges } // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with // the given name in this mutation. -func (m *ProcessMutation) RemovedIDs(name string) []ent.Value { +func (m *HostProcessMutation) RemovedIDs(name string) []ent.Value { return nil } // ClearedEdges returns all edge names that were cleared in this mutation. -func (m *ProcessMutation) ClearedEdges() []string { +func (m *HostProcessMutation) ClearedEdges() []string { edges := make([]string, 0, 2) if m.clearedhost { - edges = append(edges, process.EdgeHost) + edges = append(edges, hostprocess.EdgeHost) } if m.clearedtask { - edges = append(edges, process.EdgeTask) + edges = append(edges, hostprocess.EdgeTask) } return edges } // EdgeCleared returns a boolean which indicates if the edge with the given name // was cleared in this mutation. -func (m *ProcessMutation) EdgeCleared(name string) bool { +func (m *HostProcessMutation) EdgeCleared(name string) bool { switch name { - case process.EdgeHost: + case hostprocess.EdgeHost: return m.clearedhost - case process.EdgeTask: + case hostprocess.EdgeTask: return m.clearedtask } return false @@ -3387,30 +4927,30 @@ func (m *ProcessMutation) EdgeCleared(name string) bool { // ClearEdge clears the value of the edge with the given name. It returns an error // if that edge is not defined in the schema. -func (m *ProcessMutation) ClearEdge(name string) error { +func (m *HostProcessMutation) ClearEdge(name string) error { switch name { - case process.EdgeHost: + case hostprocess.EdgeHost: m.ClearHost() return nil - case process.EdgeTask: + case hostprocess.EdgeTask: m.ClearTask() return nil } - return fmt.Errorf("unknown Process unique edge %s", name) + return fmt.Errorf("unknown HostProcess unique edge %s", name) } // ResetEdge resets all changes to the edge with the given name in this mutation. // It returns an error if the edge is not defined in the schema. -func (m *ProcessMutation) ResetEdge(name string) error { +func (m *HostProcessMutation) ResetEdge(name string) error { switch name { - case process.EdgeHost: + case hostprocess.EdgeHost: m.ResetHost() return nil - case process.EdgeTask: + case hostprocess.EdgeTask: m.ResetTask() return nil } - return fmt.Errorf("unknown Process edge %s", name) + return fmt.Errorf("unknown HostProcess edge %s", name) } // QuestMutation represents an operation that mutates the Quest nodes in the graph. @@ -4686,6 +6226,9 @@ type TaskMutation struct { clearedquest bool beacon *int clearedbeacon bool + reported_files map[int]struct{} + removedreported_files map[int]struct{} + clearedreported_files bool reported_processes map[int]struct{} removedreported_processes map[int]struct{} clearedreported_processes bool @@ -5243,7 +6786,61 @@ func (m *TaskMutation) ResetBeacon() { m.clearedbeacon = false } -// AddReportedProcessIDs adds the "reported_processes" edge to the Process entity by ids. +// AddReportedFileIDs adds the "reported_files" edge to the HostFile entity by ids. +func (m *TaskMutation) AddReportedFileIDs(ids ...int) { + if m.reported_files == nil { + m.reported_files = make(map[int]struct{}) + } + for i := range ids { + m.reported_files[ids[i]] = struct{}{} + } +} + +// ClearReportedFiles clears the "reported_files" edge to the HostFile entity. +func (m *TaskMutation) ClearReportedFiles() { + m.clearedreported_files = true +} + +// ReportedFilesCleared reports if the "reported_files" edge to the HostFile entity was cleared. +func (m *TaskMutation) ReportedFilesCleared() bool { + return m.clearedreported_files +} + +// RemoveReportedFileIDs removes the "reported_files" edge to the HostFile entity by IDs. +func (m *TaskMutation) RemoveReportedFileIDs(ids ...int) { + if m.removedreported_files == nil { + m.removedreported_files = make(map[int]struct{}) + } + for i := range ids { + delete(m.reported_files, ids[i]) + m.removedreported_files[ids[i]] = struct{}{} + } +} + +// RemovedReportedFiles returns the removed IDs of the "reported_files" edge to the HostFile entity. +func (m *TaskMutation) RemovedReportedFilesIDs() (ids []int) { + for id := range m.removedreported_files { + ids = append(ids, id) + } + return +} + +// ReportedFilesIDs returns the "reported_files" edge IDs in the mutation. +func (m *TaskMutation) ReportedFilesIDs() (ids []int) { + for id := range m.reported_files { + ids = append(ids, id) + } + return +} + +// ResetReportedFiles resets all changes to the "reported_files" edge. +func (m *TaskMutation) ResetReportedFiles() { + m.reported_files = nil + m.clearedreported_files = false + m.removedreported_files = nil +} + +// AddReportedProcessIDs adds the "reported_processes" edge to the HostProcess entity by ids. func (m *TaskMutation) AddReportedProcessIDs(ids ...int) { if m.reported_processes == nil { m.reported_processes = make(map[int]struct{}) @@ -5253,17 +6850,17 @@ func (m *TaskMutation) AddReportedProcessIDs(ids ...int) { } } -// ClearReportedProcesses clears the "reported_processes" edge to the Process entity. +// ClearReportedProcesses clears the "reported_processes" edge to the HostProcess entity. func (m *TaskMutation) ClearReportedProcesses() { m.clearedreported_processes = true } -// ReportedProcessesCleared reports if the "reported_processes" edge to the Process entity was cleared. +// ReportedProcessesCleared reports if the "reported_processes" edge to the HostProcess entity was cleared. func (m *TaskMutation) ReportedProcessesCleared() bool { return m.clearedreported_processes } -// RemoveReportedProcessIDs removes the "reported_processes" edge to the Process entity by IDs. +// RemoveReportedProcessIDs removes the "reported_processes" edge to the HostProcess entity by IDs. func (m *TaskMutation) RemoveReportedProcessIDs(ids ...int) { if m.removedreported_processes == nil { m.removedreported_processes = make(map[int]struct{}) @@ -5274,7 +6871,7 @@ func (m *TaskMutation) RemoveReportedProcessIDs(ids ...int) { } } -// RemovedReportedProcesses returns the removed IDs of the "reported_processes" edge to the Process entity. +// RemovedReportedProcesses returns the removed IDs of the "reported_processes" edge to the HostProcess entity. func (m *TaskMutation) RemovedReportedProcessesIDs() (ids []int) { for id := range m.removedreported_processes { ids = append(ids, id) @@ -5597,13 +7194,16 @@ func (m *TaskMutation) ResetField(name string) error { // AddedEdges returns all edge names that were set/added in this mutation. func (m *TaskMutation) AddedEdges() []string { - edges := make([]string, 0, 3) + edges := make([]string, 0, 4) if m.quest != nil { edges = append(edges, task.EdgeQuest) } if m.beacon != nil { edges = append(edges, task.EdgeBeacon) } + if m.reported_files != nil { + edges = append(edges, task.EdgeReportedFiles) + } if m.reported_processes != nil { edges = append(edges, task.EdgeReportedProcesses) } @@ -5622,6 +7222,12 @@ func (m *TaskMutation) AddedIDs(name string) []ent.Value { if id := m.beacon; id != nil { return []ent.Value{*id} } + case task.EdgeReportedFiles: + ids := make([]ent.Value, 0, len(m.reported_files)) + for id := range m.reported_files { + ids = append(ids, id) + } + return ids case task.EdgeReportedProcesses: ids := make([]ent.Value, 0, len(m.reported_processes)) for id := range m.reported_processes { @@ -5634,7 +7240,10 @@ func (m *TaskMutation) AddedIDs(name string) []ent.Value { // RemovedEdges returns all edge names that were removed in this mutation. func (m *TaskMutation) RemovedEdges() []string { - edges := make([]string, 0, 3) + edges := make([]string, 0, 4) + if m.removedreported_files != nil { + edges = append(edges, task.EdgeReportedFiles) + } if m.removedreported_processes != nil { edges = append(edges, task.EdgeReportedProcesses) } @@ -5645,6 +7254,12 @@ func (m *TaskMutation) RemovedEdges() []string { // the given name in this mutation. func (m *TaskMutation) RemovedIDs(name string) []ent.Value { switch name { + case task.EdgeReportedFiles: + ids := make([]ent.Value, 0, len(m.removedreported_files)) + for id := range m.removedreported_files { + ids = append(ids, id) + } + return ids case task.EdgeReportedProcesses: ids := make([]ent.Value, 0, len(m.removedreported_processes)) for id := range m.removedreported_processes { @@ -5657,13 +7272,16 @@ func (m *TaskMutation) RemovedIDs(name string) []ent.Value { // ClearedEdges returns all edge names that were cleared in this mutation. func (m *TaskMutation) ClearedEdges() []string { - edges := make([]string, 0, 3) + edges := make([]string, 0, 4) if m.clearedquest { edges = append(edges, task.EdgeQuest) } if m.clearedbeacon { edges = append(edges, task.EdgeBeacon) } + if m.clearedreported_files { + edges = append(edges, task.EdgeReportedFiles) + } if m.clearedreported_processes { edges = append(edges, task.EdgeReportedProcesses) } @@ -5678,6 +7296,8 @@ func (m *TaskMutation) EdgeCleared(name string) bool { return m.clearedquest case task.EdgeBeacon: return m.clearedbeacon + case task.EdgeReportedFiles: + return m.clearedreported_files case task.EdgeReportedProcesses: return m.clearedreported_processes } @@ -5708,6 +7328,9 @@ func (m *TaskMutation) ResetEdge(name string) error { case task.EdgeBeacon: m.ResetBeacon() return nil + case task.EdgeReportedFiles: + m.ResetReportedFiles() + return nil case task.EdgeReportedProcesses: m.ResetReportedProcesses() return nil diff --git a/tavern/internal/ent/predicate/predicate.go b/tavern/internal/ent/predicate/predicate.go index 8b3923f42..a18133044 100644 --- a/tavern/internal/ent/predicate/predicate.go +++ b/tavern/internal/ent/predicate/predicate.go @@ -15,8 +15,11 @@ type File func(*sql.Selector) // Host is the predicate function for host builders. type Host func(*sql.Selector) -// Process is the predicate function for process builders. -type Process func(*sql.Selector) +// HostFile is the predicate function for hostfile builders. +type HostFile func(*sql.Selector) + +// HostProcess is the predicate function for hostprocess builders. +type HostProcess func(*sql.Selector) // Quest is the predicate function for quest builders. type Quest func(*sql.Selector) diff --git a/tavern/internal/ent/privacy/privacy.go b/tavern/internal/ent/privacy/privacy.go index acb3a2e64..b1f340c92 100644 --- a/tavern/internal/ent/privacy/privacy.go +++ b/tavern/internal/ent/privacy/privacy.go @@ -182,28 +182,52 @@ func (f HostMutationRuleFunc) EvalMutation(ctx context.Context, m ent.Mutation) return Denyf("ent/privacy: unexpected mutation type %T, expect *ent.HostMutation", m) } -// The ProcessQueryRuleFunc type is an adapter to allow the use of ordinary +// The HostFileQueryRuleFunc type is an adapter to allow the use of ordinary // functions as a query rule. -type ProcessQueryRuleFunc func(context.Context, *ent.ProcessQuery) error +type HostFileQueryRuleFunc func(context.Context, *ent.HostFileQuery) error // EvalQuery return f(ctx, q). -func (f ProcessQueryRuleFunc) EvalQuery(ctx context.Context, q ent.Query) error { - if q, ok := q.(*ent.ProcessQuery); ok { +func (f HostFileQueryRuleFunc) EvalQuery(ctx context.Context, q ent.Query) error { + if q, ok := q.(*ent.HostFileQuery); ok { return f(ctx, q) } - return Denyf("ent/privacy: unexpected query type %T, expect *ent.ProcessQuery", q) + return Denyf("ent/privacy: unexpected query type %T, expect *ent.HostFileQuery", q) } -// The ProcessMutationRuleFunc type is an adapter to allow the use of ordinary +// The HostFileMutationRuleFunc type is an adapter to allow the use of ordinary // functions as a mutation rule. -type ProcessMutationRuleFunc func(context.Context, *ent.ProcessMutation) error +type HostFileMutationRuleFunc func(context.Context, *ent.HostFileMutation) error // EvalMutation calls f(ctx, m). -func (f ProcessMutationRuleFunc) EvalMutation(ctx context.Context, m ent.Mutation) error { - if m, ok := m.(*ent.ProcessMutation); ok { +func (f HostFileMutationRuleFunc) EvalMutation(ctx context.Context, m ent.Mutation) error { + if m, ok := m.(*ent.HostFileMutation); ok { return f(ctx, m) } - return Denyf("ent/privacy: unexpected mutation type %T, expect *ent.ProcessMutation", m) + return Denyf("ent/privacy: unexpected mutation type %T, expect *ent.HostFileMutation", m) +} + +// The HostProcessQueryRuleFunc type is an adapter to allow the use of ordinary +// functions as a query rule. +type HostProcessQueryRuleFunc func(context.Context, *ent.HostProcessQuery) error + +// EvalQuery return f(ctx, q). +func (f HostProcessQueryRuleFunc) EvalQuery(ctx context.Context, q ent.Query) error { + if q, ok := q.(*ent.HostProcessQuery); ok { + return f(ctx, q) + } + return Denyf("ent/privacy: unexpected query type %T, expect *ent.HostProcessQuery", q) +} + +// The HostProcessMutationRuleFunc type is an adapter to allow the use of ordinary +// functions as a mutation rule. +type HostProcessMutationRuleFunc func(context.Context, *ent.HostProcessMutation) error + +// EvalMutation calls f(ctx, m). +func (f HostProcessMutationRuleFunc) EvalMutation(ctx context.Context, m ent.Mutation) error { + if m, ok := m.(*ent.HostProcessMutation); ok { + return f(ctx, m) + } + return Denyf("ent/privacy: unexpected mutation type %T, expect *ent.HostProcessMutation", m) } // The QuestQueryRuleFunc type is an adapter to allow the use of ordinary diff --git a/tavern/internal/ent/process.go b/tavern/internal/ent/process.go deleted file mode 100644 index 54232e527..000000000 --- a/tavern/internal/ent/process.go +++ /dev/null @@ -1,234 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "fmt" - "strings" - "time" - - "entgo.io/ent" - "entgo.io/ent/dialect/sql" - "realm.pub/tavern/internal/ent/host" - "realm.pub/tavern/internal/ent/process" - "realm.pub/tavern/internal/ent/task" -) - -// Process is the model entity for the Process schema. -type Process struct { - config `json:"-"` - // ID of the ent. - ID int `json:"id,omitempty"` - // Timestamp of when this ent was created - CreatedAt time.Time `json:"created_at,omitempty"` - // Timestamp of when this ent was last updated - LastModifiedAt time.Time `json:"last_modified_at,omitempty"` - // ID of the process. - Pid uint64 `json:"pid,omitempty"` - // The name of the process. - Name string `json:"name,omitempty"` - // The user the process is running as. - Principal string `json:"principal,omitempty"` - // Edges holds the relations/edges for other nodes in the graph. - // The values are being populated by the ProcessQuery when eager-loading is set. - Edges ProcessEdges `json:"edges"` - host_processes *int - process_host *int - task_reported_processes *int - selectValues sql.SelectValues -} - -// ProcessEdges holds the relations/edges for other nodes in the graph. -type ProcessEdges struct { - // Host the process was reported on. - Host *Host `json:"host,omitempty"` - // Task that reported this process. - Task *Task `json:"task,omitempty"` - // loadedTypes holds the information for reporting if a - // type was loaded (or requested) in eager-loading or not. - loadedTypes [2]bool - // totalCount holds the count of the edges above. - totalCount [2]map[string]int -} - -// HostOrErr returns the Host value or an error if the edge -// was not loaded in eager-loading, or loaded but was not found. -func (e ProcessEdges) HostOrErr() (*Host, error) { - if e.loadedTypes[0] { - if e.Host == nil { - // Edge was loaded but was not found. - return nil, &NotFoundError{label: host.Label} - } - return e.Host, nil - } - return nil, &NotLoadedError{edge: "host"} -} - -// TaskOrErr returns the Task value or an error if the edge -// was not loaded in eager-loading, or loaded but was not found. -func (e ProcessEdges) TaskOrErr() (*Task, error) { - if e.loadedTypes[1] { - if e.Task == nil { - // Edge was loaded but was not found. - return nil, &NotFoundError{label: task.Label} - } - return e.Task, nil - } - return nil, &NotLoadedError{edge: "task"} -} - -// scanValues returns the types for scanning values from sql.Rows. -func (*Process) scanValues(columns []string) ([]any, error) { - values := make([]any, len(columns)) - for i := range columns { - switch columns[i] { - case process.FieldID, process.FieldPid: - values[i] = new(sql.NullInt64) - case process.FieldName, process.FieldPrincipal: - values[i] = new(sql.NullString) - case process.FieldCreatedAt, process.FieldLastModifiedAt: - values[i] = new(sql.NullTime) - case process.ForeignKeys[0]: // host_processes - values[i] = new(sql.NullInt64) - case process.ForeignKeys[1]: // process_host - values[i] = new(sql.NullInt64) - case process.ForeignKeys[2]: // task_reported_processes - values[i] = new(sql.NullInt64) - default: - values[i] = new(sql.UnknownType) - } - } - return values, nil -} - -// assignValues assigns the values that were returned from sql.Rows (after scanning) -// to the Process fields. -func (pr *Process) assignValues(columns []string, values []any) error { - if m, n := len(values), len(columns); m < n { - return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) - } - for i := range columns { - switch columns[i] { - case process.FieldID: - value, ok := values[i].(*sql.NullInt64) - if !ok { - return fmt.Errorf("unexpected type %T for field id", value) - } - pr.ID = int(value.Int64) - case process.FieldCreatedAt: - if value, ok := values[i].(*sql.NullTime); !ok { - return fmt.Errorf("unexpected type %T for field created_at", values[i]) - } else if value.Valid { - pr.CreatedAt = value.Time - } - case process.FieldLastModifiedAt: - if value, ok := values[i].(*sql.NullTime); !ok { - return fmt.Errorf("unexpected type %T for field last_modified_at", values[i]) - } else if value.Valid { - pr.LastModifiedAt = value.Time - } - case process.FieldPid: - if value, ok := values[i].(*sql.NullInt64); !ok { - return fmt.Errorf("unexpected type %T for field pid", values[i]) - } else if value.Valid { - pr.Pid = uint64(value.Int64) - } - case process.FieldName: - if value, ok := values[i].(*sql.NullString); !ok { - return fmt.Errorf("unexpected type %T for field name", values[i]) - } else if value.Valid { - pr.Name = value.String - } - case process.FieldPrincipal: - if value, ok := values[i].(*sql.NullString); !ok { - return fmt.Errorf("unexpected type %T for field principal", values[i]) - } else if value.Valid { - pr.Principal = value.String - } - case process.ForeignKeys[0]: - if value, ok := values[i].(*sql.NullInt64); !ok { - return fmt.Errorf("unexpected type %T for edge-field host_processes", value) - } else if value.Valid { - pr.host_processes = new(int) - *pr.host_processes = int(value.Int64) - } - case process.ForeignKeys[1]: - if value, ok := values[i].(*sql.NullInt64); !ok { - return fmt.Errorf("unexpected type %T for edge-field process_host", value) - } else if value.Valid { - pr.process_host = new(int) - *pr.process_host = int(value.Int64) - } - case process.ForeignKeys[2]: - if value, ok := values[i].(*sql.NullInt64); !ok { - return fmt.Errorf("unexpected type %T for edge-field task_reported_processes", value) - } else if value.Valid { - pr.task_reported_processes = new(int) - *pr.task_reported_processes = int(value.Int64) - } - default: - pr.selectValues.Set(columns[i], values[i]) - } - } - return nil -} - -// Value returns the ent.Value that was dynamically selected and assigned to the Process. -// This includes values selected through modifiers, order, etc. -func (pr *Process) Value(name string) (ent.Value, error) { - return pr.selectValues.Get(name) -} - -// QueryHost queries the "host" edge of the Process entity. -func (pr *Process) QueryHost() *HostQuery { - return NewProcessClient(pr.config).QueryHost(pr) -} - -// QueryTask queries the "task" edge of the Process entity. -func (pr *Process) QueryTask() *TaskQuery { - return NewProcessClient(pr.config).QueryTask(pr) -} - -// Update returns a builder for updating this Process. -// Note that you need to call Process.Unwrap() before calling this method if this Process -// was returned from a transaction, and the transaction was committed or rolled back. -func (pr *Process) Update() *ProcessUpdateOne { - return NewProcessClient(pr.config).UpdateOne(pr) -} - -// Unwrap unwraps the Process entity that was returned from a transaction after it was closed, -// so that all future queries will be executed through the driver which created the transaction. -func (pr *Process) Unwrap() *Process { - _tx, ok := pr.config.driver.(*txDriver) - if !ok { - panic("ent: Process is not a transactional entity") - } - pr.config.driver = _tx.drv - return pr -} - -// String implements the fmt.Stringer. -func (pr *Process) String() string { - var builder strings.Builder - builder.WriteString("Process(") - builder.WriteString(fmt.Sprintf("id=%v, ", pr.ID)) - builder.WriteString("created_at=") - builder.WriteString(pr.CreatedAt.Format(time.ANSIC)) - builder.WriteString(", ") - builder.WriteString("last_modified_at=") - builder.WriteString(pr.LastModifiedAt.Format(time.ANSIC)) - builder.WriteString(", ") - builder.WriteString("pid=") - builder.WriteString(fmt.Sprintf("%v", pr.Pid)) - builder.WriteString(", ") - builder.WriteString("name=") - builder.WriteString(pr.Name) - builder.WriteString(", ") - builder.WriteString("principal=") - builder.WriteString(pr.Principal) - builder.WriteByte(')') - return builder.String() -} - -// Processes is a parsable slice of Process. -type Processes []*Process diff --git a/tavern/internal/ent/process/where.go b/tavern/internal/ent/process/where.go deleted file mode 100644 index 000f89446..000000000 --- a/tavern/internal/ent/process/where.go +++ /dev/null @@ -1,392 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package process - -import ( - "time" - - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" - "realm.pub/tavern/internal/ent/predicate" -) - -// ID filters vertices based on their ID field. -func ID(id int) predicate.Process { - return predicate.Process(sql.FieldEQ(FieldID, id)) -} - -// IDEQ applies the EQ predicate on the ID field. -func IDEQ(id int) predicate.Process { - return predicate.Process(sql.FieldEQ(FieldID, id)) -} - -// IDNEQ applies the NEQ predicate on the ID field. -func IDNEQ(id int) predicate.Process { - return predicate.Process(sql.FieldNEQ(FieldID, id)) -} - -// IDIn applies the In predicate on the ID field. -func IDIn(ids ...int) predicate.Process { - return predicate.Process(sql.FieldIn(FieldID, ids...)) -} - -// IDNotIn applies the NotIn predicate on the ID field. -func IDNotIn(ids ...int) predicate.Process { - return predicate.Process(sql.FieldNotIn(FieldID, ids...)) -} - -// IDGT applies the GT predicate on the ID field. -func IDGT(id int) predicate.Process { - return predicate.Process(sql.FieldGT(FieldID, id)) -} - -// IDGTE applies the GTE predicate on the ID field. -func IDGTE(id int) predicate.Process { - return predicate.Process(sql.FieldGTE(FieldID, id)) -} - -// IDLT applies the LT predicate on the ID field. -func IDLT(id int) predicate.Process { - return predicate.Process(sql.FieldLT(FieldID, id)) -} - -// IDLTE applies the LTE predicate on the ID field. -func IDLTE(id int) predicate.Process { - return predicate.Process(sql.FieldLTE(FieldID, id)) -} - -// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ. -func CreatedAt(v time.Time) predicate.Process { - return predicate.Process(sql.FieldEQ(FieldCreatedAt, v)) -} - -// LastModifiedAt applies equality check predicate on the "last_modified_at" field. It's identical to LastModifiedAtEQ. -func LastModifiedAt(v time.Time) predicate.Process { - return predicate.Process(sql.FieldEQ(FieldLastModifiedAt, v)) -} - -// Pid applies equality check predicate on the "pid" field. It's identical to PidEQ. -func Pid(v uint64) predicate.Process { - return predicate.Process(sql.FieldEQ(FieldPid, v)) -} - -// Name applies equality check predicate on the "name" field. It's identical to NameEQ. -func Name(v string) predicate.Process { - return predicate.Process(sql.FieldEQ(FieldName, v)) -} - -// Principal applies equality check predicate on the "principal" field. It's identical to PrincipalEQ. -func Principal(v string) predicate.Process { - return predicate.Process(sql.FieldEQ(FieldPrincipal, v)) -} - -// CreatedAtEQ applies the EQ predicate on the "created_at" field. -func CreatedAtEQ(v time.Time) predicate.Process { - return predicate.Process(sql.FieldEQ(FieldCreatedAt, v)) -} - -// CreatedAtNEQ applies the NEQ predicate on the "created_at" field. -func CreatedAtNEQ(v time.Time) predicate.Process { - return predicate.Process(sql.FieldNEQ(FieldCreatedAt, v)) -} - -// CreatedAtIn applies the In predicate on the "created_at" field. -func CreatedAtIn(vs ...time.Time) predicate.Process { - return predicate.Process(sql.FieldIn(FieldCreatedAt, vs...)) -} - -// CreatedAtNotIn applies the NotIn predicate on the "created_at" field. -func CreatedAtNotIn(vs ...time.Time) predicate.Process { - return predicate.Process(sql.FieldNotIn(FieldCreatedAt, vs...)) -} - -// CreatedAtGT applies the GT predicate on the "created_at" field. -func CreatedAtGT(v time.Time) predicate.Process { - return predicate.Process(sql.FieldGT(FieldCreatedAt, v)) -} - -// CreatedAtGTE applies the GTE predicate on the "created_at" field. -func CreatedAtGTE(v time.Time) predicate.Process { - return predicate.Process(sql.FieldGTE(FieldCreatedAt, v)) -} - -// CreatedAtLT applies the LT predicate on the "created_at" field. -func CreatedAtLT(v time.Time) predicate.Process { - return predicate.Process(sql.FieldLT(FieldCreatedAt, v)) -} - -// CreatedAtLTE applies the LTE predicate on the "created_at" field. -func CreatedAtLTE(v time.Time) predicate.Process { - return predicate.Process(sql.FieldLTE(FieldCreatedAt, v)) -} - -// LastModifiedAtEQ applies the EQ predicate on the "last_modified_at" field. -func LastModifiedAtEQ(v time.Time) predicate.Process { - return predicate.Process(sql.FieldEQ(FieldLastModifiedAt, v)) -} - -// LastModifiedAtNEQ applies the NEQ predicate on the "last_modified_at" field. -func LastModifiedAtNEQ(v time.Time) predicate.Process { - return predicate.Process(sql.FieldNEQ(FieldLastModifiedAt, v)) -} - -// LastModifiedAtIn applies the In predicate on the "last_modified_at" field. -func LastModifiedAtIn(vs ...time.Time) predicate.Process { - return predicate.Process(sql.FieldIn(FieldLastModifiedAt, vs...)) -} - -// LastModifiedAtNotIn applies the NotIn predicate on the "last_modified_at" field. -func LastModifiedAtNotIn(vs ...time.Time) predicate.Process { - return predicate.Process(sql.FieldNotIn(FieldLastModifiedAt, vs...)) -} - -// LastModifiedAtGT applies the GT predicate on the "last_modified_at" field. -func LastModifiedAtGT(v time.Time) predicate.Process { - return predicate.Process(sql.FieldGT(FieldLastModifiedAt, v)) -} - -// LastModifiedAtGTE applies the GTE predicate on the "last_modified_at" field. -func LastModifiedAtGTE(v time.Time) predicate.Process { - return predicate.Process(sql.FieldGTE(FieldLastModifiedAt, v)) -} - -// LastModifiedAtLT applies the LT predicate on the "last_modified_at" field. -func LastModifiedAtLT(v time.Time) predicate.Process { - return predicate.Process(sql.FieldLT(FieldLastModifiedAt, v)) -} - -// LastModifiedAtLTE applies the LTE predicate on the "last_modified_at" field. -func LastModifiedAtLTE(v time.Time) predicate.Process { - return predicate.Process(sql.FieldLTE(FieldLastModifiedAt, v)) -} - -// PidEQ applies the EQ predicate on the "pid" field. -func PidEQ(v uint64) predicate.Process { - return predicate.Process(sql.FieldEQ(FieldPid, v)) -} - -// PidNEQ applies the NEQ predicate on the "pid" field. -func PidNEQ(v uint64) predicate.Process { - return predicate.Process(sql.FieldNEQ(FieldPid, v)) -} - -// PidIn applies the In predicate on the "pid" field. -func PidIn(vs ...uint64) predicate.Process { - return predicate.Process(sql.FieldIn(FieldPid, vs...)) -} - -// PidNotIn applies the NotIn predicate on the "pid" field. -func PidNotIn(vs ...uint64) predicate.Process { - return predicate.Process(sql.FieldNotIn(FieldPid, vs...)) -} - -// PidGT applies the GT predicate on the "pid" field. -func PidGT(v uint64) predicate.Process { - return predicate.Process(sql.FieldGT(FieldPid, v)) -} - -// PidGTE applies the GTE predicate on the "pid" field. -func PidGTE(v uint64) predicate.Process { - return predicate.Process(sql.FieldGTE(FieldPid, v)) -} - -// PidLT applies the LT predicate on the "pid" field. -func PidLT(v uint64) predicate.Process { - return predicate.Process(sql.FieldLT(FieldPid, v)) -} - -// PidLTE applies the LTE predicate on the "pid" field. -func PidLTE(v uint64) predicate.Process { - return predicate.Process(sql.FieldLTE(FieldPid, v)) -} - -// NameEQ applies the EQ predicate on the "name" field. -func NameEQ(v string) predicate.Process { - return predicate.Process(sql.FieldEQ(FieldName, v)) -} - -// NameNEQ applies the NEQ predicate on the "name" field. -func NameNEQ(v string) predicate.Process { - return predicate.Process(sql.FieldNEQ(FieldName, v)) -} - -// NameIn applies the In predicate on the "name" field. -func NameIn(vs ...string) predicate.Process { - return predicate.Process(sql.FieldIn(FieldName, vs...)) -} - -// NameNotIn applies the NotIn predicate on the "name" field. -func NameNotIn(vs ...string) predicate.Process { - return predicate.Process(sql.FieldNotIn(FieldName, vs...)) -} - -// NameGT applies the GT predicate on the "name" field. -func NameGT(v string) predicate.Process { - return predicate.Process(sql.FieldGT(FieldName, v)) -} - -// NameGTE applies the GTE predicate on the "name" field. -func NameGTE(v string) predicate.Process { - return predicate.Process(sql.FieldGTE(FieldName, v)) -} - -// NameLT applies the LT predicate on the "name" field. -func NameLT(v string) predicate.Process { - return predicate.Process(sql.FieldLT(FieldName, v)) -} - -// NameLTE applies the LTE predicate on the "name" field. -func NameLTE(v string) predicate.Process { - return predicate.Process(sql.FieldLTE(FieldName, v)) -} - -// NameContains applies the Contains predicate on the "name" field. -func NameContains(v string) predicate.Process { - return predicate.Process(sql.FieldContains(FieldName, v)) -} - -// NameHasPrefix applies the HasPrefix predicate on the "name" field. -func NameHasPrefix(v string) predicate.Process { - return predicate.Process(sql.FieldHasPrefix(FieldName, v)) -} - -// NameHasSuffix applies the HasSuffix predicate on the "name" field. -func NameHasSuffix(v string) predicate.Process { - return predicate.Process(sql.FieldHasSuffix(FieldName, v)) -} - -// NameEqualFold applies the EqualFold predicate on the "name" field. -func NameEqualFold(v string) predicate.Process { - return predicate.Process(sql.FieldEqualFold(FieldName, v)) -} - -// NameContainsFold applies the ContainsFold predicate on the "name" field. -func NameContainsFold(v string) predicate.Process { - return predicate.Process(sql.FieldContainsFold(FieldName, v)) -} - -// PrincipalEQ applies the EQ predicate on the "principal" field. -func PrincipalEQ(v string) predicate.Process { - return predicate.Process(sql.FieldEQ(FieldPrincipal, v)) -} - -// PrincipalNEQ applies the NEQ predicate on the "principal" field. -func PrincipalNEQ(v string) predicate.Process { - return predicate.Process(sql.FieldNEQ(FieldPrincipal, v)) -} - -// PrincipalIn applies the In predicate on the "principal" field. -func PrincipalIn(vs ...string) predicate.Process { - return predicate.Process(sql.FieldIn(FieldPrincipal, vs...)) -} - -// PrincipalNotIn applies the NotIn predicate on the "principal" field. -func PrincipalNotIn(vs ...string) predicate.Process { - return predicate.Process(sql.FieldNotIn(FieldPrincipal, vs...)) -} - -// PrincipalGT applies the GT predicate on the "principal" field. -func PrincipalGT(v string) predicate.Process { - return predicate.Process(sql.FieldGT(FieldPrincipal, v)) -} - -// PrincipalGTE applies the GTE predicate on the "principal" field. -func PrincipalGTE(v string) predicate.Process { - return predicate.Process(sql.FieldGTE(FieldPrincipal, v)) -} - -// PrincipalLT applies the LT predicate on the "principal" field. -func PrincipalLT(v string) predicate.Process { - return predicate.Process(sql.FieldLT(FieldPrincipal, v)) -} - -// PrincipalLTE applies the LTE predicate on the "principal" field. -func PrincipalLTE(v string) predicate.Process { - return predicate.Process(sql.FieldLTE(FieldPrincipal, v)) -} - -// PrincipalContains applies the Contains predicate on the "principal" field. -func PrincipalContains(v string) predicate.Process { - return predicate.Process(sql.FieldContains(FieldPrincipal, v)) -} - -// PrincipalHasPrefix applies the HasPrefix predicate on the "principal" field. -func PrincipalHasPrefix(v string) predicate.Process { - return predicate.Process(sql.FieldHasPrefix(FieldPrincipal, v)) -} - -// PrincipalHasSuffix applies the HasSuffix predicate on the "principal" field. -func PrincipalHasSuffix(v string) predicate.Process { - return predicate.Process(sql.FieldHasSuffix(FieldPrincipal, v)) -} - -// PrincipalEqualFold applies the EqualFold predicate on the "principal" field. -func PrincipalEqualFold(v string) predicate.Process { - return predicate.Process(sql.FieldEqualFold(FieldPrincipal, v)) -} - -// PrincipalContainsFold applies the ContainsFold predicate on the "principal" field. -func PrincipalContainsFold(v string) predicate.Process { - return predicate.Process(sql.FieldContainsFold(FieldPrincipal, v)) -} - -// HasHost applies the HasEdge predicate on the "host" edge. -func HasHost() predicate.Process { - return predicate.Process(func(s *sql.Selector) { - step := sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.Edge(sqlgraph.M2O, false, HostTable, HostColumn), - ) - sqlgraph.HasNeighbors(s, step) - }) -} - -// HasHostWith applies the HasEdge predicate on the "host" edge with a given conditions (other predicates). -func HasHostWith(preds ...predicate.Host) predicate.Process { - return predicate.Process(func(s *sql.Selector) { - step := newHostStep() - sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { - for _, p := range preds { - p(s) - } - }) - }) -} - -// HasTask applies the HasEdge predicate on the "task" edge. -func HasTask() predicate.Process { - return predicate.Process(func(s *sql.Selector) { - step := sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.Edge(sqlgraph.M2O, true, TaskTable, TaskColumn), - ) - sqlgraph.HasNeighbors(s, step) - }) -} - -// HasTaskWith applies the HasEdge predicate on the "task" edge with a given conditions (other predicates). -func HasTaskWith(preds ...predicate.Task) predicate.Process { - return predicate.Process(func(s *sql.Selector) { - step := newTaskStep() - sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { - for _, p := range preds { - p(s) - } - }) - }) -} - -// And groups predicates with the AND operator between them. -func And(predicates ...predicate.Process) predicate.Process { - return predicate.Process(sql.AndPredicates(predicates...)) -} - -// Or groups predicates with the OR operator between them. -func Or(predicates ...predicate.Process) predicate.Process { - return predicate.Process(sql.OrPredicates(predicates...)) -} - -// Not applies the not operator on the given predicate. -func Not(p predicate.Process) predicate.Process { - return predicate.Process(sql.NotPredicates(p)) -} diff --git a/tavern/internal/ent/process_create.go b/tavern/internal/ent/process_create.go deleted file mode 100644 index e913e2262..000000000 --- a/tavern/internal/ent/process_create.go +++ /dev/null @@ -1,758 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "context" - "errors" - "fmt" - "time" - - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" - "entgo.io/ent/schema/field" - "realm.pub/tavern/internal/ent/host" - "realm.pub/tavern/internal/ent/process" - "realm.pub/tavern/internal/ent/task" -) - -// ProcessCreate is the builder for creating a Process entity. -type ProcessCreate struct { - config - mutation *ProcessMutation - hooks []Hook - conflict []sql.ConflictOption -} - -// SetCreatedAt sets the "created_at" field. -func (pc *ProcessCreate) SetCreatedAt(t time.Time) *ProcessCreate { - pc.mutation.SetCreatedAt(t) - return pc -} - -// SetNillableCreatedAt sets the "created_at" field if the given value is not nil. -func (pc *ProcessCreate) SetNillableCreatedAt(t *time.Time) *ProcessCreate { - if t != nil { - pc.SetCreatedAt(*t) - } - return pc -} - -// SetLastModifiedAt sets the "last_modified_at" field. -func (pc *ProcessCreate) SetLastModifiedAt(t time.Time) *ProcessCreate { - pc.mutation.SetLastModifiedAt(t) - return pc -} - -// SetNillableLastModifiedAt sets the "last_modified_at" field if the given value is not nil. -func (pc *ProcessCreate) SetNillableLastModifiedAt(t *time.Time) *ProcessCreate { - if t != nil { - pc.SetLastModifiedAt(*t) - } - return pc -} - -// SetPid sets the "pid" field. -func (pc *ProcessCreate) SetPid(u uint64) *ProcessCreate { - pc.mutation.SetPid(u) - return pc -} - -// SetName sets the "name" field. -func (pc *ProcessCreate) SetName(s string) *ProcessCreate { - pc.mutation.SetName(s) - return pc -} - -// SetPrincipal sets the "principal" field. -func (pc *ProcessCreate) SetPrincipal(s string) *ProcessCreate { - pc.mutation.SetPrincipal(s) - return pc -} - -// SetHostID sets the "host" edge to the Host entity by ID. -func (pc *ProcessCreate) SetHostID(id int) *ProcessCreate { - pc.mutation.SetHostID(id) - return pc -} - -// SetHost sets the "host" edge to the Host entity. -func (pc *ProcessCreate) SetHost(h *Host) *ProcessCreate { - return pc.SetHostID(h.ID) -} - -// SetTaskID sets the "task" edge to the Task entity by ID. -func (pc *ProcessCreate) SetTaskID(id int) *ProcessCreate { - pc.mutation.SetTaskID(id) - return pc -} - -// SetTask sets the "task" edge to the Task entity. -func (pc *ProcessCreate) SetTask(t *Task) *ProcessCreate { - return pc.SetTaskID(t.ID) -} - -// Mutation returns the ProcessMutation object of the builder. -func (pc *ProcessCreate) Mutation() *ProcessMutation { - return pc.mutation -} - -// Save creates the Process in the database. -func (pc *ProcessCreate) Save(ctx context.Context) (*Process, error) { - pc.defaults() - return withHooks(ctx, pc.sqlSave, pc.mutation, pc.hooks) -} - -// SaveX calls Save and panics if Save returns an error. -func (pc *ProcessCreate) SaveX(ctx context.Context) *Process { - v, err := pc.Save(ctx) - if err != nil { - panic(err) - } - return v -} - -// Exec executes the query. -func (pc *ProcessCreate) Exec(ctx context.Context) error { - _, err := pc.Save(ctx) - return err -} - -// ExecX is like Exec, but panics if an error occurs. -func (pc *ProcessCreate) ExecX(ctx context.Context) { - if err := pc.Exec(ctx); err != nil { - panic(err) - } -} - -// defaults sets the default values of the builder before save. -func (pc *ProcessCreate) defaults() { - if _, ok := pc.mutation.CreatedAt(); !ok { - v := process.DefaultCreatedAt() - pc.mutation.SetCreatedAt(v) - } - if _, ok := pc.mutation.LastModifiedAt(); !ok { - v := process.DefaultLastModifiedAt() - pc.mutation.SetLastModifiedAt(v) - } -} - -// check runs all checks and user-defined validators on the builder. -func (pc *ProcessCreate) check() error { - if _, ok := pc.mutation.CreatedAt(); !ok { - return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "Process.created_at"`)} - } - if _, ok := pc.mutation.LastModifiedAt(); !ok { - return &ValidationError{Name: "last_modified_at", err: errors.New(`ent: missing required field "Process.last_modified_at"`)} - } - if _, ok := pc.mutation.Pid(); !ok { - return &ValidationError{Name: "pid", err: errors.New(`ent: missing required field "Process.pid"`)} - } - if _, ok := pc.mutation.Name(); !ok { - return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "Process.name"`)} - } - if _, ok := pc.mutation.Principal(); !ok { - return &ValidationError{Name: "principal", err: errors.New(`ent: missing required field "Process.principal"`)} - } - if v, ok := pc.mutation.Principal(); ok { - if err := process.PrincipalValidator(v); err != nil { - return &ValidationError{Name: "principal", err: fmt.Errorf(`ent: validator failed for field "Process.principal": %w`, err)} - } - } - if _, ok := pc.mutation.HostID(); !ok { - return &ValidationError{Name: "host", err: errors.New(`ent: missing required edge "Process.host"`)} - } - if _, ok := pc.mutation.TaskID(); !ok { - return &ValidationError{Name: "task", err: errors.New(`ent: missing required edge "Process.task"`)} - } - return nil -} - -func (pc *ProcessCreate) sqlSave(ctx context.Context) (*Process, error) { - if err := pc.check(); err != nil { - return nil, err - } - _node, _spec := pc.createSpec() - if err := sqlgraph.CreateNode(ctx, pc.driver, _spec); err != nil { - if sqlgraph.IsConstraintError(err) { - err = &ConstraintError{msg: err.Error(), wrap: err} - } - return nil, err - } - id := _spec.ID.Value.(int64) - _node.ID = int(id) - pc.mutation.id = &_node.ID - pc.mutation.done = true - return _node, nil -} - -func (pc *ProcessCreate) createSpec() (*Process, *sqlgraph.CreateSpec) { - var ( - _node = &Process{config: pc.config} - _spec = sqlgraph.NewCreateSpec(process.Table, sqlgraph.NewFieldSpec(process.FieldID, field.TypeInt)) - ) - _spec.OnConflict = pc.conflict - if value, ok := pc.mutation.CreatedAt(); ok { - _spec.SetField(process.FieldCreatedAt, field.TypeTime, value) - _node.CreatedAt = value - } - if value, ok := pc.mutation.LastModifiedAt(); ok { - _spec.SetField(process.FieldLastModifiedAt, field.TypeTime, value) - _node.LastModifiedAt = value - } - if value, ok := pc.mutation.Pid(); ok { - _spec.SetField(process.FieldPid, field.TypeUint64, value) - _node.Pid = value - } - if value, ok := pc.mutation.Name(); ok { - _spec.SetField(process.FieldName, field.TypeString, value) - _node.Name = value - } - if value, ok := pc.mutation.Principal(); ok { - _spec.SetField(process.FieldPrincipal, field.TypeString, value) - _node.Principal = value - } - if nodes := pc.mutation.HostIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2O, - Inverse: false, - Table: process.HostTable, - Columns: []string{process.HostColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(host.FieldID, field.TypeInt), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _node.process_host = &nodes[0] - _spec.Edges = append(_spec.Edges, edge) - } - if nodes := pc.mutation.TaskIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2O, - Inverse: true, - Table: process.TaskTable, - Columns: []string{process.TaskColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(task.FieldID, field.TypeInt), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _node.task_reported_processes = &nodes[0] - _spec.Edges = append(_spec.Edges, edge) - } - return _node, _spec -} - -// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause -// of the `INSERT` statement. For example: -// -// client.Process.Create(). -// SetCreatedAt(v). -// OnConflict( -// // Update the row with the new values -// // the was proposed for insertion. -// sql.ResolveWithNewValues(), -// ). -// // Override some of the fields with custom -// // update values. -// Update(func(u *ent.ProcessUpsert) { -// SetCreatedAt(v+v). -// }). -// Exec(ctx) -func (pc *ProcessCreate) OnConflict(opts ...sql.ConflictOption) *ProcessUpsertOne { - pc.conflict = opts - return &ProcessUpsertOne{ - create: pc, - } -} - -// OnConflictColumns calls `OnConflict` and configures the columns -// as conflict target. Using this option is equivalent to using: -// -// client.Process.Create(). -// OnConflict(sql.ConflictColumns(columns...)). -// Exec(ctx) -func (pc *ProcessCreate) OnConflictColumns(columns ...string) *ProcessUpsertOne { - pc.conflict = append(pc.conflict, sql.ConflictColumns(columns...)) - return &ProcessUpsertOne{ - create: pc, - } -} - -type ( - // ProcessUpsertOne is the builder for "upsert"-ing - // one Process node. - ProcessUpsertOne struct { - create *ProcessCreate - } - - // ProcessUpsert is the "OnConflict" setter. - ProcessUpsert struct { - *sql.UpdateSet - } -) - -// SetLastModifiedAt sets the "last_modified_at" field. -func (u *ProcessUpsert) SetLastModifiedAt(v time.Time) *ProcessUpsert { - u.Set(process.FieldLastModifiedAt, v) - return u -} - -// UpdateLastModifiedAt sets the "last_modified_at" field to the value that was provided on create. -func (u *ProcessUpsert) UpdateLastModifiedAt() *ProcessUpsert { - u.SetExcluded(process.FieldLastModifiedAt) - return u -} - -// SetPid sets the "pid" field. -func (u *ProcessUpsert) SetPid(v uint64) *ProcessUpsert { - u.Set(process.FieldPid, v) - return u -} - -// UpdatePid sets the "pid" field to the value that was provided on create. -func (u *ProcessUpsert) UpdatePid() *ProcessUpsert { - u.SetExcluded(process.FieldPid) - return u -} - -// AddPid adds v to the "pid" field. -func (u *ProcessUpsert) AddPid(v uint64) *ProcessUpsert { - u.Add(process.FieldPid, v) - return u -} - -// SetName sets the "name" field. -func (u *ProcessUpsert) SetName(v string) *ProcessUpsert { - u.Set(process.FieldName, v) - return u -} - -// UpdateName sets the "name" field to the value that was provided on create. -func (u *ProcessUpsert) UpdateName() *ProcessUpsert { - u.SetExcluded(process.FieldName) - return u -} - -// SetPrincipal sets the "principal" field. -func (u *ProcessUpsert) SetPrincipal(v string) *ProcessUpsert { - u.Set(process.FieldPrincipal, v) - return u -} - -// UpdatePrincipal sets the "principal" field to the value that was provided on create. -func (u *ProcessUpsert) UpdatePrincipal() *ProcessUpsert { - u.SetExcluded(process.FieldPrincipal) - return u -} - -// UpdateNewValues updates the mutable fields using the new values that were set on create. -// Using this option is equivalent to using: -// -// client.Process.Create(). -// OnConflict( -// sql.ResolveWithNewValues(), -// ). -// Exec(ctx) -func (u *ProcessUpsertOne) UpdateNewValues() *ProcessUpsertOne { - u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues()) - u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) { - if _, exists := u.create.mutation.CreatedAt(); exists { - s.SetIgnore(process.FieldCreatedAt) - } - })) - return u -} - -// Ignore sets each column to itself in case of conflict. -// Using this option is equivalent to using: -// -// client.Process.Create(). -// OnConflict(sql.ResolveWithIgnore()). -// Exec(ctx) -func (u *ProcessUpsertOne) Ignore() *ProcessUpsertOne { - u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore()) - return u -} - -// DoNothing configures the conflict_action to `DO NOTHING`. -// Supported only by SQLite and PostgreSQL. -func (u *ProcessUpsertOne) DoNothing() *ProcessUpsertOne { - u.create.conflict = append(u.create.conflict, sql.DoNothing()) - return u -} - -// Update allows overriding fields `UPDATE` values. See the ProcessCreate.OnConflict -// documentation for more info. -func (u *ProcessUpsertOne) Update(set func(*ProcessUpsert)) *ProcessUpsertOne { - u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { - set(&ProcessUpsert{UpdateSet: update}) - })) - return u -} - -// SetLastModifiedAt sets the "last_modified_at" field. -func (u *ProcessUpsertOne) SetLastModifiedAt(v time.Time) *ProcessUpsertOne { - return u.Update(func(s *ProcessUpsert) { - s.SetLastModifiedAt(v) - }) -} - -// UpdateLastModifiedAt sets the "last_modified_at" field to the value that was provided on create. -func (u *ProcessUpsertOne) UpdateLastModifiedAt() *ProcessUpsertOne { - return u.Update(func(s *ProcessUpsert) { - s.UpdateLastModifiedAt() - }) -} - -// SetPid sets the "pid" field. -func (u *ProcessUpsertOne) SetPid(v uint64) *ProcessUpsertOne { - return u.Update(func(s *ProcessUpsert) { - s.SetPid(v) - }) -} - -// AddPid adds v to the "pid" field. -func (u *ProcessUpsertOne) AddPid(v uint64) *ProcessUpsertOne { - return u.Update(func(s *ProcessUpsert) { - s.AddPid(v) - }) -} - -// UpdatePid sets the "pid" field to the value that was provided on create. -func (u *ProcessUpsertOne) UpdatePid() *ProcessUpsertOne { - return u.Update(func(s *ProcessUpsert) { - s.UpdatePid() - }) -} - -// SetName sets the "name" field. -func (u *ProcessUpsertOne) SetName(v string) *ProcessUpsertOne { - return u.Update(func(s *ProcessUpsert) { - s.SetName(v) - }) -} - -// UpdateName sets the "name" field to the value that was provided on create. -func (u *ProcessUpsertOne) UpdateName() *ProcessUpsertOne { - return u.Update(func(s *ProcessUpsert) { - s.UpdateName() - }) -} - -// SetPrincipal sets the "principal" field. -func (u *ProcessUpsertOne) SetPrincipal(v string) *ProcessUpsertOne { - return u.Update(func(s *ProcessUpsert) { - s.SetPrincipal(v) - }) -} - -// UpdatePrincipal sets the "principal" field to the value that was provided on create. -func (u *ProcessUpsertOne) UpdatePrincipal() *ProcessUpsertOne { - return u.Update(func(s *ProcessUpsert) { - s.UpdatePrincipal() - }) -} - -// Exec executes the query. -func (u *ProcessUpsertOne) Exec(ctx context.Context) error { - if len(u.create.conflict) == 0 { - return errors.New("ent: missing options for ProcessCreate.OnConflict") - } - return u.create.Exec(ctx) -} - -// ExecX is like Exec, but panics if an error occurs. -func (u *ProcessUpsertOne) ExecX(ctx context.Context) { - if err := u.create.Exec(ctx); err != nil { - panic(err) - } -} - -// Exec executes the UPSERT query and returns the inserted/updated ID. -func (u *ProcessUpsertOne) ID(ctx context.Context) (id int, err error) { - node, err := u.create.Save(ctx) - if err != nil { - return id, err - } - return node.ID, nil -} - -// IDX is like ID, but panics if an error occurs. -func (u *ProcessUpsertOne) IDX(ctx context.Context) int { - id, err := u.ID(ctx) - if err != nil { - panic(err) - } - return id -} - -// ProcessCreateBulk is the builder for creating many Process entities in bulk. -type ProcessCreateBulk struct { - config - err error - builders []*ProcessCreate - conflict []sql.ConflictOption -} - -// Save creates the Process entities in the database. -func (pcb *ProcessCreateBulk) Save(ctx context.Context) ([]*Process, error) { - if pcb.err != nil { - return nil, pcb.err - } - specs := make([]*sqlgraph.CreateSpec, len(pcb.builders)) - nodes := make([]*Process, len(pcb.builders)) - mutators := make([]Mutator, len(pcb.builders)) - for i := range pcb.builders { - func(i int, root context.Context) { - builder := pcb.builders[i] - builder.defaults() - var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { - mutation, ok := m.(*ProcessMutation) - if !ok { - return nil, fmt.Errorf("unexpected mutation type %T", m) - } - if err := builder.check(); err != nil { - return nil, err - } - builder.mutation = mutation - var err error - nodes[i], specs[i] = builder.createSpec() - if i < len(mutators)-1 { - _, err = mutators[i+1].Mutate(root, pcb.builders[i+1].mutation) - } else { - spec := &sqlgraph.BatchCreateSpec{Nodes: specs} - spec.OnConflict = pcb.conflict - // Invoke the actual operation on the latest mutation in the chain. - if err = sqlgraph.BatchCreate(ctx, pcb.driver, spec); err != nil { - if sqlgraph.IsConstraintError(err) { - err = &ConstraintError{msg: err.Error(), wrap: err} - } - } - } - if err != nil { - return nil, err - } - mutation.id = &nodes[i].ID - if specs[i].ID.Value != nil { - id := specs[i].ID.Value.(int64) - nodes[i].ID = int(id) - } - mutation.done = true - return nodes[i], nil - }) - for i := len(builder.hooks) - 1; i >= 0; i-- { - mut = builder.hooks[i](mut) - } - mutators[i] = mut - }(i, ctx) - } - if len(mutators) > 0 { - if _, err := mutators[0].Mutate(ctx, pcb.builders[0].mutation); err != nil { - return nil, err - } - } - return nodes, nil -} - -// SaveX is like Save, but panics if an error occurs. -func (pcb *ProcessCreateBulk) SaveX(ctx context.Context) []*Process { - v, err := pcb.Save(ctx) - if err != nil { - panic(err) - } - return v -} - -// Exec executes the query. -func (pcb *ProcessCreateBulk) Exec(ctx context.Context) error { - _, err := pcb.Save(ctx) - return err -} - -// ExecX is like Exec, but panics if an error occurs. -func (pcb *ProcessCreateBulk) ExecX(ctx context.Context) { - if err := pcb.Exec(ctx); err != nil { - panic(err) - } -} - -// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause -// of the `INSERT` statement. For example: -// -// client.Process.CreateBulk(builders...). -// OnConflict( -// // Update the row with the new values -// // the was proposed for insertion. -// sql.ResolveWithNewValues(), -// ). -// // Override some of the fields with custom -// // update values. -// Update(func(u *ent.ProcessUpsert) { -// SetCreatedAt(v+v). -// }). -// Exec(ctx) -func (pcb *ProcessCreateBulk) OnConflict(opts ...sql.ConflictOption) *ProcessUpsertBulk { - pcb.conflict = opts - return &ProcessUpsertBulk{ - create: pcb, - } -} - -// OnConflictColumns calls `OnConflict` and configures the columns -// as conflict target. Using this option is equivalent to using: -// -// client.Process.Create(). -// OnConflict(sql.ConflictColumns(columns...)). -// Exec(ctx) -func (pcb *ProcessCreateBulk) OnConflictColumns(columns ...string) *ProcessUpsertBulk { - pcb.conflict = append(pcb.conflict, sql.ConflictColumns(columns...)) - return &ProcessUpsertBulk{ - create: pcb, - } -} - -// ProcessUpsertBulk is the builder for "upsert"-ing -// a bulk of Process nodes. -type ProcessUpsertBulk struct { - create *ProcessCreateBulk -} - -// UpdateNewValues updates the mutable fields using the new values that -// were set on create. Using this option is equivalent to using: -// -// client.Process.Create(). -// OnConflict( -// sql.ResolveWithNewValues(), -// ). -// Exec(ctx) -func (u *ProcessUpsertBulk) UpdateNewValues() *ProcessUpsertBulk { - u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues()) - u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) { - for _, b := range u.create.builders { - if _, exists := b.mutation.CreatedAt(); exists { - s.SetIgnore(process.FieldCreatedAt) - } - } - })) - return u -} - -// Ignore sets each column to itself in case of conflict. -// Using this option is equivalent to using: -// -// client.Process.Create(). -// OnConflict(sql.ResolveWithIgnore()). -// Exec(ctx) -func (u *ProcessUpsertBulk) Ignore() *ProcessUpsertBulk { - u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore()) - return u -} - -// DoNothing configures the conflict_action to `DO NOTHING`. -// Supported only by SQLite and PostgreSQL. -func (u *ProcessUpsertBulk) DoNothing() *ProcessUpsertBulk { - u.create.conflict = append(u.create.conflict, sql.DoNothing()) - return u -} - -// Update allows overriding fields `UPDATE` values. See the ProcessCreateBulk.OnConflict -// documentation for more info. -func (u *ProcessUpsertBulk) Update(set func(*ProcessUpsert)) *ProcessUpsertBulk { - u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { - set(&ProcessUpsert{UpdateSet: update}) - })) - return u -} - -// SetLastModifiedAt sets the "last_modified_at" field. -func (u *ProcessUpsertBulk) SetLastModifiedAt(v time.Time) *ProcessUpsertBulk { - return u.Update(func(s *ProcessUpsert) { - s.SetLastModifiedAt(v) - }) -} - -// UpdateLastModifiedAt sets the "last_modified_at" field to the value that was provided on create. -func (u *ProcessUpsertBulk) UpdateLastModifiedAt() *ProcessUpsertBulk { - return u.Update(func(s *ProcessUpsert) { - s.UpdateLastModifiedAt() - }) -} - -// SetPid sets the "pid" field. -func (u *ProcessUpsertBulk) SetPid(v uint64) *ProcessUpsertBulk { - return u.Update(func(s *ProcessUpsert) { - s.SetPid(v) - }) -} - -// AddPid adds v to the "pid" field. -func (u *ProcessUpsertBulk) AddPid(v uint64) *ProcessUpsertBulk { - return u.Update(func(s *ProcessUpsert) { - s.AddPid(v) - }) -} - -// UpdatePid sets the "pid" field to the value that was provided on create. -func (u *ProcessUpsertBulk) UpdatePid() *ProcessUpsertBulk { - return u.Update(func(s *ProcessUpsert) { - s.UpdatePid() - }) -} - -// SetName sets the "name" field. -func (u *ProcessUpsertBulk) SetName(v string) *ProcessUpsertBulk { - return u.Update(func(s *ProcessUpsert) { - s.SetName(v) - }) -} - -// UpdateName sets the "name" field to the value that was provided on create. -func (u *ProcessUpsertBulk) UpdateName() *ProcessUpsertBulk { - return u.Update(func(s *ProcessUpsert) { - s.UpdateName() - }) -} - -// SetPrincipal sets the "principal" field. -func (u *ProcessUpsertBulk) SetPrincipal(v string) *ProcessUpsertBulk { - return u.Update(func(s *ProcessUpsert) { - s.SetPrincipal(v) - }) -} - -// UpdatePrincipal sets the "principal" field to the value that was provided on create. -func (u *ProcessUpsertBulk) UpdatePrincipal() *ProcessUpsertBulk { - return u.Update(func(s *ProcessUpsert) { - s.UpdatePrincipal() - }) -} - -// Exec executes the query. -func (u *ProcessUpsertBulk) Exec(ctx context.Context) error { - if u.create.err != nil { - return u.create.err - } - for i, b := range u.create.builders { - if len(b.conflict) != 0 { - return fmt.Errorf("ent: OnConflict was set for builder %d. Set it on the ProcessCreateBulk instead", i) - } - } - if len(u.create.conflict) == 0 { - return errors.New("ent: missing options for ProcessCreateBulk.OnConflict") - } - return u.create.Exec(ctx) -} - -// ExecX is like Exec, but panics if an error occurs. -func (u *ProcessUpsertBulk) ExecX(ctx context.Context) { - if err := u.create.Exec(ctx); err != nil { - panic(err) - } -} diff --git a/tavern/internal/ent/process_delete.go b/tavern/internal/ent/process_delete.go deleted file mode 100644 index b2c7bd369..000000000 --- a/tavern/internal/ent/process_delete.go +++ /dev/null @@ -1,88 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "context" - - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" - "entgo.io/ent/schema/field" - "realm.pub/tavern/internal/ent/predicate" - "realm.pub/tavern/internal/ent/process" -) - -// ProcessDelete is the builder for deleting a Process entity. -type ProcessDelete struct { - config - hooks []Hook - mutation *ProcessMutation -} - -// Where appends a list predicates to the ProcessDelete builder. -func (pd *ProcessDelete) Where(ps ...predicate.Process) *ProcessDelete { - pd.mutation.Where(ps...) - return pd -} - -// Exec executes the deletion query and returns how many vertices were deleted. -func (pd *ProcessDelete) Exec(ctx context.Context) (int, error) { - return withHooks(ctx, pd.sqlExec, pd.mutation, pd.hooks) -} - -// ExecX is like Exec, but panics if an error occurs. -func (pd *ProcessDelete) ExecX(ctx context.Context) int { - n, err := pd.Exec(ctx) - if err != nil { - panic(err) - } - return n -} - -func (pd *ProcessDelete) sqlExec(ctx context.Context) (int, error) { - _spec := sqlgraph.NewDeleteSpec(process.Table, sqlgraph.NewFieldSpec(process.FieldID, field.TypeInt)) - if ps := pd.mutation.predicates; len(ps) > 0 { - _spec.Predicate = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - affected, err := sqlgraph.DeleteNodes(ctx, pd.driver, _spec) - if err != nil && sqlgraph.IsConstraintError(err) { - err = &ConstraintError{msg: err.Error(), wrap: err} - } - pd.mutation.done = true - return affected, err -} - -// ProcessDeleteOne is the builder for deleting a single Process entity. -type ProcessDeleteOne struct { - pd *ProcessDelete -} - -// Where appends a list predicates to the ProcessDelete builder. -func (pdo *ProcessDeleteOne) Where(ps ...predicate.Process) *ProcessDeleteOne { - pdo.pd.mutation.Where(ps...) - return pdo -} - -// Exec executes the deletion query. -func (pdo *ProcessDeleteOne) Exec(ctx context.Context) error { - n, err := pdo.pd.Exec(ctx) - switch { - case err != nil: - return err - case n == 0: - return &NotFoundError{process.Label} - default: - return nil - } -} - -// ExecX is like Exec, but panics if an error occurs. -func (pdo *ProcessDeleteOne) ExecX(ctx context.Context) { - if err := pdo.Exec(ctx); err != nil { - panic(err) - } -} diff --git a/tavern/internal/ent/process_query.go b/tavern/internal/ent/process_query.go deleted file mode 100644 index dbcfdc415..000000000 --- a/tavern/internal/ent/process_query.go +++ /dev/null @@ -1,701 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "context" - "fmt" - "math" - - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" - "entgo.io/ent/schema/field" - "realm.pub/tavern/internal/ent/host" - "realm.pub/tavern/internal/ent/predicate" - "realm.pub/tavern/internal/ent/process" - "realm.pub/tavern/internal/ent/task" -) - -// ProcessQuery is the builder for querying Process entities. -type ProcessQuery struct { - config - ctx *QueryContext - order []process.OrderOption - inters []Interceptor - predicates []predicate.Process - withHost *HostQuery - withTask *TaskQuery - withFKs bool - modifiers []func(*sql.Selector) - loadTotal []func(context.Context, []*Process) error - // intermediate query (i.e. traversal path). - sql *sql.Selector - path func(context.Context) (*sql.Selector, error) -} - -// Where adds a new predicate for the ProcessQuery builder. -func (pq *ProcessQuery) Where(ps ...predicate.Process) *ProcessQuery { - pq.predicates = append(pq.predicates, ps...) - return pq -} - -// Limit the number of records to be returned by this query. -func (pq *ProcessQuery) Limit(limit int) *ProcessQuery { - pq.ctx.Limit = &limit - return pq -} - -// Offset to start from. -func (pq *ProcessQuery) Offset(offset int) *ProcessQuery { - pq.ctx.Offset = &offset - return pq -} - -// Unique configures the query builder to filter duplicate records on query. -// By default, unique is set to true, and can be disabled using this method. -func (pq *ProcessQuery) Unique(unique bool) *ProcessQuery { - pq.ctx.Unique = &unique - return pq -} - -// Order specifies how the records should be ordered. -func (pq *ProcessQuery) Order(o ...process.OrderOption) *ProcessQuery { - pq.order = append(pq.order, o...) - return pq -} - -// QueryHost chains the current query on the "host" edge. -func (pq *ProcessQuery) QueryHost() *HostQuery { - query := (&HostClient{config: pq.config}).Query() - query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { - if err := pq.prepareQuery(ctx); err != nil { - return nil, err - } - selector := pq.sqlQuery(ctx) - if err := selector.Err(); err != nil { - return nil, err - } - step := sqlgraph.NewStep( - sqlgraph.From(process.Table, process.FieldID, selector), - sqlgraph.To(host.Table, host.FieldID), - sqlgraph.Edge(sqlgraph.M2O, false, process.HostTable, process.HostColumn), - ) - fromU = sqlgraph.SetNeighbors(pq.driver.Dialect(), step) - return fromU, nil - } - return query -} - -// QueryTask chains the current query on the "task" edge. -func (pq *ProcessQuery) QueryTask() *TaskQuery { - query := (&TaskClient{config: pq.config}).Query() - query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { - if err := pq.prepareQuery(ctx); err != nil { - return nil, err - } - selector := pq.sqlQuery(ctx) - if err := selector.Err(); err != nil { - return nil, err - } - step := sqlgraph.NewStep( - sqlgraph.From(process.Table, process.FieldID, selector), - sqlgraph.To(task.Table, task.FieldID), - sqlgraph.Edge(sqlgraph.M2O, true, process.TaskTable, process.TaskColumn), - ) - fromU = sqlgraph.SetNeighbors(pq.driver.Dialect(), step) - return fromU, nil - } - return query -} - -// First returns the first Process entity from the query. -// Returns a *NotFoundError when no Process was found. -func (pq *ProcessQuery) First(ctx context.Context) (*Process, error) { - nodes, err := pq.Limit(1).All(setContextOp(ctx, pq.ctx, "First")) - if err != nil { - return nil, err - } - if len(nodes) == 0 { - return nil, &NotFoundError{process.Label} - } - return nodes[0], nil -} - -// FirstX is like First, but panics if an error occurs. -func (pq *ProcessQuery) FirstX(ctx context.Context) *Process { - node, err := pq.First(ctx) - if err != nil && !IsNotFound(err) { - panic(err) - } - return node -} - -// FirstID returns the first Process ID from the query. -// Returns a *NotFoundError when no Process ID was found. -func (pq *ProcessQuery) FirstID(ctx context.Context) (id int, err error) { - var ids []int - if ids, err = pq.Limit(1).IDs(setContextOp(ctx, pq.ctx, "FirstID")); err != nil { - return - } - if len(ids) == 0 { - err = &NotFoundError{process.Label} - return - } - return ids[0], nil -} - -// FirstIDX is like FirstID, but panics if an error occurs. -func (pq *ProcessQuery) FirstIDX(ctx context.Context) int { - id, err := pq.FirstID(ctx) - if err != nil && !IsNotFound(err) { - panic(err) - } - return id -} - -// Only returns a single Process entity found by the query, ensuring it only returns one. -// Returns a *NotSingularError when more than one Process entity is found. -// Returns a *NotFoundError when no Process entities are found. -func (pq *ProcessQuery) Only(ctx context.Context) (*Process, error) { - nodes, err := pq.Limit(2).All(setContextOp(ctx, pq.ctx, "Only")) - if err != nil { - return nil, err - } - switch len(nodes) { - case 1: - return nodes[0], nil - case 0: - return nil, &NotFoundError{process.Label} - default: - return nil, &NotSingularError{process.Label} - } -} - -// OnlyX is like Only, but panics if an error occurs. -func (pq *ProcessQuery) OnlyX(ctx context.Context) *Process { - node, err := pq.Only(ctx) - if err != nil { - panic(err) - } - return node -} - -// OnlyID is like Only, but returns the only Process ID in the query. -// Returns a *NotSingularError when more than one Process ID is found. -// Returns a *NotFoundError when no entities are found. -func (pq *ProcessQuery) OnlyID(ctx context.Context) (id int, err error) { - var ids []int - if ids, err = pq.Limit(2).IDs(setContextOp(ctx, pq.ctx, "OnlyID")); err != nil { - return - } - switch len(ids) { - case 1: - id = ids[0] - case 0: - err = &NotFoundError{process.Label} - default: - err = &NotSingularError{process.Label} - } - return -} - -// OnlyIDX is like OnlyID, but panics if an error occurs. -func (pq *ProcessQuery) OnlyIDX(ctx context.Context) int { - id, err := pq.OnlyID(ctx) - if err != nil { - panic(err) - } - return id -} - -// All executes the query and returns a list of Processes. -func (pq *ProcessQuery) All(ctx context.Context) ([]*Process, error) { - ctx = setContextOp(ctx, pq.ctx, "All") - if err := pq.prepareQuery(ctx); err != nil { - return nil, err - } - qr := querierAll[[]*Process, *ProcessQuery]() - return withInterceptors[[]*Process](ctx, pq, qr, pq.inters) -} - -// AllX is like All, but panics if an error occurs. -func (pq *ProcessQuery) AllX(ctx context.Context) []*Process { - nodes, err := pq.All(ctx) - if err != nil { - panic(err) - } - return nodes -} - -// IDs executes the query and returns a list of Process IDs. -func (pq *ProcessQuery) IDs(ctx context.Context) (ids []int, err error) { - if pq.ctx.Unique == nil && pq.path != nil { - pq.Unique(true) - } - ctx = setContextOp(ctx, pq.ctx, "IDs") - if err = pq.Select(process.FieldID).Scan(ctx, &ids); err != nil { - return nil, err - } - return ids, nil -} - -// IDsX is like IDs, but panics if an error occurs. -func (pq *ProcessQuery) IDsX(ctx context.Context) []int { - ids, err := pq.IDs(ctx) - if err != nil { - panic(err) - } - return ids -} - -// Count returns the count of the given query. -func (pq *ProcessQuery) Count(ctx context.Context) (int, error) { - ctx = setContextOp(ctx, pq.ctx, "Count") - if err := pq.prepareQuery(ctx); err != nil { - return 0, err - } - return withInterceptors[int](ctx, pq, querierCount[*ProcessQuery](), pq.inters) -} - -// CountX is like Count, but panics if an error occurs. -func (pq *ProcessQuery) CountX(ctx context.Context) int { - count, err := pq.Count(ctx) - if err != nil { - panic(err) - } - return count -} - -// Exist returns true if the query has elements in the graph. -func (pq *ProcessQuery) Exist(ctx context.Context) (bool, error) { - ctx = setContextOp(ctx, pq.ctx, "Exist") - switch _, err := pq.FirstID(ctx); { - case IsNotFound(err): - return false, nil - case err != nil: - return false, fmt.Errorf("ent: check existence: %w", err) - default: - return true, nil - } -} - -// ExistX is like Exist, but panics if an error occurs. -func (pq *ProcessQuery) ExistX(ctx context.Context) bool { - exist, err := pq.Exist(ctx) - if err != nil { - panic(err) - } - return exist -} - -// Clone returns a duplicate of the ProcessQuery builder, including all associated steps. It can be -// used to prepare common query builders and use them differently after the clone is made. -func (pq *ProcessQuery) Clone() *ProcessQuery { - if pq == nil { - return nil - } - return &ProcessQuery{ - config: pq.config, - ctx: pq.ctx.Clone(), - order: append([]process.OrderOption{}, pq.order...), - inters: append([]Interceptor{}, pq.inters...), - predicates: append([]predicate.Process{}, pq.predicates...), - withHost: pq.withHost.Clone(), - withTask: pq.withTask.Clone(), - // clone intermediate query. - sql: pq.sql.Clone(), - path: pq.path, - } -} - -// WithHost tells the query-builder to eager-load the nodes that are connected to -// the "host" edge. The optional arguments are used to configure the query builder of the edge. -func (pq *ProcessQuery) WithHost(opts ...func(*HostQuery)) *ProcessQuery { - query := (&HostClient{config: pq.config}).Query() - for _, opt := range opts { - opt(query) - } - pq.withHost = query - return pq -} - -// WithTask tells the query-builder to eager-load the nodes that are connected to -// the "task" edge. The optional arguments are used to configure the query builder of the edge. -func (pq *ProcessQuery) WithTask(opts ...func(*TaskQuery)) *ProcessQuery { - query := (&TaskClient{config: pq.config}).Query() - for _, opt := range opts { - opt(query) - } - pq.withTask = query - return pq -} - -// GroupBy is used to group vertices by one or more fields/columns. -// It is often used with aggregate functions, like: count, max, mean, min, sum. -// -// Example: -// -// var v []struct { -// CreatedAt time.Time `json:"created_at,omitempty"` -// Count int `json:"count,omitempty"` -// } -// -// client.Process.Query(). -// GroupBy(process.FieldCreatedAt). -// Aggregate(ent.Count()). -// Scan(ctx, &v) -func (pq *ProcessQuery) GroupBy(field string, fields ...string) *ProcessGroupBy { - pq.ctx.Fields = append([]string{field}, fields...) - grbuild := &ProcessGroupBy{build: pq} - grbuild.flds = &pq.ctx.Fields - grbuild.label = process.Label - grbuild.scan = grbuild.Scan - return grbuild -} - -// Select allows the selection one or more fields/columns for the given query, -// instead of selecting all fields in the entity. -// -// Example: -// -// var v []struct { -// CreatedAt time.Time `json:"created_at,omitempty"` -// } -// -// client.Process.Query(). -// Select(process.FieldCreatedAt). -// Scan(ctx, &v) -func (pq *ProcessQuery) Select(fields ...string) *ProcessSelect { - pq.ctx.Fields = append(pq.ctx.Fields, fields...) - sbuild := &ProcessSelect{ProcessQuery: pq} - sbuild.label = process.Label - sbuild.flds, sbuild.scan = &pq.ctx.Fields, sbuild.Scan - return sbuild -} - -// Aggregate returns a ProcessSelect configured with the given aggregations. -func (pq *ProcessQuery) Aggregate(fns ...AggregateFunc) *ProcessSelect { - return pq.Select().Aggregate(fns...) -} - -func (pq *ProcessQuery) prepareQuery(ctx context.Context) error { - for _, inter := range pq.inters { - if inter == nil { - return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)") - } - if trv, ok := inter.(Traverser); ok { - if err := trv.Traverse(ctx, pq); err != nil { - return err - } - } - } - for _, f := range pq.ctx.Fields { - if !process.ValidColumn(f) { - return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} - } - } - if pq.path != nil { - prev, err := pq.path(ctx) - if err != nil { - return err - } - pq.sql = prev - } - return nil -} - -func (pq *ProcessQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Process, error) { - var ( - nodes = []*Process{} - withFKs = pq.withFKs - _spec = pq.querySpec() - loadedTypes = [2]bool{ - pq.withHost != nil, - pq.withTask != nil, - } - ) - if pq.withHost != nil || pq.withTask != nil { - withFKs = true - } - if withFKs { - _spec.Node.Columns = append(_spec.Node.Columns, process.ForeignKeys...) - } - _spec.ScanValues = func(columns []string) ([]any, error) { - return (*Process).scanValues(nil, columns) - } - _spec.Assign = func(columns []string, values []any) error { - node := &Process{config: pq.config} - nodes = append(nodes, node) - node.Edges.loadedTypes = loadedTypes - return node.assignValues(columns, values) - } - if len(pq.modifiers) > 0 { - _spec.Modifiers = pq.modifiers - } - for i := range hooks { - hooks[i](ctx, _spec) - } - if err := sqlgraph.QueryNodes(ctx, pq.driver, _spec); err != nil { - return nil, err - } - if len(nodes) == 0 { - return nodes, nil - } - if query := pq.withHost; query != nil { - if err := pq.loadHost(ctx, query, nodes, nil, - func(n *Process, e *Host) { n.Edges.Host = e }); err != nil { - return nil, err - } - } - if query := pq.withTask; query != nil { - if err := pq.loadTask(ctx, query, nodes, nil, - func(n *Process, e *Task) { n.Edges.Task = e }); err != nil { - return nil, err - } - } - for i := range pq.loadTotal { - if err := pq.loadTotal[i](ctx, nodes); err != nil { - return nil, err - } - } - return nodes, nil -} - -func (pq *ProcessQuery) loadHost(ctx context.Context, query *HostQuery, nodes []*Process, init func(*Process), assign func(*Process, *Host)) error { - ids := make([]int, 0, len(nodes)) - nodeids := make(map[int][]*Process) - for i := range nodes { - if nodes[i].process_host == nil { - continue - } - fk := *nodes[i].process_host - if _, ok := nodeids[fk]; !ok { - ids = append(ids, fk) - } - nodeids[fk] = append(nodeids[fk], nodes[i]) - } - if len(ids) == 0 { - return nil - } - query.Where(host.IDIn(ids...)) - neighbors, err := query.All(ctx) - if err != nil { - return err - } - for _, n := range neighbors { - nodes, ok := nodeids[n.ID] - if !ok { - return fmt.Errorf(`unexpected foreign-key "process_host" returned %v`, n.ID) - } - for i := range nodes { - assign(nodes[i], n) - } - } - return nil -} -func (pq *ProcessQuery) loadTask(ctx context.Context, query *TaskQuery, nodes []*Process, init func(*Process), assign func(*Process, *Task)) error { - ids := make([]int, 0, len(nodes)) - nodeids := make(map[int][]*Process) - for i := range nodes { - if nodes[i].task_reported_processes == nil { - continue - } - fk := *nodes[i].task_reported_processes - if _, ok := nodeids[fk]; !ok { - ids = append(ids, fk) - } - nodeids[fk] = append(nodeids[fk], nodes[i]) - } - if len(ids) == 0 { - return nil - } - query.Where(task.IDIn(ids...)) - neighbors, err := query.All(ctx) - if err != nil { - return err - } - for _, n := range neighbors { - nodes, ok := nodeids[n.ID] - if !ok { - return fmt.Errorf(`unexpected foreign-key "task_reported_processes" returned %v`, n.ID) - } - for i := range nodes { - assign(nodes[i], n) - } - } - return nil -} - -func (pq *ProcessQuery) sqlCount(ctx context.Context) (int, error) { - _spec := pq.querySpec() - if len(pq.modifiers) > 0 { - _spec.Modifiers = pq.modifiers - } - _spec.Node.Columns = pq.ctx.Fields - if len(pq.ctx.Fields) > 0 { - _spec.Unique = pq.ctx.Unique != nil && *pq.ctx.Unique - } - return sqlgraph.CountNodes(ctx, pq.driver, _spec) -} - -func (pq *ProcessQuery) querySpec() *sqlgraph.QuerySpec { - _spec := sqlgraph.NewQuerySpec(process.Table, process.Columns, sqlgraph.NewFieldSpec(process.FieldID, field.TypeInt)) - _spec.From = pq.sql - if unique := pq.ctx.Unique; unique != nil { - _spec.Unique = *unique - } else if pq.path != nil { - _spec.Unique = true - } - if fields := pq.ctx.Fields; len(fields) > 0 { - _spec.Node.Columns = make([]string, 0, len(fields)) - _spec.Node.Columns = append(_spec.Node.Columns, process.FieldID) - for i := range fields { - if fields[i] != process.FieldID { - _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) - } - } - } - if ps := pq.predicates; len(ps) > 0 { - _spec.Predicate = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - if limit := pq.ctx.Limit; limit != nil { - _spec.Limit = *limit - } - if offset := pq.ctx.Offset; offset != nil { - _spec.Offset = *offset - } - if ps := pq.order; len(ps) > 0 { - _spec.Order = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - return _spec -} - -func (pq *ProcessQuery) sqlQuery(ctx context.Context) *sql.Selector { - builder := sql.Dialect(pq.driver.Dialect()) - t1 := builder.Table(process.Table) - columns := pq.ctx.Fields - if len(columns) == 0 { - columns = process.Columns - } - selector := builder.Select(t1.Columns(columns...)...).From(t1) - if pq.sql != nil { - selector = pq.sql - selector.Select(selector.Columns(columns...)...) - } - if pq.ctx.Unique != nil && *pq.ctx.Unique { - selector.Distinct() - } - for _, p := range pq.predicates { - p(selector) - } - for _, p := range pq.order { - p(selector) - } - if offset := pq.ctx.Offset; offset != nil { - // limit is mandatory for offset clause. We start - // with default value, and override it below if needed. - selector.Offset(*offset).Limit(math.MaxInt32) - } - if limit := pq.ctx.Limit; limit != nil { - selector.Limit(*limit) - } - return selector -} - -// ProcessGroupBy is the group-by builder for Process entities. -type ProcessGroupBy struct { - selector - build *ProcessQuery -} - -// Aggregate adds the given aggregation functions to the group-by query. -func (pgb *ProcessGroupBy) Aggregate(fns ...AggregateFunc) *ProcessGroupBy { - pgb.fns = append(pgb.fns, fns...) - return pgb -} - -// Scan applies the selector query and scans the result into the given value. -func (pgb *ProcessGroupBy) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, pgb.build.ctx, "GroupBy") - if err := pgb.build.prepareQuery(ctx); err != nil { - return err - } - return scanWithInterceptors[*ProcessQuery, *ProcessGroupBy](ctx, pgb.build, pgb, pgb.build.inters, v) -} - -func (pgb *ProcessGroupBy) sqlScan(ctx context.Context, root *ProcessQuery, v any) error { - selector := root.sqlQuery(ctx).Select() - aggregation := make([]string, 0, len(pgb.fns)) - for _, fn := range pgb.fns { - aggregation = append(aggregation, fn(selector)) - } - if len(selector.SelectedColumns()) == 0 { - columns := make([]string, 0, len(*pgb.flds)+len(pgb.fns)) - for _, f := range *pgb.flds { - columns = append(columns, selector.C(f)) - } - columns = append(columns, aggregation...) - selector.Select(columns...) - } - selector.GroupBy(selector.Columns(*pgb.flds...)...) - if err := selector.Err(); err != nil { - return err - } - rows := &sql.Rows{} - query, args := selector.Query() - if err := pgb.build.driver.Query(ctx, query, args, rows); err != nil { - return err - } - defer rows.Close() - return sql.ScanSlice(rows, v) -} - -// ProcessSelect is the builder for selecting fields of Process entities. -type ProcessSelect struct { - *ProcessQuery - selector -} - -// Aggregate adds the given aggregation functions to the selector query. -func (ps *ProcessSelect) Aggregate(fns ...AggregateFunc) *ProcessSelect { - ps.fns = append(ps.fns, fns...) - return ps -} - -// Scan applies the selector query and scans the result into the given value. -func (ps *ProcessSelect) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, ps.ctx, "Select") - if err := ps.prepareQuery(ctx); err != nil { - return err - } - return scanWithInterceptors[*ProcessQuery, *ProcessSelect](ctx, ps.ProcessQuery, ps, ps.inters, v) -} - -func (ps *ProcessSelect) sqlScan(ctx context.Context, root *ProcessQuery, v any) error { - selector := root.sqlQuery(ctx) - aggregation := make([]string, 0, len(ps.fns)) - for _, fn := range ps.fns { - aggregation = append(aggregation, fn(selector)) - } - switch n := len(*ps.selector.flds); { - case n == 0 && len(aggregation) > 0: - selector.Select(aggregation...) - case n != 0 && len(aggregation) > 0: - selector.AppendSelect(aggregation...) - } - rows := &sql.Rows{} - query, args := selector.Query() - if err := ps.driver.Query(ctx, query, args, rows); err != nil { - return err - } - defer rows.Close() - return sql.ScanSlice(rows, v) -} diff --git a/tavern/internal/ent/process_update.go b/tavern/internal/ent/process_update.go deleted file mode 100644 index 3f9c7dcb0..000000000 --- a/tavern/internal/ent/process_update.go +++ /dev/null @@ -1,510 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "context" - "errors" - "fmt" - "time" - - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" - "entgo.io/ent/schema/field" - "realm.pub/tavern/internal/ent/host" - "realm.pub/tavern/internal/ent/predicate" - "realm.pub/tavern/internal/ent/process" - "realm.pub/tavern/internal/ent/task" -) - -// ProcessUpdate is the builder for updating Process entities. -type ProcessUpdate struct { - config - hooks []Hook - mutation *ProcessMutation -} - -// Where appends a list predicates to the ProcessUpdate builder. -func (pu *ProcessUpdate) Where(ps ...predicate.Process) *ProcessUpdate { - pu.mutation.Where(ps...) - return pu -} - -// SetLastModifiedAt sets the "last_modified_at" field. -func (pu *ProcessUpdate) SetLastModifiedAt(t time.Time) *ProcessUpdate { - pu.mutation.SetLastModifiedAt(t) - return pu -} - -// SetPid sets the "pid" field. -func (pu *ProcessUpdate) SetPid(u uint64) *ProcessUpdate { - pu.mutation.ResetPid() - pu.mutation.SetPid(u) - return pu -} - -// AddPid adds u to the "pid" field. -func (pu *ProcessUpdate) AddPid(u int64) *ProcessUpdate { - pu.mutation.AddPid(u) - return pu -} - -// SetName sets the "name" field. -func (pu *ProcessUpdate) SetName(s string) *ProcessUpdate { - pu.mutation.SetName(s) - return pu -} - -// SetPrincipal sets the "principal" field. -func (pu *ProcessUpdate) SetPrincipal(s string) *ProcessUpdate { - pu.mutation.SetPrincipal(s) - return pu -} - -// SetHostID sets the "host" edge to the Host entity by ID. -func (pu *ProcessUpdate) SetHostID(id int) *ProcessUpdate { - pu.mutation.SetHostID(id) - return pu -} - -// SetHost sets the "host" edge to the Host entity. -func (pu *ProcessUpdate) SetHost(h *Host) *ProcessUpdate { - return pu.SetHostID(h.ID) -} - -// SetTaskID sets the "task" edge to the Task entity by ID. -func (pu *ProcessUpdate) SetTaskID(id int) *ProcessUpdate { - pu.mutation.SetTaskID(id) - return pu -} - -// SetTask sets the "task" edge to the Task entity. -func (pu *ProcessUpdate) SetTask(t *Task) *ProcessUpdate { - return pu.SetTaskID(t.ID) -} - -// Mutation returns the ProcessMutation object of the builder. -func (pu *ProcessUpdate) Mutation() *ProcessMutation { - return pu.mutation -} - -// ClearHost clears the "host" edge to the Host entity. -func (pu *ProcessUpdate) ClearHost() *ProcessUpdate { - pu.mutation.ClearHost() - return pu -} - -// ClearTask clears the "task" edge to the Task entity. -func (pu *ProcessUpdate) ClearTask() *ProcessUpdate { - pu.mutation.ClearTask() - return pu -} - -// Save executes the query and returns the number of nodes affected by the update operation. -func (pu *ProcessUpdate) Save(ctx context.Context) (int, error) { - pu.defaults() - return withHooks(ctx, pu.sqlSave, pu.mutation, pu.hooks) -} - -// SaveX is like Save, but panics if an error occurs. -func (pu *ProcessUpdate) SaveX(ctx context.Context) int { - affected, err := pu.Save(ctx) - if err != nil { - panic(err) - } - return affected -} - -// Exec executes the query. -func (pu *ProcessUpdate) Exec(ctx context.Context) error { - _, err := pu.Save(ctx) - return err -} - -// ExecX is like Exec, but panics if an error occurs. -func (pu *ProcessUpdate) ExecX(ctx context.Context) { - if err := pu.Exec(ctx); err != nil { - panic(err) - } -} - -// defaults sets the default values of the builder before save. -func (pu *ProcessUpdate) defaults() { - if _, ok := pu.mutation.LastModifiedAt(); !ok { - v := process.UpdateDefaultLastModifiedAt() - pu.mutation.SetLastModifiedAt(v) - } -} - -// check runs all checks and user-defined validators on the builder. -func (pu *ProcessUpdate) check() error { - if v, ok := pu.mutation.Principal(); ok { - if err := process.PrincipalValidator(v); err != nil { - return &ValidationError{Name: "principal", err: fmt.Errorf(`ent: validator failed for field "Process.principal": %w`, err)} - } - } - if _, ok := pu.mutation.HostID(); pu.mutation.HostCleared() && !ok { - return errors.New(`ent: clearing a required unique edge "Process.host"`) - } - if _, ok := pu.mutation.TaskID(); pu.mutation.TaskCleared() && !ok { - return errors.New(`ent: clearing a required unique edge "Process.task"`) - } - return nil -} - -func (pu *ProcessUpdate) sqlSave(ctx context.Context) (n int, err error) { - if err := pu.check(); err != nil { - return n, err - } - _spec := sqlgraph.NewUpdateSpec(process.Table, process.Columns, sqlgraph.NewFieldSpec(process.FieldID, field.TypeInt)) - if ps := pu.mutation.predicates; len(ps) > 0 { - _spec.Predicate = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - if value, ok := pu.mutation.LastModifiedAt(); ok { - _spec.SetField(process.FieldLastModifiedAt, field.TypeTime, value) - } - if value, ok := pu.mutation.Pid(); ok { - _spec.SetField(process.FieldPid, field.TypeUint64, value) - } - if value, ok := pu.mutation.AddedPid(); ok { - _spec.AddField(process.FieldPid, field.TypeUint64, value) - } - if value, ok := pu.mutation.Name(); ok { - _spec.SetField(process.FieldName, field.TypeString, value) - } - if value, ok := pu.mutation.Principal(); ok { - _spec.SetField(process.FieldPrincipal, field.TypeString, value) - } - if pu.mutation.HostCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2O, - Inverse: false, - Table: process.HostTable, - Columns: []string{process.HostColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(host.FieldID, field.TypeInt), - }, - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := pu.mutation.HostIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2O, - Inverse: false, - Table: process.HostTable, - Columns: []string{process.HostColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(host.FieldID, field.TypeInt), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Add = append(_spec.Edges.Add, edge) - } - if pu.mutation.TaskCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2O, - Inverse: true, - Table: process.TaskTable, - Columns: []string{process.TaskColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(task.FieldID, field.TypeInt), - }, - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := pu.mutation.TaskIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2O, - Inverse: true, - Table: process.TaskTable, - Columns: []string{process.TaskColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(task.FieldID, field.TypeInt), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Add = append(_spec.Edges.Add, edge) - } - if n, err = sqlgraph.UpdateNodes(ctx, pu.driver, _spec); err != nil { - if _, ok := err.(*sqlgraph.NotFoundError); ok { - err = &NotFoundError{process.Label} - } else if sqlgraph.IsConstraintError(err) { - err = &ConstraintError{msg: err.Error(), wrap: err} - } - return 0, err - } - pu.mutation.done = true - return n, nil -} - -// ProcessUpdateOne is the builder for updating a single Process entity. -type ProcessUpdateOne struct { - config - fields []string - hooks []Hook - mutation *ProcessMutation -} - -// SetLastModifiedAt sets the "last_modified_at" field. -func (puo *ProcessUpdateOne) SetLastModifiedAt(t time.Time) *ProcessUpdateOne { - puo.mutation.SetLastModifiedAt(t) - return puo -} - -// SetPid sets the "pid" field. -func (puo *ProcessUpdateOne) SetPid(u uint64) *ProcessUpdateOne { - puo.mutation.ResetPid() - puo.mutation.SetPid(u) - return puo -} - -// AddPid adds u to the "pid" field. -func (puo *ProcessUpdateOne) AddPid(u int64) *ProcessUpdateOne { - puo.mutation.AddPid(u) - return puo -} - -// SetName sets the "name" field. -func (puo *ProcessUpdateOne) SetName(s string) *ProcessUpdateOne { - puo.mutation.SetName(s) - return puo -} - -// SetPrincipal sets the "principal" field. -func (puo *ProcessUpdateOne) SetPrincipal(s string) *ProcessUpdateOne { - puo.mutation.SetPrincipal(s) - return puo -} - -// SetHostID sets the "host" edge to the Host entity by ID. -func (puo *ProcessUpdateOne) SetHostID(id int) *ProcessUpdateOne { - puo.mutation.SetHostID(id) - return puo -} - -// SetHost sets the "host" edge to the Host entity. -func (puo *ProcessUpdateOne) SetHost(h *Host) *ProcessUpdateOne { - return puo.SetHostID(h.ID) -} - -// SetTaskID sets the "task" edge to the Task entity by ID. -func (puo *ProcessUpdateOne) SetTaskID(id int) *ProcessUpdateOne { - puo.mutation.SetTaskID(id) - return puo -} - -// SetTask sets the "task" edge to the Task entity. -func (puo *ProcessUpdateOne) SetTask(t *Task) *ProcessUpdateOne { - return puo.SetTaskID(t.ID) -} - -// Mutation returns the ProcessMutation object of the builder. -func (puo *ProcessUpdateOne) Mutation() *ProcessMutation { - return puo.mutation -} - -// ClearHost clears the "host" edge to the Host entity. -func (puo *ProcessUpdateOne) ClearHost() *ProcessUpdateOne { - puo.mutation.ClearHost() - return puo -} - -// ClearTask clears the "task" edge to the Task entity. -func (puo *ProcessUpdateOne) ClearTask() *ProcessUpdateOne { - puo.mutation.ClearTask() - return puo -} - -// Where appends a list predicates to the ProcessUpdate builder. -func (puo *ProcessUpdateOne) Where(ps ...predicate.Process) *ProcessUpdateOne { - puo.mutation.Where(ps...) - return puo -} - -// Select allows selecting one or more fields (columns) of the returned entity. -// The default is selecting all fields defined in the entity schema. -func (puo *ProcessUpdateOne) Select(field string, fields ...string) *ProcessUpdateOne { - puo.fields = append([]string{field}, fields...) - return puo -} - -// Save executes the query and returns the updated Process entity. -func (puo *ProcessUpdateOne) Save(ctx context.Context) (*Process, error) { - puo.defaults() - return withHooks(ctx, puo.sqlSave, puo.mutation, puo.hooks) -} - -// SaveX is like Save, but panics if an error occurs. -func (puo *ProcessUpdateOne) SaveX(ctx context.Context) *Process { - node, err := puo.Save(ctx) - if err != nil { - panic(err) - } - return node -} - -// Exec executes the query on the entity. -func (puo *ProcessUpdateOne) Exec(ctx context.Context) error { - _, err := puo.Save(ctx) - return err -} - -// ExecX is like Exec, but panics if an error occurs. -func (puo *ProcessUpdateOne) ExecX(ctx context.Context) { - if err := puo.Exec(ctx); err != nil { - panic(err) - } -} - -// defaults sets the default values of the builder before save. -func (puo *ProcessUpdateOne) defaults() { - if _, ok := puo.mutation.LastModifiedAt(); !ok { - v := process.UpdateDefaultLastModifiedAt() - puo.mutation.SetLastModifiedAt(v) - } -} - -// check runs all checks and user-defined validators on the builder. -func (puo *ProcessUpdateOne) check() error { - if v, ok := puo.mutation.Principal(); ok { - if err := process.PrincipalValidator(v); err != nil { - return &ValidationError{Name: "principal", err: fmt.Errorf(`ent: validator failed for field "Process.principal": %w`, err)} - } - } - if _, ok := puo.mutation.HostID(); puo.mutation.HostCleared() && !ok { - return errors.New(`ent: clearing a required unique edge "Process.host"`) - } - if _, ok := puo.mutation.TaskID(); puo.mutation.TaskCleared() && !ok { - return errors.New(`ent: clearing a required unique edge "Process.task"`) - } - return nil -} - -func (puo *ProcessUpdateOne) sqlSave(ctx context.Context) (_node *Process, err error) { - if err := puo.check(); err != nil { - return _node, err - } - _spec := sqlgraph.NewUpdateSpec(process.Table, process.Columns, sqlgraph.NewFieldSpec(process.FieldID, field.TypeInt)) - id, ok := puo.mutation.ID() - if !ok { - return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Process.id" for update`)} - } - _spec.Node.ID.Value = id - if fields := puo.fields; len(fields) > 0 { - _spec.Node.Columns = make([]string, 0, len(fields)) - _spec.Node.Columns = append(_spec.Node.Columns, process.FieldID) - for _, f := range fields { - if !process.ValidColumn(f) { - return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} - } - if f != process.FieldID { - _spec.Node.Columns = append(_spec.Node.Columns, f) - } - } - } - if ps := puo.mutation.predicates; len(ps) > 0 { - _spec.Predicate = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - if value, ok := puo.mutation.LastModifiedAt(); ok { - _spec.SetField(process.FieldLastModifiedAt, field.TypeTime, value) - } - if value, ok := puo.mutation.Pid(); ok { - _spec.SetField(process.FieldPid, field.TypeUint64, value) - } - if value, ok := puo.mutation.AddedPid(); ok { - _spec.AddField(process.FieldPid, field.TypeUint64, value) - } - if value, ok := puo.mutation.Name(); ok { - _spec.SetField(process.FieldName, field.TypeString, value) - } - if value, ok := puo.mutation.Principal(); ok { - _spec.SetField(process.FieldPrincipal, field.TypeString, value) - } - if puo.mutation.HostCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2O, - Inverse: false, - Table: process.HostTable, - Columns: []string{process.HostColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(host.FieldID, field.TypeInt), - }, - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := puo.mutation.HostIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2O, - Inverse: false, - Table: process.HostTable, - Columns: []string{process.HostColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(host.FieldID, field.TypeInt), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Add = append(_spec.Edges.Add, edge) - } - if puo.mutation.TaskCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2O, - Inverse: true, - Table: process.TaskTable, - Columns: []string{process.TaskColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(task.FieldID, field.TypeInt), - }, - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := puo.mutation.TaskIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2O, - Inverse: true, - Table: process.TaskTable, - Columns: []string{process.TaskColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(task.FieldID, field.TypeInt), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Add = append(_spec.Edges.Add, edge) - } - _node = &Process{config: puo.config} - _spec.Assign = _node.assignValues - _spec.ScanValues = _node.scanValues - if err = sqlgraph.UpdateNode(ctx, puo.driver, _spec); err != nil { - if _, ok := err.(*sqlgraph.NotFoundError); ok { - err = &NotFoundError{process.Label} - } else if sqlgraph.IsConstraintError(err) { - err = &ConstraintError{msg: err.Error(), wrap: err} - } - return nil, err - } - puo.mutation.done = true - return _node, nil -} diff --git a/tavern/internal/ent/runtime/runtime.go b/tavern/internal/ent/runtime/runtime.go index c02c4c589..0633ef294 100644 --- a/tavern/internal/ent/runtime/runtime.go +++ b/tavern/internal/ent/runtime/runtime.go @@ -8,7 +8,8 @@ import ( "realm.pub/tavern/internal/ent/beacon" "realm.pub/tavern/internal/ent/file" "realm.pub/tavern/internal/ent/host" - "realm.pub/tavern/internal/ent/process" + "realm.pub/tavern/internal/ent/hostfile" + "realm.pub/tavern/internal/ent/hostprocess" "realm.pub/tavern/internal/ent/quest" "realm.pub/tavern/internal/ent/schema" "realm.pub/tavern/internal/ent/tag" @@ -110,25 +111,56 @@ func init() { hostDescName := hostFields[1].Descriptor() // host.NameValidator is a validator for the "name" field. It is called by the builders before save. host.NameValidator = hostDescName.Validators[0].(func(string) error) - processMixin := schema.Process{}.Mixin() - processMixinFields0 := processMixin[0].Fields() - _ = processMixinFields0 - processFields := schema.Process{}.Fields() - _ = processFields - // processDescCreatedAt is the schema descriptor for created_at field. - processDescCreatedAt := processMixinFields0[0].Descriptor() - // process.DefaultCreatedAt holds the default value on creation for the created_at field. - process.DefaultCreatedAt = processDescCreatedAt.Default.(func() time.Time) - // processDescLastModifiedAt is the schema descriptor for last_modified_at field. - processDescLastModifiedAt := processMixinFields0[1].Descriptor() - // process.DefaultLastModifiedAt holds the default value on creation for the last_modified_at field. - process.DefaultLastModifiedAt = processDescLastModifiedAt.Default.(func() time.Time) - // process.UpdateDefaultLastModifiedAt holds the default value on update for the last_modified_at field. - process.UpdateDefaultLastModifiedAt = processDescLastModifiedAt.UpdateDefault.(func() time.Time) - // processDescPrincipal is the schema descriptor for principal field. - processDescPrincipal := processFields[2].Descriptor() - // process.PrincipalValidator is a validator for the "principal" field. It is called by the builders before save. - process.PrincipalValidator = processDescPrincipal.Validators[0].(func(string) error) + hostfileMixin := schema.HostFile{}.Mixin() + hostfileHooks := schema.HostFile{}.Hooks() + hostfile.Hooks[0] = hostfileHooks[0] + hostfileMixinFields0 := hostfileMixin[0].Fields() + _ = hostfileMixinFields0 + hostfileFields := schema.HostFile{}.Fields() + _ = hostfileFields + // hostfileDescCreatedAt is the schema descriptor for created_at field. + hostfileDescCreatedAt := hostfileMixinFields0[0].Descriptor() + // hostfile.DefaultCreatedAt holds the default value on creation for the created_at field. + hostfile.DefaultCreatedAt = hostfileDescCreatedAt.Default.(func() time.Time) + // hostfileDescLastModifiedAt is the schema descriptor for last_modified_at field. + hostfileDescLastModifiedAt := hostfileMixinFields0[1].Descriptor() + // hostfile.DefaultLastModifiedAt holds the default value on creation for the last_modified_at field. + hostfile.DefaultLastModifiedAt = hostfileDescLastModifiedAt.Default.(func() time.Time) + // hostfile.UpdateDefaultLastModifiedAt holds the default value on update for the last_modified_at field. + hostfile.UpdateDefaultLastModifiedAt = hostfileDescLastModifiedAt.UpdateDefault.(func() time.Time) + // hostfileDescPath is the schema descriptor for path field. + hostfileDescPath := hostfileFields[0].Descriptor() + // hostfile.PathValidator is a validator for the "path" field. It is called by the builders before save. + hostfile.PathValidator = hostfileDescPath.Validators[0].(func(string) error) + // hostfileDescSize is the schema descriptor for size field. + hostfileDescSize := hostfileFields[4].Descriptor() + // hostfile.DefaultSize holds the default value on creation for the size field. + hostfile.DefaultSize = hostfileDescSize.Default.(int) + // hostfile.SizeValidator is a validator for the "size" field. It is called by the builders before save. + hostfile.SizeValidator = hostfileDescSize.Validators[0].(func(int) error) + // hostfileDescHash is the schema descriptor for hash field. + hostfileDescHash := hostfileFields[5].Descriptor() + // hostfile.HashValidator is a validator for the "hash" field. It is called by the builders before save. + hostfile.HashValidator = hostfileDescHash.Validators[0].(func(string) error) + hostprocessMixin := schema.HostProcess{}.Mixin() + hostprocessMixinFields0 := hostprocessMixin[0].Fields() + _ = hostprocessMixinFields0 + hostprocessFields := schema.HostProcess{}.Fields() + _ = hostprocessFields + // hostprocessDescCreatedAt is the schema descriptor for created_at field. + hostprocessDescCreatedAt := hostprocessMixinFields0[0].Descriptor() + // hostprocess.DefaultCreatedAt holds the default value on creation for the created_at field. + hostprocess.DefaultCreatedAt = hostprocessDescCreatedAt.Default.(func() time.Time) + // hostprocessDescLastModifiedAt is the schema descriptor for last_modified_at field. + hostprocessDescLastModifiedAt := hostprocessMixinFields0[1].Descriptor() + // hostprocess.DefaultLastModifiedAt holds the default value on creation for the last_modified_at field. + hostprocess.DefaultLastModifiedAt = hostprocessDescLastModifiedAt.Default.(func() time.Time) + // hostprocess.UpdateDefaultLastModifiedAt holds the default value on update for the last_modified_at field. + hostprocess.UpdateDefaultLastModifiedAt = hostprocessDescLastModifiedAt.UpdateDefault.(func() time.Time) + // hostprocessDescPrincipal is the schema descriptor for principal field. + hostprocessDescPrincipal := hostprocessFields[3].Descriptor() + // hostprocess.PrincipalValidator is a validator for the "principal" field. It is called by the builders before save. + hostprocess.PrincipalValidator = hostprocessDescPrincipal.Validators[0].(func(string) error) questMixin := schema.Quest{}.Mixin() questMixinFields0 := questMixin[0].Fields() _ = questMixinFields0 diff --git a/tavern/internal/ent/schema/file.go b/tavern/internal/ent/schema/file.go index 60d21459d..e047cbffa 100644 --- a/tavern/internal/ent/schema/file.go +++ b/tavern/internal/ent/schema/file.go @@ -38,7 +38,7 @@ func (File) Fields() []ent.Field { Comment("The size of the file in bytes"), field.String("hash"). MaxLen(100). - Comment("A SHA3 digest of the content field"), + Comment("A SHA3-256 digest of the content field"), field.Bytes("content"). Annotations( entgql.Skip(), // Don't return file content in GraphQL queries diff --git a/tavern/internal/ent/schema/host.go b/tavern/internal/ent/schema/host.go index 4b723e895..a88b695f0 100644 --- a/tavern/internal/ent/schema/host.go +++ b/tavern/internal/ent/schema/host.go @@ -6,6 +6,7 @@ import ( "entgo.io/ent/schema" "entgo.io/ent/schema/edge" "entgo.io/ent/schema/field" + "realm.pub/tavern/internal/c2/c2pb" ) // Host holds the schema definition for the Host entity. @@ -34,8 +35,7 @@ func (Host) Fields() []ent.Field { ). Comment("Primary interface IP address reported by the agent."), field.Enum("platform"). - Values("Windows", "Linux", "MacOS", "BSD", "Unknown"). - Default("Unknown"). + GoType(c2pb.Host_Platform(0)). Annotations( entgql.Skip(entgql.SkipMutationUpdateInput), ). @@ -58,7 +58,9 @@ func (Host) Edges() []ent.Edge { edge.From("beacons", Beacon.Type). Ref("host"). Comment("Beacons that are present on this host system."), - edge.To("processes", Process.Type). + edge.To("files", HostFile.Type). + Comment("Files reported on this host system."), + edge.To("processes", HostProcess.Type). Comment("Processes reported as running on this host system."), } } diff --git a/tavern/internal/ent/schema/host_file.go b/tavern/internal/ent/schema/host_file.go new file mode 100644 index 000000000..6bd040cc6 --- /dev/null +++ b/tavern/internal/ent/schema/host_file.go @@ -0,0 +1,124 @@ +package schema + +import ( + "context" + "fmt" + + "golang.org/x/crypto/sha3" + "realm.pub/tavern/internal/ent/hook" + + "entgo.io/contrib/entgql" + "entgo.io/ent" + "entgo.io/ent/schema" + "entgo.io/ent/schema/edge" + "entgo.io/ent/schema/field" +) + +// HostFile holds the schema definition for the HostFile entity. +type HostFile struct { + ent.Schema +} + +// Fields of the HostFile. +func (HostFile) Fields() []ent.Field { + return []ent.Field{ + field.String("path"). + NotEmpty(). + Annotations( + entgql.OrderField("NAME"), + ). + Comment("Path to the file on the host system."), + field.String("owner"). + Optional(). + Comment("User who owns the file on the host system."), + field.String("group"). + Optional(). + Comment("Group who owns the file on the host system."), + field.String("permissions"). + Optional(). + Comment("Permissions for the file on the host system."), + field.Int("size"). + Default(0). + Min(0). + Annotations( + entgql.OrderField("SIZE"), + ). + Comment("The size of the file in bytes"), + field.String("hash"). + Optional(). + MaxLen(100). + Comment("A SHA3-256 digest of the content field"), + field.Bytes("content"). + Optional(). + Annotations( + entgql.Skip(), // Don't return file content in GraphQL queries + ). + Comment("The content of the file"), + } +} + +// Edges of the ent. +func (HostFile) Edges() []ent.Edge { + return []ent.Edge{ + edge.To("host", Host.Type). + Required(). + Unique(). + Comment("Host the file was reported on."), + edge.From("task", Task.Type). + Required(). + Unique(). + Ref("reported_files"). + Comment("Task that reported this file."), + } +} + +// Annotations describes additional information for the ent. +func (HostFile) Annotations() []schema.Annotation { + return []schema.Annotation{} +} + +// Mixin defines common shared properties for the ent. +func (HostFile) Mixin() []ent.Mixin { + return []ent.Mixin{ + MixinHistory{}, // created_at, last_modified_at + } +} + +// Hooks defines middleware for mutations for the ent. +func (HostFile) Hooks() []ent.Hook { + return []ent.Hook{ + hook.On(HookDeriveHostFileInfo(), ent.OpCreate|ent.OpUpdate|ent.OpUpdateOne), + } +} + +// HookDeriveHostFileInfo will update file info (e.g. size, hash) whenever it is mutated. +func HookDeriveHostFileInfo() ent.Hook { + // Get the relevant methods from the HostFile Mutation + // See this example: https://github.com/ent/ent/blob/master/entc/integration/hooks/ent/schema/user.go#L98 + type fMutation interface { + Content() ([]byte, bool) + SetSize(i int) + SetHash(s string) + } + + return func(next ent.Mutator) ent.Mutator { + return ent.MutateFunc(func(ctx context.Context, m ent.Mutation) (ent.Value, error) { + // Get the file mutation + f, ok := m.(fMutation) + if !ok { + return nil, fmt.Errorf("expected hostfile mutation in schema hook, got: %+v", m) + } + + // Set the new size + content, _ := f.Content() + f.SetSize(len(content)) + + // Set the new hash (if content exists) + if len(content) > 0 { + f.SetHash(fmt.Sprintf("%x", sha3.Sum256(content))) + } + + return next.Mutate(ctx, m) + }) + } +} diff --git a/tavern/internal/ent/schema/host_file_test.go b/tavern/internal/ent/schema/host_file_test.go new file mode 100644 index 000000000..ef6716560 --- /dev/null +++ b/tavern/internal/ent/schema/host_file_test.go @@ -0,0 +1,69 @@ +package schema_test + +import ( + "context" + "testing" + "time" + + "github.com/stretchr/testify/assert" + "realm.pub/tavern/internal/c2/c2pb" + "realm.pub/tavern/internal/ent" + "realm.pub/tavern/internal/ent/enttest" +) + +func TestHostFileHooks(t *testing.T) { + graph := enttest.Open(t, "sqlite3", "file:ent?mode=memory&cache=shared&_fk=1") + defer graph.Close() + + var ( + expectedPath = "TestFile" + expectedContent = []byte("ABunchOfBytes") + expectedSize = 13 + expectedHash = "adaf38cc9a3d8d810f051a0098cb8737001394ae9b85d9f6fa56dbc2bcc08db6" + ) + + testFile := newHostFile(graph, expectedPath, expectedContent) + assert.NotNil(t, testFile) + assert.NotZero(t, testFile.ID) + assert.Equal(t, expectedPath, testFile.Path) + assert.Equal(t, string(expectedContent), string(testFile.Content)) + assert.Equal(t, expectedSize, testFile.Size) + assert.Equal(t, expectedHash, testFile.Hash) + assert.NotZero(t, testFile.CreatedAt) + assert.WithinRange(t, testFile.CreatedAt, time.Now().Add(-1*time.Second), time.Now().Add(1*time.Second)) + assert.WithinRange(t, testFile.LastModifiedAt, time.Now().Add(-1*time.Second), time.Now().Add(1*time.Second)) + assert.NotZero(t, testFile.LastModifiedAt) +} + +// newHostFile is a helper to create files directly via ent +func newHostFile(graph *ent.Client, path string, content []byte) *ent.HostFile { + ctx := context.Background() + host := graph.Host.Create(). + SetIdentifier("AAAA-BBBB-CCCC"). + SetPlatform(c2pb.Host_PLATFORM_LINUX). + SaveX(ctx) + beacon := graph.Beacon.Create(). + SetHost(host). + SetIdentifier("ABCDEFG"). + SaveX(ctx) + tome := graph.Tome.Create(). + SetName("Wowza"). + SetDescription("Why did we require this?"). + SetAuthor("kcarretto"). + SetEldritch("blah"). + SaveX(ctx) + quest := graph.Quest.Create(). + SetName("HelloWorld"). + SetTome(tome). + SaveX(ctx) + task := graph.Task.Create(). + SetBeacon(beacon). + SetQuest(quest). + SaveX(ctx) + return graph.HostFile.Create(). + SetTask(task). + SetHost(host). + SetPath(path). + SetContent(content). + SaveX(ctx) +} diff --git a/tavern/internal/ent/schema/process.go b/tavern/internal/ent/schema/host_process.go similarity index 53% rename from tavern/internal/ent/schema/process.go rename to tavern/internal/ent/schema/host_process.go index 8ecfa55ce..83889db51 100644 --- a/tavern/internal/ent/schema/process.go +++ b/tavern/internal/ent/schema/host_process.go @@ -6,21 +6,27 @@ import ( "entgo.io/ent/schema" "entgo.io/ent/schema/edge" "entgo.io/ent/schema/field" + "realm.pub/tavern/internal/c2/c2pb" ) -// Process holds the schema definition for the Process entity. -type Process struct { +// HostProcess holds the schema definition for the HostProcess entity. +type HostProcess struct { ent.Schema } // Fields of the ent. -func (Process) Fields() []ent.Field { +func (HostProcess) Fields() []ent.Field { return []ent.Field{ field.Uint64("pid"). Annotations( entgql.OrderField("PROCESS_ID"), ). Comment("ID of the process."), + field.Uint64("ppid"). + Annotations( + entgql.OrderField("PARENT_PROCESS_ID"), + ). + Comment("ID of the parent process."), field.String("name"). Annotations( entgql.OrderField("NAME"), @@ -29,11 +35,26 @@ func (Process) Fields() []ent.Field { field.String("principal"). NotEmpty(). Comment("The user the process is running as."), + field.String("path"). + Optional(). + Comment("The path to the process executable."), + field.String("cmd"). + Optional(). + Comment("The command used to execute the process."), + field.String("env"). + Optional(). + Comment("The environment variables set for the process."), + field.String("cwd"). + Optional(). + Comment("The current working directory for the process."), + field.Enum("status"). + GoType(c2pb.Process_Status(0)). + Comment("Current process status."), } } // Edges of the ent. -func (Process) Edges() []ent.Edge { +func (HostProcess) Edges() []ent.Edge { return []ent.Edge{ edge.To("host", Host.Type). Required(). @@ -48,12 +69,12 @@ func (Process) Edges() []ent.Edge { } // Annotations describes additional information for the ent. -func (Process) Annotations() []schema.Annotation { +func (HostProcess) Annotations() []schema.Annotation { return []schema.Annotation{} } // Mixin defines common shared properties for the ent. -func (Process) Mixin() []ent.Mixin { +func (HostProcess) Mixin() []ent.Mixin { return []ent.Mixin{ MixinHistory{}, // created_at, last_modified_at } diff --git a/tavern/internal/ent/schema/task.go b/tavern/internal/ent/schema/task.go index f39a93b00..c874f0c6b 100644 --- a/tavern/internal/ent/schema/task.go +++ b/tavern/internal/ent/schema/task.go @@ -64,7 +64,9 @@ func (Task) Edges() []ent.Edge { edge.To("beacon", Beacon.Type). Required(). Unique(), - edge.To("reported_processes", Process.Type). + edge.To("reported_files", HostFile.Type). + Comment("Files that have been reported by this task."), + edge.To("reported_processes", HostProcess.Type). Comment("Processes that have been reported by this task."), } } diff --git a/tavern/internal/ent/task.go b/tavern/internal/ent/task.go index 4c2c5d94b..26812b116 100644 --- a/tavern/internal/ent/task.go +++ b/tavern/internal/ent/task.go @@ -49,15 +49,18 @@ type TaskEdges struct { Quest *Quest `json:"quest,omitempty"` // Beacon holds the value of the beacon edge. Beacon *Beacon `json:"beacon,omitempty"` + // Files that have been reported by this task. + ReportedFiles []*HostFile `json:"reported_files,omitempty"` // Processes that have been reported by this task. - ReportedProcesses []*Process `json:"reported_processes,omitempty"` + ReportedProcesses []*HostProcess `json:"reported_processes,omitempty"` // loadedTypes holds the information for reporting if a // type was loaded (or requested) in eager-loading or not. - loadedTypes [3]bool + loadedTypes [4]bool // totalCount holds the count of the edges above. - totalCount [3]map[string]int + totalCount [4]map[string]int - namedReportedProcesses map[string][]*Process + namedReportedFiles map[string][]*HostFile + namedReportedProcesses map[string][]*HostProcess } // QuestOrErr returns the Quest value or an error if the edge @@ -86,10 +89,19 @@ func (e TaskEdges) BeaconOrErr() (*Beacon, error) { return nil, &NotLoadedError{edge: "beacon"} } -// ReportedProcessesOrErr returns the ReportedProcesses value or an error if the edge +// ReportedFilesOrErr returns the ReportedFiles value or an error if the edge // was not loaded in eager-loading. -func (e TaskEdges) ReportedProcessesOrErr() ([]*Process, error) { +func (e TaskEdges) ReportedFilesOrErr() ([]*HostFile, error) { if e.loadedTypes[2] { + return e.ReportedFiles, nil + } + return nil, &NotLoadedError{edge: "reported_files"} +} + +// ReportedProcessesOrErr returns the ReportedProcesses value or an error if the edge +// was not loaded in eager-loading. +func (e TaskEdges) ReportedProcessesOrErr() ([]*HostProcess, error) { + if e.loadedTypes[3] { return e.ReportedProcesses, nil } return nil, &NotLoadedError{edge: "reported_processes"} @@ -216,8 +228,13 @@ func (t *Task) QueryBeacon() *BeaconQuery { return NewTaskClient(t.config).QueryBeacon(t) } +// QueryReportedFiles queries the "reported_files" edge of the Task entity. +func (t *Task) QueryReportedFiles() *HostFileQuery { + return NewTaskClient(t.config).QueryReportedFiles(t) +} + // QueryReportedProcesses queries the "reported_processes" edge of the Task entity. -func (t *Task) QueryReportedProcesses() *ProcessQuery { +func (t *Task) QueryReportedProcesses() *HostProcessQuery { return NewTaskClient(t.config).QueryReportedProcesses(t) } @@ -271,9 +288,33 @@ func (t *Task) String() string { return builder.String() } +// NamedReportedFiles returns the ReportedFiles named value or an error if the edge was not +// loaded in eager-loading with this name. +func (t *Task) NamedReportedFiles(name string) ([]*HostFile, error) { + if t.Edges.namedReportedFiles == nil { + return nil, &NotLoadedError{edge: name} + } + nodes, ok := t.Edges.namedReportedFiles[name] + if !ok { + return nil, &NotLoadedError{edge: name} + } + return nodes, nil +} + +func (t *Task) appendNamedReportedFiles(name string, edges ...*HostFile) { + if t.Edges.namedReportedFiles == nil { + t.Edges.namedReportedFiles = make(map[string][]*HostFile) + } + if len(edges) == 0 { + t.Edges.namedReportedFiles[name] = []*HostFile{} + } else { + t.Edges.namedReportedFiles[name] = append(t.Edges.namedReportedFiles[name], edges...) + } +} + // NamedReportedProcesses returns the ReportedProcesses named value or an error if the edge was not // loaded in eager-loading with this name. -func (t *Task) NamedReportedProcesses(name string) ([]*Process, error) { +func (t *Task) NamedReportedProcesses(name string) ([]*HostProcess, error) { if t.Edges.namedReportedProcesses == nil { return nil, &NotLoadedError{edge: name} } @@ -284,12 +325,12 @@ func (t *Task) NamedReportedProcesses(name string) ([]*Process, error) { return nodes, nil } -func (t *Task) appendNamedReportedProcesses(name string, edges ...*Process) { +func (t *Task) appendNamedReportedProcesses(name string, edges ...*HostProcess) { if t.Edges.namedReportedProcesses == nil { - t.Edges.namedReportedProcesses = make(map[string][]*Process) + t.Edges.namedReportedProcesses = make(map[string][]*HostProcess) } if len(edges) == 0 { - t.Edges.namedReportedProcesses[name] = []*Process{} + t.Edges.namedReportedProcesses[name] = []*HostProcess{} } else { t.Edges.namedReportedProcesses[name] = append(t.Edges.namedReportedProcesses[name], edges...) } diff --git a/tavern/internal/ent/task/task.go b/tavern/internal/ent/task/task.go index 37bc1628d..115429c51 100644 --- a/tavern/internal/ent/task/task.go +++ b/tavern/internal/ent/task/task.go @@ -35,6 +35,8 @@ const ( EdgeQuest = "quest" // EdgeBeacon holds the string denoting the beacon edge name in mutations. EdgeBeacon = "beacon" + // EdgeReportedFiles holds the string denoting the reported_files edge name in mutations. + EdgeReportedFiles = "reported_files" // EdgeReportedProcesses holds the string denoting the reported_processes edge name in mutations. EdgeReportedProcesses = "reported_processes" // Table holds the table name of the task in the database. @@ -53,11 +55,18 @@ const ( BeaconInverseTable = "beacons" // BeaconColumn is the table column denoting the beacon relation/edge. BeaconColumn = "task_beacon" + // ReportedFilesTable is the table that holds the reported_files relation/edge. + ReportedFilesTable = "host_files" + // ReportedFilesInverseTable is the table name for the HostFile entity. + // It exists in this package in order to avoid circular dependency with the "hostfile" package. + ReportedFilesInverseTable = "host_files" + // ReportedFilesColumn is the table column denoting the reported_files relation/edge. + ReportedFilesColumn = "task_reported_files" // ReportedProcessesTable is the table that holds the reported_processes relation/edge. - ReportedProcessesTable = "processes" - // ReportedProcessesInverseTable is the table name for the Process entity. - // It exists in this package in order to avoid circular dependency with the "process" package. - ReportedProcessesInverseTable = "processes" + ReportedProcessesTable = "host_processes" + // ReportedProcessesInverseTable is the table name for the HostProcess entity. + // It exists in this package in order to avoid circular dependency with the "hostprocess" package. + ReportedProcessesInverseTable = "host_processes" // ReportedProcessesColumn is the table column denoting the reported_processes relation/edge. ReportedProcessesColumn = "task_reported_processes" ) @@ -178,6 +187,20 @@ func ByBeaconField(field string, opts ...sql.OrderTermOption) OrderOption { } } +// ByReportedFilesCount orders the results by reported_files count. +func ByReportedFilesCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newReportedFilesStep(), opts...) + } +} + +// ByReportedFiles orders the results by reported_files terms. +func ByReportedFiles(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newReportedFilesStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} + // ByReportedProcessesCount orders the results by reported_processes count. func ByReportedProcessesCount(opts ...sql.OrderTermOption) OrderOption { return func(s *sql.Selector) { @@ -205,6 +228,13 @@ func newBeaconStep() *sqlgraph.Step { sqlgraph.Edge(sqlgraph.M2O, false, BeaconTable, BeaconColumn), ) } +func newReportedFilesStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(ReportedFilesInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, ReportedFilesTable, ReportedFilesColumn), + ) +} func newReportedProcessesStep() *sqlgraph.Step { return sqlgraph.NewStep( sqlgraph.From(Table, FieldID), diff --git a/tavern/internal/ent/task/where.go b/tavern/internal/ent/task/where.go index ccdf8b502..4b619ae68 100644 --- a/tavern/internal/ent/task/where.go +++ b/tavern/internal/ent/task/where.go @@ -561,6 +561,29 @@ func HasBeaconWith(preds ...predicate.Beacon) predicate.Task { }) } +// HasReportedFiles applies the HasEdge predicate on the "reported_files" edge. +func HasReportedFiles() predicate.Task { + return predicate.Task(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, ReportedFilesTable, ReportedFilesColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasReportedFilesWith applies the HasEdge predicate on the "reported_files" edge with a given conditions (other predicates). +func HasReportedFilesWith(preds ...predicate.HostFile) predicate.Task { + return predicate.Task(func(s *sql.Selector) { + step := newReportedFilesStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + // HasReportedProcesses applies the HasEdge predicate on the "reported_processes" edge. func HasReportedProcesses() predicate.Task { return predicate.Task(func(s *sql.Selector) { @@ -573,7 +596,7 @@ func HasReportedProcesses() predicate.Task { } // HasReportedProcessesWith applies the HasEdge predicate on the "reported_processes" edge with a given conditions (other predicates). -func HasReportedProcessesWith(preds ...predicate.Process) predicate.Task { +func HasReportedProcessesWith(preds ...predicate.HostProcess) predicate.Task { return predicate.Task(func(s *sql.Selector) { step := newReportedProcessesStep() sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { diff --git a/tavern/internal/ent/task_create.go b/tavern/internal/ent/task_create.go index 0dc601297..f1a10c529 100644 --- a/tavern/internal/ent/task_create.go +++ b/tavern/internal/ent/task_create.go @@ -12,7 +12,8 @@ import ( "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" "realm.pub/tavern/internal/ent/beacon" - "realm.pub/tavern/internal/ent/process" + "realm.pub/tavern/internal/ent/hostfile" + "realm.pub/tavern/internal/ent/hostprocess" "realm.pub/tavern/internal/ent/quest" "realm.pub/tavern/internal/ent/task" ) @@ -159,17 +160,32 @@ func (tc *TaskCreate) SetBeacon(b *Beacon) *TaskCreate { return tc.SetBeaconID(b.ID) } -// AddReportedProcessIDs adds the "reported_processes" edge to the Process entity by IDs. +// AddReportedFileIDs adds the "reported_files" edge to the HostFile entity by IDs. +func (tc *TaskCreate) AddReportedFileIDs(ids ...int) *TaskCreate { + tc.mutation.AddReportedFileIDs(ids...) + return tc +} + +// AddReportedFiles adds the "reported_files" edges to the HostFile entity. +func (tc *TaskCreate) AddReportedFiles(h ...*HostFile) *TaskCreate { + ids := make([]int, len(h)) + for i := range h { + ids[i] = h[i].ID + } + return tc.AddReportedFileIDs(ids...) +} + +// AddReportedProcessIDs adds the "reported_processes" edge to the HostProcess entity by IDs. func (tc *TaskCreate) AddReportedProcessIDs(ids ...int) *TaskCreate { tc.mutation.AddReportedProcessIDs(ids...) return tc } -// AddReportedProcesses adds the "reported_processes" edges to the Process entity. -func (tc *TaskCreate) AddReportedProcesses(p ...*Process) *TaskCreate { - ids := make([]int, len(p)) - for i := range p { - ids[i] = p[i].ID +// AddReportedProcesses adds the "reported_processes" edges to the HostProcess entity. +func (tc *TaskCreate) AddReportedProcesses(h ...*HostProcess) *TaskCreate { + ids := make([]int, len(h)) + for i := range h { + ids[i] = h[i].ID } return tc.AddReportedProcessIDs(ids...) } @@ -347,6 +363,22 @@ func (tc *TaskCreate) createSpec() (*Task, *sqlgraph.CreateSpec) { _node.task_beacon = &nodes[0] _spec.Edges = append(_spec.Edges, edge) } + if nodes := tc.mutation.ReportedFilesIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: task.ReportedFilesTable, + Columns: []string{task.ReportedFilesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(hostfile.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges = append(_spec.Edges, edge) + } if nodes := tc.mutation.ReportedProcessesIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, @@ -355,7 +387,7 @@ func (tc *TaskCreate) createSpec() (*Task, *sqlgraph.CreateSpec) { Columns: []string{task.ReportedProcessesColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(process.FieldID, field.TypeInt), + IDSpec: sqlgraph.NewFieldSpec(hostprocess.FieldID, field.TypeInt), }, } for _, k := range nodes { diff --git a/tavern/internal/ent/task_query.go b/tavern/internal/ent/task_query.go index 581996829..09f028892 100644 --- a/tavern/internal/ent/task_query.go +++ b/tavern/internal/ent/task_query.go @@ -12,8 +12,9 @@ import ( "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" "realm.pub/tavern/internal/ent/beacon" + "realm.pub/tavern/internal/ent/hostfile" + "realm.pub/tavern/internal/ent/hostprocess" "realm.pub/tavern/internal/ent/predicate" - "realm.pub/tavern/internal/ent/process" "realm.pub/tavern/internal/ent/quest" "realm.pub/tavern/internal/ent/task" ) @@ -27,11 +28,13 @@ type TaskQuery struct { predicates []predicate.Task withQuest *QuestQuery withBeacon *BeaconQuery - withReportedProcesses *ProcessQuery + withReportedFiles *HostFileQuery + withReportedProcesses *HostProcessQuery withFKs bool modifiers []func(*sql.Selector) loadTotal []func(context.Context, []*Task) error - withNamedReportedProcesses map[string]*ProcessQuery + withNamedReportedFiles map[string]*HostFileQuery + withNamedReportedProcesses map[string]*HostProcessQuery // intermediate query (i.e. traversal path). sql *sql.Selector path func(context.Context) (*sql.Selector, error) @@ -112,9 +115,31 @@ func (tq *TaskQuery) QueryBeacon() *BeaconQuery { return query } +// QueryReportedFiles chains the current query on the "reported_files" edge. +func (tq *TaskQuery) QueryReportedFiles() *HostFileQuery { + query := (&HostFileClient{config: tq.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := tq.prepareQuery(ctx); err != nil { + return nil, err + } + selector := tq.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(task.Table, task.FieldID, selector), + sqlgraph.To(hostfile.Table, hostfile.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, task.ReportedFilesTable, task.ReportedFilesColumn), + ) + fromU = sqlgraph.SetNeighbors(tq.driver.Dialect(), step) + return fromU, nil + } + return query +} + // QueryReportedProcesses chains the current query on the "reported_processes" edge. -func (tq *TaskQuery) QueryReportedProcesses() *ProcessQuery { - query := (&ProcessClient{config: tq.config}).Query() +func (tq *TaskQuery) QueryReportedProcesses() *HostProcessQuery { + query := (&HostProcessClient{config: tq.config}).Query() query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { if err := tq.prepareQuery(ctx); err != nil { return nil, err @@ -125,7 +150,7 @@ func (tq *TaskQuery) QueryReportedProcesses() *ProcessQuery { } step := sqlgraph.NewStep( sqlgraph.From(task.Table, task.FieldID, selector), - sqlgraph.To(process.Table, process.FieldID), + sqlgraph.To(hostprocess.Table, hostprocess.FieldID), sqlgraph.Edge(sqlgraph.O2M, false, task.ReportedProcessesTable, task.ReportedProcessesColumn), ) fromU = sqlgraph.SetNeighbors(tq.driver.Dialect(), step) @@ -328,6 +353,7 @@ func (tq *TaskQuery) Clone() *TaskQuery { predicates: append([]predicate.Task{}, tq.predicates...), withQuest: tq.withQuest.Clone(), withBeacon: tq.withBeacon.Clone(), + withReportedFiles: tq.withReportedFiles.Clone(), withReportedProcesses: tq.withReportedProcesses.Clone(), // clone intermediate query. sql: tq.sql.Clone(), @@ -357,10 +383,21 @@ func (tq *TaskQuery) WithBeacon(opts ...func(*BeaconQuery)) *TaskQuery { return tq } +// WithReportedFiles tells the query-builder to eager-load the nodes that are connected to +// the "reported_files" edge. The optional arguments are used to configure the query builder of the edge. +func (tq *TaskQuery) WithReportedFiles(opts ...func(*HostFileQuery)) *TaskQuery { + query := (&HostFileClient{config: tq.config}).Query() + for _, opt := range opts { + opt(query) + } + tq.withReportedFiles = query + return tq +} + // WithReportedProcesses tells the query-builder to eager-load the nodes that are connected to // the "reported_processes" edge. The optional arguments are used to configure the query builder of the edge. -func (tq *TaskQuery) WithReportedProcesses(opts ...func(*ProcessQuery)) *TaskQuery { - query := (&ProcessClient{config: tq.config}).Query() +func (tq *TaskQuery) WithReportedProcesses(opts ...func(*HostProcessQuery)) *TaskQuery { + query := (&HostProcessClient{config: tq.config}).Query() for _, opt := range opts { opt(query) } @@ -447,9 +484,10 @@ func (tq *TaskQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Task, e nodes = []*Task{} withFKs = tq.withFKs _spec = tq.querySpec() - loadedTypes = [3]bool{ + loadedTypes = [4]bool{ tq.withQuest != nil, tq.withBeacon != nil, + tq.withReportedFiles != nil, tq.withReportedProcesses != nil, } ) @@ -492,17 +530,31 @@ func (tq *TaskQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Task, e return nil, err } } + if query := tq.withReportedFiles; query != nil { + if err := tq.loadReportedFiles(ctx, query, nodes, + func(n *Task) { n.Edges.ReportedFiles = []*HostFile{} }, + func(n *Task, e *HostFile) { n.Edges.ReportedFiles = append(n.Edges.ReportedFiles, e) }); err != nil { + return nil, err + } + } if query := tq.withReportedProcesses; query != nil { if err := tq.loadReportedProcesses(ctx, query, nodes, - func(n *Task) { n.Edges.ReportedProcesses = []*Process{} }, - func(n *Task, e *Process) { n.Edges.ReportedProcesses = append(n.Edges.ReportedProcesses, e) }); err != nil { + func(n *Task) { n.Edges.ReportedProcesses = []*HostProcess{} }, + func(n *Task, e *HostProcess) { n.Edges.ReportedProcesses = append(n.Edges.ReportedProcesses, e) }); err != nil { + return nil, err + } + } + for name, query := range tq.withNamedReportedFiles { + if err := tq.loadReportedFiles(ctx, query, nodes, + func(n *Task) { n.appendNamedReportedFiles(name) }, + func(n *Task, e *HostFile) { n.appendNamedReportedFiles(name, e) }); err != nil { return nil, err } } for name, query := range tq.withNamedReportedProcesses { if err := tq.loadReportedProcesses(ctx, query, nodes, func(n *Task) { n.appendNamedReportedProcesses(name) }, - func(n *Task, e *Process) { n.appendNamedReportedProcesses(name, e) }); err != nil { + func(n *Task, e *HostProcess) { n.appendNamedReportedProcesses(name, e) }); err != nil { return nil, err } } @@ -578,7 +630,38 @@ func (tq *TaskQuery) loadBeacon(ctx context.Context, query *BeaconQuery, nodes [ } return nil } -func (tq *TaskQuery) loadReportedProcesses(ctx context.Context, query *ProcessQuery, nodes []*Task, init func(*Task), assign func(*Task, *Process)) error { +func (tq *TaskQuery) loadReportedFiles(ctx context.Context, query *HostFileQuery, nodes []*Task, init func(*Task), assign func(*Task, *HostFile)) error { + fks := make([]driver.Value, 0, len(nodes)) + nodeids := make(map[int]*Task) + for i := range nodes { + fks = append(fks, nodes[i].ID) + nodeids[nodes[i].ID] = nodes[i] + if init != nil { + init(nodes[i]) + } + } + query.withFKs = true + query.Where(predicate.HostFile(func(s *sql.Selector) { + s.Where(sql.InValues(s.C(task.ReportedFilesColumn), fks...)) + })) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + fk := n.task_reported_files + if fk == nil { + return fmt.Errorf(`foreign-key "task_reported_files" is nil for node %v`, n.ID) + } + node, ok := nodeids[*fk] + if !ok { + return fmt.Errorf(`unexpected referenced foreign-key "task_reported_files" returned %v for node %v`, *fk, n.ID) + } + assign(node, n) + } + return nil +} +func (tq *TaskQuery) loadReportedProcesses(ctx context.Context, query *HostProcessQuery, nodes []*Task, init func(*Task), assign func(*Task, *HostProcess)) error { fks := make([]driver.Value, 0, len(nodes)) nodeids := make(map[int]*Task) for i := range nodes { @@ -589,7 +672,7 @@ func (tq *TaskQuery) loadReportedProcesses(ctx context.Context, query *ProcessQu } } query.withFKs = true - query.Where(predicate.Process(func(s *sql.Selector) { + query.Where(predicate.HostProcess(func(s *sql.Selector) { s.Where(sql.InValues(s.C(task.ReportedProcessesColumn), fks...)) })) neighbors, err := query.All(ctx) @@ -694,15 +777,29 @@ func (tq *TaskQuery) sqlQuery(ctx context.Context) *sql.Selector { return selector } +// WithNamedReportedFiles tells the query-builder to eager-load the nodes that are connected to the "reported_files" +// edge with the given name. The optional arguments are used to configure the query builder of the edge. +func (tq *TaskQuery) WithNamedReportedFiles(name string, opts ...func(*HostFileQuery)) *TaskQuery { + query := (&HostFileClient{config: tq.config}).Query() + for _, opt := range opts { + opt(query) + } + if tq.withNamedReportedFiles == nil { + tq.withNamedReportedFiles = make(map[string]*HostFileQuery) + } + tq.withNamedReportedFiles[name] = query + return tq +} + // WithNamedReportedProcesses tells the query-builder to eager-load the nodes that are connected to the "reported_processes" // edge with the given name. The optional arguments are used to configure the query builder of the edge. -func (tq *TaskQuery) WithNamedReportedProcesses(name string, opts ...func(*ProcessQuery)) *TaskQuery { - query := (&ProcessClient{config: tq.config}).Query() +func (tq *TaskQuery) WithNamedReportedProcesses(name string, opts ...func(*HostProcessQuery)) *TaskQuery { + query := (&HostProcessClient{config: tq.config}).Query() for _, opt := range opts { opt(query) } if tq.withNamedReportedProcesses == nil { - tq.withNamedReportedProcesses = make(map[string]*ProcessQuery) + tq.withNamedReportedProcesses = make(map[string]*HostProcessQuery) } tq.withNamedReportedProcesses[name] = query return tq diff --git a/tavern/internal/ent/task_update.go b/tavern/internal/ent/task_update.go index 716c39469..53f1328b9 100644 --- a/tavern/internal/ent/task_update.go +++ b/tavern/internal/ent/task_update.go @@ -12,8 +12,9 @@ import ( "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" "realm.pub/tavern/internal/ent/beacon" + "realm.pub/tavern/internal/ent/hostfile" + "realm.pub/tavern/internal/ent/hostprocess" "realm.pub/tavern/internal/ent/predicate" - "realm.pub/tavern/internal/ent/process" "realm.pub/tavern/internal/ent/quest" "realm.pub/tavern/internal/ent/task" ) @@ -180,17 +181,32 @@ func (tu *TaskUpdate) SetBeacon(b *Beacon) *TaskUpdate { return tu.SetBeaconID(b.ID) } -// AddReportedProcessIDs adds the "reported_processes" edge to the Process entity by IDs. +// AddReportedFileIDs adds the "reported_files" edge to the HostFile entity by IDs. +func (tu *TaskUpdate) AddReportedFileIDs(ids ...int) *TaskUpdate { + tu.mutation.AddReportedFileIDs(ids...) + return tu +} + +// AddReportedFiles adds the "reported_files" edges to the HostFile entity. +func (tu *TaskUpdate) AddReportedFiles(h ...*HostFile) *TaskUpdate { + ids := make([]int, len(h)) + for i := range h { + ids[i] = h[i].ID + } + return tu.AddReportedFileIDs(ids...) +} + +// AddReportedProcessIDs adds the "reported_processes" edge to the HostProcess entity by IDs. func (tu *TaskUpdate) AddReportedProcessIDs(ids ...int) *TaskUpdate { tu.mutation.AddReportedProcessIDs(ids...) return tu } -// AddReportedProcesses adds the "reported_processes" edges to the Process entity. -func (tu *TaskUpdate) AddReportedProcesses(p ...*Process) *TaskUpdate { - ids := make([]int, len(p)) - for i := range p { - ids[i] = p[i].ID +// AddReportedProcesses adds the "reported_processes" edges to the HostProcess entity. +func (tu *TaskUpdate) AddReportedProcesses(h ...*HostProcess) *TaskUpdate { + ids := make([]int, len(h)) + for i := range h { + ids[i] = h[i].ID } return tu.AddReportedProcessIDs(ids...) } @@ -212,23 +228,44 @@ func (tu *TaskUpdate) ClearBeacon() *TaskUpdate { return tu } -// ClearReportedProcesses clears all "reported_processes" edges to the Process entity. +// ClearReportedFiles clears all "reported_files" edges to the HostFile entity. +func (tu *TaskUpdate) ClearReportedFiles() *TaskUpdate { + tu.mutation.ClearReportedFiles() + return tu +} + +// RemoveReportedFileIDs removes the "reported_files" edge to HostFile entities by IDs. +func (tu *TaskUpdate) RemoveReportedFileIDs(ids ...int) *TaskUpdate { + tu.mutation.RemoveReportedFileIDs(ids...) + return tu +} + +// RemoveReportedFiles removes "reported_files" edges to HostFile entities. +func (tu *TaskUpdate) RemoveReportedFiles(h ...*HostFile) *TaskUpdate { + ids := make([]int, len(h)) + for i := range h { + ids[i] = h[i].ID + } + return tu.RemoveReportedFileIDs(ids...) +} + +// ClearReportedProcesses clears all "reported_processes" edges to the HostProcess entity. func (tu *TaskUpdate) ClearReportedProcesses() *TaskUpdate { tu.mutation.ClearReportedProcesses() return tu } -// RemoveReportedProcessIDs removes the "reported_processes" edge to Process entities by IDs. +// RemoveReportedProcessIDs removes the "reported_processes" edge to HostProcess entities by IDs. func (tu *TaskUpdate) RemoveReportedProcessIDs(ids ...int) *TaskUpdate { tu.mutation.RemoveReportedProcessIDs(ids...) return tu } -// RemoveReportedProcesses removes "reported_processes" edges to Process entities. -func (tu *TaskUpdate) RemoveReportedProcesses(p ...*Process) *TaskUpdate { - ids := make([]int, len(p)) - for i := range p { - ids[i] = p[i].ID +// RemoveReportedProcesses removes "reported_processes" edges to HostProcess entities. +func (tu *TaskUpdate) RemoveReportedProcesses(h ...*HostProcess) *TaskUpdate { + ids := make([]int, len(h)) + for i := range h { + ids[i] = h[i].ID } return tu.RemoveReportedProcessIDs(ids...) } @@ -400,6 +437,51 @@ func (tu *TaskUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Add = append(_spec.Edges.Add, edge) } + if tu.mutation.ReportedFilesCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: task.ReportedFilesTable, + Columns: []string{task.ReportedFilesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(hostfile.FieldID, field.TypeInt), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := tu.mutation.RemovedReportedFilesIDs(); len(nodes) > 0 && !tu.mutation.ReportedFilesCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: task.ReportedFilesTable, + Columns: []string{task.ReportedFilesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(hostfile.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := tu.mutation.ReportedFilesIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: task.ReportedFilesTable, + Columns: []string{task.ReportedFilesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(hostfile.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } if tu.mutation.ReportedProcessesCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, @@ -408,7 +490,7 @@ func (tu *TaskUpdate) sqlSave(ctx context.Context) (n int, err error) { Columns: []string{task.ReportedProcessesColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(process.FieldID, field.TypeInt), + IDSpec: sqlgraph.NewFieldSpec(hostprocess.FieldID, field.TypeInt), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) @@ -421,7 +503,7 @@ func (tu *TaskUpdate) sqlSave(ctx context.Context) (n int, err error) { Columns: []string{task.ReportedProcessesColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(process.FieldID, field.TypeInt), + IDSpec: sqlgraph.NewFieldSpec(hostprocess.FieldID, field.TypeInt), }, } for _, k := range nodes { @@ -437,7 +519,7 @@ func (tu *TaskUpdate) sqlSave(ctx context.Context) (n int, err error) { Columns: []string{task.ReportedProcessesColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(process.FieldID, field.TypeInt), + IDSpec: sqlgraph.NewFieldSpec(hostprocess.FieldID, field.TypeInt), }, } for _, k := range nodes { @@ -614,17 +696,32 @@ func (tuo *TaskUpdateOne) SetBeacon(b *Beacon) *TaskUpdateOne { return tuo.SetBeaconID(b.ID) } -// AddReportedProcessIDs adds the "reported_processes" edge to the Process entity by IDs. +// AddReportedFileIDs adds the "reported_files" edge to the HostFile entity by IDs. +func (tuo *TaskUpdateOne) AddReportedFileIDs(ids ...int) *TaskUpdateOne { + tuo.mutation.AddReportedFileIDs(ids...) + return tuo +} + +// AddReportedFiles adds the "reported_files" edges to the HostFile entity. +func (tuo *TaskUpdateOne) AddReportedFiles(h ...*HostFile) *TaskUpdateOne { + ids := make([]int, len(h)) + for i := range h { + ids[i] = h[i].ID + } + return tuo.AddReportedFileIDs(ids...) +} + +// AddReportedProcessIDs adds the "reported_processes" edge to the HostProcess entity by IDs. func (tuo *TaskUpdateOne) AddReportedProcessIDs(ids ...int) *TaskUpdateOne { tuo.mutation.AddReportedProcessIDs(ids...) return tuo } -// AddReportedProcesses adds the "reported_processes" edges to the Process entity. -func (tuo *TaskUpdateOne) AddReportedProcesses(p ...*Process) *TaskUpdateOne { - ids := make([]int, len(p)) - for i := range p { - ids[i] = p[i].ID +// AddReportedProcesses adds the "reported_processes" edges to the HostProcess entity. +func (tuo *TaskUpdateOne) AddReportedProcesses(h ...*HostProcess) *TaskUpdateOne { + ids := make([]int, len(h)) + for i := range h { + ids[i] = h[i].ID } return tuo.AddReportedProcessIDs(ids...) } @@ -646,23 +743,44 @@ func (tuo *TaskUpdateOne) ClearBeacon() *TaskUpdateOne { return tuo } -// ClearReportedProcesses clears all "reported_processes" edges to the Process entity. +// ClearReportedFiles clears all "reported_files" edges to the HostFile entity. +func (tuo *TaskUpdateOne) ClearReportedFiles() *TaskUpdateOne { + tuo.mutation.ClearReportedFiles() + return tuo +} + +// RemoveReportedFileIDs removes the "reported_files" edge to HostFile entities by IDs. +func (tuo *TaskUpdateOne) RemoveReportedFileIDs(ids ...int) *TaskUpdateOne { + tuo.mutation.RemoveReportedFileIDs(ids...) + return tuo +} + +// RemoveReportedFiles removes "reported_files" edges to HostFile entities. +func (tuo *TaskUpdateOne) RemoveReportedFiles(h ...*HostFile) *TaskUpdateOne { + ids := make([]int, len(h)) + for i := range h { + ids[i] = h[i].ID + } + return tuo.RemoveReportedFileIDs(ids...) +} + +// ClearReportedProcesses clears all "reported_processes" edges to the HostProcess entity. func (tuo *TaskUpdateOne) ClearReportedProcesses() *TaskUpdateOne { tuo.mutation.ClearReportedProcesses() return tuo } -// RemoveReportedProcessIDs removes the "reported_processes" edge to Process entities by IDs. +// RemoveReportedProcessIDs removes the "reported_processes" edge to HostProcess entities by IDs. func (tuo *TaskUpdateOne) RemoveReportedProcessIDs(ids ...int) *TaskUpdateOne { tuo.mutation.RemoveReportedProcessIDs(ids...) return tuo } -// RemoveReportedProcesses removes "reported_processes" edges to Process entities. -func (tuo *TaskUpdateOne) RemoveReportedProcesses(p ...*Process) *TaskUpdateOne { - ids := make([]int, len(p)) - for i := range p { - ids[i] = p[i].ID +// RemoveReportedProcesses removes "reported_processes" edges to HostProcess entities. +func (tuo *TaskUpdateOne) RemoveReportedProcesses(h ...*HostProcess) *TaskUpdateOne { + ids := make([]int, len(h)) + for i := range h { + ids[i] = h[i].ID } return tuo.RemoveReportedProcessIDs(ids...) } @@ -864,6 +982,51 @@ func (tuo *TaskUpdateOne) sqlSave(ctx context.Context) (_node *Task, err error) } _spec.Edges.Add = append(_spec.Edges.Add, edge) } + if tuo.mutation.ReportedFilesCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: task.ReportedFilesTable, + Columns: []string{task.ReportedFilesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(hostfile.FieldID, field.TypeInt), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := tuo.mutation.RemovedReportedFilesIDs(); len(nodes) > 0 && !tuo.mutation.ReportedFilesCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: task.ReportedFilesTable, + Columns: []string{task.ReportedFilesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(hostfile.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := tuo.mutation.ReportedFilesIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: task.ReportedFilesTable, + Columns: []string{task.ReportedFilesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(hostfile.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } if tuo.mutation.ReportedProcessesCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, @@ -872,7 +1035,7 @@ func (tuo *TaskUpdateOne) sqlSave(ctx context.Context) (_node *Task, err error) Columns: []string{task.ReportedProcessesColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(process.FieldID, field.TypeInt), + IDSpec: sqlgraph.NewFieldSpec(hostprocess.FieldID, field.TypeInt), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) @@ -885,7 +1048,7 @@ func (tuo *TaskUpdateOne) sqlSave(ctx context.Context) (_node *Task, err error) Columns: []string{task.ReportedProcessesColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(process.FieldID, field.TypeInt), + IDSpec: sqlgraph.NewFieldSpec(hostprocess.FieldID, field.TypeInt), }, } for _, k := range nodes { @@ -901,7 +1064,7 @@ func (tuo *TaskUpdateOne) sqlSave(ctx context.Context) (_node *Task, err error) Columns: []string{task.ReportedProcessesColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(process.FieldID, field.TypeInt), + IDSpec: sqlgraph.NewFieldSpec(hostprocess.FieldID, field.TypeInt), }, } for _, k := range nodes { diff --git a/tavern/internal/ent/tx.go b/tavern/internal/ent/tx.go index 21c7321f7..248315426 100644 --- a/tavern/internal/ent/tx.go +++ b/tavern/internal/ent/tx.go @@ -18,8 +18,10 @@ type Tx struct { File *FileClient // Host is the client for interacting with the Host builders. Host *HostClient - // Process is the client for interacting with the Process builders. - Process *ProcessClient + // HostFile is the client for interacting with the HostFile builders. + HostFile *HostFileClient + // HostProcess is the client for interacting with the HostProcess builders. + HostProcess *HostProcessClient // Quest is the client for interacting with the Quest builders. Quest *QuestClient // Tag is the client for interacting with the Tag builders. @@ -164,7 +166,8 @@ func (tx *Tx) init() { tx.Beacon = NewBeaconClient(tx.config) tx.File = NewFileClient(tx.config) tx.Host = NewHostClient(tx.config) - tx.Process = NewProcessClient(tx.config) + tx.HostFile = NewHostFileClient(tx.config) + tx.HostProcess = NewHostProcessClient(tx.config) tx.Quest = NewQuestClient(tx.config) tx.Tag = NewTagClient(tx.config) tx.Task = NewTaskClient(tx.config) diff --git a/tavern/internal/graphql/ent.resolvers.go b/tavern/internal/graphql/ent.resolvers.go index ecc88ef1f..e1cbf5826 100644 --- a/tavern/internal/graphql/ent.resolvers.go +++ b/tavern/internal/graphql/ent.resolvers.go @@ -13,71 +13,116 @@ import ( ) // Pid is the resolver for the pid field. -func (r *processResolver) Pid(ctx context.Context, obj *ent.Process) (int, error) { +func (r *hostProcessResolver) Pid(ctx context.Context, obj *ent.HostProcess) (int, error) { panic(fmt.Errorf("not implemented: Pid - pid")) } +// Ppid is the resolver for the ppid field. +func (r *hostProcessResolver) Ppid(ctx context.Context, obj *ent.HostProcess) (int, error) { + panic(fmt.Errorf("not implemented: Ppid - ppid")) +} + // Node is the resolver for the node field. func (r *queryResolver) Node(ctx context.Context, id int) (ent.Noder, error) { - return r.client.Noder(ctx, id) + panic(fmt.Errorf("not implemented: Node - node")) } // Nodes is the resolver for the nodes field. func (r *queryResolver) Nodes(ctx context.Context, ids []int) ([]ent.Noder, error) { - return r.client.Noders(ctx, ids) + panic(fmt.Errorf("not implemented: Nodes - nodes")) } // Pid is the resolver for the pid field. -func (r *processWhereInputResolver) Pid(ctx context.Context, obj *ent.ProcessWhereInput, data *int) error { +func (r *hostProcessWhereInputResolver) Pid(ctx context.Context, obj *ent.HostProcessWhereInput, data *int) error { panic(fmt.Errorf("not implemented: Pid - pid")) } // PidNeq is the resolver for the pidNEQ field. -func (r *processWhereInputResolver) PidNeq(ctx context.Context, obj *ent.ProcessWhereInput, data *int) error { +func (r *hostProcessWhereInputResolver) PidNeq(ctx context.Context, obj *ent.HostProcessWhereInput, data *int) error { panic(fmt.Errorf("not implemented: PidNeq - pidNEQ")) } // PidIn is the resolver for the pidIn field. -func (r *processWhereInputResolver) PidIn(ctx context.Context, obj *ent.ProcessWhereInput, data []int) error { +func (r *hostProcessWhereInputResolver) PidIn(ctx context.Context, obj *ent.HostProcessWhereInput, data []int) error { panic(fmt.Errorf("not implemented: PidIn - pidIn")) } // PidNotIn is the resolver for the pidNotIn field. -func (r *processWhereInputResolver) PidNotIn(ctx context.Context, obj *ent.ProcessWhereInput, data []int) error { +func (r *hostProcessWhereInputResolver) PidNotIn(ctx context.Context, obj *ent.HostProcessWhereInput, data []int) error { panic(fmt.Errorf("not implemented: PidNotIn - pidNotIn")) } // PidGt is the resolver for the pidGT field. -func (r *processWhereInputResolver) PidGt(ctx context.Context, obj *ent.ProcessWhereInput, data *int) error { +func (r *hostProcessWhereInputResolver) PidGt(ctx context.Context, obj *ent.HostProcessWhereInput, data *int) error { panic(fmt.Errorf("not implemented: PidGt - pidGT")) } // PidGte is the resolver for the pidGTE field. -func (r *processWhereInputResolver) PidGte(ctx context.Context, obj *ent.ProcessWhereInput, data *int) error { +func (r *hostProcessWhereInputResolver) PidGte(ctx context.Context, obj *ent.HostProcessWhereInput, data *int) error { panic(fmt.Errorf("not implemented: PidGte - pidGTE")) } // PidLt is the resolver for the pidLT field. -func (r *processWhereInputResolver) PidLt(ctx context.Context, obj *ent.ProcessWhereInput, data *int) error { +func (r *hostProcessWhereInputResolver) PidLt(ctx context.Context, obj *ent.HostProcessWhereInput, data *int) error { panic(fmt.Errorf("not implemented: PidLt - pidLT")) } // PidLte is the resolver for the pidLTE field. -func (r *processWhereInputResolver) PidLte(ctx context.Context, obj *ent.ProcessWhereInput, data *int) error { +func (r *hostProcessWhereInputResolver) PidLte(ctx context.Context, obj *ent.HostProcessWhereInput, data *int) error { panic(fmt.Errorf("not implemented: PidLte - pidLTE")) } -// Process returns generated.ProcessResolver implementation. -func (r *Resolver) Process() generated.ProcessResolver { return &processResolver{r} } +// Ppid is the resolver for the ppid field. +func (r *hostProcessWhereInputResolver) Ppid(ctx context.Context, obj *ent.HostProcessWhereInput, data *int) error { + panic(fmt.Errorf("not implemented: Ppid - ppid")) +} + +// PpidNeq is the resolver for the ppidNEQ field. +func (r *hostProcessWhereInputResolver) PpidNeq(ctx context.Context, obj *ent.HostProcessWhereInput, data *int) error { + panic(fmt.Errorf("not implemented: PpidNeq - ppidNEQ")) +} + +// PpidIn is the resolver for the ppidIn field. +func (r *hostProcessWhereInputResolver) PpidIn(ctx context.Context, obj *ent.HostProcessWhereInput, data []int) error { + panic(fmt.Errorf("not implemented: PpidIn - ppidIn")) +} + +// PpidNotIn is the resolver for the ppidNotIn field. +func (r *hostProcessWhereInputResolver) PpidNotIn(ctx context.Context, obj *ent.HostProcessWhereInput, data []int) error { + panic(fmt.Errorf("not implemented: PpidNotIn - ppidNotIn")) +} + +// PpidGt is the resolver for the ppidGT field. +func (r *hostProcessWhereInputResolver) PpidGt(ctx context.Context, obj *ent.HostProcessWhereInput, data *int) error { + panic(fmt.Errorf("not implemented: PpidGt - ppidGT")) +} + +// PpidGte is the resolver for the ppidGTE field. +func (r *hostProcessWhereInputResolver) PpidGte(ctx context.Context, obj *ent.HostProcessWhereInput, data *int) error { + panic(fmt.Errorf("not implemented: PpidGte - ppidGTE")) +} + +// PpidLt is the resolver for the ppidLT field. +func (r *hostProcessWhereInputResolver) PpidLt(ctx context.Context, obj *ent.HostProcessWhereInput, data *int) error { + panic(fmt.Errorf("not implemented: PpidLt - ppidLT")) +} + +// PpidLte is the resolver for the ppidLTE field. +func (r *hostProcessWhereInputResolver) PpidLte(ctx context.Context, obj *ent.HostProcessWhereInput, data *int) error { + panic(fmt.Errorf("not implemented: PpidLte - ppidLTE")) +} + +// HostProcess returns generated.HostProcessResolver implementation. +func (r *Resolver) HostProcess() generated.HostProcessResolver { return &hostProcessResolver{r} } // Query returns generated.QueryResolver implementation. func (r *Resolver) Query() generated.QueryResolver { return &queryResolver{r} } -// ProcessWhereInput returns generated.ProcessWhereInputResolver implementation. -func (r *Resolver) ProcessWhereInput() generated.ProcessWhereInputResolver { - return &processWhereInputResolver{r} +// HostProcessWhereInput returns generated.HostProcessWhereInputResolver implementation. +func (r *Resolver) HostProcessWhereInput() generated.HostProcessWhereInputResolver { + return &hostProcessWhereInputResolver{r} } -type processResolver struct{ *Resolver } +type hostProcessResolver struct{ *Resolver } type queryResolver struct{ *Resolver } -type processWhereInputResolver struct{ *Resolver } +type hostProcessWhereInputResolver struct{ *Resolver } diff --git a/tavern/internal/graphql/generated/ent.generated.go b/tavern/internal/graphql/generated/ent.generated.go index d6ac047ba..cf6c054b5 100644 --- a/tavern/internal/graphql/generated/ent.generated.go +++ b/tavern/internal/graphql/generated/ent.generated.go @@ -15,16 +15,17 @@ import ( "github.com/99designs/gqlgen/graphql" "github.com/99designs/gqlgen/graphql/introspection" "github.com/vektah/gqlparser/v2/ast" + "realm.pub/tavern/internal/c2/c2pb" "realm.pub/tavern/internal/ent" - "realm.pub/tavern/internal/ent/host" "realm.pub/tavern/internal/ent/tag" "realm.pub/tavern/internal/ent/tome" ) // region ************************** generated!.gotpl ************************** -type ProcessResolver interface { - Pid(ctx context.Context, obj *ent.Process) (int, error) +type HostProcessResolver interface { + Pid(ctx context.Context, obj *ent.HostProcess) (int, error) + Ppid(ctx context.Context, obj *ent.HostProcess) (int, error) } type QueryResolver interface { Node(ctx context.Context, id int) (ent.Noder, error) @@ -40,15 +41,23 @@ type QueryResolver interface { Me(ctx context.Context) (*ent.User, error) } -type ProcessWhereInputResolver interface { - Pid(ctx context.Context, obj *ent.ProcessWhereInput, data *int) error - PidNeq(ctx context.Context, obj *ent.ProcessWhereInput, data *int) error - PidIn(ctx context.Context, obj *ent.ProcessWhereInput, data []int) error - PidNotIn(ctx context.Context, obj *ent.ProcessWhereInput, data []int) error - PidGt(ctx context.Context, obj *ent.ProcessWhereInput, data *int) error - PidGte(ctx context.Context, obj *ent.ProcessWhereInput, data *int) error - PidLt(ctx context.Context, obj *ent.ProcessWhereInput, data *int) error - PidLte(ctx context.Context, obj *ent.ProcessWhereInput, data *int) error +type HostProcessWhereInputResolver interface { + Pid(ctx context.Context, obj *ent.HostProcessWhereInput, data *int) error + PidNeq(ctx context.Context, obj *ent.HostProcessWhereInput, data *int) error + PidIn(ctx context.Context, obj *ent.HostProcessWhereInput, data []int) error + PidNotIn(ctx context.Context, obj *ent.HostProcessWhereInput, data []int) error + PidGt(ctx context.Context, obj *ent.HostProcessWhereInput, data *int) error + PidGte(ctx context.Context, obj *ent.HostProcessWhereInput, data *int) error + PidLt(ctx context.Context, obj *ent.HostProcessWhereInput, data *int) error + PidLte(ctx context.Context, obj *ent.HostProcessWhereInput, data *int) error + Ppid(ctx context.Context, obj *ent.HostProcessWhereInput, data *int) error + PpidNeq(ctx context.Context, obj *ent.HostProcessWhereInput, data *int) error + PpidIn(ctx context.Context, obj *ent.HostProcessWhereInput, data []int) error + PpidNotIn(ctx context.Context, obj *ent.HostProcessWhereInput, data []int) error + PpidGt(ctx context.Context, obj *ent.HostProcessWhereInput, data *int) error + PpidGte(ctx context.Context, obj *ent.HostProcessWhereInput, data *int) error + PpidLt(ctx context.Context, obj *ent.HostProcessWhereInput, data *int) error + PpidLte(ctx context.Context, obj *ent.HostProcessWhereInput, data *int) error } // endregion ************************** generated!.gotpl ************************** @@ -716,6 +725,8 @@ func (ec *executionContext) fieldContext_Beacon_host(ctx context.Context, field return ec.fieldContext_Host_tags(ctx, field) case "beacons": return ec.fieldContext_Host_beacons(ctx, field) + case "files": + return ec.fieldContext_Host_files(ctx, field) case "processes": return ec.fieldContext_Host_processes(ctx, field) } @@ -783,6 +794,8 @@ func (ec *executionContext) fieldContext_Beacon_tasks(ctx context.Context, field return ec.fieldContext_Task_quest(ctx, field) case "beacon": return ec.fieldContext_Task_beacon(ctx, field) + case "reportedFiles": + return ec.fieldContext_Task_reportedFiles(ctx, field) case "reportedProcesses": return ec.fieldContext_Task_reportedProcesses(ctx, field) } @@ -1407,9 +1420,9 @@ func (ec *executionContext) _Host_platform(ctx context.Context, field graphql.Co } return graphql.Null } - res := resTmp.(host.Platform) + res := resTmp.(c2pb.Host_Platform) fc.Result = res - return ec.marshalNHostPlatform2realmᚗpubᚋtavernᚋinternalᚋentᚋhostᚐPlatform(ctx, field.Selections, res) + return ec.marshalNHostPlatform2realmᚗpubᚋtavernᚋinternalᚋc2ᚋc2pbᚐHost_Platform(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Host_platform(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -1582,8 +1595,8 @@ func (ec *executionContext) fieldContext_Host_beacons(ctx context.Context, field return fc, nil } -func (ec *executionContext) _Host_processes(ctx context.Context, field graphql.CollectedField, obj *ent.Host) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Host_processes(ctx, field) +func (ec *executionContext) _Host_files(ctx context.Context, field graphql.CollectedField, obj *ent.Host) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Host_files(ctx, field) if err != nil { return graphql.Null } @@ -1596,7 +1609,7 @@ func (ec *executionContext) _Host_processes(ctx context.Context, field graphql.C }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Processes(ctx) + return obj.Files(ctx) }) if err != nil { ec.Error(ctx, err) @@ -1605,12 +1618,12 @@ func (ec *executionContext) _Host_processes(ctx context.Context, field graphql.C if resTmp == nil { return graphql.Null } - res := resTmp.([]*ent.Process) + res := resTmp.([]*ent.HostFile) fc.Result = res - return ec.marshalOProcess2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐProcessᚄ(ctx, field.Selections, res) + return ec.marshalOHostFile2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostFileᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Host_processes(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Host_files(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Host", Field: field, @@ -1619,30 +1632,36 @@ func (ec *executionContext) fieldContext_Host_processes(ctx context.Context, fie Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": - return ec.fieldContext_Process_id(ctx, field) + return ec.fieldContext_HostFile_id(ctx, field) case "createdAt": - return ec.fieldContext_Process_createdAt(ctx, field) + return ec.fieldContext_HostFile_createdAt(ctx, field) case "lastModifiedAt": - return ec.fieldContext_Process_lastModifiedAt(ctx, field) - case "pid": - return ec.fieldContext_Process_pid(ctx, field) - case "name": - return ec.fieldContext_Process_name(ctx, field) - case "principal": - return ec.fieldContext_Process_principal(ctx, field) + return ec.fieldContext_HostFile_lastModifiedAt(ctx, field) + case "path": + return ec.fieldContext_HostFile_path(ctx, field) + case "owner": + return ec.fieldContext_HostFile_owner(ctx, field) + case "group": + return ec.fieldContext_HostFile_group(ctx, field) + case "permissions": + return ec.fieldContext_HostFile_permissions(ctx, field) + case "size": + return ec.fieldContext_HostFile_size(ctx, field) + case "hash": + return ec.fieldContext_HostFile_hash(ctx, field) case "host": - return ec.fieldContext_Process_host(ctx, field) + return ec.fieldContext_HostFile_host(ctx, field) case "task": - return ec.fieldContext_Process_task(ctx, field) + return ec.fieldContext_HostFile_task(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type Process", field.Name) + return nil, fmt.Errorf("no field named %q was found under type HostFile", field.Name) }, } return fc, nil } -func (ec *executionContext) _PageInfo_hasNextPage(ctx context.Context, field graphql.CollectedField, obj *entgql.PageInfo[int]) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_PageInfo_hasNextPage(ctx, field) +func (ec *executionContext) _Host_processes(ctx context.Context, field graphql.CollectedField, obj *ent.Host) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Host_processes(ctx, field) if err != nil { return graphql.Null } @@ -1655,38 +1674,65 @@ func (ec *executionContext) _PageInfo_hasNextPage(ctx context.Context, field gra }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.HasNextPage, nil + return obj.Processes(ctx) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(bool) + res := resTmp.([]*ent.HostProcess) fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) + return ec.marshalOHostProcess2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostProcessᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_PageInfo_hasNextPage(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Host_processes(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "PageInfo", + Object: "Host", Field: field, - IsMethod: false, + IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Boolean does not have child fields") + switch field.Name { + case "id": + return ec.fieldContext_HostProcess_id(ctx, field) + case "createdAt": + return ec.fieldContext_HostProcess_createdAt(ctx, field) + case "lastModifiedAt": + return ec.fieldContext_HostProcess_lastModifiedAt(ctx, field) + case "pid": + return ec.fieldContext_HostProcess_pid(ctx, field) + case "ppid": + return ec.fieldContext_HostProcess_ppid(ctx, field) + case "name": + return ec.fieldContext_HostProcess_name(ctx, field) + case "principal": + return ec.fieldContext_HostProcess_principal(ctx, field) + case "path": + return ec.fieldContext_HostProcess_path(ctx, field) + case "cmd": + return ec.fieldContext_HostProcess_cmd(ctx, field) + case "env": + return ec.fieldContext_HostProcess_env(ctx, field) + case "cwd": + return ec.fieldContext_HostProcess_cwd(ctx, field) + case "status": + return ec.fieldContext_HostProcess_status(ctx, field) + case "host": + return ec.fieldContext_HostProcess_host(ctx, field) + case "task": + return ec.fieldContext_HostProcess_task(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type HostProcess", field.Name) }, } return fc, nil } -func (ec *executionContext) _PageInfo_hasPreviousPage(ctx context.Context, field graphql.CollectedField, obj *entgql.PageInfo[int]) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_PageInfo_hasPreviousPage(ctx, field) +func (ec *executionContext) _HostFile_id(ctx context.Context, field graphql.CollectedField, obj *ent.HostFile) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_HostFile_id(ctx, field) if err != nil { return graphql.Null } @@ -1699,7 +1745,7 @@ func (ec *executionContext) _PageInfo_hasPreviousPage(ctx context.Context, field }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.HasPreviousPage, nil + return obj.ID, nil }) if err != nil { ec.Error(ctx, err) @@ -1711,26 +1757,26 @@ func (ec *executionContext) _PageInfo_hasPreviousPage(ctx context.Context, field } return graphql.Null } - res := resTmp.(bool) + res := resTmp.(int) fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) + return ec.marshalNID2int(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_PageInfo_hasPreviousPage(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostFile_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "PageInfo", + Object: "HostFile", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Boolean does not have child fields") + return nil, errors.New("field of type ID does not have child fields") }, } return fc, nil } -func (ec *executionContext) _PageInfo_startCursor(ctx context.Context, field graphql.CollectedField, obj *entgql.PageInfo[int]) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_PageInfo_startCursor(ctx, field) +func (ec *executionContext) _HostFile_createdAt(ctx context.Context, field graphql.CollectedField, obj *ent.HostFile) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_HostFile_createdAt(ctx, field) if err != nil { return graphql.Null } @@ -1743,35 +1789,38 @@ func (ec *executionContext) _PageInfo_startCursor(ctx context.Context, field gra }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.StartCursor, nil + return obj.CreatedAt, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*entgql.Cursor[int]) + res := resTmp.(time.Time) fc.Result = res - return ec.marshalOCursor2ᚖentgoᚗioᚋcontribᚋentgqlᚐCursor(ctx, field.Selections, res) + return ec.marshalNTime2timeᚐTime(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_PageInfo_startCursor(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostFile_createdAt(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "PageInfo", + Object: "HostFile", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Cursor does not have child fields") + return nil, errors.New("field of type Time does not have child fields") }, } return fc, nil } -func (ec *executionContext) _PageInfo_endCursor(ctx context.Context, field graphql.CollectedField, obj *entgql.PageInfo[int]) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_PageInfo_endCursor(ctx, field) +func (ec *executionContext) _HostFile_lastModifiedAt(ctx context.Context, field graphql.CollectedField, obj *ent.HostFile) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_HostFile_lastModifiedAt(ctx, field) if err != nil { return graphql.Null } @@ -1784,35 +1833,38 @@ func (ec *executionContext) _PageInfo_endCursor(ctx context.Context, field graph }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.EndCursor, nil + return obj.LastModifiedAt, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*entgql.Cursor[int]) + res := resTmp.(time.Time) fc.Result = res - return ec.marshalOCursor2ᚖentgoᚗioᚋcontribᚋentgqlᚐCursor(ctx, field.Selections, res) + return ec.marshalNTime2timeᚐTime(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_PageInfo_endCursor(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostFile_lastModifiedAt(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "PageInfo", + Object: "HostFile", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Cursor does not have child fields") + return nil, errors.New("field of type Time does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Process_id(ctx context.Context, field graphql.CollectedField, obj *ent.Process) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Process_id(ctx, field) +func (ec *executionContext) _HostFile_path(ctx context.Context, field graphql.CollectedField, obj *ent.HostFile) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_HostFile_path(ctx, field) if err != nil { return graphql.Null } @@ -1825,7 +1877,7 @@ func (ec *executionContext) _Process_id(ctx context.Context, field graphql.Colle }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.ID, nil + return obj.Path, nil }) if err != nil { ec.Error(ctx, err) @@ -1837,26 +1889,26 @@ func (ec *executionContext) _Process_id(ctx context.Context, field graphql.Colle } return graphql.Null } - res := resTmp.(int) + res := resTmp.(string) fc.Result = res - return ec.marshalNID2int(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Process_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostFile_path(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Process", + Object: "HostFile", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type ID does not have child fields") + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Process_createdAt(ctx context.Context, field graphql.CollectedField, obj *ent.Process) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Process_createdAt(ctx, field) +func (ec *executionContext) _HostFile_owner(ctx context.Context, field graphql.CollectedField, obj *ent.HostFile) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_HostFile_owner(ctx, field) if err != nil { return graphql.Null } @@ -1869,38 +1921,35 @@ func (ec *executionContext) _Process_createdAt(ctx context.Context, field graphq }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.CreatedAt, nil + return obj.Owner, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(time.Time) + res := resTmp.(string) fc.Result = res - return ec.marshalNTime2timeᚐTime(ctx, field.Selections, res) + return ec.marshalOString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Process_createdAt(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostFile_owner(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Process", + Object: "HostFile", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Time does not have child fields") + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Process_lastModifiedAt(ctx context.Context, field graphql.CollectedField, obj *ent.Process) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Process_lastModifiedAt(ctx, field) +func (ec *executionContext) _HostFile_group(ctx context.Context, field graphql.CollectedField, obj *ent.HostFile) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_HostFile_group(ctx, field) if err != nil { return graphql.Null } @@ -1913,38 +1962,35 @@ func (ec *executionContext) _Process_lastModifiedAt(ctx context.Context, field g }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.LastModifiedAt, nil + return obj.Group, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(time.Time) + res := resTmp.(string) fc.Result = res - return ec.marshalNTime2timeᚐTime(ctx, field.Selections, res) + return ec.marshalOString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Process_lastModifiedAt(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostFile_group(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Process", + Object: "HostFile", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Time does not have child fields") + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Process_pid(ctx context.Context, field graphql.CollectedField, obj *ent.Process) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Process_pid(ctx, field) +func (ec *executionContext) _HostFile_permissions(ctx context.Context, field graphql.CollectedField, obj *ent.HostFile) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_HostFile_permissions(ctx, field) if err != nil { return graphql.Null } @@ -1957,38 +2003,35 @@ func (ec *executionContext) _Process_pid(ctx context.Context, field graphql.Coll }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Process().Pid(rctx, obj) + return obj.Permissions, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(int) + res := resTmp.(string) fc.Result = res - return ec.marshalNInt2int(ctx, field.Selections, res) + return ec.marshalOString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Process_pid(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostFile_permissions(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Process", + Object: "HostFile", Field: field, - IsMethod: true, - IsResolver: true, + IsMethod: false, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Int does not have child fields") + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Process_name(ctx context.Context, field graphql.CollectedField, obj *ent.Process) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Process_name(ctx, field) +func (ec *executionContext) _HostFile_size(ctx context.Context, field graphql.CollectedField, obj *ent.HostFile) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_HostFile_size(ctx, field) if err != nil { return graphql.Null } @@ -2001,7 +2044,7 @@ func (ec *executionContext) _Process_name(ctx context.Context, field graphql.Col }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Name, nil + return obj.Size, nil }) if err != nil { ec.Error(ctx, err) @@ -2013,26 +2056,26 @@ func (ec *executionContext) _Process_name(ctx context.Context, field graphql.Col } return graphql.Null } - res := resTmp.(string) + res := resTmp.(int) fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) + return ec.marshalNInt2int(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Process_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostFile_size(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Process", + Object: "HostFile", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + return nil, errors.New("field of type Int does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Process_principal(ctx context.Context, field graphql.CollectedField, obj *ent.Process) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Process_principal(ctx, field) +func (ec *executionContext) _HostFile_hash(ctx context.Context, field graphql.CollectedField, obj *ent.HostFile) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_HostFile_hash(ctx, field) if err != nil { return graphql.Null } @@ -2045,26 +2088,23 @@ func (ec *executionContext) _Process_principal(ctx context.Context, field graphq }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Principal, nil + return obj.Hash, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } res := resTmp.(string) fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) + return ec.marshalOString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Process_principal(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostFile_hash(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Process", + Object: "HostFile", Field: field, IsMethod: false, IsResolver: false, @@ -2075,8 +2115,8 @@ func (ec *executionContext) fieldContext_Process_principal(ctx context.Context, return fc, nil } -func (ec *executionContext) _Process_host(ctx context.Context, field graphql.CollectedField, obj *ent.Process) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Process_host(ctx, field) +func (ec *executionContext) _HostFile_host(ctx context.Context, field graphql.CollectedField, obj *ent.HostFile) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_HostFile_host(ctx, field) if err != nil { return graphql.Null } @@ -2106,9 +2146,9 @@ func (ec *executionContext) _Process_host(ctx context.Context, field graphql.Col return ec.marshalNHost2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHost(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Process_host(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostFile_host(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Process", + Object: "HostFile", Field: field, IsMethod: true, IsResolver: false, @@ -2134,6 +2174,8 @@ func (ec *executionContext) fieldContext_Process_host(ctx context.Context, field return ec.fieldContext_Host_tags(ctx, field) case "beacons": return ec.fieldContext_Host_beacons(ctx, field) + case "files": + return ec.fieldContext_Host_files(ctx, field) case "processes": return ec.fieldContext_Host_processes(ctx, field) } @@ -2143,8 +2185,8 @@ func (ec *executionContext) fieldContext_Process_host(ctx context.Context, field return fc, nil } -func (ec *executionContext) _Process_task(ctx context.Context, field graphql.CollectedField, obj *ent.Process) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Process_task(ctx, field) +func (ec *executionContext) _HostFile_task(ctx context.Context, field graphql.CollectedField, obj *ent.HostFile) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_HostFile_task(ctx, field) if err != nil { return graphql.Null } @@ -2174,9 +2216,9 @@ func (ec *executionContext) _Process_task(ctx context.Context, field graphql.Col return ec.marshalNTask2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTask(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Process_task(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostFile_task(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Process", + Object: "HostFile", Field: field, IsMethod: true, IsResolver: false, @@ -2204,6 +2246,8 @@ func (ec *executionContext) fieldContext_Process_task(ctx context.Context, field return ec.fieldContext_Task_quest(ctx, field) case "beacon": return ec.fieldContext_Task_beacon(ctx, field) + case "reportedFiles": + return ec.fieldContext_Task_reportedFiles(ctx, field) case "reportedProcesses": return ec.fieldContext_Task_reportedProcesses(ctx, field) } @@ -2213,8 +2257,8 @@ func (ec *executionContext) fieldContext_Process_task(ctx context.Context, field return fc, nil } -func (ec *executionContext) _Query_node(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query_node(ctx, field) +func (ec *executionContext) _HostProcess_id(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcess) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_HostProcess_id(ctx, field) if err != nil { return graphql.Null } @@ -2227,46 +2271,38 @@ func (ec *executionContext) _Query_node(ctx context.Context, field graphql.Colle }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().Node(rctx, fc.Args["id"].(int)) + return obj.ID, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(ent.Noder) + res := resTmp.(int) fc.Result = res - return ec.marshalONode2realmᚗpubᚋtavernᚋinternalᚋentᚐNoder(ctx, field.Selections, res) + return ec.marshalNID2int(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Query_node(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostProcess_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Query", + Object: "HostProcess", Field: field, - IsMethod: true, - IsResolver: true, + IsMethod: false, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("FieldContext.Child cannot be called on type INTERFACE") + return nil, errors.New("field of type ID does not have child fields") }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_node_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Query_nodes(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query_nodes(ctx, field) +func (ec *executionContext) _HostProcess_createdAt(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcess) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_HostProcess_createdAt(ctx, field) if err != nil { return graphql.Null } @@ -2279,7 +2315,7 @@ func (ec *executionContext) _Query_nodes(ctx context.Context, field graphql.Coll }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().Nodes(rctx, fc.Args["ids"].([]int)) + return obj.CreatedAt, nil }) if err != nil { ec.Error(ctx, err) @@ -2291,37 +2327,70 @@ func (ec *executionContext) _Query_nodes(ctx context.Context, field graphql.Coll } return graphql.Null } - res := resTmp.([]ent.Noder) + res := resTmp.(time.Time) fc.Result = res - return ec.marshalNNode2ᚕrealmᚗpubᚋtavernᚋinternalᚋentᚐNoder(ctx, field.Selections, res) + return ec.marshalNTime2timeᚐTime(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Query_nodes(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostProcess_createdAt(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Query", + Object: "HostProcess", Field: field, - IsMethod: true, - IsResolver: true, + IsMethod: false, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("FieldContext.Child cannot be called on type INTERFACE") + return nil, errors.New("field of type Time does not have child fields") }, } + return fc, nil +} + +func (ec *executionContext) _HostProcess_lastModifiedAt(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcess) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_HostProcess_lastModifiedAt(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) defer func() { if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null } }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_nodes_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.LastModifiedAt, nil + }) + if err != nil { ec.Error(ctx, err) - return fc, err + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(time.Time) + fc.Result = res + return ec.marshalNTime2timeᚐTime(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_HostProcess_lastModifiedAt(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "HostProcess", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Time does not have child fields") + }, } return fc, nil } -func (ec *executionContext) _Query_files(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query_files(ctx, field) +func (ec *executionContext) _HostProcess_pid(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcess) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_HostProcess_pid(ctx, field) if err != nil { return graphql.Null } @@ -2333,32 +2402,8 @@ func (ec *executionContext) _Query_files(ctx context.Context, field graphql.Coll } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - directive0 := func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().Files(rctx, fc.Args["where"].(*ent.FileWhereInput)) - } - directive1 := func(ctx context.Context) (interface{}, error) { - role, err := ec.unmarshalNRole2realmᚗpubᚋtavernᚋinternalᚋgraphqlᚋmodelsᚐRole(ctx, "USER") - if err != nil { - return nil, err - } - if ec.directives.RequireRole == nil { - return nil, errors.New("directive requireRole is not implemented") - } - return ec.directives.RequireRole(ctx, nil, directive0, role) - } - - tmp, err := directive1(rctx) - if err != nil { - return nil, graphql.ErrorOnPath(ctx, err) - } - if tmp == nil { - return nil, nil - } - if data, ok := tmp.([]*ent.File); ok { - return data, nil - } - return nil, fmt.Errorf(`unexpected type %T from directive, should be []*realm.pub/tavern/internal/ent.File`, tmp) + ctx = rctx // use context from middleware stack in children + return ec.resolvers.HostProcess().Pid(rctx, obj) }) if err != nil { ec.Error(ctx, err) @@ -2370,53 +2415,26 @@ func (ec *executionContext) _Query_files(ctx context.Context, field graphql.Coll } return graphql.Null } - res := resTmp.([]*ent.File) + res := resTmp.(int) fc.Result = res - return ec.marshalNFile2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐFileᚄ(ctx, field.Selections, res) + return ec.marshalNInt2int(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Query_files(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostProcess_pid(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Query", + Object: "HostProcess", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_File_id(ctx, field) - case "createdAt": - return ec.fieldContext_File_createdAt(ctx, field) - case "lastModifiedAt": - return ec.fieldContext_File_lastModifiedAt(ctx, field) - case "name": - return ec.fieldContext_File_name(ctx, field) - case "size": - return ec.fieldContext_File_size(ctx, field) - case "hash": - return ec.fieldContext_File_hash(ctx, field) - case "tomes": - return ec.fieldContext_File_tomes(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type File", field.Name) + return nil, errors.New("field of type Int does not have child fields") }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_files_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Query_quests(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query_quests(ctx, field) +func (ec *executionContext) _HostProcess_ppid(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcess) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_HostProcess_ppid(ctx, field) if err != nil { return graphql.Null } @@ -2428,32 +2446,8 @@ func (ec *executionContext) _Query_quests(ctx context.Context, field graphql.Col } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - directive0 := func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().Quests(rctx, fc.Args["where"].(*ent.QuestWhereInput)) - } - directive1 := func(ctx context.Context) (interface{}, error) { - role, err := ec.unmarshalNRole2realmᚗpubᚋtavernᚋinternalᚋgraphqlᚋmodelsᚐRole(ctx, "USER") - if err != nil { - return nil, err - } - if ec.directives.RequireRole == nil { - return nil, errors.New("directive requireRole is not implemented") - } - return ec.directives.RequireRole(ctx, nil, directive0, role) - } - - tmp, err := directive1(rctx) - if err != nil { - return nil, graphql.ErrorOnPath(ctx, err) - } - if tmp == nil { - return nil, nil - } - if data, ok := tmp.([]*ent.Quest); ok { - return data, nil - } - return nil, fmt.Errorf(`unexpected type %T from directive, should be []*realm.pub/tavern/internal/ent.Quest`, tmp) + ctx = rctx // use context from middleware stack in children + return ec.resolvers.HostProcess().Ppid(rctx, obj) }) if err != nil { ec.Error(ctx, err) @@ -2465,57 +2459,26 @@ func (ec *executionContext) _Query_quests(ctx context.Context, field graphql.Col } return graphql.Null } - res := resTmp.([]*ent.Quest) + res := resTmp.(int) fc.Result = res - return ec.marshalNQuest2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐQuestᚄ(ctx, field.Selections, res) + return ec.marshalNInt2int(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Query_quests(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostProcess_ppid(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Query", + Object: "HostProcess", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_Quest_id(ctx, field) - case "createdAt": - return ec.fieldContext_Quest_createdAt(ctx, field) - case "lastModifiedAt": - return ec.fieldContext_Quest_lastModifiedAt(ctx, field) - case "name": - return ec.fieldContext_Quest_name(ctx, field) - case "parameters": - return ec.fieldContext_Quest_parameters(ctx, field) - case "tome": - return ec.fieldContext_Quest_tome(ctx, field) - case "bundle": - return ec.fieldContext_Quest_bundle(ctx, field) - case "tasks": - return ec.fieldContext_Quest_tasks(ctx, field) - case "creator": - return ec.fieldContext_Quest_creator(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type Quest", field.Name) + return nil, errors.New("field of type Int does not have child fields") }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_quests_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Query_tasks(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query_tasks(ctx, field) +func (ec *executionContext) _HostProcess_name(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcess) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_HostProcess_name(ctx, field) if err != nil { return graphql.Null } @@ -2527,32 +2490,8 @@ func (ec *executionContext) _Query_tasks(ctx context.Context, field graphql.Coll } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - directive0 := func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().Tasks(rctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.TaskOrder), fc.Args["where"].(*ent.TaskWhereInput)) - } - directive1 := func(ctx context.Context) (interface{}, error) { - role, err := ec.unmarshalNRole2realmᚗpubᚋtavernᚋinternalᚋgraphqlᚋmodelsᚐRole(ctx, "USER") - if err != nil { - return nil, err - } - if ec.directives.RequireRole == nil { - return nil, errors.New("directive requireRole is not implemented") - } - return ec.directives.RequireRole(ctx, nil, directive0, role) - } - - tmp, err := directive1(rctx) - if err != nil { - return nil, graphql.ErrorOnPath(ctx, err) - } - if tmp == nil { - return nil, nil - } - if data, ok := tmp.(*ent.TaskConnection); ok { - return data, nil - } - return nil, fmt.Errorf(`unexpected type %T from directive, should be *realm.pub/tavern/internal/ent.TaskConnection`, tmp) + ctx = rctx // use context from middleware stack in children + return obj.Name, nil }) if err != nil { ec.Error(ctx, err) @@ -2564,45 +2503,26 @@ func (ec *executionContext) _Query_tasks(ctx context.Context, field graphql.Coll } return graphql.Null } - res := resTmp.(*ent.TaskConnection) + res := resTmp.(string) fc.Result = res - return ec.marshalNTaskConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTaskConnection(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Query_tasks(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostProcess_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Query", + Object: "HostProcess", Field: field, - IsMethod: true, - IsResolver: true, + IsMethod: false, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "edges": - return ec.fieldContext_TaskConnection_edges(ctx, field) - case "pageInfo": - return ec.fieldContext_TaskConnection_pageInfo(ctx, field) - case "totalCount": - return ec.fieldContext_TaskConnection_totalCount(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type TaskConnection", field.Name) + return nil, errors.New("field of type String does not have child fields") }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_tasks_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Query_beacons(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query_beacons(ctx, field) +func (ec *executionContext) _HostProcess_principal(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcess) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_HostProcess_principal(ctx, field) if err != nil { return graphql.Null } @@ -2614,32 +2534,8 @@ func (ec *executionContext) _Query_beacons(ctx context.Context, field graphql.Co } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - directive0 := func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().Beacons(rctx, fc.Args["where"].(*ent.BeaconWhereInput)) - } - directive1 := func(ctx context.Context) (interface{}, error) { - role, err := ec.unmarshalNRole2realmᚗpubᚋtavernᚋinternalᚋgraphqlᚋmodelsᚐRole(ctx, "USER") - if err != nil { - return nil, err - } - if ec.directives.RequireRole == nil { - return nil, errors.New("directive requireRole is not implemented") - } - return ec.directives.RequireRole(ctx, nil, directive0, role) - } - - tmp, err := directive1(rctx) - if err != nil { - return nil, graphql.ErrorOnPath(ctx, err) - } - if tmp == nil { - return nil, nil - } - if data, ok := tmp.([]*ent.Beacon); ok { - return data, nil - } - return nil, fmt.Errorf(`unexpected type %T from directive, should be []*realm.pub/tavern/internal/ent.Beacon`, tmp) + ctx = rctx // use context from middleware stack in children + return obj.Principal, nil }) if err != nil { ec.Error(ctx, err) @@ -2651,61 +2547,26 @@ func (ec *executionContext) _Query_beacons(ctx context.Context, field graphql.Co } return graphql.Null } - res := resTmp.([]*ent.Beacon) + res := resTmp.(string) fc.Result = res - return ec.marshalNBeacon2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBeaconᚄ(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Query_beacons(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostProcess_principal(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Query", + Object: "HostProcess", Field: field, - IsMethod: true, - IsResolver: true, + IsMethod: false, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_Beacon_id(ctx, field) - case "createdAt": - return ec.fieldContext_Beacon_createdAt(ctx, field) - case "lastModifiedAt": - return ec.fieldContext_Beacon_lastModifiedAt(ctx, field) - case "name": - return ec.fieldContext_Beacon_name(ctx, field) - case "principal": - return ec.fieldContext_Beacon_principal(ctx, field) - case "identifier": - return ec.fieldContext_Beacon_identifier(ctx, field) - case "agentIdentifier": - return ec.fieldContext_Beacon_agentIdentifier(ctx, field) - case "lastSeenAt": - return ec.fieldContext_Beacon_lastSeenAt(ctx, field) - case "interval": - return ec.fieldContext_Beacon_interval(ctx, field) - case "host": - return ec.fieldContext_Beacon_host(ctx, field) - case "tasks": - return ec.fieldContext_Beacon_tasks(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type Beacon", field.Name) + return nil, errors.New("field of type String does not have child fields") }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_beacons_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Query_hosts(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query_hosts(ctx, field) +func (ec *executionContext) _HostProcess_path(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcess) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_HostProcess_path(ctx, field) if err != nil { return graphql.Null } @@ -2717,98 +2578,77 @@ func (ec *executionContext) _Query_hosts(ctx context.Context, field graphql.Coll } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - directive0 := func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().Hosts(rctx, fc.Args["where"].(*ent.HostWhereInput)) - } - directive1 := func(ctx context.Context) (interface{}, error) { - role, err := ec.unmarshalNRole2realmᚗpubᚋtavernᚋinternalᚋgraphqlᚋmodelsᚐRole(ctx, "USER") - if err != nil { - return nil, err - } - if ec.directives.RequireRole == nil { - return nil, errors.New("directive requireRole is not implemented") - } - return ec.directives.RequireRole(ctx, nil, directive0, role) - } - - tmp, err := directive1(rctx) - if err != nil { - return nil, graphql.ErrorOnPath(ctx, err) - } - if tmp == nil { - return nil, nil - } - if data, ok := tmp.([]*ent.Host); ok { - return data, nil - } - return nil, fmt.Errorf(`unexpected type %T from directive, should be []*realm.pub/tavern/internal/ent.Host`, tmp) + ctx = rctx // use context from middleware stack in children + return obj.Path, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.([]*ent.Host) + res := resTmp.(string) fc.Result = res - return ec.marshalNHost2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostᚄ(ctx, field.Selections, res) + return ec.marshalOString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Query_hosts(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostProcess_path(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Query", + Object: "HostProcess", Field: field, - IsMethod: true, - IsResolver: true, + IsMethod: false, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_Host_id(ctx, field) - case "createdAt": - return ec.fieldContext_Host_createdAt(ctx, field) - case "lastModifiedAt": - return ec.fieldContext_Host_lastModifiedAt(ctx, field) - case "identifier": - return ec.fieldContext_Host_identifier(ctx, field) - case "name": - return ec.fieldContext_Host_name(ctx, field) - case "primaryIP": - return ec.fieldContext_Host_primaryIP(ctx, field) - case "platform": - return ec.fieldContext_Host_platform(ctx, field) - case "lastSeenAt": - return ec.fieldContext_Host_lastSeenAt(ctx, field) - case "tags": - return ec.fieldContext_Host_tags(ctx, field) - case "beacons": - return ec.fieldContext_Host_beacons(ctx, field) - case "processes": - return ec.fieldContext_Host_processes(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type Host", field.Name) + return nil, errors.New("field of type String does not have child fields") }, } + return fc, nil +} + +func (ec *executionContext) _HostProcess_cmd(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcess) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_HostProcess_cmd(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) defer func() { if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null } }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_hosts_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Cmd, nil + }) + if err != nil { ec.Error(ctx, err) - return fc, err + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalOString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_HostProcess_cmd(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "HostProcess", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, } return fc, nil } -func (ec *executionContext) _Query_tags(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query_tags(ctx, field) +func (ec *executionContext) _HostProcess_env(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcess) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_HostProcess_env(ctx, field) if err != nil { return graphql.Null } @@ -2820,84 +2660,77 @@ func (ec *executionContext) _Query_tags(ctx context.Context, field graphql.Colle } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - directive0 := func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().Tags(rctx, fc.Args["where"].(*ent.TagWhereInput)) - } - directive1 := func(ctx context.Context) (interface{}, error) { - role, err := ec.unmarshalNRole2realmᚗpubᚋtavernᚋinternalᚋgraphqlᚋmodelsᚐRole(ctx, "USER") - if err != nil { - return nil, err - } - if ec.directives.RequireRole == nil { - return nil, errors.New("directive requireRole is not implemented") - } - return ec.directives.RequireRole(ctx, nil, directive0, role) - } - - tmp, err := directive1(rctx) - if err != nil { - return nil, graphql.ErrorOnPath(ctx, err) - } - if tmp == nil { - return nil, nil - } - if data, ok := tmp.([]*ent.Tag); ok { - return data, nil - } - return nil, fmt.Errorf(`unexpected type %T from directive, should be []*realm.pub/tavern/internal/ent.Tag`, tmp) + ctx = rctx // use context from middleware stack in children + return obj.Env, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.([]*ent.Tag) + res := resTmp.(string) fc.Result = res - return ec.marshalNTag2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTagᚄ(ctx, field.Selections, res) + return ec.marshalOString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Query_tags(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostProcess_env(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Query", + Object: "HostProcess", Field: field, - IsMethod: true, - IsResolver: true, + IsMethod: false, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_Tag_id(ctx, field) - case "name": - return ec.fieldContext_Tag_name(ctx, field) - case "kind": - return ec.fieldContext_Tag_kind(ctx, field) - case "hosts": - return ec.fieldContext_Tag_hosts(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type Tag", field.Name) + return nil, errors.New("field of type String does not have child fields") }, } + return fc, nil +} + +func (ec *executionContext) _HostProcess_cwd(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcess) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_HostProcess_cwd(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) defer func() { if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null } }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_tags_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Cwd, nil + }) + if err != nil { ec.Error(ctx, err) - return fc, err + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalOString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_HostProcess_cwd(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "HostProcess", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, } return fc, nil } -func (ec *executionContext) _Query_tomes(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query_tomes(ctx, field) +func (ec *executionContext) _HostProcess_status(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcess) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_HostProcess_status(ctx, field) if err != nil { return graphql.Null } @@ -2909,32 +2742,8 @@ func (ec *executionContext) _Query_tomes(ctx context.Context, field graphql.Coll } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - directive0 := func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().Tomes(rctx, fc.Args["where"].(*ent.TomeWhereInput)) - } - directive1 := func(ctx context.Context) (interface{}, error) { - role, err := ec.unmarshalNRole2realmᚗpubᚋtavernᚋinternalᚋgraphqlᚋmodelsᚐRole(ctx, "USER") - if err != nil { - return nil, err - } - if ec.directives.RequireRole == nil { - return nil, errors.New("directive requireRole is not implemented") - } - return ec.directives.RequireRole(ctx, nil, directive0, role) - } - - tmp, err := directive1(rctx) - if err != nil { - return nil, graphql.ErrorOnPath(ctx, err) - } - if tmp == nil { - return nil, nil - } - if data, ok := tmp.([]*ent.Tome); ok { - return data, nil - } - return nil, fmt.Errorf(`unexpected type %T from directive, should be []*realm.pub/tavern/internal/ent.Tome`, tmp) + ctx = rctx // use context from middleware stack in children + return obj.Status, nil }) if err != nil { ec.Error(ctx, err) @@ -2946,63 +2755,26 @@ func (ec *executionContext) _Query_tomes(ctx context.Context, field graphql.Coll } return graphql.Null } - res := resTmp.([]*ent.Tome) + res := resTmp.(c2pb.Process_Status) fc.Result = res - return ec.marshalNTome2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTomeᚄ(ctx, field.Selections, res) + return ec.marshalNHostProcessStatus2realmᚗpubᚋtavernᚋinternalᚋc2ᚋc2pbᚐProcess_Status(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Query_tomes(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostProcess_status(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Query", + Object: "HostProcess", Field: field, - IsMethod: true, - IsResolver: true, + IsMethod: false, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_Tome_id(ctx, field) - case "createdAt": - return ec.fieldContext_Tome_createdAt(ctx, field) - case "lastModifiedAt": - return ec.fieldContext_Tome_lastModifiedAt(ctx, field) - case "name": - return ec.fieldContext_Tome_name(ctx, field) - case "description": - return ec.fieldContext_Tome_description(ctx, field) - case "author": - return ec.fieldContext_Tome_author(ctx, field) - case "supportModel": - return ec.fieldContext_Tome_supportModel(ctx, field) - case "tactic": - return ec.fieldContext_Tome_tactic(ctx, field) - case "paramDefs": - return ec.fieldContext_Tome_paramDefs(ctx, field) - case "eldritch": - return ec.fieldContext_Tome_eldritch(ctx, field) - case "files": - return ec.fieldContext_Tome_files(ctx, field) - case "uploader": - return ec.fieldContext_Tome_uploader(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type Tome", field.Name) + return nil, errors.New("field of type HostProcessStatus does not have child fields") }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_tomes_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Query_users(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query_users(ctx, field) +func (ec *executionContext) _HostProcess_host(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcess) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_HostProcess_host(ctx, field) if err != nil { return graphql.Null } @@ -3014,32 +2786,8 @@ func (ec *executionContext) _Query_users(ctx context.Context, field graphql.Coll } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - directive0 := func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().Users(rctx, fc.Args["where"].(*ent.UserWhereInput)) - } - directive1 := func(ctx context.Context) (interface{}, error) { - role, err := ec.unmarshalNRole2realmᚗpubᚋtavernᚋinternalᚋgraphqlᚋmodelsᚐRole(ctx, "USER") - if err != nil { - return nil, err - } - if ec.directives.RequireRole == nil { - return nil, errors.New("directive requireRole is not implemented") - } - return ec.directives.RequireRole(ctx, nil, directive0, role) - } - - tmp, err := directive1(rctx) - if err != nil { - return nil, graphql.ErrorOnPath(ctx, err) - } - if tmp == nil { - return nil, nil - } - if data, ok := tmp.([]*ent.User); ok { - return data, nil - } - return nil, fmt.Errorf(`unexpected type %T from directive, should be []*realm.pub/tavern/internal/ent.User`, tmp) + ctx = rctx // use context from middleware stack in children + return obj.Host(ctx) }) if err != nil { ec.Error(ctx, err) @@ -3051,51 +2799,52 @@ func (ec *executionContext) _Query_users(ctx context.Context, field graphql.Coll } return graphql.Null } - res := resTmp.([]*ent.User) + res := resTmp.(*ent.Host) fc.Result = res - return ec.marshalNUser2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐUserᚄ(ctx, field.Selections, res) + return ec.marshalNHost2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHost(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Query_users(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostProcess_host(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Query", + Object: "HostProcess", Field: field, IsMethod: true, - IsResolver: true, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": - return ec.fieldContext_User_id(ctx, field) + return ec.fieldContext_Host_id(ctx, field) + case "createdAt": + return ec.fieldContext_Host_createdAt(ctx, field) + case "lastModifiedAt": + return ec.fieldContext_Host_lastModifiedAt(ctx, field) + case "identifier": + return ec.fieldContext_Host_identifier(ctx, field) case "name": - return ec.fieldContext_User_name(ctx, field) - case "photoURL": - return ec.fieldContext_User_photoURL(ctx, field) - case "isActivated": - return ec.fieldContext_User_isActivated(ctx, field) - case "isAdmin": - return ec.fieldContext_User_isAdmin(ctx, field) - case "tomes": - return ec.fieldContext_User_tomes(ctx, field) + return ec.fieldContext_Host_name(ctx, field) + case "primaryIP": + return ec.fieldContext_Host_primaryIP(ctx, field) + case "platform": + return ec.fieldContext_Host_platform(ctx, field) + case "lastSeenAt": + return ec.fieldContext_Host_lastSeenAt(ctx, field) + case "tags": + return ec.fieldContext_Host_tags(ctx, field) + case "beacons": + return ec.fieldContext_Host_beacons(ctx, field) + case "files": + return ec.fieldContext_Host_files(ctx, field) + case "processes": + return ec.fieldContext_Host_processes(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type User", field.Name) + return nil, fmt.Errorf("no field named %q was found under type Host", field.Name) }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_users_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Query_me(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query_me(ctx, field) +func (ec *executionContext) _HostProcess_task(ctx context.Context, field graphql.CollectedField, obj *ent.HostProcess) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_HostProcess_task(ctx, field) if err != nil { return graphql.Null } @@ -3108,7 +2857,7 @@ func (ec *executionContext) _Query_me(ctx context.Context, field graphql.Collect }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().Me(rctx) + return obj.Task(ctx) }) if err != nil { ec.Error(ctx, err) @@ -3120,40 +2869,54 @@ func (ec *executionContext) _Query_me(ctx context.Context, field graphql.Collect } return graphql.Null } - res := resTmp.(*ent.User) + res := resTmp.(*ent.Task) fc.Result = res - return ec.marshalNUser2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐUser(ctx, field.Selections, res) + return ec.marshalNTask2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTask(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Query_me(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_HostProcess_task(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Query", + Object: "HostProcess", Field: field, IsMethod: true, - IsResolver: true, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": - return ec.fieldContext_User_id(ctx, field) - case "name": - return ec.fieldContext_User_name(ctx, field) - case "photoURL": - return ec.fieldContext_User_photoURL(ctx, field) - case "isActivated": - return ec.fieldContext_User_isActivated(ctx, field) - case "isAdmin": - return ec.fieldContext_User_isAdmin(ctx, field) - case "tomes": - return ec.fieldContext_User_tomes(ctx, field) + return ec.fieldContext_Task_id(ctx, field) + case "createdAt": + return ec.fieldContext_Task_createdAt(ctx, field) + case "lastModifiedAt": + return ec.fieldContext_Task_lastModifiedAt(ctx, field) + case "claimedAt": + return ec.fieldContext_Task_claimedAt(ctx, field) + case "execStartedAt": + return ec.fieldContext_Task_execStartedAt(ctx, field) + case "execFinishedAt": + return ec.fieldContext_Task_execFinishedAt(ctx, field) + case "output": + return ec.fieldContext_Task_output(ctx, field) + case "outputSize": + return ec.fieldContext_Task_outputSize(ctx, field) + case "error": + return ec.fieldContext_Task_error(ctx, field) + case "quest": + return ec.fieldContext_Task_quest(ctx, field) + case "beacon": + return ec.fieldContext_Task_beacon(ctx, field) + case "reportedFiles": + return ec.fieldContext_Task_reportedFiles(ctx, field) + case "reportedProcesses": + return ec.fieldContext_Task_reportedProcesses(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type User", field.Name) + return nil, fmt.Errorf("no field named %q was found under type Task", field.Name) }, } return fc, nil } -func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query___type(ctx, field) +func (ec *executionContext) _PageInfo_hasNextPage(ctx context.Context, field graphql.CollectedField, obj *entgql.PageInfo[int]) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_PageInfo_hasNextPage(ctx, field) if err != nil { return graphql.Null } @@ -3166,68 +2929,38 @@ func (ec *executionContext) _Query___type(ctx context.Context, field graphql.Col }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.introspectType(fc.Args["name"].(string)) + return obj.HasNextPage, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*introspection.Type) + res := resTmp.(bool) fc.Result = res - return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalNBoolean2bool(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Query___type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_PageInfo_hasNextPage(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Query", + Object: "PageInfo", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "kind": - return ec.fieldContext___Type_kind(ctx, field) - case "name": - return ec.fieldContext___Type_name(ctx, field) - case "description": - return ec.fieldContext___Type_description(ctx, field) - case "fields": - return ec.fieldContext___Type_fields(ctx, field) - case "interfaces": - return ec.fieldContext___Type_interfaces(ctx, field) - case "possibleTypes": - return ec.fieldContext___Type_possibleTypes(ctx, field) - case "enumValues": - return ec.fieldContext___Type_enumValues(ctx, field) - case "inputFields": - return ec.fieldContext___Type_inputFields(ctx, field) - case "ofType": - return ec.fieldContext___Type_ofType(ctx, field) - case "specifiedByURL": - return ec.fieldContext___Type_specifiedByURL(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + return nil, errors.New("field of type Boolean does not have child fields") }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query___type_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query___schema(ctx, field) +func (ec *executionContext) _PageInfo_hasPreviousPage(ctx context.Context, field graphql.CollectedField, obj *entgql.PageInfo[int]) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_PageInfo_hasPreviousPage(ctx, field) if err != nil { return graphql.Null } @@ -3240,49 +2973,38 @@ func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.C }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.introspectSchema() + return obj.HasPreviousPage, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*introspection.Schema) + res := resTmp.(bool) fc.Result = res - return ec.marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx, field.Selections, res) + return ec.marshalNBoolean2bool(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Query___schema(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_PageInfo_hasPreviousPage(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Query", + Object: "PageInfo", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "description": - return ec.fieldContext___Schema_description(ctx, field) - case "types": - return ec.fieldContext___Schema_types(ctx, field) - case "queryType": - return ec.fieldContext___Schema_queryType(ctx, field) - case "mutationType": - return ec.fieldContext___Schema_mutationType(ctx, field) - case "subscriptionType": - return ec.fieldContext___Schema_subscriptionType(ctx, field) - case "directives": - return ec.fieldContext___Schema_directives(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __Schema", field.Name) + return nil, errors.New("field of type Boolean does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Quest_id(ctx context.Context, field graphql.CollectedField, obj *ent.Quest) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Quest_id(ctx, field) +func (ec *executionContext) _PageInfo_startCursor(ctx context.Context, field graphql.CollectedField, obj *entgql.PageInfo[int]) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_PageInfo_startCursor(ctx, field) if err != nil { return graphql.Null } @@ -3295,38 +3017,35 @@ func (ec *executionContext) _Quest_id(ctx context.Context, field graphql.Collect }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.ID, nil + return obj.StartCursor, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(int) + res := resTmp.(*entgql.Cursor[int]) fc.Result = res - return ec.marshalNID2int(ctx, field.Selections, res) + return ec.marshalOCursor2ᚖentgoᚗioᚋcontribᚋentgqlᚐCursor(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Quest_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_PageInfo_startCursor(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Quest", + Object: "PageInfo", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type ID does not have child fields") + return nil, errors.New("field of type Cursor does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Quest_createdAt(ctx context.Context, field graphql.CollectedField, obj *ent.Quest) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Quest_createdAt(ctx, field) +func (ec *executionContext) _PageInfo_endCursor(ctx context.Context, field graphql.CollectedField, obj *entgql.PageInfo[int]) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_PageInfo_endCursor(ctx, field) if err != nil { return graphql.Null } @@ -3339,38 +3058,35 @@ func (ec *executionContext) _Quest_createdAt(ctx context.Context, field graphql. }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.CreatedAt, nil + return obj.EndCursor, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(time.Time) + res := resTmp.(*entgql.Cursor[int]) fc.Result = res - return ec.marshalNTime2timeᚐTime(ctx, field.Selections, res) + return ec.marshalOCursor2ᚖentgoᚗioᚋcontribᚋentgqlᚐCursor(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Quest_createdAt(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_PageInfo_endCursor(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Quest", + Object: "PageInfo", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Time does not have child fields") + return nil, errors.New("field of type Cursor does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Quest_lastModifiedAt(ctx context.Context, field graphql.CollectedField, obj *ent.Quest) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Quest_lastModifiedAt(ctx, field) +func (ec *executionContext) _Query_node(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_node(ctx, field) if err != nil { return graphql.Null } @@ -3383,38 +3099,46 @@ func (ec *executionContext) _Quest_lastModifiedAt(ctx context.Context, field gra }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.LastModifiedAt, nil + return ec.resolvers.Query().Node(rctx, fc.Args["id"].(int)) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(time.Time) + res := resTmp.(ent.Noder) fc.Result = res - return ec.marshalNTime2timeᚐTime(ctx, field.Selections, res) + return ec.marshalONode2realmᚗpubᚋtavernᚋinternalᚋentᚐNoder(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Quest_lastModifiedAt(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_node(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Quest", + Object: "Query", Field: field, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Time does not have child fields") + return nil, errors.New("FieldContext.Child cannot be called on type INTERFACE") }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_node_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _Quest_name(ctx context.Context, field graphql.CollectedField, obj *ent.Quest) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Quest_name(ctx, field) +func (ec *executionContext) _Query_nodes(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_nodes(ctx, field) if err != nil { return graphql.Null } @@ -3427,7 +3151,7 @@ func (ec *executionContext) _Quest_name(ctx context.Context, field graphql.Colle }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Name, nil + return ec.resolvers.Query().Nodes(rctx, fc.Args["ids"].([]int)) }) if err != nil { ec.Error(ctx, err) @@ -3439,67 +3163,37 @@ func (ec *executionContext) _Quest_name(ctx context.Context, field graphql.Colle } return graphql.Null } - res := resTmp.(string) + res := resTmp.([]ent.Noder) fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) + return ec.marshalNNode2ᚕrealmᚗpubᚋtavernᚋinternalᚋentᚐNoder(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Quest_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_nodes(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Quest", + Object: "Query", Field: field, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + return nil, errors.New("FieldContext.Child cannot be called on type INTERFACE") }, } - return fc, nil -} - -func (ec *executionContext) _Quest_parameters(ctx context.Context, field graphql.CollectedField, obj *ent.Quest) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Quest_parameters(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) defer func() { if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null + err = ec.Recover(ctx, r) + ec.Error(ctx, err) } }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Parameters, nil - }) - if err != nil { + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_nodes_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(string) - fc.Result = res - return ec.marshalOString2string(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_Quest_parameters(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Quest", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") - }, + return fc, err } return fc, nil } -func (ec *executionContext) _Quest_tome(ctx context.Context, field graphql.CollectedField, obj *ent.Quest) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Quest_tome(ctx, field) +func (ec *executionContext) _Query_files(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_files(ctx, field) if err != nil { return graphql.Null } @@ -3511,97 +3205,54 @@ func (ec *executionContext) _Quest_tome(ctx context.Context, field graphql.Colle } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Tome(ctx) - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().Files(rctx, fc.Args["where"].(*ent.FileWhereInput)) } - return graphql.Null - } - res := resTmp.(*ent.Tome) - fc.Result = res - return ec.marshalNTome2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTome(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_Quest_tome(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Quest", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_Tome_id(ctx, field) - case "createdAt": - return ec.fieldContext_Tome_createdAt(ctx, field) - case "lastModifiedAt": - return ec.fieldContext_Tome_lastModifiedAt(ctx, field) - case "name": - return ec.fieldContext_Tome_name(ctx, field) - case "description": - return ec.fieldContext_Tome_description(ctx, field) - case "author": - return ec.fieldContext_Tome_author(ctx, field) - case "supportModel": - return ec.fieldContext_Tome_supportModel(ctx, field) - case "tactic": - return ec.fieldContext_Tome_tactic(ctx, field) - case "paramDefs": - return ec.fieldContext_Tome_paramDefs(ctx, field) - case "eldritch": - return ec.fieldContext_Tome_eldritch(ctx, field) - case "files": - return ec.fieldContext_Tome_files(ctx, field) - case "uploader": - return ec.fieldContext_Tome_uploader(ctx, field) + directive1 := func(ctx context.Context) (interface{}, error) { + role, err := ec.unmarshalNRole2realmᚗpubᚋtavernᚋinternalᚋgraphqlᚋmodelsᚐRole(ctx, "USER") + if err != nil { + return nil, err } - return nil, fmt.Errorf("no field named %q was found under type Tome", field.Name) - }, - } - return fc, nil -} + if ec.directives.RequireRole == nil { + return nil, errors.New("directive requireRole is not implemented") + } + return ec.directives.RequireRole(ctx, nil, directive0, role) + } -func (ec *executionContext) _Quest_bundle(ctx context.Context, field graphql.CollectedField, obj *ent.Quest) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Quest_bundle(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Bundle(ctx) + if tmp == nil { + return nil, nil + } + if data, ok := tmp.([]*ent.File); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be []*realm.pub/tavern/internal/ent.File`, tmp) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*ent.File) + res := resTmp.([]*ent.File) fc.Result = res - return ec.marshalOFile2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐFile(ctx, field.Selections, res) + return ec.marshalNFile2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐFileᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Quest_bundle(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_files(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Quest", + Object: "Query", Field: field, IsMethod: true, - IsResolver: false, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": @@ -3622,11 +3273,22 @@ func (ec *executionContext) fieldContext_Quest_bundle(ctx context.Context, field return nil, fmt.Errorf("no field named %q was found under type File", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_files_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _Quest_tasks(ctx context.Context, field graphql.CollectedField, obj *ent.Quest) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Quest_tasks(ctx, field) +func (ec *executionContext) _Query_quests(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_quests(ctx, field) if err != nil { return graphql.Null } @@ -3638,62 +3300,94 @@ func (ec *executionContext) _Quest_tasks(ctx context.Context, field graphql.Coll } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Tasks(ctx) + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().Quests(rctx, fc.Args["where"].(*ent.QuestWhereInput)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + role, err := ec.unmarshalNRole2realmᚗpubᚋtavernᚋinternalᚋgraphqlᚋmodelsᚐRole(ctx, "USER") + if err != nil { + return nil, err + } + if ec.directives.RequireRole == nil { + return nil, errors.New("directive requireRole is not implemented") + } + return ec.directives.RequireRole(ctx, nil, directive0, role) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.([]*ent.Quest); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be []*realm.pub/tavern/internal/ent.Quest`, tmp) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.([]*ent.Task) + res := resTmp.([]*ent.Quest) fc.Result = res - return ec.marshalOTask2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTaskᚄ(ctx, field.Selections, res) + return ec.marshalNQuest2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐQuestᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Quest_tasks(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_quests(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Quest", + Object: "Query", Field: field, IsMethod: true, - IsResolver: false, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": - return ec.fieldContext_Task_id(ctx, field) + return ec.fieldContext_Quest_id(ctx, field) case "createdAt": - return ec.fieldContext_Task_createdAt(ctx, field) + return ec.fieldContext_Quest_createdAt(ctx, field) case "lastModifiedAt": - return ec.fieldContext_Task_lastModifiedAt(ctx, field) - case "claimedAt": - return ec.fieldContext_Task_claimedAt(ctx, field) - case "execStartedAt": - return ec.fieldContext_Task_execStartedAt(ctx, field) - case "execFinishedAt": - return ec.fieldContext_Task_execFinishedAt(ctx, field) - case "output": - return ec.fieldContext_Task_output(ctx, field) - case "outputSize": - return ec.fieldContext_Task_outputSize(ctx, field) - case "error": - return ec.fieldContext_Task_error(ctx, field) - case "quest": - return ec.fieldContext_Task_quest(ctx, field) - case "beacon": - return ec.fieldContext_Task_beacon(ctx, field) - case "reportedProcesses": - return ec.fieldContext_Task_reportedProcesses(ctx, field) + return ec.fieldContext_Quest_lastModifiedAt(ctx, field) + case "name": + return ec.fieldContext_Quest_name(ctx, field) + case "parameters": + return ec.fieldContext_Quest_parameters(ctx, field) + case "tome": + return ec.fieldContext_Quest_tome(ctx, field) + case "bundle": + return ec.fieldContext_Quest_bundle(ctx, field) + case "tasks": + return ec.fieldContext_Quest_tasks(ctx, field) + case "creator": + return ec.fieldContext_Quest_creator(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type Task", field.Name) + return nil, fmt.Errorf("no field named %q was found under type Quest", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_quests_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _Quest_creator(ctx context.Context, field graphql.CollectedField, obj *ent.Quest) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Quest_creator(ctx, field) +func (ec *executionContext) _Query_tasks(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_tasks(ctx, field) if err != nil { return graphql.Null } @@ -3705,50 +3399,82 @@ func (ec *executionContext) _Quest_creator(ctx context.Context, field graphql.Co } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Creator(ctx) + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().Tasks(rctx, fc.Args["after"].(*entgql.Cursor[int]), fc.Args["first"].(*int), fc.Args["before"].(*entgql.Cursor[int]), fc.Args["last"].(*int), fc.Args["orderBy"].([]*ent.TaskOrder), fc.Args["where"].(*ent.TaskWhereInput)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + role, err := ec.unmarshalNRole2realmᚗpubᚋtavernᚋinternalᚋgraphqlᚋmodelsᚐRole(ctx, "USER") + if err != nil { + return nil, err + } + if ec.directives.RequireRole == nil { + return nil, errors.New("directive requireRole is not implemented") + } + return ec.directives.RequireRole(ctx, nil, directive0, role) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(*ent.TaskConnection); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be *realm.pub/tavern/internal/ent.TaskConnection`, tmp) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*ent.User) + res := resTmp.(*ent.TaskConnection) fc.Result = res - return ec.marshalOUser2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐUser(ctx, field.Selections, res) + return ec.marshalNTaskConnection2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTaskConnection(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Quest_creator(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_tasks(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Quest", + Object: "Query", Field: field, IsMethod: true, - IsResolver: false, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "id": - return ec.fieldContext_User_id(ctx, field) - case "name": - return ec.fieldContext_User_name(ctx, field) - case "photoURL": - return ec.fieldContext_User_photoURL(ctx, field) - case "isActivated": - return ec.fieldContext_User_isActivated(ctx, field) - case "isAdmin": - return ec.fieldContext_User_isAdmin(ctx, field) - case "tomes": - return ec.fieldContext_User_tomes(ctx, field) + case "edges": + return ec.fieldContext_TaskConnection_edges(ctx, field) + case "pageInfo": + return ec.fieldContext_TaskConnection_pageInfo(ctx, field) + case "totalCount": + return ec.fieldContext_TaskConnection_totalCount(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type User", field.Name) + return nil, fmt.Errorf("no field named %q was found under type TaskConnection", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_tasks_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _Tag_id(ctx context.Context, field graphql.CollectedField, obj *ent.Tag) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Tag_id(ctx, field) +func (ec *executionContext) _Query_beacons(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_beacons(ctx, field) if err != nil { return graphql.Null } @@ -3760,8 +3486,32 @@ func (ec *executionContext) _Tag_id(ctx context.Context, field graphql.Collected } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.ID, nil + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().Beacons(rctx, fc.Args["where"].(*ent.BeaconWhereInput)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + role, err := ec.unmarshalNRole2realmᚗpubᚋtavernᚋinternalᚋgraphqlᚋmodelsᚐRole(ctx, "USER") + if err != nil { + return nil, err + } + if ec.directives.RequireRole == nil { + return nil, errors.New("directive requireRole is not implemented") + } + return ec.directives.RequireRole(ctx, nil, directive0, role) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.([]*ent.Beacon); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be []*realm.pub/tavern/internal/ent.Beacon`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -3773,26 +3523,61 @@ func (ec *executionContext) _Tag_id(ctx context.Context, field graphql.Collected } return graphql.Null } - res := resTmp.(int) + res := resTmp.([]*ent.Beacon) fc.Result = res - return ec.marshalNID2int(ctx, field.Selections, res) + return ec.marshalNBeacon2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBeaconᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Tag_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_beacons(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Tag", + Object: "Query", Field: field, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type ID does not have child fields") + switch field.Name { + case "id": + return ec.fieldContext_Beacon_id(ctx, field) + case "createdAt": + return ec.fieldContext_Beacon_createdAt(ctx, field) + case "lastModifiedAt": + return ec.fieldContext_Beacon_lastModifiedAt(ctx, field) + case "name": + return ec.fieldContext_Beacon_name(ctx, field) + case "principal": + return ec.fieldContext_Beacon_principal(ctx, field) + case "identifier": + return ec.fieldContext_Beacon_identifier(ctx, field) + case "agentIdentifier": + return ec.fieldContext_Beacon_agentIdentifier(ctx, field) + case "lastSeenAt": + return ec.fieldContext_Beacon_lastSeenAt(ctx, field) + case "interval": + return ec.fieldContext_Beacon_interval(ctx, field) + case "host": + return ec.fieldContext_Beacon_host(ctx, field) + case "tasks": + return ec.fieldContext_Beacon_tasks(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Beacon", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_beacons_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _Tag_name(ctx context.Context, field graphql.CollectedField, obj *ent.Tag) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Tag_name(ctx, field) +func (ec *executionContext) _Query_hosts(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_hosts(ctx, field) if err != nil { return graphql.Null } @@ -3804,8 +3589,32 @@ func (ec *executionContext) _Tag_name(ctx context.Context, field graphql.Collect } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Name, nil + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().Hosts(rctx, fc.Args["where"].(*ent.HostWhereInput)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + role, err := ec.unmarshalNRole2realmᚗpubᚋtavernᚋinternalᚋgraphqlᚋmodelsᚐRole(ctx, "USER") + if err != nil { + return nil, err + } + if ec.directives.RequireRole == nil { + return nil, errors.New("directive requireRole is not implemented") + } + return ec.directives.RequireRole(ctx, nil, directive0, role) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.([]*ent.Host); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be []*realm.pub/tavern/internal/ent.Host`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -3817,102 +3626,17 @@ func (ec *executionContext) _Tag_name(ctx context.Context, field graphql.Collect } return graphql.Null } - res := resTmp.(string) + res := resTmp.([]*ent.Host) fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) + return ec.marshalNHost2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Tag_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_hosts(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Tag", + Object: "Query", Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _Tag_kind(ctx context.Context, field graphql.CollectedField, obj *ent.Tag) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Tag_kind(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Kind, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(tag.Kind) - fc.Result = res - return ec.marshalNTagKind2realmᚗpubᚋtavernᚋinternalᚋentᚋtagᚐKind(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_Tag_kind(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Tag", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type TagKind does not have child fields") - }, - } - return fc, nil -} - -func (ec *executionContext) _Tag_hosts(ctx context.Context, field graphql.CollectedField, obj *ent.Tag) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Tag_hosts(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Hosts(ctx) - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.([]*ent.Host) - fc.Result = res - return ec.marshalOHost2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostᚄ(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_Tag_hosts(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Tag", - Field: field, - IsMethod: true, - IsResolver: false, + IsMethod: true, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": @@ -3935,17 +3659,30 @@ func (ec *executionContext) fieldContext_Tag_hosts(ctx context.Context, field gr return ec.fieldContext_Host_tags(ctx, field) case "beacons": return ec.fieldContext_Host_beacons(ctx, field) + case "files": + return ec.fieldContext_Host_files(ctx, field) case "processes": return ec.fieldContext_Host_processes(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Host", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_hosts_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _Task_id(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Task_id(ctx, field) +func (ec *executionContext) _Query_tags(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_tags(ctx, field) if err != nil { return graphql.Null } @@ -3957,8 +3694,32 @@ func (ec *executionContext) _Task_id(ctx context.Context, field graphql.Collecte } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.ID, nil + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().Tags(rctx, fc.Args["where"].(*ent.TagWhereInput)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + role, err := ec.unmarshalNRole2realmᚗpubᚋtavernᚋinternalᚋgraphqlᚋmodelsᚐRole(ctx, "USER") + if err != nil { + return nil, err + } + if ec.directives.RequireRole == nil { + return nil, errors.New("directive requireRole is not implemented") + } + return ec.directives.RequireRole(ctx, nil, directive0, role) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.([]*ent.Tag); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be []*realm.pub/tavern/internal/ent.Tag`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -3970,26 +3731,47 @@ func (ec *executionContext) _Task_id(ctx context.Context, field graphql.Collecte } return graphql.Null } - res := resTmp.(int) + res := resTmp.([]*ent.Tag) fc.Result = res - return ec.marshalNID2int(ctx, field.Selections, res) + return ec.marshalNTag2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTagᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Task_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_tags(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Task", + Object: "Query", Field: field, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type ID does not have child fields") + switch field.Name { + case "id": + return ec.fieldContext_Tag_id(ctx, field) + case "name": + return ec.fieldContext_Tag_name(ctx, field) + case "kind": + return ec.fieldContext_Tag_kind(ctx, field) + case "hosts": + return ec.fieldContext_Tag_hosts(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Tag", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_tags_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _Task_createdAt(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Task_createdAt(ctx, field) +func (ec *executionContext) _Query_tomes(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_tomes(ctx, field) if err != nil { return graphql.Null } @@ -4001,8 +3783,32 @@ func (ec *executionContext) _Task_createdAt(ctx context.Context, field graphql.C } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.CreatedAt, nil + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().Tomes(rctx, fc.Args["where"].(*ent.TomeWhereInput)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + role, err := ec.unmarshalNRole2realmᚗpubᚋtavernᚋinternalᚋgraphqlᚋmodelsᚐRole(ctx, "USER") + if err != nil { + return nil, err + } + if ec.directives.RequireRole == nil { + return nil, errors.New("directive requireRole is not implemented") + } + return ec.directives.RequireRole(ctx, nil, directive0, role) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.([]*ent.Tome); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be []*realm.pub/tavern/internal/ent.Tome`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -4014,26 +3820,63 @@ func (ec *executionContext) _Task_createdAt(ctx context.Context, field graphql.C } return graphql.Null } - res := resTmp.(time.Time) + res := resTmp.([]*ent.Tome) fc.Result = res - return ec.marshalNTime2timeᚐTime(ctx, field.Selections, res) + return ec.marshalNTome2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTomeᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Task_createdAt(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_tomes(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Task", + Object: "Query", Field: field, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Time does not have child fields") + switch field.Name { + case "id": + return ec.fieldContext_Tome_id(ctx, field) + case "createdAt": + return ec.fieldContext_Tome_createdAt(ctx, field) + case "lastModifiedAt": + return ec.fieldContext_Tome_lastModifiedAt(ctx, field) + case "name": + return ec.fieldContext_Tome_name(ctx, field) + case "description": + return ec.fieldContext_Tome_description(ctx, field) + case "author": + return ec.fieldContext_Tome_author(ctx, field) + case "supportModel": + return ec.fieldContext_Tome_supportModel(ctx, field) + case "tactic": + return ec.fieldContext_Tome_tactic(ctx, field) + case "paramDefs": + return ec.fieldContext_Tome_paramDefs(ctx, field) + case "eldritch": + return ec.fieldContext_Tome_eldritch(ctx, field) + case "files": + return ec.fieldContext_Tome_files(ctx, field) + case "uploader": + return ec.fieldContext_Tome_uploader(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Tome", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_tomes_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _Task_lastModifiedAt(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Task_lastModifiedAt(ctx, field) +func (ec *executionContext) _Query_users(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_users(ctx, field) if err != nil { return graphql.Null } @@ -4045,39 +3888,88 @@ func (ec *executionContext) _Task_lastModifiedAt(ctx context.Context, field grap } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.LastModifiedAt, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().Users(rctx, fc.Args["where"].(*ent.UserWhereInput)) } - return graphql.Null - } - res := resTmp.(time.Time) - fc.Result = res - return ec.marshalNTime2timeᚐTime(ctx, field.Selections, res) + directive1 := func(ctx context.Context) (interface{}, error) { + role, err := ec.unmarshalNRole2realmᚗpubᚋtavernᚋinternalᚋgraphqlᚋmodelsᚐRole(ctx, "USER") + if err != nil { + return nil, err + } + if ec.directives.RequireRole == nil { + return nil, errors.New("directive requireRole is not implemented") + } + return ec.directives.RequireRole(ctx, nil, directive0, role) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.([]*ent.User); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be []*realm.pub/tavern/internal/ent.User`, tmp) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.([]*ent.User) + fc.Result = res + return ec.marshalNUser2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐUserᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Task_lastModifiedAt(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_users(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Task", + Object: "Query", Field: field, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Time does not have child fields") + switch field.Name { + case "id": + return ec.fieldContext_User_id(ctx, field) + case "name": + return ec.fieldContext_User_name(ctx, field) + case "photoURL": + return ec.fieldContext_User_photoURL(ctx, field) + case "isActivated": + return ec.fieldContext_User_isActivated(ctx, field) + case "isAdmin": + return ec.fieldContext_User_isAdmin(ctx, field) + case "tomes": + return ec.fieldContext_User_tomes(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type User", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_users_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _Task_claimedAt(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Task_claimedAt(ctx, field) +func (ec *executionContext) _Query_me(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_me(ctx, field) if err != nil { return graphql.Null } @@ -4090,35 +3982,52 @@ func (ec *executionContext) _Task_claimedAt(ctx context.Context, field graphql.C }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.ClaimedAt, nil + return ec.resolvers.Query().Me(rctx) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(time.Time) + res := resTmp.(*ent.User) fc.Result = res - return ec.marshalOTime2timeᚐTime(ctx, field.Selections, res) + return ec.marshalNUser2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐUser(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Task_claimedAt(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_me(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Task", + Object: "Query", Field: field, - IsMethod: false, - IsResolver: false, + IsMethod: true, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Time does not have child fields") + switch field.Name { + case "id": + return ec.fieldContext_User_id(ctx, field) + case "name": + return ec.fieldContext_User_name(ctx, field) + case "photoURL": + return ec.fieldContext_User_photoURL(ctx, field) + case "isActivated": + return ec.fieldContext_User_isActivated(ctx, field) + case "isAdmin": + return ec.fieldContext_User_isAdmin(ctx, field) + case "tomes": + return ec.fieldContext_User_tomes(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type User", field.Name) }, } return fc, nil } -func (ec *executionContext) _Task_execStartedAt(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Task_execStartedAt(ctx, field) +func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query___type(ctx, field) if err != nil { return graphql.Null } @@ -4131,7 +4040,7 @@ func (ec *executionContext) _Task_execStartedAt(ctx context.Context, field graph }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.ExecStartedAt, nil + return ec.introspectType(fc.Args["name"].(string)) }) if err != nil { ec.Error(ctx, err) @@ -4140,26 +4049,59 @@ func (ec *executionContext) _Task_execStartedAt(ctx context.Context, field graph if resTmp == nil { return graphql.Null } - res := resTmp.(time.Time) + res := resTmp.(*introspection.Type) fc.Result = res - return ec.marshalOTime2timeᚐTime(ctx, field.Selections, res) + return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Task_execStartedAt(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query___type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Task", + Object: "Query", Field: field, - IsMethod: false, + IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Time does not have child fields") + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query___type_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -func (ec *executionContext) _Task_execFinishedAt(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Task_execFinishedAt(ctx, field) +func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query___schema(ctx, field) if err != nil { return graphql.Null } @@ -4172,7 +4114,7 @@ func (ec *executionContext) _Task_execFinishedAt(ctx context.Context, field grap }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.ExecFinishedAt, nil + return ec.introspectSchema() }) if err != nil { ec.Error(ctx, err) @@ -4181,26 +4123,40 @@ func (ec *executionContext) _Task_execFinishedAt(ctx context.Context, field grap if resTmp == nil { return graphql.Null } - res := resTmp.(time.Time) + res := resTmp.(*introspection.Schema) fc.Result = res - return ec.marshalOTime2timeᚐTime(ctx, field.Selections, res) + return ec.marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Task_execFinishedAt(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query___schema(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Task", + Object: "Query", Field: field, - IsMethod: false, + IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Time does not have child fields") + switch field.Name { + case "description": + return ec.fieldContext___Schema_description(ctx, field) + case "types": + return ec.fieldContext___Schema_types(ctx, field) + case "queryType": + return ec.fieldContext___Schema_queryType(ctx, field) + case "mutationType": + return ec.fieldContext___Schema_mutationType(ctx, field) + case "subscriptionType": + return ec.fieldContext___Schema_subscriptionType(ctx, field) + case "directives": + return ec.fieldContext___Schema_directives(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Schema", field.Name) }, } return fc, nil } -func (ec *executionContext) _Task_output(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Task_output(ctx, field) +func (ec *executionContext) _Quest_id(ctx context.Context, field graphql.CollectedField, obj *ent.Quest) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Quest_id(ctx, field) if err != nil { return graphql.Null } @@ -4213,35 +4169,38 @@ func (ec *executionContext) _Task_output(ctx context.Context, field graphql.Coll }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Output, nil + return obj.ID, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(string) + res := resTmp.(int) fc.Result = res - return ec.marshalOString2string(ctx, field.Selections, res) + return ec.marshalNID2int(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Task_output(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Quest_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Task", + Object: "Quest", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + return nil, errors.New("field of type ID does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Task_outputSize(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Task_outputSize(ctx, field) +func (ec *executionContext) _Quest_createdAt(ctx context.Context, field graphql.CollectedField, obj *ent.Quest) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Quest_createdAt(ctx, field) if err != nil { return graphql.Null } @@ -4254,7 +4213,7 @@ func (ec *executionContext) _Task_outputSize(ctx context.Context, field graphql. }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.OutputSize, nil + return obj.CreatedAt, nil }) if err != nil { ec.Error(ctx, err) @@ -4266,26 +4225,26 @@ func (ec *executionContext) _Task_outputSize(ctx context.Context, field graphql. } return graphql.Null } - res := resTmp.(int) + res := resTmp.(time.Time) fc.Result = res - return ec.marshalNInt2int(ctx, field.Selections, res) + return ec.marshalNTime2timeᚐTime(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Task_outputSize(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Quest_createdAt(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Task", + Object: "Quest", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Int does not have child fields") + return nil, errors.New("field of type Time does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Task_error(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Task_error(ctx, field) +func (ec *executionContext) _Quest_lastModifiedAt(ctx context.Context, field graphql.CollectedField, obj *ent.Quest) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Quest_lastModifiedAt(ctx, field) if err != nil { return graphql.Null } @@ -4298,35 +4257,38 @@ func (ec *executionContext) _Task_error(ctx context.Context, field graphql.Colle }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Error, nil + return obj.LastModifiedAt, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(string) + res := resTmp.(time.Time) fc.Result = res - return ec.marshalOString2string(ctx, field.Selections, res) + return ec.marshalNTime2timeᚐTime(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Task_error(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Quest_lastModifiedAt(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Task", + Object: "Quest", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + return nil, errors.New("field of type Time does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Task_quest(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Task_quest(ctx, field) +func (ec *executionContext) _Quest_name(ctx context.Context, field graphql.CollectedField, obj *ent.Quest) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Quest_name(ctx, field) if err != nil { return graphql.Null } @@ -4339,7 +4301,7 @@ func (ec *executionContext) _Task_quest(ctx context.Context, field graphql.Colle }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Quest(ctx) + return obj.Name, nil }) if err != nil { ec.Error(ctx, err) @@ -4351,46 +4313,26 @@ func (ec *executionContext) _Task_quest(ctx context.Context, field graphql.Colle } return graphql.Null } - res := resTmp.(*ent.Quest) + res := resTmp.(string) fc.Result = res - return ec.marshalNQuest2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐQuest(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Task_quest(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Quest_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Task", + Object: "Quest", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_Quest_id(ctx, field) - case "createdAt": - return ec.fieldContext_Quest_createdAt(ctx, field) - case "lastModifiedAt": - return ec.fieldContext_Quest_lastModifiedAt(ctx, field) - case "name": - return ec.fieldContext_Quest_name(ctx, field) - case "parameters": - return ec.fieldContext_Quest_parameters(ctx, field) - case "tome": - return ec.fieldContext_Quest_tome(ctx, field) - case "bundle": - return ec.fieldContext_Quest_bundle(ctx, field) - case "tasks": - return ec.fieldContext_Quest_tasks(ctx, field) - case "creator": - return ec.fieldContext_Quest_creator(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type Quest", field.Name) + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Task_beacon(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Task_beacon(ctx, field) +func (ec *executionContext) _Quest_parameters(ctx context.Context, field graphql.CollectedField, obj *ent.Quest) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Quest_parameters(ctx, field) if err != nil { return graphql.Null } @@ -4403,7 +4345,48 @@ func (ec *executionContext) _Task_beacon(ctx context.Context, field graphql.Coll }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Beacon(ctx) + return obj.Parameters, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalOString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Quest_parameters(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Quest", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Quest_tome(ctx context.Context, field graphql.CollectedField, obj *ent.Quest) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Quest_tome(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Tome(ctx) }) if err != nil { ec.Error(ctx, err) @@ -4415,50 +4398,52 @@ func (ec *executionContext) _Task_beacon(ctx context.Context, field graphql.Coll } return graphql.Null } - res := resTmp.(*ent.Beacon) + res := resTmp.(*ent.Tome) fc.Result = res - return ec.marshalNBeacon2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBeacon(ctx, field.Selections, res) + return ec.marshalNTome2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTome(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Task_beacon(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Quest_tome(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Task", + Object: "Quest", Field: field, IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": - return ec.fieldContext_Beacon_id(ctx, field) + return ec.fieldContext_Tome_id(ctx, field) case "createdAt": - return ec.fieldContext_Beacon_createdAt(ctx, field) + return ec.fieldContext_Tome_createdAt(ctx, field) case "lastModifiedAt": - return ec.fieldContext_Beacon_lastModifiedAt(ctx, field) + return ec.fieldContext_Tome_lastModifiedAt(ctx, field) case "name": - return ec.fieldContext_Beacon_name(ctx, field) - case "principal": - return ec.fieldContext_Beacon_principal(ctx, field) - case "identifier": - return ec.fieldContext_Beacon_identifier(ctx, field) - case "agentIdentifier": - return ec.fieldContext_Beacon_agentIdentifier(ctx, field) - case "lastSeenAt": - return ec.fieldContext_Beacon_lastSeenAt(ctx, field) - case "interval": - return ec.fieldContext_Beacon_interval(ctx, field) - case "host": - return ec.fieldContext_Beacon_host(ctx, field) - case "tasks": - return ec.fieldContext_Beacon_tasks(ctx, field) + return ec.fieldContext_Tome_name(ctx, field) + case "description": + return ec.fieldContext_Tome_description(ctx, field) + case "author": + return ec.fieldContext_Tome_author(ctx, field) + case "supportModel": + return ec.fieldContext_Tome_supportModel(ctx, field) + case "tactic": + return ec.fieldContext_Tome_tactic(ctx, field) + case "paramDefs": + return ec.fieldContext_Tome_paramDefs(ctx, field) + case "eldritch": + return ec.fieldContext_Tome_eldritch(ctx, field) + case "files": + return ec.fieldContext_Tome_files(ctx, field) + case "uploader": + return ec.fieldContext_Tome_uploader(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type Beacon", field.Name) + return nil, fmt.Errorf("no field named %q was found under type Tome", field.Name) }, } return fc, nil } -func (ec *executionContext) _Task_reportedProcesses(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Task_reportedProcesses(ctx, field) +func (ec *executionContext) _Quest_bundle(ctx context.Context, field graphql.CollectedField, obj *ent.Quest) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Quest_bundle(ctx, field) if err != nil { return graphql.Null } @@ -4471,7 +4456,7 @@ func (ec *executionContext) _Task_reportedProcesses(ctx context.Context, field g }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.ReportedProcesses(ctx) + return obj.Bundle(ctx) }) if err != nil { ec.Error(ctx, err) @@ -4480,44 +4465,42 @@ func (ec *executionContext) _Task_reportedProcesses(ctx context.Context, field g if resTmp == nil { return graphql.Null } - res := resTmp.([]*ent.Process) + res := resTmp.(*ent.File) fc.Result = res - return ec.marshalOProcess2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐProcessᚄ(ctx, field.Selections, res) + return ec.marshalOFile2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐFile(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Task_reportedProcesses(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Quest_bundle(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Task", + Object: "Quest", Field: field, IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": - return ec.fieldContext_Process_id(ctx, field) + return ec.fieldContext_File_id(ctx, field) case "createdAt": - return ec.fieldContext_Process_createdAt(ctx, field) + return ec.fieldContext_File_createdAt(ctx, field) case "lastModifiedAt": - return ec.fieldContext_Process_lastModifiedAt(ctx, field) - case "pid": - return ec.fieldContext_Process_pid(ctx, field) + return ec.fieldContext_File_lastModifiedAt(ctx, field) case "name": - return ec.fieldContext_Process_name(ctx, field) - case "principal": - return ec.fieldContext_Process_principal(ctx, field) - case "host": - return ec.fieldContext_Process_host(ctx, field) - case "task": - return ec.fieldContext_Process_task(ctx, field) + return ec.fieldContext_File_name(ctx, field) + case "size": + return ec.fieldContext_File_size(ctx, field) + case "hash": + return ec.fieldContext_File_hash(ctx, field) + case "tomes": + return ec.fieldContext_File_tomes(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type Process", field.Name) + return nil, fmt.Errorf("no field named %q was found under type File", field.Name) }, } return fc, nil } -func (ec *executionContext) _TaskConnection_edges(ctx context.Context, field graphql.CollectedField, obj *ent.TaskConnection) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_TaskConnection_edges(ctx, field) +func (ec *executionContext) _Quest_tasks(ctx context.Context, field graphql.CollectedField, obj *ent.Quest) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Quest_tasks(ctx, field) if err != nil { return graphql.Null } @@ -4530,7 +4513,7 @@ func (ec *executionContext) _TaskConnection_edges(ctx context.Context, field gra }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Edges, nil + return obj.Tasks(ctx) }) if err != nil { ec.Error(ctx, err) @@ -4539,32 +4522,54 @@ func (ec *executionContext) _TaskConnection_edges(ctx context.Context, field gra if resTmp == nil { return graphql.Null } - res := resTmp.([]*ent.TaskEdge) + res := resTmp.([]*ent.Task) fc.Result = res - return ec.marshalOTaskEdge2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTaskEdge(ctx, field.Selections, res) + return ec.marshalOTask2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTaskᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_TaskConnection_edges(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Quest_tasks(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "TaskConnection", + Object: "Quest", Field: field, - IsMethod: false, + IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "node": - return ec.fieldContext_TaskEdge_node(ctx, field) - case "cursor": - return ec.fieldContext_TaskEdge_cursor(ctx, field) + case "id": + return ec.fieldContext_Task_id(ctx, field) + case "createdAt": + return ec.fieldContext_Task_createdAt(ctx, field) + case "lastModifiedAt": + return ec.fieldContext_Task_lastModifiedAt(ctx, field) + case "claimedAt": + return ec.fieldContext_Task_claimedAt(ctx, field) + case "execStartedAt": + return ec.fieldContext_Task_execStartedAt(ctx, field) + case "execFinishedAt": + return ec.fieldContext_Task_execFinishedAt(ctx, field) + case "output": + return ec.fieldContext_Task_output(ctx, field) + case "outputSize": + return ec.fieldContext_Task_outputSize(ctx, field) + case "error": + return ec.fieldContext_Task_error(ctx, field) + case "quest": + return ec.fieldContext_Task_quest(ctx, field) + case "beacon": + return ec.fieldContext_Task_beacon(ctx, field) + case "reportedFiles": + return ec.fieldContext_Task_reportedFiles(ctx, field) + case "reportedProcesses": + return ec.fieldContext_Task_reportedProcesses(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type TaskEdge", field.Name) + return nil, fmt.Errorf("no field named %q was found under type Task", field.Name) }, } return fc, nil } -func (ec *executionContext) _TaskConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.TaskConnection) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_TaskConnection_pageInfo(ctx, field) +func (ec *executionContext) _Quest_creator(ctx context.Context, field graphql.CollectedField, obj *ent.Quest) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Quest_creator(ctx, field) if err != nil { return graphql.Null } @@ -4577,48 +4582,49 @@ func (ec *executionContext) _TaskConnection_pageInfo(ctx context.Context, field }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.PageInfo, nil + return obj.Creator(ctx) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(entgql.PageInfo[int]) + res := resTmp.(*ent.User) fc.Result = res - return ec.marshalNPageInfo2entgoᚗioᚋcontribᚋentgqlᚐPageInfo(ctx, field.Selections, res) + return ec.marshalOUser2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐUser(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_TaskConnection_pageInfo(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Quest_creator(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "TaskConnection", + Object: "Quest", Field: field, - IsMethod: false, + IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "hasNextPage": - return ec.fieldContext_PageInfo_hasNextPage(ctx, field) - case "hasPreviousPage": - return ec.fieldContext_PageInfo_hasPreviousPage(ctx, field) - case "startCursor": - return ec.fieldContext_PageInfo_startCursor(ctx, field) - case "endCursor": - return ec.fieldContext_PageInfo_endCursor(ctx, field) + case "id": + return ec.fieldContext_User_id(ctx, field) + case "name": + return ec.fieldContext_User_name(ctx, field) + case "photoURL": + return ec.fieldContext_User_photoURL(ctx, field) + case "isActivated": + return ec.fieldContext_User_isActivated(ctx, field) + case "isAdmin": + return ec.fieldContext_User_isAdmin(ctx, field) + case "tomes": + return ec.fieldContext_User_tomes(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type PageInfo", field.Name) + return nil, fmt.Errorf("no field named %q was found under type User", field.Name) }, } return fc, nil } -func (ec *executionContext) _TaskConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *ent.TaskConnection) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_TaskConnection_totalCount(ctx, field) +func (ec *executionContext) _Tag_id(ctx context.Context, field graphql.CollectedField, obj *ent.Tag) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Tag_id(ctx, field) if err != nil { return graphql.Null } @@ -4631,7 +4637,7 @@ func (ec *executionContext) _TaskConnection_totalCount(ctx context.Context, fiel }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.TotalCount, nil + return obj.ID, nil }) if err != nil { ec.Error(ctx, err) @@ -4645,24 +4651,24 @@ func (ec *executionContext) _TaskConnection_totalCount(ctx context.Context, fiel } res := resTmp.(int) fc.Result = res - return ec.marshalNInt2int(ctx, field.Selections, res) + return ec.marshalNID2int(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_TaskConnection_totalCount(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Tag_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "TaskConnection", + Object: "Tag", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Int does not have child fields") + return nil, errors.New("field of type ID does not have child fields") }, } return fc, nil } -func (ec *executionContext) _TaskEdge_node(ctx context.Context, field graphql.CollectedField, obj *ent.TaskEdge) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_TaskEdge_node(ctx, field) +func (ec *executionContext) _Tag_name(ctx context.Context, field graphql.CollectedField, obj *ent.Tag) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Tag_name(ctx, field) if err != nil { return graphql.Null } @@ -4675,61 +4681,38 @@ func (ec *executionContext) _TaskEdge_node(ctx context.Context, field graphql.Co }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Node, nil + return obj.Name, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*ent.Task) + res := resTmp.(string) fc.Result = res - return ec.marshalOTask2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTask(ctx, field.Selections, res) + return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_TaskEdge_node(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Tag_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "TaskEdge", + Object: "Tag", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_Task_id(ctx, field) - case "createdAt": - return ec.fieldContext_Task_createdAt(ctx, field) - case "lastModifiedAt": - return ec.fieldContext_Task_lastModifiedAt(ctx, field) - case "claimedAt": - return ec.fieldContext_Task_claimedAt(ctx, field) - case "execStartedAt": - return ec.fieldContext_Task_execStartedAt(ctx, field) - case "execFinishedAt": - return ec.fieldContext_Task_execFinishedAt(ctx, field) - case "output": - return ec.fieldContext_Task_output(ctx, field) - case "outputSize": - return ec.fieldContext_Task_outputSize(ctx, field) - case "error": - return ec.fieldContext_Task_error(ctx, field) - case "quest": - return ec.fieldContext_Task_quest(ctx, field) - case "beacon": - return ec.fieldContext_Task_beacon(ctx, field) - case "reportedProcesses": - return ec.fieldContext_Task_reportedProcesses(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type Task", field.Name) + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _TaskEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *ent.TaskEdge) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_TaskEdge_cursor(ctx, field) +func (ec *executionContext) _Tag_kind(ctx context.Context, field graphql.CollectedField, obj *ent.Tag) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Tag_kind(ctx, field) if err != nil { return graphql.Null } @@ -4742,7 +4725,7 @@ func (ec *executionContext) _TaskEdge_cursor(ctx context.Context, field graphql. }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Cursor, nil + return obj.Kind, nil }) if err != nil { ec.Error(ctx, err) @@ -4754,26 +4737,93 @@ func (ec *executionContext) _TaskEdge_cursor(ctx context.Context, field graphql. } return graphql.Null } - res := resTmp.(entgql.Cursor[int]) + res := resTmp.(tag.Kind) fc.Result = res - return ec.marshalNCursor2entgoᚗioᚋcontribᚋentgqlᚐCursor(ctx, field.Selections, res) + return ec.marshalNTagKind2realmᚗpubᚋtavernᚋinternalᚋentᚋtagᚐKind(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_TaskEdge_cursor(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Tag_kind(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "TaskEdge", + Object: "Tag", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Cursor does not have child fields") + return nil, errors.New("field of type TagKind does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Tome_id(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Tome_id(ctx, field) +func (ec *executionContext) _Tag_hosts(ctx context.Context, field graphql.CollectedField, obj *ent.Tag) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Tag_hosts(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Hosts(ctx) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]*ent.Host) + fc.Result = res + return ec.marshalOHost2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Tag_hosts(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Tag", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_Host_id(ctx, field) + case "createdAt": + return ec.fieldContext_Host_createdAt(ctx, field) + case "lastModifiedAt": + return ec.fieldContext_Host_lastModifiedAt(ctx, field) + case "identifier": + return ec.fieldContext_Host_identifier(ctx, field) + case "name": + return ec.fieldContext_Host_name(ctx, field) + case "primaryIP": + return ec.fieldContext_Host_primaryIP(ctx, field) + case "platform": + return ec.fieldContext_Host_platform(ctx, field) + case "lastSeenAt": + return ec.fieldContext_Host_lastSeenAt(ctx, field) + case "tags": + return ec.fieldContext_Host_tags(ctx, field) + case "beacons": + return ec.fieldContext_Host_beacons(ctx, field) + case "files": + return ec.fieldContext_Host_files(ctx, field) + case "processes": + return ec.fieldContext_Host_processes(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Host", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Task_id(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Task_id(ctx, field) if err != nil { return graphql.Null } @@ -4803,9 +4853,9 @@ func (ec *executionContext) _Tome_id(ctx context.Context, field graphql.Collecte return ec.marshalNID2int(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Tome_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Task_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Tome", + Object: "Task", Field: field, IsMethod: false, IsResolver: false, @@ -4816,8 +4866,8 @@ func (ec *executionContext) fieldContext_Tome_id(ctx context.Context, field grap return fc, nil } -func (ec *executionContext) _Tome_createdAt(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Tome_createdAt(ctx, field) +func (ec *executionContext) _Task_createdAt(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Task_createdAt(ctx, field) if err != nil { return graphql.Null } @@ -4847,9 +4897,9 @@ func (ec *executionContext) _Tome_createdAt(ctx context.Context, field graphql.C return ec.marshalNTime2timeᚐTime(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Tome_createdAt(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Task_createdAt(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Tome", + Object: "Task", Field: field, IsMethod: false, IsResolver: false, @@ -4860,8 +4910,8 @@ func (ec *executionContext) fieldContext_Tome_createdAt(ctx context.Context, fie return fc, nil } -func (ec *executionContext) _Tome_lastModifiedAt(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Tome_lastModifiedAt(ctx, field) +func (ec *executionContext) _Task_lastModifiedAt(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Task_lastModifiedAt(ctx, field) if err != nil { return graphql.Null } @@ -4891,9 +4941,9 @@ func (ec *executionContext) _Tome_lastModifiedAt(ctx context.Context, field grap return ec.marshalNTime2timeᚐTime(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Tome_lastModifiedAt(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Task_lastModifiedAt(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Tome", + Object: "Task", Field: field, IsMethod: false, IsResolver: false, @@ -4904,8 +4954,8 @@ func (ec *executionContext) fieldContext_Tome_lastModifiedAt(ctx context.Context return fc, nil } -func (ec *executionContext) _Tome_name(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Tome_name(ctx, field) +func (ec *executionContext) _Task_claimedAt(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Task_claimedAt(ctx, field) if err != nil { return graphql.Null } @@ -4918,38 +4968,35 @@ func (ec *executionContext) _Tome_name(ctx context.Context, field graphql.Collec }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Name, nil + return obj.ClaimedAt, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(string) + res := resTmp.(time.Time) fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) + return ec.marshalOTime2timeᚐTime(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Tome_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Task_claimedAt(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Tome", + Object: "Task", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + return nil, errors.New("field of type Time does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Tome_description(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Tome_description(ctx, field) +func (ec *executionContext) _Task_execStartedAt(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Task_execStartedAt(ctx, field) if err != nil { return graphql.Null } @@ -4962,38 +5009,35 @@ func (ec *executionContext) _Tome_description(ctx context.Context, field graphql }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Description, nil + return obj.ExecStartedAt, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(string) + res := resTmp.(time.Time) fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) + return ec.marshalOTime2timeᚐTime(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Tome_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Task_execStartedAt(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Tome", + Object: "Task", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + return nil, errors.New("field of type Time does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Tome_author(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Tome_author(ctx, field) +func (ec *executionContext) _Task_execFinishedAt(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Task_execFinishedAt(ctx, field) if err != nil { return graphql.Null } @@ -5006,38 +5050,35 @@ func (ec *executionContext) _Tome_author(ctx context.Context, field graphql.Coll }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Author, nil + return obj.ExecFinishedAt, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(string) + res := resTmp.(time.Time) fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) + return ec.marshalOTime2timeᚐTime(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Tome_author(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Task_execFinishedAt(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Tome", + Object: "Task", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + return nil, errors.New("field of type Time does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Tome_supportModel(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Tome_supportModel(ctx, field) +func (ec *executionContext) _Task_output(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Task_output(ctx, field) if err != nil { return graphql.Null } @@ -5050,38 +5091,35 @@ func (ec *executionContext) _Tome_supportModel(ctx context.Context, field graphq }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.SupportModel, nil + return obj.Output, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(tome.SupportModel) + res := resTmp.(string) fc.Result = res - return ec.marshalNTomeSupportModel2realmᚗpubᚋtavernᚋinternalᚋentᚋtomeᚐSupportModel(ctx, field.Selections, res) + return ec.marshalOString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Tome_supportModel(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Task_output(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Tome", + Object: "Task", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type TomeSupportModel does not have child fields") + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Tome_tactic(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Tome_tactic(ctx, field) +func (ec *executionContext) _Task_outputSize(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Task_outputSize(ctx, field) if err != nil { return graphql.Null } @@ -5094,7 +5132,7 @@ func (ec *executionContext) _Tome_tactic(ctx context.Context, field graphql.Coll }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Tactic, nil + return obj.OutputSize, nil }) if err != nil { ec.Error(ctx, err) @@ -5106,26 +5144,26 @@ func (ec *executionContext) _Tome_tactic(ctx context.Context, field graphql.Coll } return graphql.Null } - res := resTmp.(tome.Tactic) + res := resTmp.(int) fc.Result = res - return ec.marshalNTomeTactic2realmᚗpubᚋtavernᚋinternalᚋentᚋtomeᚐTactic(ctx, field.Selections, res) + return ec.marshalNInt2int(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Tome_tactic(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Task_outputSize(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Tome", + Object: "Task", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type TomeTactic does not have child fields") + return nil, errors.New("field of type Int does not have child fields") }, } return fc, nil } -func (ec *executionContext) _Tome_paramDefs(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Tome_paramDefs(ctx, field) +func (ec *executionContext) _Task_error(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Task_error(ctx, field) if err != nil { return graphql.Null } @@ -5138,7 +5176,7 @@ func (ec *executionContext) _Tome_paramDefs(ctx context.Context, field graphql.C }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.ParamDefs, nil + return obj.Error, nil }) if err != nil { ec.Error(ctx, err) @@ -5152,9 +5190,9 @@ func (ec *executionContext) _Tome_paramDefs(ctx context.Context, field graphql.C return ec.marshalOString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Tome_paramDefs(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Task_error(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Tome", + Object: "Task", Field: field, IsMethod: false, IsResolver: false, @@ -5165,8 +5203,8 @@ func (ec *executionContext) fieldContext_Tome_paramDefs(ctx context.Context, fie return fc, nil } -func (ec *executionContext) _Tome_eldritch(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Tome_eldritch(ctx, field) +func (ec *executionContext) _Task_quest(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Task_quest(ctx, field) if err != nil { return graphql.Null } @@ -5179,7 +5217,7 @@ func (ec *executionContext) _Tome_eldritch(ctx context.Context, field graphql.Co }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Eldritch, nil + return obj.Quest(ctx) }) if err != nil { ec.Error(ctx, err) @@ -5191,26 +5229,46 @@ func (ec *executionContext) _Tome_eldritch(ctx context.Context, field graphql.Co } return graphql.Null } - res := resTmp.(string) + res := resTmp.(*ent.Quest) fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) + return ec.marshalNQuest2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐQuest(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Tome_eldritch(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Task_quest(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Tome", + Object: "Task", Field: field, - IsMethod: false, + IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + switch field.Name { + case "id": + return ec.fieldContext_Quest_id(ctx, field) + case "createdAt": + return ec.fieldContext_Quest_createdAt(ctx, field) + case "lastModifiedAt": + return ec.fieldContext_Quest_lastModifiedAt(ctx, field) + case "name": + return ec.fieldContext_Quest_name(ctx, field) + case "parameters": + return ec.fieldContext_Quest_parameters(ctx, field) + case "tome": + return ec.fieldContext_Quest_tome(ctx, field) + case "bundle": + return ec.fieldContext_Quest_bundle(ctx, field) + case "tasks": + return ec.fieldContext_Quest_tasks(ctx, field) + case "creator": + return ec.fieldContext_Quest_creator(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Quest", field.Name) }, } return fc, nil } -func (ec *executionContext) _Tome_files(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Tome_files(ctx, field) +func (ec *executionContext) _Task_beacon(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Task_beacon(ctx, field) if err != nil { return graphql.Null } @@ -5223,51 +5281,127 @@ func (ec *executionContext) _Tome_files(ctx context.Context, field graphql.Colle }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Files(ctx) + return obj.Beacon(ctx) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.([]*ent.File) + res := resTmp.(*ent.Beacon) fc.Result = res - return ec.marshalOFile2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐFileᚄ(ctx, field.Selections, res) + return ec.marshalNBeacon2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBeacon(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Tome_files(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Task_beacon(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Tome", + Object: "Task", Field: field, IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": - return ec.fieldContext_File_id(ctx, field) + return ec.fieldContext_Beacon_id(ctx, field) case "createdAt": - return ec.fieldContext_File_createdAt(ctx, field) + return ec.fieldContext_Beacon_createdAt(ctx, field) case "lastModifiedAt": - return ec.fieldContext_File_lastModifiedAt(ctx, field) + return ec.fieldContext_Beacon_lastModifiedAt(ctx, field) case "name": - return ec.fieldContext_File_name(ctx, field) + return ec.fieldContext_Beacon_name(ctx, field) + case "principal": + return ec.fieldContext_Beacon_principal(ctx, field) + case "identifier": + return ec.fieldContext_Beacon_identifier(ctx, field) + case "agentIdentifier": + return ec.fieldContext_Beacon_agentIdentifier(ctx, field) + case "lastSeenAt": + return ec.fieldContext_Beacon_lastSeenAt(ctx, field) + case "interval": + return ec.fieldContext_Beacon_interval(ctx, field) + case "host": + return ec.fieldContext_Beacon_host(ctx, field) + case "tasks": + return ec.fieldContext_Beacon_tasks(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Beacon", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Task_reportedFiles(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Task_reportedFiles(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.ReportedFiles(ctx) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]*ent.HostFile) + fc.Result = res + return ec.marshalOHostFile2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostFileᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Task_reportedFiles(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Task", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_HostFile_id(ctx, field) + case "createdAt": + return ec.fieldContext_HostFile_createdAt(ctx, field) + case "lastModifiedAt": + return ec.fieldContext_HostFile_lastModifiedAt(ctx, field) + case "path": + return ec.fieldContext_HostFile_path(ctx, field) + case "owner": + return ec.fieldContext_HostFile_owner(ctx, field) + case "group": + return ec.fieldContext_HostFile_group(ctx, field) + case "permissions": + return ec.fieldContext_HostFile_permissions(ctx, field) case "size": - return ec.fieldContext_File_size(ctx, field) + return ec.fieldContext_HostFile_size(ctx, field) case "hash": - return ec.fieldContext_File_hash(ctx, field) - case "tomes": - return ec.fieldContext_File_tomes(ctx, field) + return ec.fieldContext_HostFile_hash(ctx, field) + case "host": + return ec.fieldContext_HostFile_host(ctx, field) + case "task": + return ec.fieldContext_HostFile_task(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type File", field.Name) + return nil, fmt.Errorf("no field named %q was found under type HostFile", field.Name) }, } return fc, nil } -func (ec *executionContext) _Tome_uploader(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Tome_uploader(ctx, field) +func (ec *executionContext) _Task_reportedProcesses(ctx context.Context, field graphql.CollectedField, obj *ent.Task) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Task_reportedProcesses(ctx, field) if err != nil { return graphql.Null } @@ -5280,7 +5414,7 @@ func (ec *executionContext) _Tome_uploader(ctx context.Context, field graphql.Co }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Uploader(ctx) + return obj.ReportedProcesses(ctx) }) if err != nil { ec.Error(ctx, err) @@ -5289,40 +5423,56 @@ func (ec *executionContext) _Tome_uploader(ctx context.Context, field graphql.Co if resTmp == nil { return graphql.Null } - res := resTmp.(*ent.User) + res := resTmp.([]*ent.HostProcess) fc.Result = res - return ec.marshalOUser2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐUser(ctx, field.Selections, res) + return ec.marshalOHostProcess2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostProcessᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Tome_uploader(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Task_reportedProcesses(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Tome", + Object: "Task", Field: field, IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": - return ec.fieldContext_User_id(ctx, field) + return ec.fieldContext_HostProcess_id(ctx, field) + case "createdAt": + return ec.fieldContext_HostProcess_createdAt(ctx, field) + case "lastModifiedAt": + return ec.fieldContext_HostProcess_lastModifiedAt(ctx, field) + case "pid": + return ec.fieldContext_HostProcess_pid(ctx, field) + case "ppid": + return ec.fieldContext_HostProcess_ppid(ctx, field) case "name": - return ec.fieldContext_User_name(ctx, field) - case "photoURL": - return ec.fieldContext_User_photoURL(ctx, field) - case "isActivated": - return ec.fieldContext_User_isActivated(ctx, field) - case "isAdmin": - return ec.fieldContext_User_isAdmin(ctx, field) - case "tomes": - return ec.fieldContext_User_tomes(ctx, field) + return ec.fieldContext_HostProcess_name(ctx, field) + case "principal": + return ec.fieldContext_HostProcess_principal(ctx, field) + case "path": + return ec.fieldContext_HostProcess_path(ctx, field) + case "cmd": + return ec.fieldContext_HostProcess_cmd(ctx, field) + case "env": + return ec.fieldContext_HostProcess_env(ctx, field) + case "cwd": + return ec.fieldContext_HostProcess_cwd(ctx, field) + case "status": + return ec.fieldContext_HostProcess_status(ctx, field) + case "host": + return ec.fieldContext_HostProcess_host(ctx, field) + case "task": + return ec.fieldContext_HostProcess_task(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type User", field.Name) + return nil, fmt.Errorf("no field named %q was found under type HostProcess", field.Name) }, } return fc, nil } -func (ec *executionContext) _User_id(ctx context.Context, field graphql.CollectedField, obj *ent.User) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_User_id(ctx, field) +func (ec *executionContext) _TaskConnection_edges(ctx context.Context, field graphql.CollectedField, obj *ent.TaskConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_TaskConnection_edges(ctx, field) if err != nil { return graphql.Null } @@ -5335,38 +5485,41 @@ func (ec *executionContext) _User_id(ctx context.Context, field graphql.Collecte }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.ID, nil + return obj.Edges, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(int) + res := resTmp.([]*ent.TaskEdge) fc.Result = res - return ec.marshalNID2int(ctx, field.Selections, res) + return ec.marshalOTaskEdge2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTaskEdge(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_User_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_TaskConnection_edges(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "User", + Object: "TaskConnection", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type ID does not have child fields") + switch field.Name { + case "node": + return ec.fieldContext_TaskEdge_node(ctx, field) + case "cursor": + return ec.fieldContext_TaskEdge_cursor(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type TaskEdge", field.Name) }, } return fc, nil } -func (ec *executionContext) _User_name(ctx context.Context, field graphql.CollectedField, obj *ent.User) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_User_name(ctx, field) +func (ec *executionContext) _TaskConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *ent.TaskConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_TaskConnection_pageInfo(ctx, field) if err != nil { return graphql.Null } @@ -5379,7 +5532,7 @@ func (ec *executionContext) _User_name(ctx context.Context, field graphql.Collec }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Name, nil + return obj.PageInfo, nil }) if err != nil { ec.Error(ctx, err) @@ -5391,26 +5544,36 @@ func (ec *executionContext) _User_name(ctx context.Context, field graphql.Collec } return graphql.Null } - res := resTmp.(string) + res := resTmp.(entgql.PageInfo[int]) fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) + return ec.marshalNPageInfo2entgoᚗioᚋcontribᚋentgqlᚐPageInfo(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_User_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_TaskConnection_pageInfo(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "User", + Object: "TaskConnection", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + switch field.Name { + case "hasNextPage": + return ec.fieldContext_PageInfo_hasNextPage(ctx, field) + case "hasPreviousPage": + return ec.fieldContext_PageInfo_hasPreviousPage(ctx, field) + case "startCursor": + return ec.fieldContext_PageInfo_startCursor(ctx, field) + case "endCursor": + return ec.fieldContext_PageInfo_endCursor(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type PageInfo", field.Name) }, } return fc, nil } -func (ec *executionContext) _User_photoURL(ctx context.Context, field graphql.CollectedField, obj *ent.User) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_User_photoURL(ctx, field) +func (ec *executionContext) _TaskConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *ent.TaskConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_TaskConnection_totalCount(ctx, field) if err != nil { return graphql.Null } @@ -5423,7 +5586,7 @@ func (ec *executionContext) _User_photoURL(ctx context.Context, field graphql.Co }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.PhotoURL, nil + return obj.TotalCount, nil }) if err != nil { ec.Error(ctx, err) @@ -5435,185 +5598,2819 @@ func (ec *executionContext) _User_photoURL(ctx context.Context, field graphql.Co } return graphql.Null } - res := resTmp.(string) + res := resTmp.(int) fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) + return ec.marshalNInt2int(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_User_photoURL(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_TaskConnection_totalCount(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "User", + Object: "TaskConnection", Field: field, IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + return nil, errors.New("field of type Int does not have child fields") }, } return fc, nil } -func (ec *executionContext) _User_isActivated(ctx context.Context, field graphql.CollectedField, obj *ent.User) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_User_isActivated(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.IsActivated, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(bool) - fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) -} +func (ec *executionContext) _TaskEdge_node(ctx context.Context, field graphql.CollectedField, obj *ent.TaskEdge) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_TaskEdge_node(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Node, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*ent.Task) + fc.Result = res + return ec.marshalOTask2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTask(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_TaskEdge_node(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "TaskEdge", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_Task_id(ctx, field) + case "createdAt": + return ec.fieldContext_Task_createdAt(ctx, field) + case "lastModifiedAt": + return ec.fieldContext_Task_lastModifiedAt(ctx, field) + case "claimedAt": + return ec.fieldContext_Task_claimedAt(ctx, field) + case "execStartedAt": + return ec.fieldContext_Task_execStartedAt(ctx, field) + case "execFinishedAt": + return ec.fieldContext_Task_execFinishedAt(ctx, field) + case "output": + return ec.fieldContext_Task_output(ctx, field) + case "outputSize": + return ec.fieldContext_Task_outputSize(ctx, field) + case "error": + return ec.fieldContext_Task_error(ctx, field) + case "quest": + return ec.fieldContext_Task_quest(ctx, field) + case "beacon": + return ec.fieldContext_Task_beacon(ctx, field) + case "reportedFiles": + return ec.fieldContext_Task_reportedFiles(ctx, field) + case "reportedProcesses": + return ec.fieldContext_Task_reportedProcesses(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Task", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _TaskEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *ent.TaskEdge) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_TaskEdge_cursor(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Cursor, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(entgql.Cursor[int]) + fc.Result = res + return ec.marshalNCursor2entgoᚗioᚋcontribᚋentgqlᚐCursor(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_TaskEdge_cursor(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "TaskEdge", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Cursor does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Tome_id(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Tome_id(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.ID, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(int) + fc.Result = res + return ec.marshalNID2int(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Tome_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Tome", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type ID does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Tome_createdAt(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Tome_createdAt(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.CreatedAt, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(time.Time) + fc.Result = res + return ec.marshalNTime2timeᚐTime(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Tome_createdAt(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Tome", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Time does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Tome_lastModifiedAt(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Tome_lastModifiedAt(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.LastModifiedAt, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(time.Time) + fc.Result = res + return ec.marshalNTime2timeᚐTime(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Tome_lastModifiedAt(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Tome", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Time does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Tome_name(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Tome_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Name, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Tome_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Tome", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Tome_description(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Tome_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Tome_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Tome", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Tome_author(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Tome_author(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Author, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Tome_author(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Tome", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Tome_supportModel(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Tome_supportModel(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.SupportModel, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(tome.SupportModel) + fc.Result = res + return ec.marshalNTomeSupportModel2realmᚗpubᚋtavernᚋinternalᚋentᚋtomeᚐSupportModel(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Tome_supportModel(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Tome", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type TomeSupportModel does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Tome_tactic(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Tome_tactic(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Tactic, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(tome.Tactic) + fc.Result = res + return ec.marshalNTomeTactic2realmᚗpubᚋtavernᚋinternalᚋentᚋtomeᚐTactic(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Tome_tactic(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Tome", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type TomeTactic does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Tome_paramDefs(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Tome_paramDefs(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.ParamDefs, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalOString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Tome_paramDefs(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Tome", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Tome_eldritch(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Tome_eldritch(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Eldritch, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Tome_eldritch(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Tome", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Tome_files(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Tome_files(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Files(ctx) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]*ent.File) + fc.Result = res + return ec.marshalOFile2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐFileᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Tome_files(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Tome", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_File_id(ctx, field) + case "createdAt": + return ec.fieldContext_File_createdAt(ctx, field) + case "lastModifiedAt": + return ec.fieldContext_File_lastModifiedAt(ctx, field) + case "name": + return ec.fieldContext_File_name(ctx, field) + case "size": + return ec.fieldContext_File_size(ctx, field) + case "hash": + return ec.fieldContext_File_hash(ctx, field) + case "tomes": + return ec.fieldContext_File_tomes(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type File", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Tome_uploader(ctx context.Context, field graphql.CollectedField, obj *ent.Tome) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Tome_uploader(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Uploader(ctx) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*ent.User) + fc.Result = res + return ec.marshalOUser2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐUser(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Tome_uploader(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Tome", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_User_id(ctx, field) + case "name": + return ec.fieldContext_User_name(ctx, field) + case "photoURL": + return ec.fieldContext_User_photoURL(ctx, field) + case "isActivated": + return ec.fieldContext_User_isActivated(ctx, field) + case "isAdmin": + return ec.fieldContext_User_isAdmin(ctx, field) + case "tomes": + return ec.fieldContext_User_tomes(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type User", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _User_id(ctx context.Context, field graphql.CollectedField, obj *ent.User) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_User_id(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.ID, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(int) + fc.Result = res + return ec.marshalNID2int(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_User_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "User", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type ID does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _User_name(ctx context.Context, field graphql.CollectedField, obj *ent.User) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_User_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Name, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_User_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "User", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _User_photoURL(ctx context.Context, field graphql.CollectedField, obj *ent.User) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_User_photoURL(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.PhotoURL, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_User_photoURL(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "User", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _User_isActivated(ctx context.Context, field graphql.CollectedField, obj *ent.User) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_User_isActivated(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.IsActivated, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(bool) + fc.Result = res + return ec.marshalNBoolean2bool(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_User_isActivated(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "User", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _User_isAdmin(ctx context.Context, field graphql.CollectedField, obj *ent.User) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_User_isAdmin(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.IsAdmin, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(bool) + fc.Result = res + return ec.marshalNBoolean2bool(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_User_isAdmin(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "User", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _User_tomes(ctx context.Context, field graphql.CollectedField, obj *ent.User) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_User_tomes(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Tomes(ctx) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]*ent.Tome) + fc.Result = res + return ec.marshalOTome2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTomeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_User_tomes(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "User", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_Tome_id(ctx, field) + case "createdAt": + return ec.fieldContext_Tome_createdAt(ctx, field) + case "lastModifiedAt": + return ec.fieldContext_Tome_lastModifiedAt(ctx, field) + case "name": + return ec.fieldContext_Tome_name(ctx, field) + case "description": + return ec.fieldContext_Tome_description(ctx, field) + case "author": + return ec.fieldContext_Tome_author(ctx, field) + case "supportModel": + return ec.fieldContext_Tome_supportModel(ctx, field) + case "tactic": + return ec.fieldContext_Tome_tactic(ctx, field) + case "paramDefs": + return ec.fieldContext_Tome_paramDefs(ctx, field) + case "eldritch": + return ec.fieldContext_Tome_eldritch(ctx, field) + case "files": + return ec.fieldContext_Tome_files(ctx, field) + case "uploader": + return ec.fieldContext_Tome_uploader(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Tome", field.Name) + }, + } + return fc, nil +} + +// endregion **************************** field.gotpl ***************************** + +// region **************************** input.gotpl ***************************** + +func (ec *executionContext) unmarshalInputBeaconOrder(ctx context.Context, obj interface{}) (ent.BeaconOrder, error) { + var it ent.BeaconOrder + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + + if _, present := asMap["direction"]; !present { + asMap["direction"] = "ASC" + } + + fieldsInOrder := [...]string{"direction", "field"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "direction": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("direction")) + data, err := ec.unmarshalNOrderDirection2entgoᚗioᚋcontribᚋentgqlᚐOrderDirection(ctx, v) + if err != nil { + return it, err + } + it.Direction = data + case "field": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field")) + data, err := ec.unmarshalNBeaconOrderField2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBeaconOrderField(ctx, v) + if err != nil { + return it, err + } + it.Field = data + } + } + + return it, nil +} + +func (ec *executionContext) unmarshalInputBeaconWhereInput(ctx context.Context, obj interface{}) (ent.BeaconWhereInput, error) { + var it ent.BeaconWhereInput + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "createdAt", "createdAtNEQ", "createdAtIn", "createdAtNotIn", "createdAtGT", "createdAtGTE", "createdAtLT", "createdAtLTE", "lastModifiedAt", "lastModifiedAtNEQ", "lastModifiedAtIn", "lastModifiedAtNotIn", "lastModifiedAtGT", "lastModifiedAtGTE", "lastModifiedAtLT", "lastModifiedAtLTE", "name", "nameNEQ", "nameIn", "nameNotIn", "nameGT", "nameGTE", "nameLT", "nameLTE", "nameContains", "nameHasPrefix", "nameHasSuffix", "nameEqualFold", "nameContainsFold", "principal", "principalNEQ", "principalIn", "principalNotIn", "principalGT", "principalGTE", "principalLT", "principalLTE", "principalContains", "principalHasPrefix", "principalHasSuffix", "principalIsNil", "principalNotNil", "principalEqualFold", "principalContainsFold", "identifier", "identifierNEQ", "identifierIn", "identifierNotIn", "identifierGT", "identifierGTE", "identifierLT", "identifierLTE", "identifierContains", "identifierHasPrefix", "identifierHasSuffix", "identifierEqualFold", "identifierContainsFold", "agentIdentifier", "agentIdentifierNEQ", "agentIdentifierIn", "agentIdentifierNotIn", "agentIdentifierGT", "agentIdentifierGTE", "agentIdentifierLT", "agentIdentifierLTE", "agentIdentifierContains", "agentIdentifierHasPrefix", "agentIdentifierHasSuffix", "agentIdentifierIsNil", "agentIdentifierNotNil", "agentIdentifierEqualFold", "agentIdentifierContainsFold", "lastSeenAt", "lastSeenAtNEQ", "lastSeenAtIn", "lastSeenAtNotIn", "lastSeenAtGT", "lastSeenAtGTE", "lastSeenAtLT", "lastSeenAtLTE", "lastSeenAtIsNil", "lastSeenAtNotNil", "interval", "intervalNEQ", "intervalIn", "intervalNotIn", "intervalGT", "intervalGTE", "intervalLT", "intervalLTE", "intervalIsNil", "intervalNotNil", "hasHost", "hasHostWith", "hasTasks", "hasTasksWith"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "not": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("not")) + data, err := ec.unmarshalOBeaconWhereInput2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBeaconWhereInput(ctx, v) + if err != nil { + return it, err + } + it.Not = data + case "and": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("and")) + data, err := ec.unmarshalOBeaconWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBeaconWhereInputᚄ(ctx, v) + if err != nil { + return it, err + } + it.And = data + case "or": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("or")) + data, err := ec.unmarshalOBeaconWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBeaconWhereInputᚄ(ctx, v) + if err != nil { + return it, err + } + it.Or = data + case "id": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) + data, err := ec.unmarshalOID2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.ID = data + case "idNEQ": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNEQ")) + data, err := ec.unmarshalOID2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.IDNEQ = data + case "idIn": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idIn")) + data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) + if err != nil { + return it, err + } + it.IDIn = data + case "idNotIn": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNotIn")) + data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) + if err != nil { + return it, err + } + it.IDNotIn = data + case "idGT": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGT")) + data, err := ec.unmarshalOID2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.IDGT = data + case "idGTE": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGTE")) + data, err := ec.unmarshalOID2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.IDGTE = data + case "idLT": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLT")) + data, err := ec.unmarshalOID2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.IDLT = data + case "idLTE": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLTE")) + data, err := ec.unmarshalOID2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.IDLTE = data + case "createdAt": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAt")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.CreatedAt = data + case "createdAtNEQ": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtNEQ")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.CreatedAtNEQ = data + case "createdAtIn": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtIn")) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + if err != nil { + return it, err + } + it.CreatedAtIn = data + case "createdAtNotIn": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtNotIn")) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + if err != nil { + return it, err + } + it.CreatedAtNotIn = data + case "createdAtGT": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtGT")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.CreatedAtGT = data + case "createdAtGTE": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtGTE")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.CreatedAtGTE = data + case "createdAtLT": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtLT")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.CreatedAtLT = data + case "createdAtLTE": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtLTE")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.CreatedAtLTE = data + case "lastModifiedAt": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAt")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.LastModifiedAt = data + case "lastModifiedAtNEQ": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtNEQ")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.LastModifiedAtNEQ = data + case "lastModifiedAtIn": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtIn")) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + if err != nil { + return it, err + } + it.LastModifiedAtIn = data + case "lastModifiedAtNotIn": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtNotIn")) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + if err != nil { + return it, err + } + it.LastModifiedAtNotIn = data + case "lastModifiedAtGT": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtGT")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.LastModifiedAtGT = data + case "lastModifiedAtGTE": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtGTE")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.LastModifiedAtGTE = data + case "lastModifiedAtLT": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtLT")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.LastModifiedAtLT = data + case "lastModifiedAtLTE": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtLTE")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.LastModifiedAtLTE = data + case "name": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.Name = data + case "nameNEQ": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameNEQ")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameNEQ = data + case "nameIn": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.NameIn = data + case "nameNotIn": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameNotIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.NameNotIn = data + case "nameGT": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameGT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameGT = data + case "nameGTE": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameGTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameGTE = data + case "nameLT": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameLT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameLT = data + case "nameLTE": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameLTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameLTE = data + case "nameContains": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameContains")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameContains = data + case "nameHasPrefix": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameHasPrefix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameHasPrefix = data + case "nameHasSuffix": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameHasSuffix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameHasSuffix = data + case "nameEqualFold": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameEqualFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameEqualFold = data + case "nameContainsFold": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameContainsFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameContainsFold = data + case "principal": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principal")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.Principal = data + case "principalNEQ": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalNEQ")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.PrincipalNEQ = data + case "principalIn": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.PrincipalIn = data + case "principalNotIn": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalNotIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.PrincipalNotIn = data + case "principalGT": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalGT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.PrincipalGT = data + case "principalGTE": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalGTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.PrincipalGTE = data + case "principalLT": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalLT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.PrincipalLT = data + case "principalLTE": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalLTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.PrincipalLTE = data + case "principalContains": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalContains")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.PrincipalContains = data + case "principalHasPrefix": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalHasPrefix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.PrincipalHasPrefix = data + case "principalHasSuffix": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalHasSuffix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.PrincipalHasSuffix = data + case "principalIsNil": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalIsNil")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) + if err != nil { + return it, err + } + it.PrincipalIsNil = data + case "principalNotNil": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalNotNil")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) + if err != nil { + return it, err + } + it.PrincipalNotNil = data + case "principalEqualFold": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalEqualFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.PrincipalEqualFold = data + case "principalContainsFold": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalContainsFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.PrincipalContainsFold = data + case "identifier": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifier")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.Identifier = data + case "identifierNEQ": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierNEQ")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.IdentifierNEQ = data + case "identifierIn": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.IdentifierIn = data + case "identifierNotIn": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierNotIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.IdentifierNotIn = data + case "identifierGT": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierGT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.IdentifierGT = data + case "identifierGTE": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierGTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.IdentifierGTE = data + case "identifierLT": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierLT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.IdentifierLT = data + case "identifierLTE": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierLTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.IdentifierLTE = data + case "identifierContains": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierContains")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.IdentifierContains = data + case "identifierHasPrefix": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierHasPrefix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.IdentifierHasPrefix = data + case "identifierHasSuffix": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierHasSuffix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.IdentifierHasSuffix = data + case "identifierEqualFold": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierEqualFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.IdentifierEqualFold = data + case "identifierContainsFold": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierContainsFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.IdentifierContainsFold = data + case "agentIdentifier": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifier")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.AgentIdentifier = data + case "agentIdentifierNEQ": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierNEQ")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.AgentIdentifierNEQ = data + case "agentIdentifierIn": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.AgentIdentifierIn = data + case "agentIdentifierNotIn": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierNotIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.AgentIdentifierNotIn = data + case "agentIdentifierGT": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierGT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.AgentIdentifierGT = data + case "agentIdentifierGTE": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierGTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.AgentIdentifierGTE = data + case "agentIdentifierLT": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierLT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.AgentIdentifierLT = data + case "agentIdentifierLTE": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierLTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.AgentIdentifierLTE = data + case "agentIdentifierContains": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierContains")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.AgentIdentifierContains = data + case "agentIdentifierHasPrefix": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierHasPrefix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.AgentIdentifierHasPrefix = data + case "agentIdentifierHasSuffix": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierHasSuffix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.AgentIdentifierHasSuffix = data + case "agentIdentifierIsNil": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierIsNil")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) + if err != nil { + return it, err + } + it.AgentIdentifierIsNil = data + case "agentIdentifierNotNil": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierNotNil")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) + if err != nil { + return it, err + } + it.AgentIdentifierNotNil = data + case "agentIdentifierEqualFold": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierEqualFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.AgentIdentifierEqualFold = data + case "agentIdentifierContainsFold": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierContainsFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.AgentIdentifierContainsFold = data + case "lastSeenAt": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAt")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.LastSeenAt = data + case "lastSeenAtNEQ": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtNEQ")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.LastSeenAtNEQ = data + case "lastSeenAtIn": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtIn")) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + if err != nil { + return it, err + } + it.LastSeenAtIn = data + case "lastSeenAtNotIn": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtNotIn")) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + if err != nil { + return it, err + } + it.LastSeenAtNotIn = data + case "lastSeenAtGT": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtGT")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.LastSeenAtGT = data + case "lastSeenAtGTE": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtGTE")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.LastSeenAtGTE = data + case "lastSeenAtLT": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtLT")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.LastSeenAtLT = data + case "lastSeenAtLTE": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtLTE")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.LastSeenAtLTE = data + case "lastSeenAtIsNil": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtIsNil")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) + if err != nil { + return it, err + } + it.LastSeenAtIsNil = data + case "lastSeenAtNotNil": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtNotNil")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) + if err != nil { + return it, err + } + it.LastSeenAtNotNil = data + case "interval": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("interval")) + data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) + if err != nil { + return it, err + } + it.Interval = data + case "intervalNEQ": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("intervalNEQ")) + data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) + if err != nil { + return it, err + } + it.IntervalNEQ = data + case "intervalIn": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("intervalIn")) + data, err := ec.unmarshalOUint642ᚕuint64ᚄ(ctx, v) + if err != nil { + return it, err + } + it.IntervalIn = data + case "intervalNotIn": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("intervalNotIn")) + data, err := ec.unmarshalOUint642ᚕuint64ᚄ(ctx, v) + if err != nil { + return it, err + } + it.IntervalNotIn = data + case "intervalGT": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("intervalGT")) + data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) + if err != nil { + return it, err + } + it.IntervalGT = data + case "intervalGTE": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("intervalGTE")) + data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) + if err != nil { + return it, err + } + it.IntervalGTE = data + case "intervalLT": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("intervalLT")) + data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) + if err != nil { + return it, err + } + it.IntervalLT = data + case "intervalLTE": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("intervalLTE")) + data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) + if err != nil { + return it, err + } + it.IntervalLTE = data + case "intervalIsNil": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("intervalIsNil")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) + if err != nil { + return it, err + } + it.IntervalIsNil = data + case "intervalNotNil": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("intervalNotNil")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) + if err != nil { + return it, err + } + it.IntervalNotNil = data + case "hasHost": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasHost")) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) + if err != nil { + return it, err + } + it.HasHost = data + case "hasHostWith": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasHostWith")) + data, err := ec.unmarshalOHostWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostWhereInputᚄ(ctx, v) + if err != nil { + return it, err + } + it.HasHostWith = data + case "hasTasks": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasTasks")) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) + if err != nil { + return it, err + } + it.HasTasks = data + case "hasTasksWith": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasTasksWith")) + data, err := ec.unmarshalOTaskWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTaskWhereInputᚄ(ctx, v) + if err != nil { + return it, err + } + it.HasTasksWith = data + } + } + + return it, nil +} + +func (ec *executionContext) unmarshalInputCreateQuestInput(ctx context.Context, obj interface{}) (ent.CreateQuestInput, error) { + var it ent.CreateQuestInput + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"name", "parameters", "tomeID"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "name": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) + data, err := ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + it.Name = data + case "parameters": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("parameters")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.Parameters = data + case "tomeID": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("tomeID")) + data, err := ec.unmarshalNID2int(ctx, v) + if err != nil { + return it, err + } + it.TomeID = data + } + } + + return it, nil +} + +func (ec *executionContext) unmarshalInputCreateTagInput(ctx context.Context, obj interface{}) (ent.CreateTagInput, error) { + var it ent.CreateTagInput + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"name", "kind", "hostIDs"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "name": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) + data, err := ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + it.Name = data + case "kind": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("kind")) + data, err := ec.unmarshalNTagKind2realmᚗpubᚋtavernᚋinternalᚋentᚋtagᚐKind(ctx, v) + if err != nil { + return it, err + } + it.Kind = data + case "hostIDs": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hostIDs")) + data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) + if err != nil { + return it, err + } + it.HostIDs = data + } + } + + return it, nil +} + +func (ec *executionContext) unmarshalInputCreateTomeInput(ctx context.Context, obj interface{}) (ent.CreateTomeInput, error) { + var it ent.CreateTomeInput + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"name", "description", "author", "supportModel", "tactic", "paramDefs", "eldritch", "fileIDs"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "name": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) + data, err := ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + it.Name = data + case "description": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("description")) + data, err := ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + it.Description = data + case "author": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("author")) + data, err := ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + it.Author = data + case "supportModel": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("supportModel")) + data, err := ec.unmarshalOTomeSupportModel2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚋtomeᚐSupportModel(ctx, v) + if err != nil { + return it, err + } + it.SupportModel = data + case "tactic": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("tactic")) + data, err := ec.unmarshalOTomeTactic2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚋtomeᚐTactic(ctx, v) + if err != nil { + return it, err + } + it.Tactic = data + case "paramDefs": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("paramDefs")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.ParamDefs = data + case "eldritch": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("eldritch")) + data, err := ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + it.Eldritch = data + case "fileIDs": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("fileIDs")) + data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) + if err != nil { + return it, err + } + it.FileIDs = data + } + } + + return it, nil +} + +func (ec *executionContext) unmarshalInputFileOrder(ctx context.Context, obj interface{}) (ent.FileOrder, error) { + var it ent.FileOrder + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + + if _, present := asMap["direction"]; !present { + asMap["direction"] = "ASC" + } + + fieldsInOrder := [...]string{"direction", "field"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "direction": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("direction")) + data, err := ec.unmarshalNOrderDirection2entgoᚗioᚋcontribᚋentgqlᚐOrderDirection(ctx, v) + if err != nil { + return it, err + } + it.Direction = data + case "field": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field")) + data, err := ec.unmarshalNFileOrderField2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐFileOrderField(ctx, v) + if err != nil { + return it, err + } + it.Field = data + } + } + + return it, nil +} + +func (ec *executionContext) unmarshalInputFileWhereInput(ctx context.Context, obj interface{}) (ent.FileWhereInput, error) { + var it ent.FileWhereInput + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "createdAt", "createdAtNEQ", "createdAtIn", "createdAtNotIn", "createdAtGT", "createdAtGTE", "createdAtLT", "createdAtLTE", "lastModifiedAt", "lastModifiedAtNEQ", "lastModifiedAtIn", "lastModifiedAtNotIn", "lastModifiedAtGT", "lastModifiedAtGTE", "lastModifiedAtLT", "lastModifiedAtLTE", "name", "nameNEQ", "nameIn", "nameNotIn", "nameGT", "nameGTE", "nameLT", "nameLTE", "nameContains", "nameHasPrefix", "nameHasSuffix", "nameEqualFold", "nameContainsFold", "size", "sizeNEQ", "sizeIn", "sizeNotIn", "sizeGT", "sizeGTE", "sizeLT", "sizeLTE", "hash", "hashNEQ", "hashIn", "hashNotIn", "hashGT", "hashGTE", "hashLT", "hashLTE", "hashContains", "hashHasPrefix", "hashHasSuffix", "hashEqualFold", "hashContainsFold", "hasTomes", "hasTomesWith"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "not": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("not")) + data, err := ec.unmarshalOFileWhereInput2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐFileWhereInput(ctx, v) + if err != nil { + return it, err + } + it.Not = data + case "and": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("and")) + data, err := ec.unmarshalOFileWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐFileWhereInputᚄ(ctx, v) + if err != nil { + return it, err + } + it.And = data + case "or": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("or")) + data, err := ec.unmarshalOFileWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐFileWhereInputᚄ(ctx, v) + if err != nil { + return it, err + } + it.Or = data + case "id": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) + data, err := ec.unmarshalOID2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.ID = data + case "idNEQ": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNEQ")) + data, err := ec.unmarshalOID2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.IDNEQ = data + case "idIn": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idIn")) + data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) + if err != nil { + return it, err + } + it.IDIn = data + case "idNotIn": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNotIn")) + data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) + if err != nil { + return it, err + } + it.IDNotIn = data + case "idGT": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGT")) + data, err := ec.unmarshalOID2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.IDGT = data + case "idGTE": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGTE")) + data, err := ec.unmarshalOID2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.IDGTE = data + case "idLT": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLT")) + data, err := ec.unmarshalOID2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.IDLT = data + case "idLTE": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLTE")) + data, err := ec.unmarshalOID2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.IDLTE = data + case "createdAt": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAt")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.CreatedAt = data + case "createdAtNEQ": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtNEQ")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.CreatedAtNEQ = data + case "createdAtIn": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtIn")) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + if err != nil { + return it, err + } + it.CreatedAtIn = data + case "createdAtNotIn": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtNotIn")) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + if err != nil { + return it, err + } + it.CreatedAtNotIn = data + case "createdAtGT": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtGT")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.CreatedAtGT = data + case "createdAtGTE": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtGTE")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.CreatedAtGTE = data + case "createdAtLT": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtLT")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.CreatedAtLT = data + case "createdAtLTE": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtLTE")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.CreatedAtLTE = data + case "lastModifiedAt": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAt")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.LastModifiedAt = data + case "lastModifiedAtNEQ": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtNEQ")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.LastModifiedAtNEQ = data + case "lastModifiedAtIn": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtIn")) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + if err != nil { + return it, err + } + it.LastModifiedAtIn = data + case "lastModifiedAtNotIn": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtNotIn")) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + if err != nil { + return it, err + } + it.LastModifiedAtNotIn = data + case "lastModifiedAtGT": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtGT")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.LastModifiedAtGT = data + case "lastModifiedAtGTE": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtGTE")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.LastModifiedAtGTE = data + case "lastModifiedAtLT": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtLT")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.LastModifiedAtLT = data + case "lastModifiedAtLTE": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtLTE")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + if err != nil { + return it, err + } + it.LastModifiedAtLTE = data + case "name": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.Name = data + case "nameNEQ": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameNEQ")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameNEQ = data + case "nameIn": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.NameIn = data + case "nameNotIn": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameNotIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.NameNotIn = data + case "nameGT": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameGT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameGT = data + case "nameGTE": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameGTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameGTE = data + case "nameLT": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameLT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameLT = data + case "nameLTE": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameLTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameLTE = data + case "nameContains": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameContains")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameContains = data + case "nameHasPrefix": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameHasPrefix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameHasPrefix = data + case "nameHasSuffix": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameHasSuffix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameHasSuffix = data + case "nameEqualFold": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameEqualFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameEqualFold = data + case "nameContainsFold": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameContainsFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameContainsFold = data + case "size": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("size")) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.Size = data + case "sizeNEQ": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeNEQ")) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.SizeNEQ = data + case "sizeIn": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeIn")) + data, err := ec.unmarshalOInt2ᚕintᚄ(ctx, v) + if err != nil { + return it, err + } + it.SizeIn = data + case "sizeNotIn": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeNotIn")) + data, err := ec.unmarshalOInt2ᚕintᚄ(ctx, v) + if err != nil { + return it, err + } + it.SizeNotIn = data + case "sizeGT": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeGT")) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.SizeGT = data + case "sizeGTE": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeGTE")) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.SizeGTE = data + case "sizeLT": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeLT")) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.SizeLT = data + case "sizeLTE": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeLTE")) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) + if err != nil { + return it, err + } + it.SizeLTE = data + case "hash": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hash")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.Hash = data + case "hashNEQ": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashNEQ")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.HashNEQ = data + case "hashIn": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.HashIn = data + case "hashNotIn": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashNotIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.HashNotIn = data + case "hashGT": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashGT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.HashGT = data + case "hashGTE": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashGTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.HashGTE = data + case "hashLT": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashLT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.HashLT = data + case "hashLTE": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashLTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.HashLTE = data + case "hashContains": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashContains")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.HashContains = data + case "hashHasPrefix": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashHasPrefix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.HashHasPrefix = data + case "hashHasSuffix": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashHasSuffix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.HashHasSuffix = data + case "hashEqualFold": + var err error -func (ec *executionContext) fieldContext_User_isActivated(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "User", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Boolean does not have child fields") - }, - } - return fc, nil -} + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashEqualFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.HashEqualFold = data + case "hashContainsFold": + var err error -func (ec *executionContext) _User_isAdmin(ctx context.Context, field graphql.CollectedField, obj *ent.User) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_User_isAdmin(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.IsAdmin, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(bool) - fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) -} + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashContainsFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.HashContainsFold = data + case "hasTomes": + var err error -func (ec *executionContext) fieldContext_User_isAdmin(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "User", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Boolean does not have child fields") - }, - } - return fc, nil -} + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasTomes")) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) + if err != nil { + return it, err + } + it.HasTomes = data + case "hasTomesWith": + var err error -func (ec *executionContext) _User_tomes(ctx context.Context, field graphql.CollectedField, obj *ent.User) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_User_tomes(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasTomesWith")) + data, err := ec.unmarshalOTomeWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTomeWhereInputᚄ(ctx, v) + if err != nil { + return it, err + } + it.HasTomesWith = data } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Tomes(ctx) - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null } - res := resTmp.([]*ent.Tome) - fc.Result = res - return ec.marshalOTome2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTomeᚄ(ctx, field.Selections, res) -} -func (ec *executionContext) fieldContext_User_tomes(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "User", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_Tome_id(ctx, field) - case "createdAt": - return ec.fieldContext_Tome_createdAt(ctx, field) - case "lastModifiedAt": - return ec.fieldContext_Tome_lastModifiedAt(ctx, field) - case "name": - return ec.fieldContext_Tome_name(ctx, field) - case "description": - return ec.fieldContext_Tome_description(ctx, field) - case "author": - return ec.fieldContext_Tome_author(ctx, field) - case "supportModel": - return ec.fieldContext_Tome_supportModel(ctx, field) - case "tactic": - return ec.fieldContext_Tome_tactic(ctx, field) - case "paramDefs": - return ec.fieldContext_Tome_paramDefs(ctx, field) - case "eldritch": - return ec.fieldContext_Tome_eldritch(ctx, field) - case "files": - return ec.fieldContext_Tome_files(ctx, field) - case "uploader": - return ec.fieldContext_Tome_uploader(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type Tome", field.Name) - }, - } - return fc, nil + return it, nil } -// endregion **************************** field.gotpl ***************************** - -// region **************************** input.gotpl ***************************** - -func (ec *executionContext) unmarshalInputBeaconOrder(ctx context.Context, obj interface{}) (ent.BeaconOrder, error) { - var it ent.BeaconOrder +func (ec *executionContext) unmarshalInputHostFileOrder(ctx context.Context, obj interface{}) (ent.HostFileOrder, error) { + var it ent.HostFileOrder asMap := map[string]interface{}{} for k, v := range obj.(map[string]interface{}) { asMap[k] = v @@ -5643,7 +8440,7 @@ func (ec *executionContext) unmarshalInputBeaconOrder(ctx context.Context, obj i var err error ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field")) - data, err := ec.unmarshalNBeaconOrderField2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBeaconOrderField(ctx, v) + data, err := ec.unmarshalNHostFileOrderField2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostFileOrderField(ctx, v) if err != nil { return it, err } @@ -5654,14 +8451,14 @@ func (ec *executionContext) unmarshalInputBeaconOrder(ctx context.Context, obj i return it, nil } -func (ec *executionContext) unmarshalInputBeaconWhereInput(ctx context.Context, obj interface{}) (ent.BeaconWhereInput, error) { - var it ent.BeaconWhereInput +func (ec *executionContext) unmarshalInputHostFileWhereInput(ctx context.Context, obj interface{}) (ent.HostFileWhereInput, error) { + var it ent.HostFileWhereInput asMap := map[string]interface{}{} for k, v := range obj.(map[string]interface{}) { asMap[k] = v } - fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "createdAt", "createdAtNEQ", "createdAtIn", "createdAtNotIn", "createdAtGT", "createdAtGTE", "createdAtLT", "createdAtLTE", "lastModifiedAt", "lastModifiedAtNEQ", "lastModifiedAtIn", "lastModifiedAtNotIn", "lastModifiedAtGT", "lastModifiedAtGTE", "lastModifiedAtLT", "lastModifiedAtLTE", "name", "nameNEQ", "nameIn", "nameNotIn", "nameGT", "nameGTE", "nameLT", "nameLTE", "nameContains", "nameHasPrefix", "nameHasSuffix", "nameEqualFold", "nameContainsFold", "principal", "principalNEQ", "principalIn", "principalNotIn", "principalGT", "principalGTE", "principalLT", "principalLTE", "principalContains", "principalHasPrefix", "principalHasSuffix", "principalIsNil", "principalNotNil", "principalEqualFold", "principalContainsFold", "identifier", "identifierNEQ", "identifierIn", "identifierNotIn", "identifierGT", "identifierGTE", "identifierLT", "identifierLTE", "identifierContains", "identifierHasPrefix", "identifierHasSuffix", "identifierEqualFold", "identifierContainsFold", "agentIdentifier", "agentIdentifierNEQ", "agentIdentifierIn", "agentIdentifierNotIn", "agentIdentifierGT", "agentIdentifierGTE", "agentIdentifierLT", "agentIdentifierLTE", "agentIdentifierContains", "agentIdentifierHasPrefix", "agentIdentifierHasSuffix", "agentIdentifierIsNil", "agentIdentifierNotNil", "agentIdentifierEqualFold", "agentIdentifierContainsFold", "lastSeenAt", "lastSeenAtNEQ", "lastSeenAtIn", "lastSeenAtNotIn", "lastSeenAtGT", "lastSeenAtGTE", "lastSeenAtLT", "lastSeenAtLTE", "lastSeenAtIsNil", "lastSeenAtNotNil", "interval", "intervalNEQ", "intervalIn", "intervalNotIn", "intervalGT", "intervalGTE", "intervalLT", "intervalLTE", "intervalIsNil", "intervalNotNil", "hasHost", "hasHostWith", "hasTasks", "hasTasksWith"} + fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "createdAt", "createdAtNEQ", "createdAtIn", "createdAtNotIn", "createdAtGT", "createdAtGTE", "createdAtLT", "createdAtLTE", "lastModifiedAt", "lastModifiedAtNEQ", "lastModifiedAtIn", "lastModifiedAtNotIn", "lastModifiedAtGT", "lastModifiedAtGTE", "lastModifiedAtLT", "lastModifiedAtLTE", "path", "pathNEQ", "pathIn", "pathNotIn", "pathGT", "pathGTE", "pathLT", "pathLTE", "pathContains", "pathHasPrefix", "pathHasSuffix", "pathEqualFold", "pathContainsFold", "owner", "ownerNEQ", "ownerIn", "ownerNotIn", "ownerGT", "ownerGTE", "ownerLT", "ownerLTE", "ownerContains", "ownerHasPrefix", "ownerHasSuffix", "ownerIsNil", "ownerNotNil", "ownerEqualFold", "ownerContainsFold", "group", "groupNEQ", "groupIn", "groupNotIn", "groupGT", "groupGTE", "groupLT", "groupLTE", "groupContains", "groupHasPrefix", "groupHasSuffix", "groupIsNil", "groupNotNil", "groupEqualFold", "groupContainsFold", "permissions", "permissionsNEQ", "permissionsIn", "permissionsNotIn", "permissionsGT", "permissionsGTE", "permissionsLT", "permissionsLTE", "permissionsContains", "permissionsHasPrefix", "permissionsHasSuffix", "permissionsIsNil", "permissionsNotNil", "permissionsEqualFold", "permissionsContainsFold", "size", "sizeNEQ", "sizeIn", "sizeNotIn", "sizeGT", "sizeGTE", "sizeLT", "sizeLTE", "hash", "hashNEQ", "hashIn", "hashNotIn", "hashGT", "hashGTE", "hashLT", "hashLTE", "hashContains", "hashHasPrefix", "hashHasSuffix", "hashIsNil", "hashNotNil", "hashEqualFold", "hashContainsFold", "hasHost", "hasHostWith", "hasTask", "hasTaskWith"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { @@ -5672,7 +8469,7 @@ func (ec *executionContext) unmarshalInputBeaconWhereInput(ctx context.Context, var err error ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("not")) - data, err := ec.unmarshalOBeaconWhereInput2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBeaconWhereInput(ctx, v) + data, err := ec.unmarshalOHostFileWhereInput2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostFileWhereInput(ctx, v) if err != nil { return it, err } @@ -5681,7 +8478,7 @@ func (ec *executionContext) unmarshalInputBeaconWhereInput(ctx context.Context, var err error ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("and")) - data, err := ec.unmarshalOBeaconWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBeaconWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOHostFileWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostFileWhereInputᚄ(ctx, v) if err != nil { return it, err } @@ -5690,7 +8487,7 @@ func (ec *executionContext) unmarshalInputBeaconWhereInput(ctx context.Context, var err error ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("or")) - data, err := ec.unmarshalOBeaconWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBeaconWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOHostFileWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostFileWhereInputᚄ(ctx, v) if err != nil { return it, err } @@ -5911,920 +8708,821 @@ func (ec *executionContext) unmarshalInputBeaconWhereInput(ctx context.Context, return it, err } it.LastModifiedAtLTE = data - case "name": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.Name = data - case "nameNEQ": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameNEQ")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.NameNEQ = data - case "nameIn": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameIn")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) - if err != nil { - return it, err - } - it.NameIn = data - case "nameNotIn": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameNotIn")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) - if err != nil { - return it, err - } - it.NameNotIn = data - case "nameGT": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameGT")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.NameGT = data - case "nameGTE": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameGTE")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.NameGTE = data - case "nameLT": + case "path": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameLT")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("path")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.NameLT = data - case "nameLTE": + it.Path = data + case "pathNEQ": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameLTE")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pathNEQ")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.NameLTE = data - case "nameContains": + it.PathNEQ = data + case "pathIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameContains")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pathIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - it.NameContains = data - case "nameHasPrefix": + it.PathIn = data + case "pathNotIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameHasPrefix")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pathNotIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - it.NameHasPrefix = data - case "nameHasSuffix": + it.PathNotIn = data + case "pathGT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameHasSuffix")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pathGT")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.NameHasSuffix = data - case "nameEqualFold": + it.PathGT = data + case "pathGTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameEqualFold")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pathGTE")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.NameEqualFold = data - case "nameContainsFold": + it.PathGTE = data + case "pathLT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameContainsFold")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pathLT")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.NameContainsFold = data - case "principal": + it.PathLT = data + case "pathLTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principal")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pathLTE")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.Principal = data - case "principalNEQ": + it.PathLTE = data + case "pathContains": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalNEQ")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pathContains")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.PrincipalNEQ = data - case "principalIn": + it.PathContains = data + case "pathHasPrefix": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalIn")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pathHasPrefix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.PrincipalIn = data - case "principalNotIn": + it.PathHasPrefix = data + case "pathHasSuffix": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalNotIn")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pathHasSuffix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.PrincipalNotIn = data - case "principalGT": + it.PathHasSuffix = data + case "pathEqualFold": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalGT")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pathEqualFold")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.PrincipalGT = data - case "principalGTE": + it.PathEqualFold = data + case "pathContainsFold": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalGTE")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pathContainsFold")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.PrincipalGTE = data - case "principalLT": + it.PathContainsFold = data + case "owner": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalLT")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("owner")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.PrincipalLT = data - case "principalLTE": + it.Owner = data + case "ownerNEQ": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalLTE")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ownerNEQ")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.PrincipalLTE = data - case "principalContains": + it.OwnerNEQ = data + case "ownerIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalContains")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ownerIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - it.PrincipalContains = data - case "principalHasPrefix": + it.OwnerIn = data + case "ownerNotIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalHasPrefix")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ownerNotIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - it.PrincipalHasPrefix = data - case "principalHasSuffix": + it.OwnerNotIn = data + case "ownerGT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalHasSuffix")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ownerGT")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.PrincipalHasSuffix = data - case "principalIsNil": + it.OwnerGT = data + case "ownerGTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalIsNil")) - data, err := ec.unmarshalOBoolean2bool(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ownerGTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.PrincipalIsNil = data - case "principalNotNil": + it.OwnerGTE = data + case "ownerLT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalNotNil")) - data, err := ec.unmarshalOBoolean2bool(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ownerLT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.PrincipalNotNil = data - case "principalEqualFold": + it.OwnerLT = data + case "ownerLTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalEqualFold")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ownerLTE")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.PrincipalEqualFold = data - case "principalContainsFold": + it.OwnerLTE = data + case "ownerContains": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalContainsFold")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ownerContains")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.PrincipalContainsFold = data - case "identifier": + it.OwnerContains = data + case "ownerHasPrefix": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifier")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ownerHasPrefix")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.Identifier = data - case "identifierNEQ": + it.OwnerHasPrefix = data + case "ownerHasSuffix": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierNEQ")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ownerHasSuffix")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.IdentifierNEQ = data - case "identifierIn": + it.OwnerHasSuffix = data + case "ownerIsNil": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierIn")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ownerIsNil")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } - it.IdentifierIn = data - case "identifierNotIn": + it.OwnerIsNil = data + case "ownerNotNil": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierNotIn")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ownerNotNil")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } - it.IdentifierNotIn = data - case "identifierGT": + it.OwnerNotNil = data + case "ownerEqualFold": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierGT")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ownerEqualFold")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.IdentifierGT = data - case "identifierGTE": + it.OwnerEqualFold = data + case "ownerContainsFold": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierGTE")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ownerContainsFold")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.IdentifierGTE = data - case "identifierLT": + it.OwnerContainsFold = data + case "group": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierLT")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("group")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.IdentifierLT = data - case "identifierLTE": + it.Group = data + case "groupNEQ": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierLTE")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("groupNEQ")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.IdentifierLTE = data - case "identifierContains": + it.GroupNEQ = data + case "groupIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierContains")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("groupIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - it.IdentifierContains = data - case "identifierHasPrefix": + it.GroupIn = data + case "groupNotIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierHasPrefix")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("groupNotIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - it.IdentifierHasPrefix = data - case "identifierHasSuffix": + it.GroupNotIn = data + case "groupGT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierHasSuffix")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("groupGT")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.IdentifierHasSuffix = data - case "identifierEqualFold": + it.GroupGT = data + case "groupGTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierEqualFold")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("groupGTE")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.IdentifierEqualFold = data - case "identifierContainsFold": + it.GroupGTE = data + case "groupLT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierContainsFold")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("groupLT")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.IdentifierContainsFold = data - case "agentIdentifier": + it.GroupLT = data + case "groupLTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifier")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("groupLTE")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.AgentIdentifier = data - case "agentIdentifierNEQ": + it.GroupLTE = data + case "groupContains": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierNEQ")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("groupContains")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.AgentIdentifierNEQ = data - case "agentIdentifierIn": + it.GroupContains = data + case "groupHasPrefix": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierIn")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("groupHasPrefix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.AgentIdentifierIn = data - case "agentIdentifierNotIn": + it.GroupHasPrefix = data + case "groupHasSuffix": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierNotIn")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("groupHasSuffix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.AgentIdentifierNotIn = data - case "agentIdentifierGT": + it.GroupHasSuffix = data + case "groupIsNil": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierGT")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("groupIsNil")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } - it.AgentIdentifierGT = data - case "agentIdentifierGTE": + it.GroupIsNil = data + case "groupNotNil": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierGTE")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("groupNotNil")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } - it.AgentIdentifierGTE = data - case "agentIdentifierLT": + it.GroupNotNil = data + case "groupEqualFold": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierLT")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("groupEqualFold")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.AgentIdentifierLT = data - case "agentIdentifierLTE": + it.GroupEqualFold = data + case "groupContainsFold": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierLTE")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("groupContainsFold")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.AgentIdentifierLTE = data - case "agentIdentifierContains": + it.GroupContainsFold = data + case "permissions": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierContains")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("permissions")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.AgentIdentifierContains = data - case "agentIdentifierHasPrefix": + it.Permissions = data + case "permissionsNEQ": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierHasPrefix")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("permissionsNEQ")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.AgentIdentifierHasPrefix = data - case "agentIdentifierHasSuffix": + it.PermissionsNEQ = data + case "permissionsIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierHasSuffix")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("permissionsIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - it.AgentIdentifierHasSuffix = data - case "agentIdentifierIsNil": + it.PermissionsIn = data + case "permissionsNotIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierIsNil")) - data, err := ec.unmarshalOBoolean2bool(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("permissionsNotIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - it.AgentIdentifierIsNil = data - case "agentIdentifierNotNil": + it.PermissionsNotIn = data + case "permissionsGT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierNotNil")) - data, err := ec.unmarshalOBoolean2bool(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("permissionsGT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.AgentIdentifierNotNil = data - case "agentIdentifierEqualFold": + it.PermissionsGT = data + case "permissionsGTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierEqualFold")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("permissionsGTE")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.AgentIdentifierEqualFold = data - case "agentIdentifierContainsFold": + it.PermissionsGTE = data + case "permissionsLT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("agentIdentifierContainsFold")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("permissionsLT")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.AgentIdentifierContainsFold = data - case "lastSeenAt": + it.PermissionsLT = data + case "permissionsLTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAt")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("permissionsLTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.LastSeenAt = data - case "lastSeenAtNEQ": + it.PermissionsLTE = data + case "permissionsContains": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtNEQ")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("permissionsContains")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.LastSeenAtNEQ = data - case "lastSeenAtIn": + it.PermissionsContains = data + case "permissionsHasPrefix": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtIn")) - data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("permissionsHasPrefix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.LastSeenAtIn = data - case "lastSeenAtNotIn": + it.PermissionsHasPrefix = data + case "permissionsHasSuffix": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtNotIn")) - data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("permissionsHasSuffix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.LastSeenAtNotIn = data - case "lastSeenAtGT": + it.PermissionsHasSuffix = data + case "permissionsIsNil": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtGT")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("permissionsIsNil")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } - it.LastSeenAtGT = data - case "lastSeenAtGTE": + it.PermissionsIsNil = data + case "permissionsNotNil": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtGTE")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("permissionsNotNil")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } - it.LastSeenAtGTE = data - case "lastSeenAtLT": + it.PermissionsNotNil = data + case "permissionsEqualFold": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtLT")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("permissionsEqualFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.LastSeenAtLT = data - case "lastSeenAtLTE": + it.PermissionsEqualFold = data + case "permissionsContainsFold": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtLTE")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("permissionsContainsFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.LastSeenAtLTE = data - case "lastSeenAtIsNil": + it.PermissionsContainsFold = data + case "size": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtIsNil")) - data, err := ec.unmarshalOBoolean2bool(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("size")) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) if err != nil { return it, err } - it.LastSeenAtIsNil = data - case "lastSeenAtNotNil": + it.Size = data + case "sizeNEQ": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtNotNil")) - data, err := ec.unmarshalOBoolean2bool(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeNEQ")) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) if err != nil { return it, err } - it.LastSeenAtNotNil = data - case "interval": + it.SizeNEQ = data + case "sizeIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("interval")) - data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeIn")) + data, err := ec.unmarshalOInt2ᚕintᚄ(ctx, v) if err != nil { return it, err } - it.Interval = data - case "intervalNEQ": + it.SizeIn = data + case "sizeNotIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("intervalNEQ")) - data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeNotIn")) + data, err := ec.unmarshalOInt2ᚕintᚄ(ctx, v) if err != nil { return it, err } - it.IntervalNEQ = data - case "intervalIn": + it.SizeNotIn = data + case "sizeGT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("intervalIn")) - data, err := ec.unmarshalOUint642ᚕuint64ᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeGT")) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) if err != nil { return it, err } - it.IntervalIn = data - case "intervalNotIn": + it.SizeGT = data + case "sizeGTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("intervalNotIn")) - data, err := ec.unmarshalOUint642ᚕuint64ᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeGTE")) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) if err != nil { return it, err } - it.IntervalNotIn = data - case "intervalGT": + it.SizeGTE = data + case "sizeLT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("intervalGT")) - data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeLT")) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) if err != nil { return it, err } - it.IntervalGT = data - case "intervalGTE": + it.SizeLT = data + case "sizeLTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("intervalGTE")) - data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeLTE")) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) if err != nil { return it, err } - it.IntervalGTE = data - case "intervalLT": + it.SizeLTE = data + case "hash": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("intervalLT")) - data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hash")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.IntervalLT = data - case "intervalLTE": + it.Hash = data + case "hashNEQ": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("intervalLTE")) - data, err := ec.unmarshalOUint642ᚖuint64(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashNEQ")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.IntervalLTE = data - case "intervalIsNil": + it.HashNEQ = data + case "hashIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("intervalIsNil")) - data, err := ec.unmarshalOBoolean2bool(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - it.IntervalIsNil = data - case "intervalNotNil": + it.HashIn = data + case "hashNotIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("intervalNotNil")) - data, err := ec.unmarshalOBoolean2bool(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashNotIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - it.IntervalNotNil = data - case "hasHost": + it.HashNotIn = data + case "hashGT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasHost")) - data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashGT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.HasHost = data - case "hasHostWith": + it.HashGT = data + case "hashGTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasHostWith")) - data, err := ec.unmarshalOHostWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostWhereInputᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashGTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.HasHostWith = data - case "hasTasks": + it.HashGTE = data + case "hashLT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasTasks")) - data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashLT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.HasTasks = data - case "hasTasksWith": + it.HashLT = data + case "hashLTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasTasksWith")) - data, err := ec.unmarshalOTaskWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTaskWhereInputᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashLTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.HasTasksWith = data - } - } - - return it, nil -} - -func (ec *executionContext) unmarshalInputCreateQuestInput(ctx context.Context, obj interface{}) (ent.CreateQuestInput, error) { - var it ent.CreateQuestInput - asMap := map[string]interface{}{} - for k, v := range obj.(map[string]interface{}) { - asMap[k] = v - } - - fieldsInOrder := [...]string{"name", "parameters", "tomeID"} - for _, k := range fieldsInOrder { - v, ok := asMap[k] - if !ok { - continue - } - switch k { - case "name": + it.HashLTE = data + case "hashContains": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) - data, err := ec.unmarshalNString2string(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashContains")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.Name = data - case "parameters": + it.HashContains = data + case "hashHasPrefix": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("parameters")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashHasPrefix")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.Parameters = data - case "tomeID": + it.HashHasPrefix = data + case "hashHasSuffix": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("tomeID")) - data, err := ec.unmarshalNID2int(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashHasSuffix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.TomeID = data - } - } - - return it, nil -} - -func (ec *executionContext) unmarshalInputCreateTagInput(ctx context.Context, obj interface{}) (ent.CreateTagInput, error) { - var it ent.CreateTagInput - asMap := map[string]interface{}{} - for k, v := range obj.(map[string]interface{}) { - asMap[k] = v - } - - fieldsInOrder := [...]string{"name", "kind", "hostIDs"} - for _, k := range fieldsInOrder { - v, ok := asMap[k] - if !ok { - continue - } - switch k { - case "name": + it.HashHasSuffix = data + case "hashIsNil": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) - data, err := ec.unmarshalNString2string(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashIsNil")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } - it.Name = data - case "kind": + it.HashIsNil = data + case "hashNotNil": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("kind")) - data, err := ec.unmarshalNTagKind2realmᚗpubᚋtavernᚋinternalᚋentᚋtagᚐKind(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashNotNil")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } - it.Kind = data - case "hostIDs": + it.HashNotNil = data + case "hashEqualFold": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hostIDs")) - data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashEqualFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.HostIDs = data - } - } - - return it, nil -} - -func (ec *executionContext) unmarshalInputCreateTomeInput(ctx context.Context, obj interface{}) (ent.CreateTomeInput, error) { - var it ent.CreateTomeInput - asMap := map[string]interface{}{} - for k, v := range obj.(map[string]interface{}) { - asMap[k] = v - } - - fieldsInOrder := [...]string{"name", "description", "author", "supportModel", "tactic", "paramDefs", "eldritch", "fileIDs"} - for _, k := range fieldsInOrder { - v, ok := asMap[k] - if !ok { - continue - } - switch k { - case "name": + it.HashEqualFold = data + case "hashContainsFold": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) - data, err := ec.unmarshalNString2string(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashContainsFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.Name = data - case "description": + it.HashContainsFold = data + case "hasHost": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("description")) - data, err := ec.unmarshalNString2string(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasHost")) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { return it, err } - it.Description = data - case "author": + it.HasHost = data + case "hasHostWith": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("author")) - data, err := ec.unmarshalNString2string(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasHostWith")) + data, err := ec.unmarshalOHostWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostWhereInputᚄ(ctx, v) if err != nil { return it, err } - it.Author = data - case "supportModel": + it.HasHostWith = data + case "hasTask": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("supportModel")) - data, err := ec.unmarshalOTomeSupportModel2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚋtomeᚐSupportModel(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasTask")) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { return it, err } - it.SupportModel = data - case "tactic": + it.HasTask = data + case "hasTaskWith": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("tactic")) - data, err := ec.unmarshalOTomeTactic2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚋtomeᚐTactic(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasTaskWith")) + data, err := ec.unmarshalOTaskWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTaskWhereInputᚄ(ctx, v) if err != nil { return it, err } - it.Tactic = data - case "paramDefs": - var err error + it.HasTaskWith = data + } + } + + return it, nil +} + +func (ec *executionContext) unmarshalInputHostOrder(ctx context.Context, obj interface{}) (ent.HostOrder, error) { + var it ent.HostOrder + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + + if _, present := asMap["direction"]; !present { + asMap["direction"] = "ASC" + } - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("paramDefs")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.ParamDefs = data - case "eldritch": + fieldsInOrder := [...]string{"direction", "field"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "direction": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("eldritch")) - data, err := ec.unmarshalNString2string(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("direction")) + data, err := ec.unmarshalNOrderDirection2entgoᚗioᚋcontribᚋentgqlᚐOrderDirection(ctx, v) if err != nil { return it, err } - it.Eldritch = data - case "fileIDs": + it.Direction = data + case "field": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("fileIDs")) - data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field")) + data, err := ec.unmarshalNHostOrderField2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostOrderField(ctx, v) if err != nil { return it, err } - it.FileIDs = data + it.Field = data } } return it, nil } -func (ec *executionContext) unmarshalInputFileOrder(ctx context.Context, obj interface{}) (ent.FileOrder, error) { - var it ent.FileOrder +func (ec *executionContext) unmarshalInputHostProcessOrder(ctx context.Context, obj interface{}) (ent.HostProcessOrder, error) { + var it ent.HostProcessOrder asMap := map[string]interface{}{} for k, v := range obj.(map[string]interface{}) { asMap[k] = v @@ -6854,7 +9552,7 @@ func (ec *executionContext) unmarshalInputFileOrder(ctx context.Context, obj int var err error ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field")) - data, err := ec.unmarshalNFileOrderField2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐFileOrderField(ctx, v) + data, err := ec.unmarshalNHostProcessOrderField2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostProcessOrderField(ctx, v) if err != nil { return it, err } @@ -6865,14 +9563,14 @@ func (ec *executionContext) unmarshalInputFileOrder(ctx context.Context, obj int return it, nil } -func (ec *executionContext) unmarshalInputFileWhereInput(ctx context.Context, obj interface{}) (ent.FileWhereInput, error) { - var it ent.FileWhereInput +func (ec *executionContext) unmarshalInputHostProcessWhereInput(ctx context.Context, obj interface{}) (ent.HostProcessWhereInput, error) { + var it ent.HostProcessWhereInput asMap := map[string]interface{}{} for k, v := range obj.(map[string]interface{}) { asMap[k] = v } - fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "createdAt", "createdAtNEQ", "createdAtIn", "createdAtNotIn", "createdAtGT", "createdAtGTE", "createdAtLT", "createdAtLTE", "lastModifiedAt", "lastModifiedAtNEQ", "lastModifiedAtIn", "lastModifiedAtNotIn", "lastModifiedAtGT", "lastModifiedAtGTE", "lastModifiedAtLT", "lastModifiedAtLTE", "name", "nameNEQ", "nameIn", "nameNotIn", "nameGT", "nameGTE", "nameLT", "nameLTE", "nameContains", "nameHasPrefix", "nameHasSuffix", "nameEqualFold", "nameContainsFold", "size", "sizeNEQ", "sizeIn", "sizeNotIn", "sizeGT", "sizeGTE", "sizeLT", "sizeLTE", "hash", "hashNEQ", "hashIn", "hashNotIn", "hashGT", "hashGTE", "hashLT", "hashLTE", "hashContains", "hashHasPrefix", "hashHasSuffix", "hashEqualFold", "hashContainsFold", "hasTomes", "hasTomesWith"} + fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "createdAt", "createdAtNEQ", "createdAtIn", "createdAtNotIn", "createdAtGT", "createdAtGTE", "createdAtLT", "createdAtLTE", "lastModifiedAt", "lastModifiedAtNEQ", "lastModifiedAtIn", "lastModifiedAtNotIn", "lastModifiedAtGT", "lastModifiedAtGTE", "lastModifiedAtLT", "lastModifiedAtLTE", "pid", "pidNEQ", "pidIn", "pidNotIn", "pidGT", "pidGTE", "pidLT", "pidLTE", "ppid", "ppidNEQ", "ppidIn", "ppidNotIn", "ppidGT", "ppidGTE", "ppidLT", "ppidLTE", "name", "nameNEQ", "nameIn", "nameNotIn", "nameGT", "nameGTE", "nameLT", "nameLTE", "nameContains", "nameHasPrefix", "nameHasSuffix", "nameEqualFold", "nameContainsFold", "principal", "principalNEQ", "principalIn", "principalNotIn", "principalGT", "principalGTE", "principalLT", "principalLTE", "principalContains", "principalHasPrefix", "principalHasSuffix", "principalEqualFold", "principalContainsFold", "path", "pathNEQ", "pathIn", "pathNotIn", "pathGT", "pathGTE", "pathLT", "pathLTE", "pathContains", "pathHasPrefix", "pathHasSuffix", "pathIsNil", "pathNotNil", "pathEqualFold", "pathContainsFold", "cmd", "cmdNEQ", "cmdIn", "cmdNotIn", "cmdGT", "cmdGTE", "cmdLT", "cmdLTE", "cmdContains", "cmdHasPrefix", "cmdHasSuffix", "cmdIsNil", "cmdNotNil", "cmdEqualFold", "cmdContainsFold", "env", "envNEQ", "envIn", "envNotIn", "envGT", "envGTE", "envLT", "envLTE", "envContains", "envHasPrefix", "envHasSuffix", "envIsNil", "envNotNil", "envEqualFold", "envContainsFold", "cwd", "cwdNEQ", "cwdIn", "cwdNotIn", "cwdGT", "cwdGTE", "cwdLT", "cwdLTE", "cwdContains", "cwdHasPrefix", "cwdHasSuffix", "cwdIsNil", "cwdNotNil", "cwdEqualFold", "cwdContainsFold", "status", "statusNEQ", "statusIn", "statusNotIn", "hasHost", "hasHostWith", "hasTask", "hasTaskWith"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { @@ -6883,7 +9581,7 @@ func (ec *executionContext) unmarshalInputFileWhereInput(ctx context.Context, ob var err error ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("not")) - data, err := ec.unmarshalOFileWhereInput2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐFileWhereInput(ctx, v) + data, err := ec.unmarshalOHostProcessWhereInput2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostProcessWhereInput(ctx, v) if err != nil { return it, err } @@ -6892,7 +9590,7 @@ func (ec *executionContext) unmarshalInputFileWhereInput(ctx context.Context, ob var err error ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("and")) - data, err := ec.unmarshalOFileWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐFileWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOHostProcessWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostProcessWhereInputᚄ(ctx, v) if err != nil { return it, err } @@ -6901,7 +9599,7 @@ func (ec *executionContext) unmarshalInputFileWhereInput(ctx context.Context, ob var err error ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("or")) - data, err := ec.unmarshalOFileWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐFileWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOHostProcessWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostProcessWhereInputᚄ(ctx, v) if err != nil { return it, err } @@ -6999,1381 +9697,1165 @@ func (ec *executionContext) unmarshalInputFileWhereInput(ctx context.Context, ob case "createdAtIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtIn")) - data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) - if err != nil { - return it, err - } - it.CreatedAtIn = data - case "createdAtNotIn": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtNotIn")) - data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) - if err != nil { - return it, err - } - it.CreatedAtNotIn = data - case "createdAtGT": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtGT")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) - if err != nil { - return it, err - } - it.CreatedAtGT = data - case "createdAtGTE": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtGTE")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) - if err != nil { - return it, err - } - it.CreatedAtGTE = data - case "createdAtLT": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtLT")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) - if err != nil { - return it, err - } - it.CreatedAtLT = data - case "createdAtLTE": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtLTE")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) - if err != nil { - return it, err - } - it.CreatedAtLTE = data - case "lastModifiedAt": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAt")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) - if err != nil { - return it, err - } - it.LastModifiedAt = data - case "lastModifiedAtNEQ": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtNEQ")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) - if err != nil { - return it, err - } - it.LastModifiedAtNEQ = data - case "lastModifiedAtIn": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtIn")) - data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) - if err != nil { - return it, err - } - it.LastModifiedAtIn = data - case "lastModifiedAtNotIn": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtNotIn")) - data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) - if err != nil { - return it, err - } - it.LastModifiedAtNotIn = data - case "lastModifiedAtGT": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtGT")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) - if err != nil { - return it, err - } - it.LastModifiedAtGT = data - case "lastModifiedAtGTE": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtGTE")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) - if err != nil { - return it, err - } - it.LastModifiedAtGTE = data - case "lastModifiedAtLT": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtLT")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) - if err != nil { - return it, err - } - it.LastModifiedAtLT = data - case "lastModifiedAtLTE": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtLTE")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) - if err != nil { - return it, err - } - it.LastModifiedAtLTE = data - case "name": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.Name = data - case "nameNEQ": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameNEQ")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.NameNEQ = data - case "nameIn": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameIn")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) - if err != nil { - return it, err - } - it.NameIn = data - case "nameNotIn": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameNotIn")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) - if err != nil { - return it, err - } - it.NameNotIn = data - case "nameGT": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameGT")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.NameGT = data - case "nameGTE": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameGTE")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.NameGTE = data - case "nameLT": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameLT")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.NameLT = data - case "nameLTE": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameLTE")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.NameLTE = data - case "nameContains": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameContains")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.NameContains = data - case "nameHasPrefix": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameHasPrefix")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.NameHasPrefix = data - case "nameHasSuffix": - var err error - - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameHasSuffix")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtIn")) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) if err != nil { return it, err } - it.NameHasSuffix = data - case "nameEqualFold": + it.CreatedAtIn = data + case "createdAtNotIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameEqualFold")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtNotIn")) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) if err != nil { return it, err } - it.NameEqualFold = data - case "nameContainsFold": + it.CreatedAtNotIn = data + case "createdAtGT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameContainsFold")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtGT")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.NameContainsFold = data - case "size": + it.CreatedAtGT = data + case "createdAtGTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("size")) - data, err := ec.unmarshalOInt2ᚖint(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtGTE")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.Size = data - case "sizeNEQ": + it.CreatedAtGTE = data + case "createdAtLT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeNEQ")) - data, err := ec.unmarshalOInt2ᚖint(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtLT")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.SizeNEQ = data - case "sizeIn": + it.CreatedAtLT = data + case "createdAtLTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeIn")) - data, err := ec.unmarshalOInt2ᚕintᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtLTE")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.SizeIn = data - case "sizeNotIn": + it.CreatedAtLTE = data + case "lastModifiedAt": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeNotIn")) - data, err := ec.unmarshalOInt2ᚕintᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAt")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.SizeNotIn = data - case "sizeGT": + it.LastModifiedAt = data + case "lastModifiedAtNEQ": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeGT")) - data, err := ec.unmarshalOInt2ᚖint(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtNEQ")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.SizeGT = data - case "sizeGTE": + it.LastModifiedAtNEQ = data + case "lastModifiedAtIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeGTE")) - data, err := ec.unmarshalOInt2ᚖint(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtIn")) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) if err != nil { return it, err } - it.SizeGTE = data - case "sizeLT": + it.LastModifiedAtIn = data + case "lastModifiedAtNotIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeLT")) - data, err := ec.unmarshalOInt2ᚖint(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtNotIn")) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) if err != nil { return it, err } - it.SizeLT = data - case "sizeLTE": + it.LastModifiedAtNotIn = data + case "lastModifiedAtGT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sizeLTE")) - data, err := ec.unmarshalOInt2ᚖint(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtGT")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.SizeLTE = data - case "hash": + it.LastModifiedAtGT = data + case "lastModifiedAtGTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hash")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtGTE")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.Hash = data - case "hashNEQ": + it.LastModifiedAtGTE = data + case "lastModifiedAtLT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashNEQ")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtLT")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.HashNEQ = data - case "hashIn": + it.LastModifiedAtLT = data + case "lastModifiedAtLTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashIn")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtLTE")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.HashIn = data - case "hashNotIn": + it.LastModifiedAtLTE = data + case "pid": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashNotIn")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pid")) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) if err != nil { return it, err } - it.HashNotIn = data - case "hashGT": + if err = ec.resolvers.HostProcessWhereInput().Pid(ctx, &it, data); err != nil { + return it, err + } + case "pidNEQ": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashGT")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pidNEQ")) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) if err != nil { return it, err } - it.HashGT = data - case "hashGTE": + if err = ec.resolvers.HostProcessWhereInput().PidNeq(ctx, &it, data); err != nil { + return it, err + } + case "pidIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashGTE")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pidIn")) + data, err := ec.unmarshalOInt2ᚕintᚄ(ctx, v) if err != nil { return it, err } - it.HashGTE = data - case "hashLT": + if err = ec.resolvers.HostProcessWhereInput().PidIn(ctx, &it, data); err != nil { + return it, err + } + case "pidNotIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashLT")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pidNotIn")) + data, err := ec.unmarshalOInt2ᚕintᚄ(ctx, v) if err != nil { return it, err } - it.HashLT = data - case "hashLTE": + if err = ec.resolvers.HostProcessWhereInput().PidNotIn(ctx, &it, data); err != nil { + return it, err + } + case "pidGT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashLTE")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pidGT")) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) if err != nil { return it, err } - it.HashLTE = data - case "hashContains": + if err = ec.resolvers.HostProcessWhereInput().PidGt(ctx, &it, data); err != nil { + return it, err + } + case "pidGTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashContains")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pidGTE")) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) if err != nil { return it, err } - it.HashContains = data - case "hashHasPrefix": + if err = ec.resolvers.HostProcessWhereInput().PidGte(ctx, &it, data); err != nil { + return it, err + } + case "pidLT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashHasPrefix")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pidLT")) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) if err != nil { return it, err } - it.HashHasPrefix = data - case "hashHasSuffix": + if err = ec.resolvers.HostProcessWhereInput().PidLt(ctx, &it, data); err != nil { + return it, err + } + case "pidLTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashHasSuffix")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pidLTE")) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) if err != nil { return it, err } - it.HashHasSuffix = data - case "hashEqualFold": + if err = ec.resolvers.HostProcessWhereInput().PidLte(ctx, &it, data); err != nil { + return it, err + } + case "ppid": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashEqualFold")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ppid")) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) if err != nil { return it, err } - it.HashEqualFold = data - case "hashContainsFold": + if err = ec.resolvers.HostProcessWhereInput().Ppid(ctx, &it, data); err != nil { + return it, err + } + case "ppidNEQ": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashContainsFold")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ppidNEQ")) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) if err != nil { return it, err } - it.HashContainsFold = data - case "hasTomes": + if err = ec.resolvers.HostProcessWhereInput().PpidNeq(ctx, &it, data); err != nil { + return it, err + } + case "ppidIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasTomes")) - data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ppidIn")) + data, err := ec.unmarshalOInt2ᚕintᚄ(ctx, v) if err != nil { return it, err } - it.HasTomes = data - case "hasTomesWith": + if err = ec.resolvers.HostProcessWhereInput().PpidIn(ctx, &it, data); err != nil { + return it, err + } + case "ppidNotIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasTomesWith")) - data, err := ec.unmarshalOTomeWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTomeWhereInputᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ppidNotIn")) + data, err := ec.unmarshalOInt2ᚕintᚄ(ctx, v) if err != nil { return it, err } - it.HasTomesWith = data - } - } - - return it, nil -} - -func (ec *executionContext) unmarshalInputHostOrder(ctx context.Context, obj interface{}) (ent.HostOrder, error) { - var it ent.HostOrder - asMap := map[string]interface{}{} - for k, v := range obj.(map[string]interface{}) { - asMap[k] = v - } - - if _, present := asMap["direction"]; !present { - asMap["direction"] = "ASC" - } - - fieldsInOrder := [...]string{"direction", "field"} - for _, k := range fieldsInOrder { - v, ok := asMap[k] - if !ok { - continue - } - switch k { - case "direction": + if err = ec.resolvers.HostProcessWhereInput().PpidNotIn(ctx, &it, data); err != nil { + return it, err + } + case "ppidGT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("direction")) - data, err := ec.unmarshalNOrderDirection2entgoᚗioᚋcontribᚋentgqlᚐOrderDirection(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ppidGT")) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) if err != nil { return it, err } - it.Direction = data - case "field": + if err = ec.resolvers.HostProcessWhereInput().PpidGt(ctx, &it, data); err != nil { + return it, err + } + case "ppidGTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field")) - data, err := ec.unmarshalNHostOrderField2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostOrderField(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ppidGTE")) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) if err != nil { return it, err } - it.Field = data - } - } - - return it, nil -} - -func (ec *executionContext) unmarshalInputHostWhereInput(ctx context.Context, obj interface{}) (ent.HostWhereInput, error) { - var it ent.HostWhereInput - asMap := map[string]interface{}{} - for k, v := range obj.(map[string]interface{}) { - asMap[k] = v - } + if err = ec.resolvers.HostProcessWhereInput().PpidGte(ctx, &it, data); err != nil { + return it, err + } + case "ppidLT": + var err error - fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "createdAt", "createdAtNEQ", "createdAtIn", "createdAtNotIn", "createdAtGT", "createdAtGTE", "createdAtLT", "createdAtLTE", "lastModifiedAt", "lastModifiedAtNEQ", "lastModifiedAtIn", "lastModifiedAtNotIn", "lastModifiedAtGT", "lastModifiedAtGTE", "lastModifiedAtLT", "lastModifiedAtLTE", "identifier", "identifierNEQ", "identifierIn", "identifierNotIn", "identifierGT", "identifierGTE", "identifierLT", "identifierLTE", "identifierContains", "identifierHasPrefix", "identifierHasSuffix", "identifierEqualFold", "identifierContainsFold", "name", "nameNEQ", "nameIn", "nameNotIn", "nameGT", "nameGTE", "nameLT", "nameLTE", "nameContains", "nameHasPrefix", "nameHasSuffix", "nameIsNil", "nameNotNil", "nameEqualFold", "nameContainsFold", "primaryIP", "primaryIPNEQ", "primaryIPIn", "primaryIPNotIn", "primaryIPGT", "primaryIPGTE", "primaryIPLT", "primaryIPLTE", "primaryIPContains", "primaryIPHasPrefix", "primaryIPHasSuffix", "primaryIPIsNil", "primaryIPNotNil", "primaryIPEqualFold", "primaryIPContainsFold", "platform", "platformNEQ", "platformIn", "platformNotIn", "lastSeenAt", "lastSeenAtNEQ", "lastSeenAtIn", "lastSeenAtNotIn", "lastSeenAtGT", "lastSeenAtGTE", "lastSeenAtLT", "lastSeenAtLTE", "lastSeenAtIsNil", "lastSeenAtNotNil", "hasTags", "hasTagsWith", "hasBeacons", "hasBeaconsWith", "hasProcesses", "hasProcessesWith"} - for _, k := range fieldsInOrder { - v, ok := asMap[k] - if !ok { - continue - } - switch k { - case "not": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ppidLT")) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) + if err != nil { + return it, err + } + if err = ec.resolvers.HostProcessWhereInput().PpidLt(ctx, &it, data); err != nil { + return it, err + } + case "ppidLTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("not")) - data, err := ec.unmarshalOHostWhereInput2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostWhereInput(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ppidLTE")) + data, err := ec.unmarshalOInt2ᚖint(ctx, v) if err != nil { return it, err } - it.Not = data - case "and": + if err = ec.resolvers.HostProcessWhereInput().PpidLte(ctx, &it, data); err != nil { + return it, err + } + case "name": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("and")) - data, err := ec.unmarshalOHostWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostWhereInputᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.And = data - case "or": + it.Name = data + case "nameNEQ": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("or")) - data, err := ec.unmarshalOHostWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostWhereInputᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameNEQ")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.Or = data - case "id": + it.NameNEQ = data + case "nameIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - it.ID = data - case "idNEQ": + it.NameIn = data + case "nameNotIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNEQ")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameNotIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - it.IDNEQ = data - case "idIn": + it.NameNotIn = data + case "nameGT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idIn")) - data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameGT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.IDIn = data - case "idNotIn": + it.NameGT = data + case "nameGTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idNotIn")) - data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameGTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.IDNotIn = data - case "idGT": + it.NameGTE = data + case "nameLT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGT")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameLT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.IDGT = data - case "idGTE": + it.NameLT = data + case "nameLTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idGTE")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameLTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.IDGTE = data - case "idLT": + it.NameLTE = data + case "nameContains": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLT")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameContains")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.IDLT = data - case "idLTE": + it.NameContains = data + case "nameHasPrefix": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("idLTE")) - data, err := ec.unmarshalOID2ᚖint(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameHasPrefix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.IDLTE = data - case "createdAt": + it.NameHasPrefix = data + case "nameHasSuffix": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAt")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameHasSuffix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.CreatedAt = data - case "createdAtNEQ": + it.NameHasSuffix = data + case "nameEqualFold": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtNEQ")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameEqualFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.CreatedAtNEQ = data - case "createdAtIn": + it.NameEqualFold = data + case "nameContainsFold": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtIn")) - data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameContainsFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.CreatedAtIn = data - case "createdAtNotIn": + it.NameContainsFold = data + case "principal": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtNotIn")) - data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principal")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.CreatedAtNotIn = data - case "createdAtGT": + it.Principal = data + case "principalNEQ": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtGT")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalNEQ")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.CreatedAtGT = data - case "createdAtGTE": + it.PrincipalNEQ = data + case "principalIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtGTE")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - it.CreatedAtGTE = data - case "createdAtLT": + it.PrincipalIn = data + case "principalNotIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtLT")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalNotIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - it.CreatedAtLT = data - case "createdAtLTE": + it.PrincipalNotIn = data + case "principalGT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("createdAtLTE")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalGT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.CreatedAtLTE = data - case "lastModifiedAt": + it.PrincipalGT = data + case "principalGTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAt")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalGTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.LastModifiedAt = data - case "lastModifiedAtNEQ": + it.PrincipalGTE = data + case "principalLT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtNEQ")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalLT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.LastModifiedAtNEQ = data - case "lastModifiedAtIn": + it.PrincipalLT = data + case "principalLTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtIn")) - data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalLTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.LastModifiedAtIn = data - case "lastModifiedAtNotIn": + it.PrincipalLTE = data + case "principalContains": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtNotIn")) - data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalContains")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.LastModifiedAtNotIn = data - case "lastModifiedAtGT": + it.PrincipalContains = data + case "principalHasPrefix": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtGT")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalHasPrefix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.LastModifiedAtGT = data - case "lastModifiedAtGTE": + it.PrincipalHasPrefix = data + case "principalHasSuffix": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtGTE")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalHasSuffix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.LastModifiedAtGTE = data - case "lastModifiedAtLT": + it.PrincipalHasSuffix = data + case "principalEqualFold": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtLT")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalEqualFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.LastModifiedAtLT = data - case "lastModifiedAtLTE": + it.PrincipalEqualFold = data + case "principalContainsFold": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastModifiedAtLTE")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalContainsFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.LastModifiedAtLTE = data - case "identifier": + it.PrincipalContainsFold = data + case "path": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifier")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("path")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.Identifier = data - case "identifierNEQ": + it.Path = data + case "pathNEQ": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierNEQ")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pathNEQ")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.IdentifierNEQ = data - case "identifierIn": + it.PathNEQ = data + case "pathIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierIn")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pathIn")) data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - it.IdentifierIn = data - case "identifierNotIn": + it.PathIn = data + case "pathNotIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierNotIn")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pathNotIn")) data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - it.IdentifierNotIn = data - case "identifierGT": + it.PathNotIn = data + case "pathGT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierGT")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pathGT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.PathGT = data + case "pathGTE": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pathGTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.PathGTE = data + case "pathLT": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pathLT")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.IdentifierGT = data - case "identifierGTE": + it.PathLT = data + case "pathLTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierGTE")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pathLTE")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.IdentifierGTE = data - case "identifierLT": + it.PathLTE = data + case "pathContains": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierLT")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pathContains")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.IdentifierLT = data - case "identifierLTE": + it.PathContains = data + case "pathHasPrefix": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierLTE")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pathHasPrefix")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.IdentifierLTE = data - case "identifierContains": + it.PathHasPrefix = data + case "pathHasSuffix": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierContains")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pathHasSuffix")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.IdentifierContains = data - case "identifierHasPrefix": + it.PathHasSuffix = data + case "pathIsNil": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierHasPrefix")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pathIsNil")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } - it.IdentifierHasPrefix = data - case "identifierHasSuffix": + it.PathIsNil = data + case "pathNotNil": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierHasSuffix")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pathNotNil")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } - it.IdentifierHasSuffix = data - case "identifierEqualFold": + it.PathNotNil = data + case "pathEqualFold": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierEqualFold")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pathEqualFold")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.IdentifierEqualFold = data - case "identifierContainsFold": + it.PathEqualFold = data + case "pathContainsFold": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierContainsFold")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pathContainsFold")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.IdentifierContainsFold = data - case "name": + it.PathContainsFold = data + case "cmd": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("cmd")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.Name = data - case "nameNEQ": + it.Cmd = data + case "cmdNEQ": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameNEQ")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("cmdNEQ")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.NameNEQ = data - case "nameIn": + it.CmdNEQ = data + case "cmdIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameIn")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("cmdIn")) data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - it.NameIn = data - case "nameNotIn": + it.CmdIn = data + case "cmdNotIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameNotIn")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("cmdNotIn")) data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - it.NameNotIn = data - case "nameGT": + it.CmdNotIn = data + case "cmdGT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameGT")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("cmdGT")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.NameGT = data - case "nameGTE": + it.CmdGT = data + case "cmdGTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameGTE")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("cmdGTE")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.NameGTE = data - case "nameLT": + it.CmdGTE = data + case "cmdLT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameLT")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("cmdLT")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.NameLT = data - case "nameLTE": + it.CmdLT = data + case "cmdLTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameLTE")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("cmdLTE")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.NameLTE = data - case "nameContains": + it.CmdLTE = data + case "cmdContains": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameContains")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("cmdContains")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.NameContains = data - case "nameHasPrefix": + it.CmdContains = data + case "cmdHasPrefix": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameHasPrefix")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("cmdHasPrefix")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.NameHasPrefix = data - case "nameHasSuffix": + it.CmdHasPrefix = data + case "cmdHasSuffix": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameHasSuffix")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("cmdHasSuffix")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.NameHasSuffix = data - case "nameIsNil": + it.CmdHasSuffix = data + case "cmdIsNil": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameIsNil")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("cmdIsNil")) data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } - it.NameIsNil = data - case "nameNotNil": + it.CmdIsNil = data + case "cmdNotNil": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameNotNil")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("cmdNotNil")) data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } - it.NameNotNil = data - case "nameEqualFold": + it.CmdNotNil = data + case "cmdEqualFold": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameEqualFold")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("cmdEqualFold")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.NameEqualFold = data - case "nameContainsFold": + it.CmdEqualFold = data + case "cmdContainsFold": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameContainsFold")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("cmdContainsFold")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.NameContainsFold = data - case "primaryIP": + it.CmdContainsFold = data + case "env": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("primaryIP")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("env")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.PrimaryIP = data - case "primaryIPNEQ": + it.Env = data + case "envNEQ": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("primaryIPNEQ")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("envNEQ")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.PrimaryIPNEQ = data - case "primaryIPIn": + it.EnvNEQ = data + case "envIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("primaryIPIn")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("envIn")) data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - it.PrimaryIPIn = data - case "primaryIPNotIn": + it.EnvIn = data + case "envNotIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("primaryIPNotIn")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("envNotIn")) data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - it.PrimaryIPNotIn = data - case "primaryIPGT": + it.EnvNotIn = data + case "envGT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("primaryIPGT")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("envGT")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.PrimaryIPGT = data - case "primaryIPGTE": + it.EnvGT = data + case "envGTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("primaryIPGTE")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("envGTE")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.PrimaryIPGTE = data - case "primaryIPLT": + it.EnvGTE = data + case "envLT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("primaryIPLT")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("envLT")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.PrimaryIPLT = data - case "primaryIPLTE": + it.EnvLT = data + case "envLTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("primaryIPLTE")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("envLTE")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.PrimaryIPLTE = data - case "primaryIPContains": + it.EnvLTE = data + case "envContains": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("primaryIPContains")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("envContains")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.PrimaryIPContains = data - case "primaryIPHasPrefix": + it.EnvContains = data + case "envHasPrefix": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("primaryIPHasPrefix")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("envHasPrefix")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.PrimaryIPHasPrefix = data - case "primaryIPHasSuffix": + it.EnvHasPrefix = data + case "envHasSuffix": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("primaryIPHasSuffix")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("envHasSuffix")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.PrimaryIPHasSuffix = data - case "primaryIPIsNil": + it.EnvHasSuffix = data + case "envIsNil": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("primaryIPIsNil")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("envIsNil")) data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } - it.PrimaryIPIsNil = data - case "primaryIPNotNil": + it.EnvIsNil = data + case "envNotNil": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("primaryIPNotNil")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("envNotNil")) data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } - it.PrimaryIPNotNil = data - case "primaryIPEqualFold": + it.EnvNotNil = data + case "envEqualFold": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("primaryIPEqualFold")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("envEqualFold")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.PrimaryIPEqualFold = data - case "primaryIPContainsFold": + it.EnvEqualFold = data + case "envContainsFold": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("primaryIPContainsFold")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("envContainsFold")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.PrimaryIPContainsFold = data - case "platform": + it.EnvContainsFold = data + case "cwd": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("platform")) - data, err := ec.unmarshalOHostPlatform2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚋhostᚐPlatform(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("cwd")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.Platform = data - case "platformNEQ": + it.Cwd = data + case "cwdNEQ": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("platformNEQ")) - data, err := ec.unmarshalOHostPlatform2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚋhostᚐPlatform(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("cwdNEQ")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.PlatformNEQ = data - case "platformIn": + it.CwdNEQ = data + case "cwdIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("platformIn")) - data, err := ec.unmarshalOHostPlatform2ᚕrealmᚗpubᚋtavernᚋinternalᚋentᚋhostᚐPlatformᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("cwdIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - it.PlatformIn = data - case "platformNotIn": + it.CwdIn = data + case "cwdNotIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("platformNotIn")) - data, err := ec.unmarshalOHostPlatform2ᚕrealmᚗpubᚋtavernᚋinternalᚋentᚋhostᚐPlatformᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("cwdNotIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - it.PlatformNotIn = data - case "lastSeenAt": + it.CwdNotIn = data + case "cwdGT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAt")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("cwdGT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.LastSeenAt = data - case "lastSeenAtNEQ": + it.CwdGT = data + case "cwdGTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtNEQ")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("cwdGTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.LastSeenAtNEQ = data - case "lastSeenAtIn": + it.CwdGTE = data + case "cwdLT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtIn")) - data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("cwdLT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.LastSeenAtIn = data - case "lastSeenAtNotIn": + it.CwdLT = data + case "cwdLTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtNotIn")) - data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("cwdLTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.LastSeenAtNotIn = data - case "lastSeenAtGT": + it.CwdLTE = data + case "cwdContains": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtGT")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("cwdContains")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.LastSeenAtGT = data - case "lastSeenAtGTE": + it.CwdContains = data + case "cwdHasPrefix": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtGTE")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("cwdHasPrefix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.LastSeenAtGTE = data - case "lastSeenAtLT": + it.CwdHasPrefix = data + case "cwdHasSuffix": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtLT")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("cwdHasSuffix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.LastSeenAtLT = data - case "lastSeenAtLTE": + it.CwdHasSuffix = data + case "cwdIsNil": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtLTE")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("cwdIsNil")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } - it.LastSeenAtLTE = data - case "lastSeenAtIsNil": + it.CwdIsNil = data + case "cwdNotNil": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtIsNil")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("cwdNotNil")) data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } - it.LastSeenAtIsNil = data - case "lastSeenAtNotNil": + it.CwdNotNil = data + case "cwdEqualFold": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtNotNil")) - data, err := ec.unmarshalOBoolean2bool(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("cwdEqualFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.LastSeenAtNotNil = data - case "hasTags": + it.CwdEqualFold = data + case "cwdContainsFold": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasTags")) - data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("cwdContainsFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.HasTags = data - case "hasTagsWith": + it.CwdContainsFold = data + case "status": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasTagsWith")) - data, err := ec.unmarshalOTagWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTagWhereInputᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("status")) + data, err := ec.unmarshalOHostProcessStatus2ᚖrealmᚗpubᚋtavernᚋinternalᚋc2ᚋc2pbᚐProcess_Status(ctx, v) if err != nil { return it, err } - it.HasTagsWith = data - case "hasBeacons": + it.Status = data + case "statusNEQ": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasBeacons")) - data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("statusNEQ")) + data, err := ec.unmarshalOHostProcessStatus2ᚖrealmᚗpubᚋtavernᚋinternalᚋc2ᚋc2pbᚐProcess_Status(ctx, v) if err != nil { return it, err } - it.HasBeacons = data - case "hasBeaconsWith": + it.StatusNEQ = data + case "statusIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasBeaconsWith")) - data, err := ec.unmarshalOBeaconWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBeaconWhereInputᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("statusIn")) + data, err := ec.unmarshalOHostProcessStatus2ᚕrealmᚗpubᚋtavernᚋinternalᚋc2ᚋc2pbᚐProcess_Statusᚄ(ctx, v) if err != nil { return it, err } - it.HasBeaconsWith = data - case "hasProcesses": + it.StatusIn = data + case "statusNotIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasProcesses")) - data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("statusNotIn")) + data, err := ec.unmarshalOHostProcessStatus2ᚕrealmᚗpubᚋtavernᚋinternalᚋc2ᚋc2pbᚐProcess_Statusᚄ(ctx, v) if err != nil { return it, err } - it.HasProcesses = data - case "hasProcessesWith": + it.StatusNotIn = data + case "hasHost": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasProcessesWith")) - data, err := ec.unmarshalOProcessWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐProcessWhereInputᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasHost")) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { return it, err } - it.HasProcessesWith = data - } - } - - return it, nil -} - -func (ec *executionContext) unmarshalInputProcessOrder(ctx context.Context, obj interface{}) (ent.ProcessOrder, error) { - var it ent.ProcessOrder - asMap := map[string]interface{}{} - for k, v := range obj.(map[string]interface{}) { - asMap[k] = v - } - - if _, present := asMap["direction"]; !present { - asMap["direction"] = "ASC" - } + it.HasHost = data + case "hasHostWith": + var err error - fieldsInOrder := [...]string{"direction", "field"} - for _, k := range fieldsInOrder { - v, ok := asMap[k] - if !ok { - continue - } - switch k { - case "direction": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasHostWith")) + data, err := ec.unmarshalOHostWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostWhereInputᚄ(ctx, v) + if err != nil { + return it, err + } + it.HasHostWith = data + case "hasTask": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("direction")) - data, err := ec.unmarshalNOrderDirection2entgoᚗioᚋcontribᚋentgqlᚐOrderDirection(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasTask")) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { return it, err } - it.Direction = data - case "field": + it.HasTask = data + case "hasTaskWith": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("field")) - data, err := ec.unmarshalNProcessOrderField2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐProcessOrderField(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasTaskWith")) + data, err := ec.unmarshalOTaskWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTaskWhereInputᚄ(ctx, v) if err != nil { return it, err } - it.Field = data + it.HasTaskWith = data } } return it, nil } -func (ec *executionContext) unmarshalInputProcessWhereInput(ctx context.Context, obj interface{}) (ent.ProcessWhereInput, error) { - var it ent.ProcessWhereInput +func (ec *executionContext) unmarshalInputHostWhereInput(ctx context.Context, obj interface{}) (ent.HostWhereInput, error) { + var it ent.HostWhereInput asMap := map[string]interface{}{} for k, v := range obj.(map[string]interface{}) { asMap[k] = v } - fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "createdAt", "createdAtNEQ", "createdAtIn", "createdAtNotIn", "createdAtGT", "createdAtGTE", "createdAtLT", "createdAtLTE", "lastModifiedAt", "lastModifiedAtNEQ", "lastModifiedAtIn", "lastModifiedAtNotIn", "lastModifiedAtGT", "lastModifiedAtGTE", "lastModifiedAtLT", "lastModifiedAtLTE", "pid", "pidNEQ", "pidIn", "pidNotIn", "pidGT", "pidGTE", "pidLT", "pidLTE", "name", "nameNEQ", "nameIn", "nameNotIn", "nameGT", "nameGTE", "nameLT", "nameLTE", "nameContains", "nameHasPrefix", "nameHasSuffix", "nameEqualFold", "nameContainsFold", "principal", "principalNEQ", "principalIn", "principalNotIn", "principalGT", "principalGTE", "principalLT", "principalLTE", "principalContains", "principalHasPrefix", "principalHasSuffix", "principalEqualFold", "principalContainsFold", "hasHost", "hasHostWith", "hasTask", "hasTaskWith"} + fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "createdAt", "createdAtNEQ", "createdAtIn", "createdAtNotIn", "createdAtGT", "createdAtGTE", "createdAtLT", "createdAtLTE", "lastModifiedAt", "lastModifiedAtNEQ", "lastModifiedAtIn", "lastModifiedAtNotIn", "lastModifiedAtGT", "lastModifiedAtGTE", "lastModifiedAtLT", "lastModifiedAtLTE", "identifier", "identifierNEQ", "identifierIn", "identifierNotIn", "identifierGT", "identifierGTE", "identifierLT", "identifierLTE", "identifierContains", "identifierHasPrefix", "identifierHasSuffix", "identifierEqualFold", "identifierContainsFold", "name", "nameNEQ", "nameIn", "nameNotIn", "nameGT", "nameGTE", "nameLT", "nameLTE", "nameContains", "nameHasPrefix", "nameHasSuffix", "nameIsNil", "nameNotNil", "nameEqualFold", "nameContainsFold", "primaryIP", "primaryIPNEQ", "primaryIPIn", "primaryIPNotIn", "primaryIPGT", "primaryIPGTE", "primaryIPLT", "primaryIPLTE", "primaryIPContains", "primaryIPHasPrefix", "primaryIPHasSuffix", "primaryIPIsNil", "primaryIPNotNil", "primaryIPEqualFold", "primaryIPContainsFold", "platform", "platformNEQ", "platformIn", "platformNotIn", "lastSeenAt", "lastSeenAtNEQ", "lastSeenAtIn", "lastSeenAtNotIn", "lastSeenAtGT", "lastSeenAtGTE", "lastSeenAtLT", "lastSeenAtLTE", "lastSeenAtIsNil", "lastSeenAtNotNil", "hasTags", "hasTagsWith", "hasBeacons", "hasBeaconsWith", "hasFiles", "hasFilesWith", "hasProcesses", "hasProcessesWith"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { @@ -8384,7 +10866,7 @@ func (ec *executionContext) unmarshalInputProcessWhereInput(ctx context.Context, var err error ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("not")) - data, err := ec.unmarshalOProcessWhereInput2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐProcessWhereInput(ctx, v) + data, err := ec.unmarshalOHostWhereInput2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostWhereInput(ctx, v) if err != nil { return it, err } @@ -8393,7 +10875,7 @@ func (ec *executionContext) unmarshalInputProcessWhereInput(ctx context.Context, var err error ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("and")) - data, err := ec.unmarshalOProcessWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐProcessWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOHostWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostWhereInputᚄ(ctx, v) if err != nil { return it, err } @@ -8402,7 +10884,7 @@ func (ec *executionContext) unmarshalInputProcessWhereInput(ctx context.Context, var err error ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("or")) - data, err := ec.unmarshalOProcessWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐProcessWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOHostWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostWhereInputᚄ(ctx, v) if err != nil { return it, err } @@ -8623,364 +11105,591 @@ func (ec *executionContext) unmarshalInputProcessWhereInput(ctx context.Context, return it, err } it.LastModifiedAtLTE = data - case "pid": + case "identifier": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pid")) - data, err := ec.unmarshalOInt2ᚖint(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifier")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.Identifier = data + case "identifierNEQ": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierNEQ")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - if err = ec.resolvers.ProcessWhereInput().Pid(ctx, &it, data); err != nil { + it.IdentifierNEQ = data + case "identifierIn": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + if err != nil { return it, err } - case "pidNEQ": + it.IdentifierIn = data + case "identifierNotIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pidNEQ")) - data, err := ec.unmarshalOInt2ᚖint(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierNotIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.IdentifierNotIn = data + case "identifierGT": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierGT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.IdentifierGT = data + case "identifierGTE": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierGTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.IdentifierGTE = data + case "identifierLT": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierLT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.IdentifierLT = data + case "identifierLTE": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierLTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.IdentifierLTE = data + case "identifierContains": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierContains")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.IdentifierContains = data + case "identifierHasPrefix": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierHasPrefix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.IdentifierHasPrefix = data + case "identifierHasSuffix": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierHasSuffix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.IdentifierHasSuffix = data + case "identifierEqualFold": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierEqualFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.IdentifierEqualFold = data + case "identifierContainsFold": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("identifierContainsFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.IdentifierContainsFold = data + case "name": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.Name = data + case "nameNEQ": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameNEQ")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameNEQ = data + case "nameIn": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.NameIn = data + case "nameNotIn": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameNotIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + if err != nil { + return it, err + } + it.NameNotIn = data + case "nameGT": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameGT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameGT = data + case "nameGTE": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameGTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameGTE = data + case "nameLT": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameLT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameLT = data + case "nameLTE": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameLTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameLTE = data + case "nameContains": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameContains")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameContains = data + case "nameHasPrefix": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameHasPrefix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameHasPrefix = data + case "nameHasSuffix": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameHasSuffix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameHasSuffix = data + case "nameIsNil": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameIsNil")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) + if err != nil { + return it, err + } + it.NameIsNil = data + case "nameNotNil": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameNotNil")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) + if err != nil { + return it, err + } + it.NameNotNil = data + case "nameEqualFold": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameEqualFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameEqualFold = data + case "nameContainsFold": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameContainsFold")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.NameContainsFold = data + case "primaryIP": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("primaryIP")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - if err = ec.resolvers.ProcessWhereInput().PidNeq(ctx, &it, data); err != nil { - return it, err - } - case "pidIn": + it.PrimaryIP = data + case "primaryIPNEQ": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pidIn")) - data, err := ec.unmarshalOInt2ᚕintᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("primaryIPNEQ")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - if err = ec.resolvers.ProcessWhereInput().PidIn(ctx, &it, data); err != nil { - return it, err - } - case "pidNotIn": + it.PrimaryIPNEQ = data + case "primaryIPIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pidNotIn")) - data, err := ec.unmarshalOInt2ᚕintᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("primaryIPIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - if err = ec.resolvers.ProcessWhereInput().PidNotIn(ctx, &it, data); err != nil { - return it, err - } - case "pidGT": + it.PrimaryIPIn = data + case "primaryIPNotIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pidGT")) - data, err := ec.unmarshalOInt2ᚖint(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("primaryIPNotIn")) + data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) if err != nil { return it, err } - if err = ec.resolvers.ProcessWhereInput().PidGt(ctx, &it, data); err != nil { - return it, err - } - case "pidGTE": + it.PrimaryIPNotIn = data + case "primaryIPGT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pidGTE")) - data, err := ec.unmarshalOInt2ᚖint(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("primaryIPGT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - if err = ec.resolvers.ProcessWhereInput().PidGte(ctx, &it, data); err != nil { - return it, err - } - case "pidLT": + it.PrimaryIPGT = data + case "primaryIPGTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pidLT")) - data, err := ec.unmarshalOInt2ᚖint(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("primaryIPGTE")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - if err = ec.resolvers.ProcessWhereInput().PidLt(ctx, &it, data); err != nil { - return it, err - } - case "pidLTE": + it.PrimaryIPGTE = data + case "primaryIPLT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pidLTE")) - data, err := ec.unmarshalOInt2ᚖint(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("primaryIPLT")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - if err = ec.resolvers.ProcessWhereInput().PidLte(ctx, &it, data); err != nil { - return it, err - } - case "name": + it.PrimaryIPLT = data + case "primaryIPLTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("primaryIPLTE")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.Name = data - case "nameNEQ": + it.PrimaryIPLTE = data + case "primaryIPContains": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameNEQ")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("primaryIPContains")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.NameNEQ = data - case "nameIn": + it.PrimaryIPContains = data + case "primaryIPHasPrefix": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameIn")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("primaryIPHasPrefix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.NameIn = data - case "nameNotIn": + it.PrimaryIPHasPrefix = data + case "primaryIPHasSuffix": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameNotIn")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("primaryIPHasSuffix")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.NameNotIn = data - case "nameGT": + it.PrimaryIPHasSuffix = data + case "primaryIPIsNil": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameGT")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("primaryIPIsNil")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } - it.NameGT = data - case "nameGTE": + it.PrimaryIPIsNil = data + case "primaryIPNotNil": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameGTE")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("primaryIPNotNil")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } - it.NameGTE = data - case "nameLT": + it.PrimaryIPNotNil = data + case "primaryIPEqualFold": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameLT")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("primaryIPEqualFold")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.NameLT = data - case "nameLTE": + it.PrimaryIPEqualFold = data + case "primaryIPContainsFold": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameLTE")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("primaryIPContainsFold")) data, err := ec.unmarshalOString2ᚖstring(ctx, v) if err != nil { return it, err } - it.NameLTE = data - case "nameContains": + it.PrimaryIPContainsFold = data + case "platform": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameContains")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("platform")) + data, err := ec.unmarshalOHostPlatform2ᚖrealmᚗpubᚋtavernᚋinternalᚋc2ᚋc2pbᚐHost_Platform(ctx, v) if err != nil { return it, err } - it.NameContains = data - case "nameHasPrefix": + it.Platform = data + case "platformNEQ": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameHasPrefix")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("platformNEQ")) + data, err := ec.unmarshalOHostPlatform2ᚖrealmᚗpubᚋtavernᚋinternalᚋc2ᚋc2pbᚐHost_Platform(ctx, v) if err != nil { return it, err } - it.NameHasPrefix = data - case "nameHasSuffix": + it.PlatformNEQ = data + case "platformIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameHasSuffix")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("platformIn")) + data, err := ec.unmarshalOHostPlatform2ᚕrealmᚗpubᚋtavernᚋinternalᚋc2ᚋc2pbᚐHost_Platformᚄ(ctx, v) if err != nil { return it, err } - it.NameHasSuffix = data - case "nameEqualFold": + it.PlatformIn = data + case "platformNotIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameEqualFold")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("platformNotIn")) + data, err := ec.unmarshalOHostPlatform2ᚕrealmᚗpubᚋtavernᚋinternalᚋc2ᚋc2pbᚐHost_Platformᚄ(ctx, v) if err != nil { return it, err } - it.NameEqualFold = data - case "nameContainsFold": + it.PlatformNotIn = data + case "lastSeenAt": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("nameContainsFold")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAt")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.NameContainsFold = data - case "principal": + it.LastSeenAt = data + case "lastSeenAtNEQ": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principal")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtNEQ")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.Principal = data - case "principalNEQ": + it.LastSeenAtNEQ = data + case "lastSeenAtIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalNEQ")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtIn")) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) if err != nil { return it, err } - it.PrincipalNEQ = data - case "principalIn": + it.LastSeenAtIn = data + case "lastSeenAtNotIn": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalIn")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtNotIn")) + data, err := ec.unmarshalOTime2ᚕtimeᚐTimeᚄ(ctx, v) if err != nil { return it, err } - it.PrincipalIn = data - case "principalNotIn": + it.LastSeenAtNotIn = data + case "lastSeenAtGT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalNotIn")) - data, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtGT")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.PrincipalNotIn = data - case "principalGT": + it.LastSeenAtGT = data + case "lastSeenAtGTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalGT")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtGTE")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.PrincipalGT = data - case "principalGTE": + it.LastSeenAtGTE = data + case "lastSeenAtLT": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalGTE")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtLT")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.PrincipalGTE = data - case "principalLT": + it.LastSeenAtLT = data + case "lastSeenAtLTE": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalLT")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtLTE")) + data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) if err != nil { return it, err } - it.PrincipalLT = data - case "principalLTE": + it.LastSeenAtLTE = data + case "lastSeenAtIsNil": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalLTE")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtIsNil")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } - it.PrincipalLTE = data - case "principalContains": + it.LastSeenAtIsNil = data + case "lastSeenAtNotNil": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalContains")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("lastSeenAtNotNil")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) if err != nil { return it, err } - it.PrincipalContains = data - case "principalHasPrefix": + it.LastSeenAtNotNil = data + case "hasTags": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalHasPrefix")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasTags")) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { return it, err } - it.PrincipalHasPrefix = data - case "principalHasSuffix": + it.HasTags = data + case "hasTagsWith": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalHasSuffix")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasTagsWith")) + data, err := ec.unmarshalOTagWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTagWhereInputᚄ(ctx, v) if err != nil { return it, err } - it.PrincipalHasSuffix = data - case "principalEqualFold": + it.HasTagsWith = data + case "hasBeacons": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalEqualFold")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasBeacons")) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { return it, err } - it.PrincipalEqualFold = data - case "principalContainsFold": + it.HasBeacons = data + case "hasBeaconsWith": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("principalContainsFold")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasBeaconsWith")) + data, err := ec.unmarshalOBeaconWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐBeaconWhereInputᚄ(ctx, v) if err != nil { return it, err - } - it.PrincipalContainsFold = data - case "hasHost": + } + it.HasBeaconsWith = data + case "hasFiles": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasHost")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasFiles")) data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { return it, err } - it.HasHost = data - case "hasHostWith": + it.HasFiles = data + case "hasFilesWith": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasHostWith")) - data, err := ec.unmarshalOHostWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostWhereInputᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasFilesWith")) + data, err := ec.unmarshalOHostFileWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostFileWhereInputᚄ(ctx, v) if err != nil { return it, err } - it.HasHostWith = data - case "hasTask": + it.HasFilesWith = data + case "hasProcesses": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasTask")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasProcesses")) data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) if err != nil { return it, err } - it.HasTask = data - case "hasTaskWith": + it.HasProcesses = data + case "hasProcessesWith": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasTaskWith")) - data, err := ec.unmarshalOTaskWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐTaskWhereInputᚄ(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasProcessesWith")) + data, err := ec.unmarshalOHostProcessWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostProcessWhereInputᚄ(ctx, v) if err != nil { return it, err } - it.HasTaskWith = data + it.HasProcessesWith = data } } @@ -9997,7 +12706,7 @@ func (ec *executionContext) unmarshalInputTaskWhereInput(ctx context.Context, ob asMap[k] = v } - fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "createdAt", "createdAtNEQ", "createdAtIn", "createdAtNotIn", "createdAtGT", "createdAtGTE", "createdAtLT", "createdAtLTE", "lastModifiedAt", "lastModifiedAtNEQ", "lastModifiedAtIn", "lastModifiedAtNotIn", "lastModifiedAtGT", "lastModifiedAtGTE", "lastModifiedAtLT", "lastModifiedAtLTE", "claimedAt", "claimedAtNEQ", "claimedAtIn", "claimedAtNotIn", "claimedAtGT", "claimedAtGTE", "claimedAtLT", "claimedAtLTE", "claimedAtIsNil", "claimedAtNotNil", "execStartedAt", "execStartedAtNEQ", "execStartedAtIn", "execStartedAtNotIn", "execStartedAtGT", "execStartedAtGTE", "execStartedAtLT", "execStartedAtLTE", "execStartedAtIsNil", "execStartedAtNotNil", "execFinishedAt", "execFinishedAtNEQ", "execFinishedAtIn", "execFinishedAtNotIn", "execFinishedAtGT", "execFinishedAtGTE", "execFinishedAtLT", "execFinishedAtLTE", "execFinishedAtIsNil", "execFinishedAtNotNil", "output", "outputNEQ", "outputIn", "outputNotIn", "outputGT", "outputGTE", "outputLT", "outputLTE", "outputContains", "outputHasPrefix", "outputHasSuffix", "outputIsNil", "outputNotNil", "outputEqualFold", "outputContainsFold", "outputSize", "outputSizeNEQ", "outputSizeIn", "outputSizeNotIn", "outputSizeGT", "outputSizeGTE", "outputSizeLT", "outputSizeLTE", "error", "errorNEQ", "errorIn", "errorNotIn", "errorGT", "errorGTE", "errorLT", "errorLTE", "errorContains", "errorHasPrefix", "errorHasSuffix", "errorIsNil", "errorNotNil", "errorEqualFold", "errorContainsFold", "hasQuest", "hasQuestWith", "hasBeacon", "hasBeaconWith", "hasReportedProcesses", "hasReportedProcessesWith"} + fieldsInOrder := [...]string{"not", "and", "or", "id", "idNEQ", "idIn", "idNotIn", "idGT", "idGTE", "idLT", "idLTE", "createdAt", "createdAtNEQ", "createdAtIn", "createdAtNotIn", "createdAtGT", "createdAtGTE", "createdAtLT", "createdAtLTE", "lastModifiedAt", "lastModifiedAtNEQ", "lastModifiedAtIn", "lastModifiedAtNotIn", "lastModifiedAtGT", "lastModifiedAtGTE", "lastModifiedAtLT", "lastModifiedAtLTE", "claimedAt", "claimedAtNEQ", "claimedAtIn", "claimedAtNotIn", "claimedAtGT", "claimedAtGTE", "claimedAtLT", "claimedAtLTE", "claimedAtIsNil", "claimedAtNotNil", "execStartedAt", "execStartedAtNEQ", "execStartedAtIn", "execStartedAtNotIn", "execStartedAtGT", "execStartedAtGTE", "execStartedAtLT", "execStartedAtLTE", "execStartedAtIsNil", "execStartedAtNotNil", "execFinishedAt", "execFinishedAtNEQ", "execFinishedAtIn", "execFinishedAtNotIn", "execFinishedAtGT", "execFinishedAtGTE", "execFinishedAtLT", "execFinishedAtLTE", "execFinishedAtIsNil", "execFinishedAtNotNil", "output", "outputNEQ", "outputIn", "outputNotIn", "outputGT", "outputGTE", "outputLT", "outputLTE", "outputContains", "outputHasPrefix", "outputHasSuffix", "outputIsNil", "outputNotNil", "outputEqualFold", "outputContainsFold", "outputSize", "outputSizeNEQ", "outputSizeIn", "outputSizeNotIn", "outputSizeGT", "outputSizeGTE", "outputSizeLT", "outputSizeLTE", "error", "errorNEQ", "errorIn", "errorNotIn", "errorGT", "errorGTE", "errorLT", "errorLTE", "errorContains", "errorHasPrefix", "errorHasSuffix", "errorIsNil", "errorNotNil", "errorEqualFold", "errorContainsFold", "hasQuest", "hasQuestWith", "hasBeacon", "hasBeaconWith", "hasReportedFiles", "hasReportedFilesWith", "hasReportedProcesses", "hasReportedProcessesWith"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { @@ -10895,6 +13604,24 @@ func (ec *executionContext) unmarshalInputTaskWhereInput(ctx context.Context, ob return it, err } it.HasBeaconWith = data + case "hasReportedFiles": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasReportedFiles")) + data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) + if err != nil { + return it, err + } + it.HasReportedFiles = data + case "hasReportedFilesWith": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasReportedFilesWith")) + data, err := ec.unmarshalOHostFileWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostFileWhereInputᚄ(ctx, v) + if err != nil { + return it, err + } + it.HasReportedFilesWith = data case "hasReportedProcesses": var err error @@ -10908,7 +13635,7 @@ func (ec *executionContext) unmarshalInputTaskWhereInput(ctx context.Context, ob var err error ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasReportedProcessesWith")) - data, err := ec.unmarshalOProcessWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐProcessWhereInputᚄ(ctx, v) + data, err := ec.unmarshalOHostProcessWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostProcessWhereInputᚄ(ctx, v) if err != nil { return it, err } @@ -11980,7 +14707,7 @@ func (ec *executionContext) unmarshalInputUpdateHostInput(ctx context.Context, o asMap[k] = v } - fieldsInOrder := [...]string{"lastModifiedAt", "name", "clearName", "addTagIDs", "removeTagIDs", "clearTags", "addBeaconIDs", "removeBeaconIDs", "clearBeacons", "addProcessIDs", "removeProcessIDs", "clearProcesses"} + fieldsInOrder := [...]string{"lastModifiedAt", "name", "clearName", "addTagIDs", "removeTagIDs", "clearTags", "addBeaconIDs", "removeBeaconIDs", "clearBeacons", "addFileIDs", "removeFileIDs", "clearFiles", "addProcessIDs", "removeProcessIDs", "clearProcesses"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { @@ -12068,6 +14795,33 @@ func (ec *executionContext) unmarshalInputUpdateHostInput(ctx context.Context, o return it, err } it.ClearBeacons = data + case "addFileIDs": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("addFileIDs")) + data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) + if err != nil { + return it, err + } + it.AddFileIDs = data + case "removeFileIDs": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("removeFileIDs")) + data, err := ec.unmarshalOID2ᚕintᚄ(ctx, v) + if err != nil { + return it, err + } + it.RemoveFileIDs = data + case "clearFiles": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("clearFiles")) + data, err := ec.unmarshalOBoolean2bool(ctx, v) + if err != nil { + return it, err + } + it.ClearFiles = data case "addProcessIDs": var err error @@ -12807,11 +15561,16 @@ func (ec *executionContext) _Node(ctx context.Context, sel ast.SelectionSet, obj return graphql.Null } return ec._Host(ctx, sel, obj) - case *ent.Process: + case *ent.HostFile: + if obj == nil { + return graphql.Null + } + return ec._HostFile(ctx, sel, obj) + case *ent.HostProcess: if obj == nil { return graphql.Null } - return ec._Process(ctx, sel, obj) + return ec._HostProcess(ctx, sel, obj) case *ent.Quest: if obj == nil { return graphql.Null @@ -13023,7 +15782,204 @@ func (ec *executionContext) _File(ctx context.Context, sel ast.SelectionSet, obj if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } - case "tomes": + case "tomes": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._File_tomes(ctx, field, obj) + return res + } + + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +var hostImplementors = []string{"Host", "Node"} + +func (ec *executionContext) _Host(ctx context.Context, sel ast.SelectionSet, obj *ent.Host) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, hostImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Host") + case "id": + out.Values[i] = ec._Host_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "createdAt": + out.Values[i] = ec._Host_createdAt(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "lastModifiedAt": + out.Values[i] = ec._Host_lastModifiedAt(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "identifier": + out.Values[i] = ec._Host_identifier(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "name": + out.Values[i] = ec._Host_name(ctx, field, obj) + case "primaryIP": + out.Values[i] = ec._Host_primaryIP(ctx, field, obj) + case "platform": + out.Values[i] = ec._Host_platform(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "lastSeenAt": + out.Values[i] = ec._Host_lastSeenAt(ctx, field, obj) + case "tags": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Host_tags(ctx, field, obj) + return res + } + + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + case "beacons": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Host_beacons(ctx, field, obj) + return res + } + + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + case "files": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Host_files(ctx, field, obj) + return res + } + + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + case "processes": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { @@ -13032,7 +15988,7 @@ func (ec *executionContext) _File(ctx context.Context, sel ast.SelectionSet, obj ec.Error(ctx, ec.Recover(ctx, r)) } }() - res = ec._File_tomes(ctx, field, obj) + res = ec._Host_processes(ctx, field, obj) return res } @@ -13079,49 +16035,51 @@ func (ec *executionContext) _File(ctx context.Context, sel ast.SelectionSet, obj return out } -var hostImplementors = []string{"Host", "Node"} +var hostFileImplementors = []string{"HostFile", "Node"} -func (ec *executionContext) _Host(ctx context.Context, sel ast.SelectionSet, obj *ent.Host) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, hostImplementors) +func (ec *executionContext) _HostFile(ctx context.Context, sel ast.SelectionSet, obj *ent.HostFile) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, hostFileImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": - out.Values[i] = graphql.MarshalString("Host") + out.Values[i] = graphql.MarshalString("HostFile") case "id": - out.Values[i] = ec._Host_id(ctx, field, obj) + out.Values[i] = ec._HostFile_id(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } case "createdAt": - out.Values[i] = ec._Host_createdAt(ctx, field, obj) + out.Values[i] = ec._HostFile_createdAt(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } case "lastModifiedAt": - out.Values[i] = ec._Host_lastModifiedAt(ctx, field, obj) + out.Values[i] = ec._HostFile_lastModifiedAt(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } - case "identifier": - out.Values[i] = ec._Host_identifier(ctx, field, obj) + case "path": + out.Values[i] = ec._HostFile_path(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } - case "name": - out.Values[i] = ec._Host_name(ctx, field, obj) - case "primaryIP": - out.Values[i] = ec._Host_primaryIP(ctx, field, obj) - case "platform": - out.Values[i] = ec._Host_platform(ctx, field, obj) + case "owner": + out.Values[i] = ec._HostFile_owner(ctx, field, obj) + case "group": + out.Values[i] = ec._HostFile_group(ctx, field, obj) + case "permissions": + out.Values[i] = ec._HostFile_permissions(ctx, field, obj) + case "size": + out.Values[i] = ec._HostFile_size(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } - case "lastSeenAt": - out.Values[i] = ec._Host_lastSeenAt(ctx, field, obj) - case "tags": + case "hash": + out.Values[i] = ec._HostFile_hash(ctx, field, obj) + case "host": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { @@ -13130,40 +16088,10 @@ func (ec *executionContext) _Host(ctx context.Context, sel ast.SelectionSet, obj ec.Error(ctx, ec.Recover(ctx, r)) } }() - res = ec._Host_tags(ctx, field, obj) - return res - } - - if field.Deferrable != nil { - dfs, ok := deferred[field.Deferrable.Label] - di := 0 - if ok { - dfs.AddField(field) - di = len(dfs.Values) - 1 - } else { - dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) - deferred[field.Deferrable.Label] = dfs + res = ec._HostFile_host(ctx, field, obj) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) } - dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { - return innerFunc(ctx, dfs) - }) - - // don't run the out.Concurrently() call below - out.Values[i] = graphql.Null - continue - } - - out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) - case "beacons": - field := field - - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._Host_beacons(ctx, field, obj) return res } @@ -13187,7 +16115,7 @@ func (ec *executionContext) _Host(ctx context.Context, sel ast.SelectionSet, obj } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) - case "processes": + case "task": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { @@ -13196,7 +16124,10 @@ func (ec *executionContext) _Host(ctx context.Context, sel ast.SelectionSet, obj ec.Error(ctx, ec.Recover(ctx, r)) } }() - res = ec._Host_processes(ctx, field, obj) + res = ec._HostFile_task(ctx, field, obj) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } return res } @@ -13243,77 +16174,29 @@ func (ec *executionContext) _Host(ctx context.Context, sel ast.SelectionSet, obj return out } -var pageInfoImplementors = []string{"PageInfo"} - -func (ec *executionContext) _PageInfo(ctx context.Context, sel ast.SelectionSet, obj *entgql.PageInfo[int]) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, pageInfoImplementors) - - out := graphql.NewFieldSet(fields) - deferred := make(map[string]*graphql.FieldSet) - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("PageInfo") - case "hasNextPage": - out.Values[i] = ec._PageInfo_hasNextPage(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "hasPreviousPage": - out.Values[i] = ec._PageInfo_hasPreviousPage(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "startCursor": - out.Values[i] = ec._PageInfo_startCursor(ctx, field, obj) - case "endCursor": - out.Values[i] = ec._PageInfo_endCursor(ctx, field, obj) - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch(ctx) - if out.Invalids > 0 { - return graphql.Null - } - - atomic.AddInt32(&ec.deferred, int32(len(deferred))) - - for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ - Label: label, - Path: graphql.GetPath(ctx), - FieldSet: dfs, - Context: ctx, - }) - } - - return out -} - -var processImplementors = []string{"Process", "Node"} +var hostProcessImplementors = []string{"HostProcess", "Node"} -func (ec *executionContext) _Process(ctx context.Context, sel ast.SelectionSet, obj *ent.Process) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, processImplementors) +func (ec *executionContext) _HostProcess(ctx context.Context, sel ast.SelectionSet, obj *ent.HostProcess) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, hostProcessImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": - out.Values[i] = graphql.MarshalString("Process") + out.Values[i] = graphql.MarshalString("HostProcess") case "id": - out.Values[i] = ec._Process_id(ctx, field, obj) + out.Values[i] = ec._HostProcess_id(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } case "createdAt": - out.Values[i] = ec._Process_createdAt(ctx, field, obj) + out.Values[i] = ec._HostProcess_createdAt(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } case "lastModifiedAt": - out.Values[i] = ec._Process_lastModifiedAt(ctx, field, obj) + out.Values[i] = ec._HostProcess_lastModifiedAt(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } @@ -13326,7 +16209,43 @@ func (ec *executionContext) _Process(ctx context.Context, sel ast.SelectionSet, ec.Error(ctx, ec.Recover(ctx, r)) } }() - res = ec._Process_pid(ctx, field, obj) + res = ec._HostProcess_pid(ctx, field, obj) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res + } + + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + case "ppid": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._HostProcess_ppid(ctx, field, obj) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } @@ -13354,12 +16273,25 @@ func (ec *executionContext) _Process(ctx context.Context, sel ast.SelectionSet, out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) case "name": - out.Values[i] = ec._Process_name(ctx, field, obj) + out.Values[i] = ec._HostProcess_name(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } case "principal": - out.Values[i] = ec._Process_principal(ctx, field, obj) + out.Values[i] = ec._HostProcess_principal(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "path": + out.Values[i] = ec._HostProcess_path(ctx, field, obj) + case "cmd": + out.Values[i] = ec._HostProcess_cmd(ctx, field, obj) + case "env": + out.Values[i] = ec._HostProcess_env(ctx, field, obj) + case "cwd": + out.Values[i] = ec._HostProcess_cwd(ctx, field, obj) + case "status": + out.Values[i] = ec._HostProcess_status(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } @@ -13372,7 +16304,7 @@ func (ec *executionContext) _Process(ctx context.Context, sel ast.SelectionSet, ec.Error(ctx, ec.Recover(ctx, r)) } }() - res = ec._Process_host(ctx, field, obj) + res = ec._HostProcess_host(ctx, field, obj) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } @@ -13408,7 +16340,7 @@ func (ec *executionContext) _Process(ctx context.Context, sel ast.SelectionSet, ec.Error(ctx, ec.Recover(ctx, r)) } }() - res = ec._Process_task(ctx, field, obj) + res = ec._HostProcess_task(ctx, field, obj) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } @@ -13458,6 +16390,54 @@ func (ec *executionContext) _Process(ctx context.Context, sel ast.SelectionSet, return out } +var pageInfoImplementors = []string{"PageInfo"} + +func (ec *executionContext) _PageInfo(ctx context.Context, sel ast.SelectionSet, obj *entgql.PageInfo[int]) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, pageInfoImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("PageInfo") + case "hasNextPage": + out.Values[i] = ec._PageInfo_hasNextPage(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "hasPreviousPage": + out.Values[i] = ec._PageInfo_hasPreviousPage(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "startCursor": + out.Values[i] = ec._PageInfo_startCursor(ctx, field, obj) + case "endCursor": + out.Values[i] = ec._PageInfo_endCursor(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + var queryImplementors = []string{"Query"} func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { @@ -14132,6 +17112,39 @@ func (ec *executionContext) _Task(ctx context.Context, sel ast.SelectionSet, obj continue } + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + case "reportedFiles": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Task_reportedFiles(ctx, field, obj) + return res + } + + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) case "reportedProcesses": field := field @@ -14733,27 +17746,58 @@ func (ec *executionContext) marshalNHost2ᚕᚖrealmᚗpubᚋtavernᚋinternal } else { go f(i) } - + + } + wg.Wait() + + for _, e := range ret { + if e == graphql.Null { + return graphql.Null + } + } + + return ret +} + +func (ec *executionContext) marshalNHost2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHost(ctx context.Context, sel ast.SelectionSet, v *ent.Host) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null } - wg.Wait() + return ec._Host(ctx, sel, v) +} - for _, e := range ret { - if e == graphql.Null { - return graphql.Null +func (ec *executionContext) marshalNHostFile2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostFile(ctx context.Context, sel ast.SelectionSet, v *ent.HostFile) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") } + return graphql.Null } + return ec._HostFile(ctx, sel, v) +} - return ret +func (ec *executionContext) unmarshalNHostFileOrderField2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostFileOrderField(ctx context.Context, v interface{}) (*ent.HostFileOrderField, error) { + var res = new(ent.HostFileOrderField) + err := res.UnmarshalGQL(v) + return res, graphql.ErrorOnPath(ctx, err) } -func (ec *executionContext) marshalNHost2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHost(ctx context.Context, sel ast.SelectionSet, v *ent.Host) graphql.Marshaler { +func (ec *executionContext) marshalNHostFileOrderField2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostFileOrderField(ctx context.Context, sel ast.SelectionSet, v *ent.HostFileOrderField) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "the requested element is null which the schema does not allow") } return graphql.Null } - return ec._Host(ctx, sel, v) + return v +} + +func (ec *executionContext) unmarshalNHostFileWhereInput2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostFileWhereInput(ctx context.Context, v interface{}) (*ent.HostFileWhereInput, error) { + res, err := ec.unmarshalInputHostFileWhereInput(ctx, v) + return &res, graphql.ErrorOnPath(ctx, err) } func (ec *executionContext) unmarshalNHostOrderField2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostOrderField(ctx context.Context, v interface{}) (*ent.HostOrderField, error) { @@ -14772,16 +17816,57 @@ func (ec *executionContext) marshalNHostOrderField2ᚖrealmᚗpubᚋtavernᚋint return v } -func (ec *executionContext) unmarshalNHostPlatform2realmᚗpubᚋtavernᚋinternalᚋentᚋhostᚐPlatform(ctx context.Context, v interface{}) (host.Platform, error) { - var res host.Platform +func (ec *executionContext) unmarshalNHostPlatform2realmᚗpubᚋtavernᚋinternalᚋc2ᚋc2pbᚐHost_Platform(ctx context.Context, v interface{}) (c2pb.Host_Platform, error) { + var res c2pb.Host_Platform + err := res.UnmarshalGQL(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalNHostPlatform2realmᚗpubᚋtavernᚋinternalᚋc2ᚋc2pbᚐHost_Platform(ctx context.Context, sel ast.SelectionSet, v c2pb.Host_Platform) graphql.Marshaler { + return v +} + +func (ec *executionContext) marshalNHostProcess2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostProcess(ctx context.Context, sel ast.SelectionSet, v *ent.HostProcess) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._HostProcess(ctx, sel, v) +} + +func (ec *executionContext) unmarshalNHostProcessOrderField2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostProcessOrderField(ctx context.Context, v interface{}) (*ent.HostProcessOrderField, error) { + var res = new(ent.HostProcessOrderField) + err := res.UnmarshalGQL(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalNHostProcessOrderField2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostProcessOrderField(ctx context.Context, sel ast.SelectionSet, v *ent.HostProcessOrderField) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return v +} + +func (ec *executionContext) unmarshalNHostProcessStatus2realmᚗpubᚋtavernᚋinternalᚋc2ᚋc2pbᚐProcess_Status(ctx context.Context, v interface{}) (c2pb.Process_Status, error) { + var res c2pb.Process_Status err := res.UnmarshalGQL(v) return res, graphql.ErrorOnPath(ctx, err) } -func (ec *executionContext) marshalNHostPlatform2realmᚗpubᚋtavernᚋinternalᚋentᚋhostᚐPlatform(ctx context.Context, sel ast.SelectionSet, v host.Platform) graphql.Marshaler { +func (ec *executionContext) marshalNHostProcessStatus2realmᚗpubᚋtavernᚋinternalᚋc2ᚋc2pbᚐProcess_Status(ctx context.Context, sel ast.SelectionSet, v c2pb.Process_Status) graphql.Marshaler { return v } +func (ec *executionContext) unmarshalNHostProcessWhereInput2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostProcessWhereInput(ctx context.Context, v interface{}) (*ent.HostProcessWhereInput, error) { + res, err := ec.unmarshalInputHostProcessWhereInput(ctx, v) + return &res, graphql.ErrorOnPath(ctx, err) +} + func (ec *executionContext) unmarshalNHostWhereInput2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostWhereInput(ctx context.Context, v interface{}) (*ent.HostWhereInput, error) { res, err := ec.unmarshalInputHostWhereInput(ctx, v) return &res, graphql.ErrorOnPath(ctx, err) @@ -14839,37 +17924,6 @@ func (ec *executionContext) marshalNPageInfo2entgoᚗioᚋcontribᚋentgqlᚐPag return ec._PageInfo(ctx, sel, &v) } -func (ec *executionContext) marshalNProcess2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐProcess(ctx context.Context, sel ast.SelectionSet, v *ent.Process) graphql.Marshaler { - if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "the requested element is null which the schema does not allow") - } - return graphql.Null - } - return ec._Process(ctx, sel, v) -} - -func (ec *executionContext) unmarshalNProcessOrderField2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐProcessOrderField(ctx context.Context, v interface{}) (*ent.ProcessOrderField, error) { - var res = new(ent.ProcessOrderField) - err := res.UnmarshalGQL(v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalNProcessOrderField2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐProcessOrderField(ctx context.Context, sel ast.SelectionSet, v *ent.ProcessOrderField) graphql.Marshaler { - if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "the requested element is null which the schema does not allow") - } - return graphql.Null - } - return v -} - -func (ec *executionContext) unmarshalNProcessWhereInput2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐProcessWhereInput(ctx context.Context, v interface{}) (*ent.ProcessWhereInput, error) { - res, err := ec.unmarshalInputProcessWhereInput(ctx, v) - return &res, graphql.ErrorOnPath(ctx, err) -} - func (ec *executionContext) marshalNQuest2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐQuestᚄ(ctx context.Context, sel ast.SelectionSet, v []*ent.Quest) graphql.Marshaler { ret := make(graphql.Array, len(v)) var wg sync.WaitGroup @@ -15491,7 +18545,82 @@ func (ec *executionContext) marshalOHost2ᚕᚖrealmᚗpubᚋtavernᚋinternal return ret } -func (ec *executionContext) unmarshalOHostPlatform2ᚕrealmᚗpubᚋtavernᚋinternalᚋentᚋhostᚐPlatformᚄ(ctx context.Context, v interface{}) ([]host.Platform, error) { +func (ec *executionContext) marshalOHostFile2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostFileᚄ(ctx context.Context, sel ast.SelectionSet, v []*ent.HostFile) graphql.Marshaler { + if v == nil { + return graphql.Null + } + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + fc := &graphql.FieldContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithFieldContext(ctx, fc) + f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalNHostFile2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostFile(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + for _, e := range ret { + if e == graphql.Null { + return graphql.Null + } + } + + return ret +} + +func (ec *executionContext) unmarshalOHostFileWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostFileWhereInputᚄ(ctx context.Context, v interface{}) ([]*ent.HostFileWhereInput, error) { + if v == nil { + return nil, nil + } + var vSlice []interface{} + if v != nil { + vSlice = graphql.CoerceList(v) + } + var err error + res := make([]*ent.HostFileWhereInput, len(vSlice)) + for i := range vSlice { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) + res[i], err = ec.unmarshalNHostFileWhereInput2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostFileWhereInput(ctx, vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil +} + +func (ec *executionContext) unmarshalOHostFileWhereInput2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostFileWhereInput(ctx context.Context, v interface{}) (*ent.HostFileWhereInput, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalInputHostFileWhereInput(ctx, v) + return &res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) unmarshalOHostPlatform2ᚕrealmᚗpubᚋtavernᚋinternalᚋc2ᚋc2pbᚐHost_Platformᚄ(ctx context.Context, v interface{}) ([]c2pb.Host_Platform, error) { if v == nil { return nil, nil } @@ -15500,10 +18629,10 @@ func (ec *executionContext) unmarshalOHostPlatform2ᚕrealmᚗpubᚋtavernᚋint vSlice = graphql.CoerceList(v) } var err error - res := make([]host.Platform, len(vSlice)) + res := make([]c2pb.Host_Platform, len(vSlice)) for i := range vSlice { ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) - res[i], err = ec.unmarshalNHostPlatform2realmᚗpubᚋtavernᚋinternalᚋentᚋhostᚐPlatform(ctx, vSlice[i]) + res[i], err = ec.unmarshalNHostPlatform2realmᚗpubᚋtavernᚋinternalᚋc2ᚋc2pbᚐHost_Platform(ctx, vSlice[i]) if err != nil { return nil, err } @@ -15511,7 +18640,7 @@ func (ec *executionContext) unmarshalOHostPlatform2ᚕrealmᚗpubᚋtavernᚋint return res, nil } -func (ec *executionContext) marshalOHostPlatform2ᚕrealmᚗpubᚋtavernᚋinternalᚋentᚋhostᚐPlatformᚄ(ctx context.Context, sel ast.SelectionSet, v []host.Platform) graphql.Marshaler { +func (ec *executionContext) marshalOHostPlatform2ᚕrealmᚗpubᚋtavernᚋinternalᚋc2ᚋc2pbᚐHost_Platformᚄ(ctx context.Context, sel ast.SelectionSet, v []c2pb.Host_Platform) graphql.Marshaler { if v == nil { return graphql.Null } @@ -15538,7 +18667,7 @@ func (ec *executionContext) marshalOHostPlatform2ᚕrealmᚗpubᚋtavernᚋinter if !isLen1 { defer wg.Done() } - ret[i] = ec.marshalNHostPlatform2realmᚗpubᚋtavernᚋinternalᚋentᚋhostᚐPlatform(ctx, sel, v[i]) + ret[i] = ec.marshalNHostPlatform2realmᚗpubᚋtavernᚋinternalᚋc2ᚋc2pbᚐHost_Platform(ctx, sel, v[i]) } if isLen1 { f(i) @@ -15558,23 +18687,70 @@ func (ec *executionContext) marshalOHostPlatform2ᚕrealmᚗpubᚋtavernᚋinter return ret } -func (ec *executionContext) unmarshalOHostPlatform2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚋhostᚐPlatform(ctx context.Context, v interface{}) (*host.Platform, error) { +func (ec *executionContext) unmarshalOHostPlatform2ᚖrealmᚗpubᚋtavernᚋinternalᚋc2ᚋc2pbᚐHost_Platform(ctx context.Context, v interface{}) (*c2pb.Host_Platform, error) { if v == nil { return nil, nil } - var res = new(host.Platform) + var res = new(c2pb.Host_Platform) err := res.UnmarshalGQL(v) return res, graphql.ErrorOnPath(ctx, err) } -func (ec *executionContext) marshalOHostPlatform2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚋhostᚐPlatform(ctx context.Context, sel ast.SelectionSet, v *host.Platform) graphql.Marshaler { +func (ec *executionContext) marshalOHostPlatform2ᚖrealmᚗpubᚋtavernᚋinternalᚋc2ᚋc2pbᚐHost_Platform(ctx context.Context, sel ast.SelectionSet, v *c2pb.Host_Platform) graphql.Marshaler { if v == nil { return graphql.Null } return v } -func (ec *executionContext) unmarshalOHostWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostWhereInputᚄ(ctx context.Context, v interface{}) ([]*ent.HostWhereInput, error) { +func (ec *executionContext) marshalOHostProcess2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostProcessᚄ(ctx context.Context, sel ast.SelectionSet, v []*ent.HostProcess) graphql.Marshaler { + if v == nil { + return graphql.Null + } + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + fc := &graphql.FieldContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithFieldContext(ctx, fc) + f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalNHostProcess2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostProcess(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + for _, e := range ret { + if e == graphql.Null { + return graphql.Null + } + } + + return ret +} + +func (ec *executionContext) unmarshalOHostProcessStatus2ᚕrealmᚗpubᚋtavernᚋinternalᚋc2ᚋc2pbᚐProcess_Statusᚄ(ctx context.Context, v interface{}) ([]c2pb.Process_Status, error) { if v == nil { return nil, nil } @@ -15583,10 +18759,10 @@ func (ec *executionContext) unmarshalOHostWhereInput2ᚕᚖrealmᚗpubᚋtavern vSlice = graphql.CoerceList(v) } var err error - res := make([]*ent.HostWhereInput, len(vSlice)) + res := make([]c2pb.Process_Status, len(vSlice)) for i := range vSlice { ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) - res[i], err = ec.unmarshalNHostWhereInput2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostWhereInput(ctx, vSlice[i]) + res[i], err = ec.unmarshalNHostProcessStatus2realmᚗpubᚋtavernᚋinternalᚋc2ᚋc2pbᚐProcess_Status(ctx, vSlice[i]) if err != nil { return nil, err } @@ -15594,22 +18770,7 @@ func (ec *executionContext) unmarshalOHostWhereInput2ᚕᚖrealmᚗpubᚋtavern return res, nil } -func (ec *executionContext) unmarshalOHostWhereInput2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostWhereInput(ctx context.Context, v interface{}) (*ent.HostWhereInput, error) { - if v == nil { - return nil, nil - } - res, err := ec.unmarshalInputHostWhereInput(ctx, v) - return &res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalONode2realmᚗpubᚋtavernᚋinternalᚋentᚐNoder(ctx context.Context, sel ast.SelectionSet, v ent.Noder) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return ec._Node(ctx, sel, v) -} - -func (ec *executionContext) marshalOProcess2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐProcessᚄ(ctx context.Context, sel ast.SelectionSet, v []*ent.Process) graphql.Marshaler { +func (ec *executionContext) marshalOHostProcessStatus2ᚕrealmᚗpubᚋtavernᚋinternalᚋc2ᚋc2pbᚐProcess_Statusᚄ(ctx context.Context, sel ast.SelectionSet, v []c2pb.Process_Status) graphql.Marshaler { if v == nil { return graphql.Null } @@ -15636,7 +18797,7 @@ func (ec *executionContext) marshalOProcess2ᚕᚖrealmᚗpubᚋtavernᚋinterna if !isLen1 { defer wg.Done() } - ret[i] = ec.marshalNProcess2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐProcess(ctx, sel, v[i]) + ret[i] = ec.marshalNHostProcessStatus2realmᚗpubᚋtavernᚋinternalᚋc2ᚋc2pbᚐProcess_Status(ctx, sel, v[i]) } if isLen1 { f(i) @@ -15656,7 +18817,51 @@ func (ec *executionContext) marshalOProcess2ᚕᚖrealmᚗpubᚋtavernᚋinterna return ret } -func (ec *executionContext) unmarshalOProcessWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐProcessWhereInputᚄ(ctx context.Context, v interface{}) ([]*ent.ProcessWhereInput, error) { +func (ec *executionContext) unmarshalOHostProcessStatus2ᚖrealmᚗpubᚋtavernᚋinternalᚋc2ᚋc2pbᚐProcess_Status(ctx context.Context, v interface{}) (*c2pb.Process_Status, error) { + if v == nil { + return nil, nil + } + var res = new(c2pb.Process_Status) + err := res.UnmarshalGQL(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalOHostProcessStatus2ᚖrealmᚗpubᚋtavernᚋinternalᚋc2ᚋc2pbᚐProcess_Status(ctx context.Context, sel ast.SelectionSet, v *c2pb.Process_Status) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return v +} + +func (ec *executionContext) unmarshalOHostProcessWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostProcessWhereInputᚄ(ctx context.Context, v interface{}) ([]*ent.HostProcessWhereInput, error) { + if v == nil { + return nil, nil + } + var vSlice []interface{} + if v != nil { + vSlice = graphql.CoerceList(v) + } + var err error + res := make([]*ent.HostProcessWhereInput, len(vSlice)) + for i := range vSlice { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) + res[i], err = ec.unmarshalNHostProcessWhereInput2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostProcessWhereInput(ctx, vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil +} + +func (ec *executionContext) unmarshalOHostProcessWhereInput2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostProcessWhereInput(ctx context.Context, v interface{}) (*ent.HostProcessWhereInput, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalInputHostProcessWhereInput(ctx, v) + return &res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) unmarshalOHostWhereInput2ᚕᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostWhereInputᚄ(ctx context.Context, v interface{}) ([]*ent.HostWhereInput, error) { if v == nil { return nil, nil } @@ -15665,10 +18870,10 @@ func (ec *executionContext) unmarshalOProcessWhereInput2ᚕᚖrealmᚗpubᚋtave vSlice = graphql.CoerceList(v) } var err error - res := make([]*ent.ProcessWhereInput, len(vSlice)) + res := make([]*ent.HostWhereInput, len(vSlice)) for i := range vSlice { ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) - res[i], err = ec.unmarshalNProcessWhereInput2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐProcessWhereInput(ctx, vSlice[i]) + res[i], err = ec.unmarshalNHostWhereInput2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostWhereInput(ctx, vSlice[i]) if err != nil { return nil, err } @@ -15676,14 +18881,21 @@ func (ec *executionContext) unmarshalOProcessWhereInput2ᚕᚖrealmᚗpubᚋtave return res, nil } -func (ec *executionContext) unmarshalOProcessWhereInput2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐProcessWhereInput(ctx context.Context, v interface{}) (*ent.ProcessWhereInput, error) { +func (ec *executionContext) unmarshalOHostWhereInput2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐHostWhereInput(ctx context.Context, v interface{}) (*ent.HostWhereInput, error) { if v == nil { return nil, nil } - res, err := ec.unmarshalInputProcessWhereInput(ctx, v) + res, err := ec.unmarshalInputHostWhereInput(ctx, v) return &res, graphql.ErrorOnPath(ctx, err) } +func (ec *executionContext) marshalONode2realmᚗpubᚋtavernᚋinternalᚋentᚐNoder(ctx context.Context, sel ast.SelectionSet, v ent.Noder) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._Node(ctx, sel, v) +} + func (ec *executionContext) marshalOQuest2ᚖrealmᚗpubᚋtavernᚋinternalᚋentᚐQuest(ctx context.Context, sel ast.SelectionSet, v *ent.Quest) graphql.Marshaler { if v == nil { return graphql.Null diff --git a/tavern/internal/graphql/generated/inputs.generated.go b/tavern/internal/graphql/generated/inputs.generated.go index 41f50985f..90aa66b05 100644 --- a/tavern/internal/graphql/generated/inputs.generated.go +++ b/tavern/internal/graphql/generated/inputs.generated.go @@ -63,7 +63,7 @@ func (ec *executionContext) unmarshalInputClaimTasksInput(ctx context.Context, o var err error ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hostPlatform")) - data, err := ec.unmarshalNHostPlatform2realmᚗpubᚋtavernᚋinternalᚋentᚋhostᚐPlatform(ctx, v) + data, err := ec.unmarshalNHostPlatform2realmᚗpubᚋtavernᚋinternalᚋc2ᚋc2pbᚐHost_Platform(ctx, v) if err != nil { return it, err } diff --git a/tavern/internal/graphql/generated/mutation.generated.go b/tavern/internal/graphql/generated/mutation.generated.go index 34135493b..fc4605f72 100644 --- a/tavern/internal/graphql/generated/mutation.generated.go +++ b/tavern/internal/graphql/generated/mutation.generated.go @@ -511,6 +511,8 @@ func (ec *executionContext) fieldContext_Mutation_updateHost(ctx context.Context return ec.fieldContext_Host_tags(ctx, field) case "beacons": return ec.fieldContext_Host_beacons(ctx, field) + case "files": + return ec.fieldContext_Host_files(ctx, field) case "processes": return ec.fieldContext_Host_processes(ctx, field) } diff --git a/tavern/internal/graphql/generated/root_.generated.go b/tavern/internal/graphql/generated/root_.generated.go index a395b78fa..dcc444405 100644 --- a/tavern/internal/graphql/generated/root_.generated.go +++ b/tavern/internal/graphql/generated/root_.generated.go @@ -35,10 +35,10 @@ type Config struct { } type ResolverRoot interface { + HostProcess() HostProcessResolver Mutation() MutationResolver - Process() ProcessResolver Query() QueryResolver - ProcessWhereInput() ProcessWhereInputResolver + HostProcessWhereInput() HostProcessWhereInputResolver } type DirectiveRoot struct { @@ -73,6 +73,7 @@ type ComplexityRoot struct { Host struct { Beacons func(childComplexity int) int CreatedAt func(childComplexity int) int + Files func(childComplexity int) int ID func(childComplexity int) int Identifier func(childComplexity int) int LastModifiedAt func(childComplexity int) int @@ -84,6 +85,37 @@ type ComplexityRoot struct { Tags func(childComplexity int) int } + HostFile struct { + CreatedAt func(childComplexity int) int + Group func(childComplexity int) int + Hash func(childComplexity int) int + Host func(childComplexity int) int + ID func(childComplexity int) int + LastModifiedAt func(childComplexity int) int + Owner func(childComplexity int) int + Path func(childComplexity int) int + Permissions func(childComplexity int) int + Size func(childComplexity int) int + Task func(childComplexity int) int + } + + HostProcess struct { + Cmd func(childComplexity int) int + CreatedAt func(childComplexity int) int + Cwd func(childComplexity int) int + Env func(childComplexity int) int + Host func(childComplexity int) int + ID func(childComplexity int) int + LastModifiedAt func(childComplexity int) int + Name func(childComplexity int) int + Path func(childComplexity int) int + Pid func(childComplexity int) int + Ppid func(childComplexity int) int + Principal func(childComplexity int) int + Status func(childComplexity int) int + Task func(childComplexity int) int + } + Mutation struct { CreateQuest func(childComplexity int, beaconIDs []int, input ent.CreateQuestInput) int CreateTag func(childComplexity int, input ent.CreateTagInput) int @@ -103,17 +135,6 @@ type ComplexityRoot struct { StartCursor func(childComplexity int) int } - Process struct { - CreatedAt func(childComplexity int) int - Host func(childComplexity int) int - ID func(childComplexity int) int - LastModifiedAt func(childComplexity int) int - Name func(childComplexity int) int - Pid func(childComplexity int) int - Principal func(childComplexity int) int - Task func(childComplexity int) int - } - Query struct { Beacons func(childComplexity int, where *ent.BeaconWhereInput) int Files func(childComplexity int, where *ent.FileWhereInput) int @@ -159,6 +180,7 @@ type ComplexityRoot struct { Output func(childComplexity int) int OutputSize func(childComplexity int) int Quest func(childComplexity int) int + ReportedFiles func(childComplexity int) int ReportedProcesses func(childComplexity int) int } @@ -357,6 +379,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Host.CreatedAt(childComplexity), true + case "Host.files": + if e.complexity.Host.Files == nil { + break + } + + return e.complexity.Host.Files(childComplexity), true + case "Host.id": if e.complexity.Host.ID == nil { break @@ -420,6 +449,181 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Host.Tags(childComplexity), true + case "HostFile.createdAt": + if e.complexity.HostFile.CreatedAt == nil { + break + } + + return e.complexity.HostFile.CreatedAt(childComplexity), true + + case "HostFile.group": + if e.complexity.HostFile.Group == nil { + break + } + + return e.complexity.HostFile.Group(childComplexity), true + + case "HostFile.hash": + if e.complexity.HostFile.Hash == nil { + break + } + + return e.complexity.HostFile.Hash(childComplexity), true + + case "HostFile.host": + if e.complexity.HostFile.Host == nil { + break + } + + return e.complexity.HostFile.Host(childComplexity), true + + case "HostFile.id": + if e.complexity.HostFile.ID == nil { + break + } + + return e.complexity.HostFile.ID(childComplexity), true + + case "HostFile.lastModifiedAt": + if e.complexity.HostFile.LastModifiedAt == nil { + break + } + + return e.complexity.HostFile.LastModifiedAt(childComplexity), true + + case "HostFile.owner": + if e.complexity.HostFile.Owner == nil { + break + } + + return e.complexity.HostFile.Owner(childComplexity), true + + case "HostFile.path": + if e.complexity.HostFile.Path == nil { + break + } + + return e.complexity.HostFile.Path(childComplexity), true + + case "HostFile.permissions": + if e.complexity.HostFile.Permissions == nil { + break + } + + return e.complexity.HostFile.Permissions(childComplexity), true + + case "HostFile.size": + if e.complexity.HostFile.Size == nil { + break + } + + return e.complexity.HostFile.Size(childComplexity), true + + case "HostFile.task": + if e.complexity.HostFile.Task == nil { + break + } + + return e.complexity.HostFile.Task(childComplexity), true + + case "HostProcess.cmd": + if e.complexity.HostProcess.Cmd == nil { + break + } + + return e.complexity.HostProcess.Cmd(childComplexity), true + + case "HostProcess.createdAt": + if e.complexity.HostProcess.CreatedAt == nil { + break + } + + return e.complexity.HostProcess.CreatedAt(childComplexity), true + + case "HostProcess.cwd": + if e.complexity.HostProcess.Cwd == nil { + break + } + + return e.complexity.HostProcess.Cwd(childComplexity), true + + case "HostProcess.env": + if e.complexity.HostProcess.Env == nil { + break + } + + return e.complexity.HostProcess.Env(childComplexity), true + + case "HostProcess.host": + if e.complexity.HostProcess.Host == nil { + break + } + + return e.complexity.HostProcess.Host(childComplexity), true + + case "HostProcess.id": + if e.complexity.HostProcess.ID == nil { + break + } + + return e.complexity.HostProcess.ID(childComplexity), true + + case "HostProcess.lastModifiedAt": + if e.complexity.HostProcess.LastModifiedAt == nil { + break + } + + return e.complexity.HostProcess.LastModifiedAt(childComplexity), true + + case "HostProcess.name": + if e.complexity.HostProcess.Name == nil { + break + } + + return e.complexity.HostProcess.Name(childComplexity), true + + case "HostProcess.path": + if e.complexity.HostProcess.Path == nil { + break + } + + return e.complexity.HostProcess.Path(childComplexity), true + + case "HostProcess.pid": + if e.complexity.HostProcess.Pid == nil { + break + } + + return e.complexity.HostProcess.Pid(childComplexity), true + + case "HostProcess.ppid": + if e.complexity.HostProcess.Ppid == nil { + break + } + + return e.complexity.HostProcess.Ppid(childComplexity), true + + case "HostProcess.principal": + if e.complexity.HostProcess.Principal == nil { + break + } + + return e.complexity.HostProcess.Principal(childComplexity), true + + case "HostProcess.status": + if e.complexity.HostProcess.Status == nil { + break + } + + return e.complexity.HostProcess.Status(childComplexity), true + + case "HostProcess.task": + if e.complexity.HostProcess.Task == nil { + break + } + + return e.complexity.HostProcess.Task(childComplexity), true + case "Mutation.createQuest": if e.complexity.Mutation.CreateQuest == nil { break @@ -556,62 +760,6 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.PageInfo.StartCursor(childComplexity), true - case "Process.createdAt": - if e.complexity.Process.CreatedAt == nil { - break - } - - return e.complexity.Process.CreatedAt(childComplexity), true - - case "Process.host": - if e.complexity.Process.Host == nil { - break - } - - return e.complexity.Process.Host(childComplexity), true - - case "Process.id": - if e.complexity.Process.ID == nil { - break - } - - return e.complexity.Process.ID(childComplexity), true - - case "Process.lastModifiedAt": - if e.complexity.Process.LastModifiedAt == nil { - break - } - - return e.complexity.Process.LastModifiedAt(childComplexity), true - - case "Process.name": - if e.complexity.Process.Name == nil { - break - } - - return e.complexity.Process.Name(childComplexity), true - - case "Process.pid": - if e.complexity.Process.Pid == nil { - break - } - - return e.complexity.Process.Pid(childComplexity), true - - case "Process.principal": - if e.complexity.Process.Principal == nil { - break - } - - return e.complexity.Process.Principal(childComplexity), true - - case "Process.task": - if e.complexity.Process.Task == nil { - break - } - - return e.complexity.Process.Task(childComplexity), true - case "Query.beacons": if e.complexity.Query.Beacons == nil { break @@ -907,6 +1055,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Task.Quest(childComplexity), true + case "Task.reportedFiles": + if e.complexity.Task.ReportedFiles == nil { + break + } + + return e.complexity.Task.ReportedFiles(childComplexity), true + case "Task.reportedProcesses": if e.complexity.Task.ReportedProcesses == nil { break @@ -1091,10 +1246,12 @@ func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { ec.unmarshalInputCreateTomeInput, ec.unmarshalInputFileOrder, ec.unmarshalInputFileWhereInput, + ec.unmarshalInputHostFileOrder, + ec.unmarshalInputHostFileWhereInput, ec.unmarshalInputHostOrder, + ec.unmarshalInputHostProcessOrder, + ec.unmarshalInputHostProcessWhereInput, ec.unmarshalInputHostWhereInput, - ec.unmarshalInputProcessOrder, - ec.unmarshalInputProcessWhereInput, ec.unmarshalInputQuestOrder, ec.unmarshalInputQuestWhereInput, ec.unmarshalInputSubmitTaskResultInput, @@ -1434,7 +1591,7 @@ type File implements Node { name: String! """The size of the file in bytes""" size: Int! - """A SHA3 digest of the content field""" + """A SHA3-256 digest of the content field""" hash: String! tomes: [Tome!] } @@ -1548,8 +1705,176 @@ type Host implements Node { tags: [Tag!] """Beacons that are present on this host system.""" beacons: [Beacon!] + """Files reported on this host system.""" + files: [HostFile!] """Processes reported as running on this host system.""" - processes: [Process!] + processes: [HostProcess!] +} +type HostFile implements Node { + id: ID! + """Timestamp of when this ent was created""" + createdAt: Time! + """Timestamp of when this ent was last updated""" + lastModifiedAt: Time! + """Path to the file on the host system.""" + path: String! + """User who owns the file on the host system.""" + owner: String + """Group who owns the file on the host system.""" + group: String + """Permissions for the file on the host system.""" + permissions: String + """The size of the file in bytes""" + size: Int! + """A SHA3-256 digest of the content field""" + hash: String + """Host the file was reported on.""" + host: Host! + """Task that reported this file.""" + task: Task! +} +"""Ordering options for HostFile connections""" +input HostFileOrder { + """The ordering direction.""" + direction: OrderDirection! = ASC + """The field by which to order HostFiles.""" + field: HostFileOrderField! +} +"""Properties by which HostFile connections can be ordered.""" +enum HostFileOrderField { + CREATED_AT + LAST_MODIFIED_AT + NAME + SIZE +} +""" +HostFileWhereInput is used for filtering HostFile objects. +Input was generated by ent. +""" +input HostFileWhereInput { + not: HostFileWhereInput + and: [HostFileWhereInput!] + or: [HostFileWhereInput!] + """id field predicates""" + id: ID + idNEQ: ID + idIn: [ID!] + idNotIn: [ID!] + idGT: ID + idGTE: ID + idLT: ID + idLTE: ID + """created_at field predicates""" + createdAt: Time + createdAtNEQ: Time + createdAtIn: [Time!] + createdAtNotIn: [Time!] + createdAtGT: Time + createdAtGTE: Time + createdAtLT: Time + createdAtLTE: Time + """last_modified_at field predicates""" + lastModifiedAt: Time + lastModifiedAtNEQ: Time + lastModifiedAtIn: [Time!] + lastModifiedAtNotIn: [Time!] + lastModifiedAtGT: Time + lastModifiedAtGTE: Time + lastModifiedAtLT: Time + lastModifiedAtLTE: Time + """path field predicates""" + path: String + pathNEQ: String + pathIn: [String!] + pathNotIn: [String!] + pathGT: String + pathGTE: String + pathLT: String + pathLTE: String + pathContains: String + pathHasPrefix: String + pathHasSuffix: String + pathEqualFold: String + pathContainsFold: String + """owner field predicates""" + owner: String + ownerNEQ: String + ownerIn: [String!] + ownerNotIn: [String!] + ownerGT: String + ownerGTE: String + ownerLT: String + ownerLTE: String + ownerContains: String + ownerHasPrefix: String + ownerHasSuffix: String + ownerIsNil: Boolean + ownerNotNil: Boolean + ownerEqualFold: String + ownerContainsFold: String + """group field predicates""" + group: String + groupNEQ: String + groupIn: [String!] + groupNotIn: [String!] + groupGT: String + groupGTE: String + groupLT: String + groupLTE: String + groupContains: String + groupHasPrefix: String + groupHasSuffix: String + groupIsNil: Boolean + groupNotNil: Boolean + groupEqualFold: String + groupContainsFold: String + """permissions field predicates""" + permissions: String + permissionsNEQ: String + permissionsIn: [String!] + permissionsNotIn: [String!] + permissionsGT: String + permissionsGTE: String + permissionsLT: String + permissionsLTE: String + permissionsContains: String + permissionsHasPrefix: String + permissionsHasSuffix: String + permissionsIsNil: Boolean + permissionsNotNil: Boolean + permissionsEqualFold: String + permissionsContainsFold: String + """size field predicates""" + size: Int + sizeNEQ: Int + sizeIn: [Int!] + sizeNotIn: [Int!] + sizeGT: Int + sizeGTE: Int + sizeLT: Int + sizeLTE: Int + """hash field predicates""" + hash: String + hashNEQ: String + hashIn: [String!] + hashNotIn: [String!] + hashGT: String + hashGTE: String + hashLT: String + hashLTE: String + hashContains: String + hashHasPrefix: String + hashHasSuffix: String + hashIsNil: Boolean + hashNotNil: Boolean + hashEqualFold: String + hashContainsFold: String + """host edge predicates""" + hasHost: Boolean + hasHostWith: [HostWhereInput!] + """task edge predicates""" + hasTask: Boolean + hasTaskWith: [TaskWhereInput!] } """Ordering options for Host connections""" input HostOrder { @@ -1565,12 +1890,230 @@ enum HostOrderField { LAST_SEEN_AT } """HostPlatform is enum for the field platform""" -enum HostPlatform @goModel(model: "realm.pub/tavern/internal/ent/host.Platform") { - Windows - Linux - MacOS - BSD - Unknown +enum HostPlatform @goModel(model: "realm.pub/tavern/internal/c2/c2pb.Host_Platform") { + PLATFORM_BSD + PLATFORM_UNSPECIFIED + PLATFORM_WINDOWS + PLATFORM_LINUX + PLATFORM_MACOS +} +type HostProcess implements Node { + id: ID! + """Timestamp of when this ent was created""" + createdAt: Time! + """Timestamp of when this ent was last updated""" + lastModifiedAt: Time! + """ID of the process.""" + pid: Int! + """ID of the parent process.""" + ppid: Int! + """The name of the process.""" + name: String! + """The user the process is running as.""" + principal: String! + """The path to the process executable.""" + path: String + """The command used to execute the process.""" + cmd: String + """The environment variables set for the process.""" + env: String + """The current working directory for the process.""" + cwd: String + """Current process status.""" + status: HostProcessStatus! + """Host the process was reported on.""" + host: Host! + """Task that reported this process.""" + task: Task! +} +"""Ordering options for HostProcess connections""" +input HostProcessOrder { + """The ordering direction.""" + direction: OrderDirection! = ASC + """The field by which to order HostProcesses.""" + field: HostProcessOrderField! +} +"""Properties by which HostProcess connections can be ordered.""" +enum HostProcessOrderField { + CREATED_AT + LAST_MODIFIED_AT + PROCESS_ID + PARENT_PROCESS_ID + NAME +} +"""HostProcessStatus is enum for the field status""" +enum HostProcessStatus @goModel(model: "realm.pub/tavern/internal/c2/c2pb.Process_Status") { + STATUS_STOP + STATUS_TRACING + STATUS_WAKE_KILL + STATUS_UNKNOWN + STATUS_IDLE + STATUS_SLEEP + STATUS_WAKING + STATUS_UNSPECIFIED + STATUS_PARKED + STATUS_LOCK_BLOCKED + STATUS_DEAD + STATUS_ZOMBIE + STATUS_UNINTERUPTIBLE_DISK_SLEEP + STATUS_RUN +} +""" +HostProcessWhereInput is used for filtering HostProcess objects. +Input was generated by ent. +""" +input HostProcessWhereInput { + not: HostProcessWhereInput + and: [HostProcessWhereInput!] + or: [HostProcessWhereInput!] + """id field predicates""" + id: ID + idNEQ: ID + idIn: [ID!] + idNotIn: [ID!] + idGT: ID + idGTE: ID + idLT: ID + idLTE: ID + """created_at field predicates""" + createdAt: Time + createdAtNEQ: Time + createdAtIn: [Time!] + createdAtNotIn: [Time!] + createdAtGT: Time + createdAtGTE: Time + createdAtLT: Time + createdAtLTE: Time + """last_modified_at field predicates""" + lastModifiedAt: Time + lastModifiedAtNEQ: Time + lastModifiedAtIn: [Time!] + lastModifiedAtNotIn: [Time!] + lastModifiedAtGT: Time + lastModifiedAtGTE: Time + lastModifiedAtLT: Time + lastModifiedAtLTE: Time + """pid field predicates""" + pid: Int + pidNEQ: Int + pidIn: [Int!] + pidNotIn: [Int!] + pidGT: Int + pidGTE: Int + pidLT: Int + pidLTE: Int + """ppid field predicates""" + ppid: Int + ppidNEQ: Int + ppidIn: [Int!] + ppidNotIn: [Int!] + ppidGT: Int + ppidGTE: Int + ppidLT: Int + ppidLTE: Int + """name field predicates""" + name: String + nameNEQ: String + nameIn: [String!] + nameNotIn: [String!] + nameGT: String + nameGTE: String + nameLT: String + nameLTE: String + nameContains: String + nameHasPrefix: String + nameHasSuffix: String + nameEqualFold: String + nameContainsFold: String + """principal field predicates""" + principal: String + principalNEQ: String + principalIn: [String!] + principalNotIn: [String!] + principalGT: String + principalGTE: String + principalLT: String + principalLTE: String + principalContains: String + principalHasPrefix: String + principalHasSuffix: String + principalEqualFold: String + principalContainsFold: String + """path field predicates""" + path: String + pathNEQ: String + pathIn: [String!] + pathNotIn: [String!] + pathGT: String + pathGTE: String + pathLT: String + pathLTE: String + pathContains: String + pathHasPrefix: String + pathHasSuffix: String + pathIsNil: Boolean + pathNotNil: Boolean + pathEqualFold: String + pathContainsFold: String + """cmd field predicates""" + cmd: String + cmdNEQ: String + cmdIn: [String!] + cmdNotIn: [String!] + cmdGT: String + cmdGTE: String + cmdLT: String + cmdLTE: String + cmdContains: String + cmdHasPrefix: String + cmdHasSuffix: String + cmdIsNil: Boolean + cmdNotNil: Boolean + cmdEqualFold: String + cmdContainsFold: String + """env field predicates""" + env: String + envNEQ: String + envIn: [String!] + envNotIn: [String!] + envGT: String + envGTE: String + envLT: String + envLTE: String + envContains: String + envHasPrefix: String + envHasSuffix: String + envIsNil: Boolean + envNotNil: Boolean + envEqualFold: String + envContainsFold: String + """cwd field predicates""" + cwd: String + cwdNEQ: String + cwdIn: [String!] + cwdNotIn: [String!] + cwdGT: String + cwdGTE: String + cwdLT: String + cwdLTE: String + cwdContains: String + cwdHasPrefix: String + cwdHasSuffix: String + cwdIsNil: Boolean + cwdNotNil: Boolean + cwdEqualFold: String + cwdContainsFold: String + """status field predicates""" + status: HostProcessStatus + statusNEQ: HostProcessStatus + statusIn: [HostProcessStatus!] + statusNotIn: [HostProcessStatus!] + """host edge predicates""" + hasHost: Boolean + hasHostWith: [HostWhereInput!] + """task edge predicates""" + hasTask: Boolean + hasTaskWith: [TaskWhereInput!] } """ HostWhereInput is used for filtering Host objects. @@ -1675,9 +2218,12 @@ input HostWhereInput { """beacons edge predicates""" hasBeacons: Boolean hasBeaconsWith: [BeaconWhereInput!] + """files edge predicates""" + hasFiles: Boolean + hasFilesWith: [HostFileWhereInput!] """processes edge predicates""" hasProcesses: Boolean - hasProcessesWith: [ProcessWhereInput!] + hasProcessesWith: [HostProcessWhereInput!] } """ An object with an ID. @@ -1708,116 +2254,6 @@ type PageInfo { """When paginating forwards, the cursor to continue.""" endCursor: Cursor } -type Process implements Node { - id: ID! - """Timestamp of when this ent was created""" - createdAt: Time! - """Timestamp of when this ent was last updated""" - lastModifiedAt: Time! - """ID of the process.""" - pid: Int! - """The name of the process.""" - name: String! - """The user the process is running as.""" - principal: String! - """Host the process was reported on.""" - host: Host! - """Task that reported this process.""" - task: Task! -} -"""Ordering options for Process connections""" -input ProcessOrder { - """The ordering direction.""" - direction: OrderDirection! = ASC - """The field by which to order Processes.""" - field: ProcessOrderField! -} -"""Properties by which Process connections can be ordered.""" -enum ProcessOrderField { - CREATED_AT - LAST_MODIFIED_AT - PROCESS_ID - NAME -} -""" -ProcessWhereInput is used for filtering Process objects. -Input was generated by ent. -""" -input ProcessWhereInput { - not: ProcessWhereInput - and: [ProcessWhereInput!] - or: [ProcessWhereInput!] - """id field predicates""" - id: ID - idNEQ: ID - idIn: [ID!] - idNotIn: [ID!] - idGT: ID - idGTE: ID - idLT: ID - idLTE: ID - """created_at field predicates""" - createdAt: Time - createdAtNEQ: Time - createdAtIn: [Time!] - createdAtNotIn: [Time!] - createdAtGT: Time - createdAtGTE: Time - createdAtLT: Time - createdAtLTE: Time - """last_modified_at field predicates""" - lastModifiedAt: Time - lastModifiedAtNEQ: Time - lastModifiedAtIn: [Time!] - lastModifiedAtNotIn: [Time!] - lastModifiedAtGT: Time - lastModifiedAtGTE: Time - lastModifiedAtLT: Time - lastModifiedAtLTE: Time - """pid field predicates""" - pid: Int - pidNEQ: Int - pidIn: [Int!] - pidNotIn: [Int!] - pidGT: Int - pidGTE: Int - pidLT: Int - pidLTE: Int - """name field predicates""" - name: String - nameNEQ: String - nameIn: [String!] - nameNotIn: [String!] - nameGT: String - nameGTE: String - nameLT: String - nameLTE: String - nameContains: String - nameHasPrefix: String - nameHasSuffix: String - nameEqualFold: String - nameContainsFold: String - """principal field predicates""" - principal: String - principalNEQ: String - principalIn: [String!] - principalNotIn: [String!] - principalGT: String - principalGTE: String - principalLT: String - principalLTE: String - principalContains: String - principalHasPrefix: String - principalHasSuffix: String - principalEqualFold: String - principalContainsFold: String - """host edge predicates""" - hasHost: Boolean - hasHostWith: [HostWhereInput!] - """task edge predicates""" - hasTask: Boolean - hasTaskWith: [TaskWhereInput!] -} type Query { """Fetches an object given its ID.""" node( @@ -2024,8 +2460,10 @@ type Task implements Node { error: String quest: Quest! beacon: Beacon! + """Files that have been reported by this task.""" + reportedFiles: [HostFile!] """Processes that have been reported by this task.""" - reportedProcesses: [Process!] + reportedProcesses: [HostProcess!] } """A connection to a list of items.""" type TaskConnection { @@ -2174,9 +2612,12 @@ input TaskWhereInput { """beacon edge predicates""" hasBeacon: Boolean hasBeaconWith: [BeaconWhereInput!] + """reported_files edge predicates""" + hasReportedFiles: Boolean + hasReportedFilesWith: [HostFileWhereInput!] """reported_processes edge predicates""" hasReportedProcesses: Boolean - hasReportedProcessesWith: [ProcessWhereInput!] + hasReportedProcessesWith: [HostProcessWhereInput!] } type Tome implements Node { id: ID! @@ -2389,6 +2830,9 @@ input UpdateHostInput { addBeaconIDs: [ID!] removeBeaconIDs: [ID!] clearBeacons: Boolean + addFileIDs: [ID!] + removeFileIDs: [ID!] + clearFiles: Boolean addProcessIDs: [ID!] removeProcessIDs: [ID!] clearProcesses: Boolean diff --git a/tavern/internal/graphql/gqlgen.yml b/tavern/internal/graphql/gqlgen.yml index 90ce0a7e0..3deeb4ec7 100644 --- a/tavern/internal/graphql/gqlgen.yml +++ b/tavern/internal/graphql/gqlgen.yml @@ -30,10 +30,10 @@ autobind: - realm.pub/tavern/internal/ent/tag - realm.pub/tavern/internal/ent/beacon - realm.pub/tavern/internal/ent/host + - realm.pub/tavern/internal/ent/hostprocess - realm.pub/tavern/internal/ent/quest - realm.pub/tavern/internal/ent/task - realm.pub/tavern/internal/ent/tome - - realm.pub/tavern/internal/ent/process struct_tag: json @@ -58,10 +58,13 @@ models: - realm.pub/tavern/internal/ent/tag.Kind Platform: model: - - realm.pub/tavern/internal/ent/host.Platform + - realm.pub/tavern/internal/c2/c2pb.Host_Platform SupportModel: model: - realm.pub/tavern/internal/ent/tome.SupportModel Tactic: model: - realm.pub/tavern/internal/ent/tome.Tactic + Status: + model: + - realm.pub/tavern/internal/c2/c2pb.Process_Status diff --git a/tavern/internal/graphql/models/gqlgen_models.go b/tavern/internal/graphql/models/gqlgen_models.go index 472ce04b7..08a2f6115 100644 --- a/tavern/internal/graphql/models/gqlgen_models.go +++ b/tavern/internal/graphql/models/gqlgen_models.go @@ -8,7 +8,7 @@ import ( "strconv" "time" - "realm.pub/tavern/internal/ent/host" + "realm.pub/tavern/internal/c2/c2pb" ) type ClaimTasksInput struct { @@ -17,7 +17,7 @@ type ClaimTasksInput struct { // The hostname of the system the beacon is running on. Hostname string `json:"hostname"` // The platform the agent is operating on. - HostPlatform host.Platform `json:"hostPlatform"` + HostPlatform c2pb.Host_Platform `json:"hostPlatform"` // The IP address of the hosts primary interface (if available). HostPrimaryIP *string `json:"hostPrimaryIP,omitempty"` // Unique identifier of the beacon, each running instance will be different. diff --git a/tavern/internal/graphql/quest_test.go b/tavern/internal/graphql/quest_test.go index 2886daed5..56f23ffcf 100644 --- a/tavern/internal/graphql/quest_test.go +++ b/tavern/internal/graphql/quest_test.go @@ -13,6 +13,7 @@ import ( "github.com/99designs/gqlgen/graphql/handler" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "realm.pub/tavern/internal/c2/c2pb" "realm.pub/tavern/internal/ent" "realm.pub/tavern/internal/ent/enttest" "realm.pub/tavern/internal/graphql" @@ -35,7 +36,10 @@ func TestCreateQuest(t *testing.T) { gqlClient := client.New(srv, client.Path("/graphql")) // Initialize sample data - testHost := graph.Host.Create().SetIdentifier("ABCDEFG").SaveX(ctx) + testHost := graph.Host.Create(). + SetIdentifier("ABCDEFG"). + SetPlatform(c2pb.Host_PLATFORM_UNSPECIFIED). + SaveX(ctx) testBeacons := []*ent.Beacon{ graph.Beacon.Create(). SetHost(testHost). diff --git a/tavern/internal/graphql/schema.graphql b/tavern/internal/graphql/schema.graphql index c37c4412e..243f87f31 100644 --- a/tavern/internal/graphql/schema.graphql +++ b/tavern/internal/graphql/schema.graphql @@ -224,7 +224,7 @@ type File implements Node { name: String! """The size of the file in bytes""" size: Int! - """A SHA3 digest of the content field""" + """A SHA3-256 digest of the content field""" hash: String! tomes: [Tome!] } @@ -338,8 +338,176 @@ type Host implements Node { tags: [Tag!] """Beacons that are present on this host system.""" beacons: [Beacon!] + """Files reported on this host system.""" + files: [HostFile!] """Processes reported as running on this host system.""" - processes: [Process!] + processes: [HostProcess!] +} +type HostFile implements Node { + id: ID! + """Timestamp of when this ent was created""" + createdAt: Time! + """Timestamp of when this ent was last updated""" + lastModifiedAt: Time! + """Path to the file on the host system.""" + path: String! + """User who owns the file on the host system.""" + owner: String + """Group who owns the file on the host system.""" + group: String + """Permissions for the file on the host system.""" + permissions: String + """The size of the file in bytes""" + size: Int! + """A SHA3-256 digest of the content field""" + hash: String + """Host the file was reported on.""" + host: Host! + """Task that reported this file.""" + task: Task! +} +"""Ordering options for HostFile connections""" +input HostFileOrder { + """The ordering direction.""" + direction: OrderDirection! = ASC + """The field by which to order HostFiles.""" + field: HostFileOrderField! +} +"""Properties by which HostFile connections can be ordered.""" +enum HostFileOrderField { + CREATED_AT + LAST_MODIFIED_AT + NAME + SIZE +} +""" +HostFileWhereInput is used for filtering HostFile objects. +Input was generated by ent. +""" +input HostFileWhereInput { + not: HostFileWhereInput + and: [HostFileWhereInput!] + or: [HostFileWhereInput!] + """id field predicates""" + id: ID + idNEQ: ID + idIn: [ID!] + idNotIn: [ID!] + idGT: ID + idGTE: ID + idLT: ID + idLTE: ID + """created_at field predicates""" + createdAt: Time + createdAtNEQ: Time + createdAtIn: [Time!] + createdAtNotIn: [Time!] + createdAtGT: Time + createdAtGTE: Time + createdAtLT: Time + createdAtLTE: Time + """last_modified_at field predicates""" + lastModifiedAt: Time + lastModifiedAtNEQ: Time + lastModifiedAtIn: [Time!] + lastModifiedAtNotIn: [Time!] + lastModifiedAtGT: Time + lastModifiedAtGTE: Time + lastModifiedAtLT: Time + lastModifiedAtLTE: Time + """path field predicates""" + path: String + pathNEQ: String + pathIn: [String!] + pathNotIn: [String!] + pathGT: String + pathGTE: String + pathLT: String + pathLTE: String + pathContains: String + pathHasPrefix: String + pathHasSuffix: String + pathEqualFold: String + pathContainsFold: String + """owner field predicates""" + owner: String + ownerNEQ: String + ownerIn: [String!] + ownerNotIn: [String!] + ownerGT: String + ownerGTE: String + ownerLT: String + ownerLTE: String + ownerContains: String + ownerHasPrefix: String + ownerHasSuffix: String + ownerIsNil: Boolean + ownerNotNil: Boolean + ownerEqualFold: String + ownerContainsFold: String + """group field predicates""" + group: String + groupNEQ: String + groupIn: [String!] + groupNotIn: [String!] + groupGT: String + groupGTE: String + groupLT: String + groupLTE: String + groupContains: String + groupHasPrefix: String + groupHasSuffix: String + groupIsNil: Boolean + groupNotNil: Boolean + groupEqualFold: String + groupContainsFold: String + """permissions field predicates""" + permissions: String + permissionsNEQ: String + permissionsIn: [String!] + permissionsNotIn: [String!] + permissionsGT: String + permissionsGTE: String + permissionsLT: String + permissionsLTE: String + permissionsContains: String + permissionsHasPrefix: String + permissionsHasSuffix: String + permissionsIsNil: Boolean + permissionsNotNil: Boolean + permissionsEqualFold: String + permissionsContainsFold: String + """size field predicates""" + size: Int + sizeNEQ: Int + sizeIn: [Int!] + sizeNotIn: [Int!] + sizeGT: Int + sizeGTE: Int + sizeLT: Int + sizeLTE: Int + """hash field predicates""" + hash: String + hashNEQ: String + hashIn: [String!] + hashNotIn: [String!] + hashGT: String + hashGTE: String + hashLT: String + hashLTE: String + hashContains: String + hashHasPrefix: String + hashHasSuffix: String + hashIsNil: Boolean + hashNotNil: Boolean + hashEqualFold: String + hashContainsFold: String + """host edge predicates""" + hasHost: Boolean + hasHostWith: [HostWhereInput!] + """task edge predicates""" + hasTask: Boolean + hasTaskWith: [TaskWhereInput!] } """Ordering options for Host connections""" input HostOrder { @@ -355,12 +523,230 @@ enum HostOrderField { LAST_SEEN_AT } """HostPlatform is enum for the field platform""" -enum HostPlatform @goModel(model: "realm.pub/tavern/internal/ent/host.Platform") { - Windows - Linux - MacOS - BSD - Unknown +enum HostPlatform @goModel(model: "realm.pub/tavern/internal/c2/c2pb.Host_Platform") { + PLATFORM_BSD + PLATFORM_UNSPECIFIED + PLATFORM_WINDOWS + PLATFORM_LINUX + PLATFORM_MACOS +} +type HostProcess implements Node { + id: ID! + """Timestamp of when this ent was created""" + createdAt: Time! + """Timestamp of when this ent was last updated""" + lastModifiedAt: Time! + """ID of the process.""" + pid: Int! + """ID of the parent process.""" + ppid: Int! + """The name of the process.""" + name: String! + """The user the process is running as.""" + principal: String! + """The path to the process executable.""" + path: String + """The command used to execute the process.""" + cmd: String + """The environment variables set for the process.""" + env: String + """The current working directory for the process.""" + cwd: String + """Current process status.""" + status: HostProcessStatus! + """Host the process was reported on.""" + host: Host! + """Task that reported this process.""" + task: Task! +} +"""Ordering options for HostProcess connections""" +input HostProcessOrder { + """The ordering direction.""" + direction: OrderDirection! = ASC + """The field by which to order HostProcesses.""" + field: HostProcessOrderField! +} +"""Properties by which HostProcess connections can be ordered.""" +enum HostProcessOrderField { + CREATED_AT + LAST_MODIFIED_AT + PROCESS_ID + PARENT_PROCESS_ID + NAME +} +"""HostProcessStatus is enum for the field status""" +enum HostProcessStatus @goModel(model: "realm.pub/tavern/internal/c2/c2pb.Process_Status") { + STATUS_STOP + STATUS_TRACING + STATUS_WAKE_KILL + STATUS_UNKNOWN + STATUS_IDLE + STATUS_SLEEP + STATUS_WAKING + STATUS_UNSPECIFIED + STATUS_PARKED + STATUS_LOCK_BLOCKED + STATUS_DEAD + STATUS_ZOMBIE + STATUS_UNINTERUPTIBLE_DISK_SLEEP + STATUS_RUN +} +""" +HostProcessWhereInput is used for filtering HostProcess objects. +Input was generated by ent. +""" +input HostProcessWhereInput { + not: HostProcessWhereInput + and: [HostProcessWhereInput!] + or: [HostProcessWhereInput!] + """id field predicates""" + id: ID + idNEQ: ID + idIn: [ID!] + idNotIn: [ID!] + idGT: ID + idGTE: ID + idLT: ID + idLTE: ID + """created_at field predicates""" + createdAt: Time + createdAtNEQ: Time + createdAtIn: [Time!] + createdAtNotIn: [Time!] + createdAtGT: Time + createdAtGTE: Time + createdAtLT: Time + createdAtLTE: Time + """last_modified_at field predicates""" + lastModifiedAt: Time + lastModifiedAtNEQ: Time + lastModifiedAtIn: [Time!] + lastModifiedAtNotIn: [Time!] + lastModifiedAtGT: Time + lastModifiedAtGTE: Time + lastModifiedAtLT: Time + lastModifiedAtLTE: Time + """pid field predicates""" + pid: Int + pidNEQ: Int + pidIn: [Int!] + pidNotIn: [Int!] + pidGT: Int + pidGTE: Int + pidLT: Int + pidLTE: Int + """ppid field predicates""" + ppid: Int + ppidNEQ: Int + ppidIn: [Int!] + ppidNotIn: [Int!] + ppidGT: Int + ppidGTE: Int + ppidLT: Int + ppidLTE: Int + """name field predicates""" + name: String + nameNEQ: String + nameIn: [String!] + nameNotIn: [String!] + nameGT: String + nameGTE: String + nameLT: String + nameLTE: String + nameContains: String + nameHasPrefix: String + nameHasSuffix: String + nameEqualFold: String + nameContainsFold: String + """principal field predicates""" + principal: String + principalNEQ: String + principalIn: [String!] + principalNotIn: [String!] + principalGT: String + principalGTE: String + principalLT: String + principalLTE: String + principalContains: String + principalHasPrefix: String + principalHasSuffix: String + principalEqualFold: String + principalContainsFold: String + """path field predicates""" + path: String + pathNEQ: String + pathIn: [String!] + pathNotIn: [String!] + pathGT: String + pathGTE: String + pathLT: String + pathLTE: String + pathContains: String + pathHasPrefix: String + pathHasSuffix: String + pathIsNil: Boolean + pathNotNil: Boolean + pathEqualFold: String + pathContainsFold: String + """cmd field predicates""" + cmd: String + cmdNEQ: String + cmdIn: [String!] + cmdNotIn: [String!] + cmdGT: String + cmdGTE: String + cmdLT: String + cmdLTE: String + cmdContains: String + cmdHasPrefix: String + cmdHasSuffix: String + cmdIsNil: Boolean + cmdNotNil: Boolean + cmdEqualFold: String + cmdContainsFold: String + """env field predicates""" + env: String + envNEQ: String + envIn: [String!] + envNotIn: [String!] + envGT: String + envGTE: String + envLT: String + envLTE: String + envContains: String + envHasPrefix: String + envHasSuffix: String + envIsNil: Boolean + envNotNil: Boolean + envEqualFold: String + envContainsFold: String + """cwd field predicates""" + cwd: String + cwdNEQ: String + cwdIn: [String!] + cwdNotIn: [String!] + cwdGT: String + cwdGTE: String + cwdLT: String + cwdLTE: String + cwdContains: String + cwdHasPrefix: String + cwdHasSuffix: String + cwdIsNil: Boolean + cwdNotNil: Boolean + cwdEqualFold: String + cwdContainsFold: String + """status field predicates""" + status: HostProcessStatus + statusNEQ: HostProcessStatus + statusIn: [HostProcessStatus!] + statusNotIn: [HostProcessStatus!] + """host edge predicates""" + hasHost: Boolean + hasHostWith: [HostWhereInput!] + """task edge predicates""" + hasTask: Boolean + hasTaskWith: [TaskWhereInput!] } """ HostWhereInput is used for filtering Host objects. @@ -465,9 +851,12 @@ input HostWhereInput { """beacons edge predicates""" hasBeacons: Boolean hasBeaconsWith: [BeaconWhereInput!] + """files edge predicates""" + hasFiles: Boolean + hasFilesWith: [HostFileWhereInput!] """processes edge predicates""" hasProcesses: Boolean - hasProcessesWith: [ProcessWhereInput!] + hasProcessesWith: [HostProcessWhereInput!] } """ An object with an ID. @@ -498,116 +887,6 @@ type PageInfo { """When paginating forwards, the cursor to continue.""" endCursor: Cursor } -type Process implements Node { - id: ID! - """Timestamp of when this ent was created""" - createdAt: Time! - """Timestamp of when this ent was last updated""" - lastModifiedAt: Time! - """ID of the process.""" - pid: Int! - """The name of the process.""" - name: String! - """The user the process is running as.""" - principal: String! - """Host the process was reported on.""" - host: Host! - """Task that reported this process.""" - task: Task! -} -"""Ordering options for Process connections""" -input ProcessOrder { - """The ordering direction.""" - direction: OrderDirection! = ASC - """The field by which to order Processes.""" - field: ProcessOrderField! -} -"""Properties by which Process connections can be ordered.""" -enum ProcessOrderField { - CREATED_AT - LAST_MODIFIED_AT - PROCESS_ID - NAME -} -""" -ProcessWhereInput is used for filtering Process objects. -Input was generated by ent. -""" -input ProcessWhereInput { - not: ProcessWhereInput - and: [ProcessWhereInput!] - or: [ProcessWhereInput!] - """id field predicates""" - id: ID - idNEQ: ID - idIn: [ID!] - idNotIn: [ID!] - idGT: ID - idGTE: ID - idLT: ID - idLTE: ID - """created_at field predicates""" - createdAt: Time - createdAtNEQ: Time - createdAtIn: [Time!] - createdAtNotIn: [Time!] - createdAtGT: Time - createdAtGTE: Time - createdAtLT: Time - createdAtLTE: Time - """last_modified_at field predicates""" - lastModifiedAt: Time - lastModifiedAtNEQ: Time - lastModifiedAtIn: [Time!] - lastModifiedAtNotIn: [Time!] - lastModifiedAtGT: Time - lastModifiedAtGTE: Time - lastModifiedAtLT: Time - lastModifiedAtLTE: Time - """pid field predicates""" - pid: Int - pidNEQ: Int - pidIn: [Int!] - pidNotIn: [Int!] - pidGT: Int - pidGTE: Int - pidLT: Int - pidLTE: Int - """name field predicates""" - name: String - nameNEQ: String - nameIn: [String!] - nameNotIn: [String!] - nameGT: String - nameGTE: String - nameLT: String - nameLTE: String - nameContains: String - nameHasPrefix: String - nameHasSuffix: String - nameEqualFold: String - nameContainsFold: String - """principal field predicates""" - principal: String - principalNEQ: String - principalIn: [String!] - principalNotIn: [String!] - principalGT: String - principalGTE: String - principalLT: String - principalLTE: String - principalContains: String - principalHasPrefix: String - principalHasSuffix: String - principalEqualFold: String - principalContainsFold: String - """host edge predicates""" - hasHost: Boolean - hasHostWith: [HostWhereInput!] - """task edge predicates""" - hasTask: Boolean - hasTaskWith: [TaskWhereInput!] -} type Query { """Fetches an object given its ID.""" node( @@ -814,8 +1093,10 @@ type Task implements Node { error: String quest: Quest! beacon: Beacon! + """Files that have been reported by this task.""" + reportedFiles: [HostFile!] """Processes that have been reported by this task.""" - reportedProcesses: [Process!] + reportedProcesses: [HostProcess!] } """A connection to a list of items.""" type TaskConnection { @@ -964,9 +1245,12 @@ input TaskWhereInput { """beacon edge predicates""" hasBeacon: Boolean hasBeaconWith: [BeaconWhereInput!] + """reported_files edge predicates""" + hasReportedFiles: Boolean + hasReportedFilesWith: [HostFileWhereInput!] """reported_processes edge predicates""" hasReportedProcesses: Boolean - hasReportedProcessesWith: [ProcessWhereInput!] + hasReportedProcessesWith: [HostProcessWhereInput!] } type Tome implements Node { id: ID! @@ -1179,6 +1463,9 @@ input UpdateHostInput { addBeaconIDs: [ID!] removeBeaconIDs: [ID!] clearBeacons: Boolean + addFileIDs: [ID!] + removeFileIDs: [ID!] + clearFiles: Boolean addProcessIDs: [ID!] removeProcessIDs: [ID!] clearProcesses: Boolean diff --git a/tavern/internal/graphql/schema/ent.graphql b/tavern/internal/graphql/schema/ent.graphql index 3eca04e09..56d217a48 100644 --- a/tavern/internal/graphql/schema/ent.graphql +++ b/tavern/internal/graphql/schema/ent.graphql @@ -219,7 +219,7 @@ type File implements Node { name: String! """The size of the file in bytes""" size: Int! - """A SHA3 digest of the content field""" + """A SHA3-256 digest of the content field""" hash: String! tomes: [Tome!] } @@ -333,8 +333,176 @@ type Host implements Node { tags: [Tag!] """Beacons that are present on this host system.""" beacons: [Beacon!] + """Files reported on this host system.""" + files: [HostFile!] """Processes reported as running on this host system.""" - processes: [Process!] + processes: [HostProcess!] +} +type HostFile implements Node { + id: ID! + """Timestamp of when this ent was created""" + createdAt: Time! + """Timestamp of when this ent was last updated""" + lastModifiedAt: Time! + """Path to the file on the host system.""" + path: String! + """User who owns the file on the host system.""" + owner: String + """Group who owns the file on the host system.""" + group: String + """Permissions for the file on the host system.""" + permissions: String + """The size of the file in bytes""" + size: Int! + """A SHA3-256 digest of the content field""" + hash: String + """Host the file was reported on.""" + host: Host! + """Task that reported this file.""" + task: Task! +} +"""Ordering options for HostFile connections""" +input HostFileOrder { + """The ordering direction.""" + direction: OrderDirection! = ASC + """The field by which to order HostFiles.""" + field: HostFileOrderField! +} +"""Properties by which HostFile connections can be ordered.""" +enum HostFileOrderField { + CREATED_AT + LAST_MODIFIED_AT + NAME + SIZE +} +""" +HostFileWhereInput is used for filtering HostFile objects. +Input was generated by ent. +""" +input HostFileWhereInput { + not: HostFileWhereInput + and: [HostFileWhereInput!] + or: [HostFileWhereInput!] + """id field predicates""" + id: ID + idNEQ: ID + idIn: [ID!] + idNotIn: [ID!] + idGT: ID + idGTE: ID + idLT: ID + idLTE: ID + """created_at field predicates""" + createdAt: Time + createdAtNEQ: Time + createdAtIn: [Time!] + createdAtNotIn: [Time!] + createdAtGT: Time + createdAtGTE: Time + createdAtLT: Time + createdAtLTE: Time + """last_modified_at field predicates""" + lastModifiedAt: Time + lastModifiedAtNEQ: Time + lastModifiedAtIn: [Time!] + lastModifiedAtNotIn: [Time!] + lastModifiedAtGT: Time + lastModifiedAtGTE: Time + lastModifiedAtLT: Time + lastModifiedAtLTE: Time + """path field predicates""" + path: String + pathNEQ: String + pathIn: [String!] + pathNotIn: [String!] + pathGT: String + pathGTE: String + pathLT: String + pathLTE: String + pathContains: String + pathHasPrefix: String + pathHasSuffix: String + pathEqualFold: String + pathContainsFold: String + """owner field predicates""" + owner: String + ownerNEQ: String + ownerIn: [String!] + ownerNotIn: [String!] + ownerGT: String + ownerGTE: String + ownerLT: String + ownerLTE: String + ownerContains: String + ownerHasPrefix: String + ownerHasSuffix: String + ownerIsNil: Boolean + ownerNotNil: Boolean + ownerEqualFold: String + ownerContainsFold: String + """group field predicates""" + group: String + groupNEQ: String + groupIn: [String!] + groupNotIn: [String!] + groupGT: String + groupGTE: String + groupLT: String + groupLTE: String + groupContains: String + groupHasPrefix: String + groupHasSuffix: String + groupIsNil: Boolean + groupNotNil: Boolean + groupEqualFold: String + groupContainsFold: String + """permissions field predicates""" + permissions: String + permissionsNEQ: String + permissionsIn: [String!] + permissionsNotIn: [String!] + permissionsGT: String + permissionsGTE: String + permissionsLT: String + permissionsLTE: String + permissionsContains: String + permissionsHasPrefix: String + permissionsHasSuffix: String + permissionsIsNil: Boolean + permissionsNotNil: Boolean + permissionsEqualFold: String + permissionsContainsFold: String + """size field predicates""" + size: Int + sizeNEQ: Int + sizeIn: [Int!] + sizeNotIn: [Int!] + sizeGT: Int + sizeGTE: Int + sizeLT: Int + sizeLTE: Int + """hash field predicates""" + hash: String + hashNEQ: String + hashIn: [String!] + hashNotIn: [String!] + hashGT: String + hashGTE: String + hashLT: String + hashLTE: String + hashContains: String + hashHasPrefix: String + hashHasSuffix: String + hashIsNil: Boolean + hashNotNil: Boolean + hashEqualFold: String + hashContainsFold: String + """host edge predicates""" + hasHost: Boolean + hasHostWith: [HostWhereInput!] + """task edge predicates""" + hasTask: Boolean + hasTaskWith: [TaskWhereInput!] } """Ordering options for Host connections""" input HostOrder { @@ -350,12 +518,230 @@ enum HostOrderField { LAST_SEEN_AT } """HostPlatform is enum for the field platform""" -enum HostPlatform @goModel(model: "realm.pub/tavern/internal/ent/host.Platform") { - Windows - Linux - MacOS - BSD - Unknown +enum HostPlatform @goModel(model: "realm.pub/tavern/internal/c2/c2pb.Host_Platform") { + PLATFORM_BSD + PLATFORM_UNSPECIFIED + PLATFORM_WINDOWS + PLATFORM_LINUX + PLATFORM_MACOS +} +type HostProcess implements Node { + id: ID! + """Timestamp of when this ent was created""" + createdAt: Time! + """Timestamp of when this ent was last updated""" + lastModifiedAt: Time! + """ID of the process.""" + pid: Int! + """ID of the parent process.""" + ppid: Int! + """The name of the process.""" + name: String! + """The user the process is running as.""" + principal: String! + """The path to the process executable.""" + path: String + """The command used to execute the process.""" + cmd: String + """The environment variables set for the process.""" + env: String + """The current working directory for the process.""" + cwd: String + """Current process status.""" + status: HostProcessStatus! + """Host the process was reported on.""" + host: Host! + """Task that reported this process.""" + task: Task! +} +"""Ordering options for HostProcess connections""" +input HostProcessOrder { + """The ordering direction.""" + direction: OrderDirection! = ASC + """The field by which to order HostProcesses.""" + field: HostProcessOrderField! +} +"""Properties by which HostProcess connections can be ordered.""" +enum HostProcessOrderField { + CREATED_AT + LAST_MODIFIED_AT + PROCESS_ID + PARENT_PROCESS_ID + NAME +} +"""HostProcessStatus is enum for the field status""" +enum HostProcessStatus @goModel(model: "realm.pub/tavern/internal/c2/c2pb.Process_Status") { + STATUS_STOP + STATUS_TRACING + STATUS_WAKE_KILL + STATUS_UNKNOWN + STATUS_IDLE + STATUS_SLEEP + STATUS_WAKING + STATUS_UNSPECIFIED + STATUS_PARKED + STATUS_LOCK_BLOCKED + STATUS_DEAD + STATUS_ZOMBIE + STATUS_UNINTERUPTIBLE_DISK_SLEEP + STATUS_RUN +} +""" +HostProcessWhereInput is used for filtering HostProcess objects. +Input was generated by ent. +""" +input HostProcessWhereInput { + not: HostProcessWhereInput + and: [HostProcessWhereInput!] + or: [HostProcessWhereInput!] + """id field predicates""" + id: ID + idNEQ: ID + idIn: [ID!] + idNotIn: [ID!] + idGT: ID + idGTE: ID + idLT: ID + idLTE: ID + """created_at field predicates""" + createdAt: Time + createdAtNEQ: Time + createdAtIn: [Time!] + createdAtNotIn: [Time!] + createdAtGT: Time + createdAtGTE: Time + createdAtLT: Time + createdAtLTE: Time + """last_modified_at field predicates""" + lastModifiedAt: Time + lastModifiedAtNEQ: Time + lastModifiedAtIn: [Time!] + lastModifiedAtNotIn: [Time!] + lastModifiedAtGT: Time + lastModifiedAtGTE: Time + lastModifiedAtLT: Time + lastModifiedAtLTE: Time + """pid field predicates""" + pid: Int + pidNEQ: Int + pidIn: [Int!] + pidNotIn: [Int!] + pidGT: Int + pidGTE: Int + pidLT: Int + pidLTE: Int + """ppid field predicates""" + ppid: Int + ppidNEQ: Int + ppidIn: [Int!] + ppidNotIn: [Int!] + ppidGT: Int + ppidGTE: Int + ppidLT: Int + ppidLTE: Int + """name field predicates""" + name: String + nameNEQ: String + nameIn: [String!] + nameNotIn: [String!] + nameGT: String + nameGTE: String + nameLT: String + nameLTE: String + nameContains: String + nameHasPrefix: String + nameHasSuffix: String + nameEqualFold: String + nameContainsFold: String + """principal field predicates""" + principal: String + principalNEQ: String + principalIn: [String!] + principalNotIn: [String!] + principalGT: String + principalGTE: String + principalLT: String + principalLTE: String + principalContains: String + principalHasPrefix: String + principalHasSuffix: String + principalEqualFold: String + principalContainsFold: String + """path field predicates""" + path: String + pathNEQ: String + pathIn: [String!] + pathNotIn: [String!] + pathGT: String + pathGTE: String + pathLT: String + pathLTE: String + pathContains: String + pathHasPrefix: String + pathHasSuffix: String + pathIsNil: Boolean + pathNotNil: Boolean + pathEqualFold: String + pathContainsFold: String + """cmd field predicates""" + cmd: String + cmdNEQ: String + cmdIn: [String!] + cmdNotIn: [String!] + cmdGT: String + cmdGTE: String + cmdLT: String + cmdLTE: String + cmdContains: String + cmdHasPrefix: String + cmdHasSuffix: String + cmdIsNil: Boolean + cmdNotNil: Boolean + cmdEqualFold: String + cmdContainsFold: String + """env field predicates""" + env: String + envNEQ: String + envIn: [String!] + envNotIn: [String!] + envGT: String + envGTE: String + envLT: String + envLTE: String + envContains: String + envHasPrefix: String + envHasSuffix: String + envIsNil: Boolean + envNotNil: Boolean + envEqualFold: String + envContainsFold: String + """cwd field predicates""" + cwd: String + cwdNEQ: String + cwdIn: [String!] + cwdNotIn: [String!] + cwdGT: String + cwdGTE: String + cwdLT: String + cwdLTE: String + cwdContains: String + cwdHasPrefix: String + cwdHasSuffix: String + cwdIsNil: Boolean + cwdNotNil: Boolean + cwdEqualFold: String + cwdContainsFold: String + """status field predicates""" + status: HostProcessStatus + statusNEQ: HostProcessStatus + statusIn: [HostProcessStatus!] + statusNotIn: [HostProcessStatus!] + """host edge predicates""" + hasHost: Boolean + hasHostWith: [HostWhereInput!] + """task edge predicates""" + hasTask: Boolean + hasTaskWith: [TaskWhereInput!] } """ HostWhereInput is used for filtering Host objects. @@ -460,9 +846,12 @@ input HostWhereInput { """beacons edge predicates""" hasBeacons: Boolean hasBeaconsWith: [BeaconWhereInput!] + """files edge predicates""" + hasFiles: Boolean + hasFilesWith: [HostFileWhereInput!] """processes edge predicates""" hasProcesses: Boolean - hasProcessesWith: [ProcessWhereInput!] + hasProcessesWith: [HostProcessWhereInput!] } """ An object with an ID. @@ -493,116 +882,6 @@ type PageInfo { """When paginating forwards, the cursor to continue.""" endCursor: Cursor } -type Process implements Node { - id: ID! - """Timestamp of when this ent was created""" - createdAt: Time! - """Timestamp of when this ent was last updated""" - lastModifiedAt: Time! - """ID of the process.""" - pid: Int! - """The name of the process.""" - name: String! - """The user the process is running as.""" - principal: String! - """Host the process was reported on.""" - host: Host! - """Task that reported this process.""" - task: Task! -} -"""Ordering options for Process connections""" -input ProcessOrder { - """The ordering direction.""" - direction: OrderDirection! = ASC - """The field by which to order Processes.""" - field: ProcessOrderField! -} -"""Properties by which Process connections can be ordered.""" -enum ProcessOrderField { - CREATED_AT - LAST_MODIFIED_AT - PROCESS_ID - NAME -} -""" -ProcessWhereInput is used for filtering Process objects. -Input was generated by ent. -""" -input ProcessWhereInput { - not: ProcessWhereInput - and: [ProcessWhereInput!] - or: [ProcessWhereInput!] - """id field predicates""" - id: ID - idNEQ: ID - idIn: [ID!] - idNotIn: [ID!] - idGT: ID - idGTE: ID - idLT: ID - idLTE: ID - """created_at field predicates""" - createdAt: Time - createdAtNEQ: Time - createdAtIn: [Time!] - createdAtNotIn: [Time!] - createdAtGT: Time - createdAtGTE: Time - createdAtLT: Time - createdAtLTE: Time - """last_modified_at field predicates""" - lastModifiedAt: Time - lastModifiedAtNEQ: Time - lastModifiedAtIn: [Time!] - lastModifiedAtNotIn: [Time!] - lastModifiedAtGT: Time - lastModifiedAtGTE: Time - lastModifiedAtLT: Time - lastModifiedAtLTE: Time - """pid field predicates""" - pid: Int - pidNEQ: Int - pidIn: [Int!] - pidNotIn: [Int!] - pidGT: Int - pidGTE: Int - pidLT: Int - pidLTE: Int - """name field predicates""" - name: String - nameNEQ: String - nameIn: [String!] - nameNotIn: [String!] - nameGT: String - nameGTE: String - nameLT: String - nameLTE: String - nameContains: String - nameHasPrefix: String - nameHasSuffix: String - nameEqualFold: String - nameContainsFold: String - """principal field predicates""" - principal: String - principalNEQ: String - principalIn: [String!] - principalNotIn: [String!] - principalGT: String - principalGTE: String - principalLT: String - principalLTE: String - principalContains: String - principalHasPrefix: String - principalHasSuffix: String - principalEqualFold: String - principalContainsFold: String - """host edge predicates""" - hasHost: Boolean - hasHostWith: [HostWhereInput!] - """task edge predicates""" - hasTask: Boolean - hasTaskWith: [TaskWhereInput!] -} type Query { """Fetches an object given its ID.""" node( @@ -809,8 +1088,10 @@ type Task implements Node { error: String quest: Quest! beacon: Beacon! + """Files that have been reported by this task.""" + reportedFiles: [HostFile!] """Processes that have been reported by this task.""" - reportedProcesses: [Process!] + reportedProcesses: [HostProcess!] } """A connection to a list of items.""" type TaskConnection { @@ -959,9 +1240,12 @@ input TaskWhereInput { """beacon edge predicates""" hasBeacon: Boolean hasBeaconWith: [BeaconWhereInput!] + """reported_files edge predicates""" + hasReportedFiles: Boolean + hasReportedFilesWith: [HostFileWhereInput!] """reported_processes edge predicates""" hasReportedProcesses: Boolean - hasReportedProcessesWith: [ProcessWhereInput!] + hasReportedProcessesWith: [HostProcessWhereInput!] } type Tome implements Node { id: ID! @@ -1174,6 +1458,9 @@ input UpdateHostInput { addBeaconIDs: [ID!] removeBeaconIDs: [ID!] clearBeacons: Boolean + addFileIDs: [ID!] + removeFileIDs: [ID!] + clearFiles: Boolean addProcessIDs: [ID!] removeProcessIDs: [ID!] clearProcesses: Boolean diff --git a/tavern/internal/graphql/testdata/mutations/createQuest/NoFiles.yml b/tavern/internal/graphql/testdata/mutations/createQuest/NoFiles.yml index efa3b2fec..0b1cafeaf 100644 --- a/tavern/internal/graphql/testdata/mutations/createQuest/NoFiles.yml +++ b/tavern/internal/graphql/testdata/mutations/createQuest/NoFiles.yml @@ -1,8 +1,8 @@ state: | INSERT INTO `users` (id,oauth_id,photo_url,name,session_token,is_activated,is_admin) VALUES (5,"test_oauth_id","https://photos.com","test","secretToken",true,true); - INSERT INTO `hosts` (id, name, identifier, created_at, last_modified_at) - VALUES (1010,"db1","EXISTING-HOST", "2023-03-04 14:51:13", "2023-03-04 14:51:13"); + INSERT INTO `hosts` (id, name, identifier, platform, created_at, last_modified_at) + VALUES (1010,"db1","EXISTING-HOST", "PLATFORM_UNSPECIFIED", "2023-03-04 14:51:13", "2023-03-04 14:51:13"); INSERT INTO `beacons` (id, name, identifier, beacon_host, created_at, last_modified_at) VALUES (1337,"delightful-lich","ABCDEFG-123456",1010, "2024-01-22 14:51:13", "2024-01-22 14:51:13"); INSERT INTO `tomes` (id, name, description, author, eldritch, hash, created_at, last_modified_at) diff --git a/tavern/internal/graphql/testdata/mutations/createQuest/WithFiles.yml b/tavern/internal/graphql/testdata/mutations/createQuest/WithFiles.yml index 080af2ced..1653a4800 100644 --- a/tavern/internal/graphql/testdata/mutations/createQuest/WithFiles.yml +++ b/tavern/internal/graphql/testdata/mutations/createQuest/WithFiles.yml @@ -1,8 +1,8 @@ state: | INSERT INTO `users` (id,oauth_id,photo_url,name,session_token,is_activated,is_admin) VALUES (5,"test_oauth_id","https://photos.com","test","secretToken",true,true); - INSERT INTO `hosts` (id, name, identifier, created_at, last_modified_at) - VALUES (1010,"db1","EXISTING-HOST", "2023-03-04 14:51:13", "2023-03-04 14:51:13"); + INSERT INTO `hosts` (id, name, identifier, platform, created_at, last_modified_at) + VALUES (1010,"db1","EXISTING-HOST", "PLATFORM_UNSPECIFIED", "2023-03-04 14:51:13", "2023-03-04 14:51:13"); INSERT INTO `beacons` (id, name, identifier, beacon_host, created_at, last_modified_at) VALUES (1337,"delightful-lich","ABCDEFG-123456",1010, "2024-01-22 14:51:13", "2024-01-22 14:51:13"); INSERT INTO `tomes` (id, name, description, author, eldritch, hash, created_at, last_modified_at) diff --git a/tavern/internal/graphql/testdata/mutations/createTag/Group.yml b/tavern/internal/graphql/testdata/mutations/createTag/Group.yml index aeeee4e26..625071b14 100644 --- a/tavern/internal/graphql/testdata/mutations/createTag/Group.yml +++ b/tavern/internal/graphql/testdata/mutations/createTag/Group.yml @@ -1,8 +1,8 @@ state: | INSERT INTO `users` (id,oauth_id,photo_url,name,session_token,is_activated,is_admin) VALUES (5,"test_oauth_id","https://photos.com","test","secretToken",true,true); - INSERT INTO `hosts` (id, name, identifier, created_at, last_modified_at) - VALUES (1010,"db1","EXISTING-HOST","2024-01-22 14:51:13", "2024-01-22 14:51:13"); + INSERT INTO `hosts` (id, name, identifier, platform, created_at, last_modified_at) + VALUES (1010,"db1","EXISTING-HOST","PLATFORM_UNSPECIFIED","2024-01-22 14:51:13", "2024-01-22 14:51:13"); INSERT INTO `beacons` (id, name, identifier, beacon_host, created_at, last_modified_at) VALUES (1337,"delightful-lich","ABCDEFG-123456", 1010, "2024-01-22 14:51:13", "2024-01-22 14:51:13"); requestor: diff --git a/tavern/internal/graphql/testdata/mutations/createTag/MultipleHosts.yml b/tavern/internal/graphql/testdata/mutations/createTag/MultipleHosts.yml index 952ca3712..6156dc38a 100644 --- a/tavern/internal/graphql/testdata/mutations/createTag/MultipleHosts.yml +++ b/tavern/internal/graphql/testdata/mutations/createTag/MultipleHosts.yml @@ -1,10 +1,10 @@ state: | INSERT INTO `users` (id,oauth_id,photo_url,name,session_token,is_activated,is_admin) VALUES (5,"test_oauth_id","https://photos.com","test","secretToken",true,true); - INSERT INTO `hosts` (id, name, identifier, created_at, last_modified_at) - VALUES (1010,"db1","EXISTING-HOST", "2024-01-22 14:51:13", "2024-01-22 14:51:13"); - INSERT INTO `hosts` (id, name, identifier, created_at, last_modified_at) - VALUES (1011,"db2","EXISTING-HOST2", "2024-01-22 14:51:13", "2024-01-22 14:51:13"); + INSERT INTO `hosts` (id, name, identifier, platform, created_at, last_modified_at) + VALUES (1010,"db1","EXISTING-HOST", "PLATFORM_LINUX", "2024-01-22 14:51:13", "2024-01-22 14:51:13"); + INSERT INTO `hosts` (id, name, identifier, platform, created_at, last_modified_at) + VALUES (1011,"db2","EXISTING-HOST2", "PLATFORM_UNSPECIFIED", "2024-01-22 14:51:13", "2024-01-22 14:51:13"); INSERT INTO `beacons` (id, name, identifier, beacon_host, created_at, last_modified_at) VALUES (1337,"delightful-lich","ABCDEFG-123456",1010, "2024-01-22 14:51:13", "2024-01-22 14:51:13"); INSERT INTO `beacons` (id, name, identifier, beacon_host, created_at, last_modified_at) diff --git a/tavern/internal/graphql/testdata/mutations/createTag/Service.yml b/tavern/internal/graphql/testdata/mutations/createTag/Service.yml index f6d77350e..72a16c5b7 100644 --- a/tavern/internal/graphql/testdata/mutations/createTag/Service.yml +++ b/tavern/internal/graphql/testdata/mutations/createTag/Service.yml @@ -1,8 +1,8 @@ state: | INSERT INTO `users` (id,oauth_id,photo_url,name,session_token,is_activated,is_admin) VALUES (5,"test_oauth_id","https://photos.com","test","secretToken",true,true); - INSERT INTO `hosts` (id, name, identifier, created_at, last_modified_at) - VALUES (1010,"db1","EXISTING-HOST", "2024-01-22 14:51:13", "2024-01-22 14:51:13"); + INSERT INTO `hosts` (id, name, identifier, platform, created_at, last_modified_at) + VALUES (1010,"db1","EXISTING-HOST", "PLATFORM_UNSPECIFIED", "2024-01-22 14:51:13", "2024-01-22 14:51:13"); INSERT INTO `beacons` (id, name, identifier, beacon_host, created_at, last_modified_at) VALUES (1337,"delightful-lich","ABCDEFG-123456",1010, "2024-01-22 14:51:13", "2024-01-22 14:51:13"); requestor: diff --git a/tavern/internal/graphql/testdata/mutations/createTome/WithFiles.yml b/tavern/internal/graphql/testdata/mutations/createTome/WithFiles.yml index ce2ed87d0..f1a3bcb4b 100644 --- a/tavern/internal/graphql/testdata/mutations/createTome/WithFiles.yml +++ b/tavern/internal/graphql/testdata/mutations/createTome/WithFiles.yml @@ -1,8 +1,8 @@ state: | INSERT INTO `users` (id,oauth_id,photo_url,name,session_token,is_activated,is_admin) VALUES (5,"test_oauth_id","https://photos.com","test","secretToken",true,true); - INSERT INTO `hosts` (id, name, identifier, created_at, last_modified_at) - VALUES (1010,"db1","EXISTING-HOST", "2024-01-22 14:51:13", "2024-01-22 14:51:13"); + INSERT INTO `hosts` (id, name, identifier, platform, created_at, last_modified_at) + VALUES (1010,"db1","EXISTING-HOST", "PLATFORM_UNSPECIFIED", "2024-01-22 14:51:13", "2024-01-22 14:51:13"); INSERT INTO `beacons` (id, name, identifier, beacon_host, created_at, last_modified_at) VALUES (1337,"delightful-lich","ABCDEFG-123456",1010, "2024-01-22 14:51:13", "2024-01-22 14:51:13"); INSERT INTO `files` (id, name, content, hash, created_at, last_modified_at) diff --git a/tavern/internal/graphql/testdata/mutations/deleteTome/PermissionDenied.yml b/tavern/internal/graphql/testdata/mutations/deleteTome/PermissionDenied.yml index 7578bf192..a01a902a8 100644 --- a/tavern/internal/graphql/testdata/mutations/deleteTome/PermissionDenied.yml +++ b/tavern/internal/graphql/testdata/mutations/deleteTome/PermissionDenied.yml @@ -1,8 +1,8 @@ state: | INSERT INTO `users` (id,oauth_id,photo_url,name,session_token,is_activated,is_admin) VALUES (5,"test_oauth_id","https://photos.com","test","secretToken",true,false); - INSERT INTO `hosts` (id, name, identifier, created_at, last_modified_at) - VALUES (1010,"db1","EXISTING-HOST", "2024-01-22 14:51:13", "2024-01-22 14:51:13"); + INSERT INTO `hosts` (id, name, identifier, platform, created_at, last_modified_at) + VALUES (1010,"db1","EXISTING-HOST", "PLATFORM_UNSPECIFIED", "2024-01-22 14:51:13", "2024-01-22 14:51:13"); INSERT INTO `beacons` (id, name, identifier, beacon_host, created_at, last_modified_at) VALUES (1337,"delightful-lich","ABCDEFG-123456",1010, "2024-01-22 14:51:13", "2024-01-22 14:51:13"); INSERT INTO `tomes` (id, name, description, author, eldritch, hash, created_at, last_modified_at) diff --git a/tavern/internal/graphql/testdata/mutations/deleteTome/Singular.yml b/tavern/internal/graphql/testdata/mutations/deleteTome/Singular.yml index d1d29a14b..a40219c39 100644 --- a/tavern/internal/graphql/testdata/mutations/deleteTome/Singular.yml +++ b/tavern/internal/graphql/testdata/mutations/deleteTome/Singular.yml @@ -1,8 +1,8 @@ state: | INSERT INTO `users` (id,oauth_id,photo_url,name,session_token,is_activated,is_admin) VALUES (5,"test_oauth_id","https://photos.com","test","secretToken",true,true); - INSERT INTO `hosts` (id, name, identifier, created_at, last_modified_at) - VALUES (1010,"db1","EXISTING-HOST", "2024-01-22 14:51:13", "2024-01-22 14:51:13"); + INSERT INTO `hosts` (id, name, identifier, platform, created_at, last_modified_at) + VALUES (1010,"db1","EXISTING-HOST", "PLATFORM_UNSPECIFIED", "2024-01-22 14:51:13", "2024-01-22 14:51:13"); INSERT INTO `beacons` (id, name, identifier, beacon_host, created_at, last_modified_at) VALUES (1337,"delightful-lich","ABCDEFG-123456",1010, "2024-01-22 14:51:13", "2024-01-22 14:51:13"); INSERT INTO `tomes` (id, name, description, author, eldritch, hash, created_at, last_modified_at) diff --git a/tavern/internal/graphql/testdata/mutations/updateBeacon/ChangeNameError.yml b/tavern/internal/graphql/testdata/mutations/updateBeacon/ChangeNameError.yml index e36331253..4a3baf518 100644 --- a/tavern/internal/graphql/testdata/mutations/updateBeacon/ChangeNameError.yml +++ b/tavern/internal/graphql/testdata/mutations/updateBeacon/ChangeNameError.yml @@ -1,8 +1,8 @@ state: | INSERT INTO `users` (id,oauth_id,photo_url,name,session_token,is_activated,is_admin) VALUES (5,"test_oauth_id","https://photos.com","test","secretToken",true,true); - INSERT INTO `hosts` (id, name, identifier, created_at, last_modified_at) - VALUES (1010,"db1","EXISTING-HOST", "2024-01-22 14:51:13", "2024-01-22 14:51:13"); + INSERT INTO `hosts` (id, name, identifier, platform, created_at, last_modified_at) + VALUES (1010,"db1","EXISTING-HOST", "PLATFORM_UNSPECIFIED", "2024-01-22 14:51:13", "2024-01-22 14:51:13"); INSERT INTO `beacons` (id, name, identifier, beacon_host, created_at, last_modified_at) VALUES (1337,"delightful-lich","ABCDEFG-123456",1010, "2024-01-22 14:51:13", "2024-01-22 14:51:13"); requestor: diff --git a/tavern/internal/graphql/testdata/mutations/updateHost/AddTag.yml b/tavern/internal/graphql/testdata/mutations/updateHost/AddTag.yml index 7b15dc243..8f15ac1c3 100644 --- a/tavern/internal/graphql/testdata/mutations/updateHost/AddTag.yml +++ b/tavern/internal/graphql/testdata/mutations/updateHost/AddTag.yml @@ -1,8 +1,8 @@ state: | INSERT INTO `users` (id,oauth_id,photo_url,name,session_token,is_activated,is_admin) VALUES (5,"test_oauth_id","https://photos.com","test","secretToken",true,true); - INSERT INTO `hosts` (id, name, identifier, created_at, last_modified_at) - VALUES (1010,"db1","EXISTING-HOST", "2024-01-22 14:51:13", "2024-01-22 14:51:13"); + INSERT INTO `hosts` (id, name, identifier, platform, created_at, last_modified_at) + VALUES (1010,"db1","EXISTING-HOST", "PLATFORM_UNSPECIFIED", "2024-01-22 14:51:13", "2024-01-22 14:51:13"); INSERT INTO `beacons` (id, name, identifier, beacon_host, created_at, last_modified_at) VALUES (1337,"delightful-lich","ABCDEFG-123456", 1010, "2024-01-22 14:51:13", "2024-01-22 14:51:13"); INSERT INTO `tags` (id, name, kind) diff --git a/tavern/internal/graphql/testdata/mutations/updateHost/ChangeHostname.yml b/tavern/internal/graphql/testdata/mutations/updateHost/ChangeHostname.yml index dc03bd9c3..d42efd40f 100644 --- a/tavern/internal/graphql/testdata/mutations/updateHost/ChangeHostname.yml +++ b/tavern/internal/graphql/testdata/mutations/updateHost/ChangeHostname.yml @@ -1,8 +1,8 @@ state: | INSERT INTO `users` (id,oauth_id,photo_url,name,session_token,is_activated,is_admin) VALUES (5,"test_oauth_id","https://photos.com","test","secretToken",true,true); - INSERT INTO `hosts` (id, name, identifier, created_at, last_modified_at) - VALUES (1010,"db1","EXISTING-HOST", "2024-01-22 14:51:13", "2024-01-22 14:51:13"); + INSERT INTO `hosts` (id, name, identifier, platform, created_at, last_modified_at) + VALUES (1010,"db1","EXISTING-HOST", "PLATFORM_WINDOWS", "2024-01-22 14:51:13", "2024-01-22 14:51:13"); INSERT INTO `beacons` (id, name, identifier, beacon_host, created_at, last_modified_at) VALUES (1337,"delightful-lich","ABCDEFG-123456",1010, "2024-01-22 14:51:13", "2024-01-22 14:51:13"); requestor: @@ -12,6 +12,7 @@ query: | updateHost(hostID: $hostID, input: $input) { id name + platform } } variables: @@ -23,3 +24,4 @@ expected: updateHost: id: "1010" name: "CoolNewName" + platform: "PLATFORM_WINDOWS" diff --git a/tavern/internal/graphql/testdata/mutations/updateHost/RemoveTag.yml b/tavern/internal/graphql/testdata/mutations/updateHost/RemoveTag.yml index bd19f106e..119941888 100644 --- a/tavern/internal/graphql/testdata/mutations/updateHost/RemoveTag.yml +++ b/tavern/internal/graphql/testdata/mutations/updateHost/RemoveTag.yml @@ -1,8 +1,8 @@ state: | INSERT INTO `users` (id,oauth_id,photo_url,name,session_token,is_activated,is_admin) VALUES (5,"test_oauth_id","https://photos.com","test","secretToken",true,true); - INSERT INTO `hosts` (id, name, identifier, created_at, last_modified_at) - VALUES (1010,"db1","EXISTING-HOST", "2024-01-22 14:51:13", "2024-01-22 14:51:13"); + INSERT INTO `hosts` (id, name, identifier, platform, created_at, last_modified_at) + VALUES (1010,"db1","EXISTING-HOST", "PLATFORM_UNSPECIFIED", "2024-01-22 14:51:13", "2024-01-22 14:51:13"); INSERT INTO `beacons` (id, name, identifier, beacon_host, created_at, last_modified_at) VALUES (1337,"delightful-lich","ABCDEFG-123456",1010, "2024-01-22 14:51:13", "2024-01-22 14:51:13"); INSERT INTO `tags` (id, name, kind) diff --git a/tavern/internal/graphql/testdata/mutations/updateTag/ChangeName.yml b/tavern/internal/graphql/testdata/mutations/updateTag/ChangeName.yml index 5baab6404..fd726190e 100644 --- a/tavern/internal/graphql/testdata/mutations/updateTag/ChangeName.yml +++ b/tavern/internal/graphql/testdata/mutations/updateTag/ChangeName.yml @@ -1,8 +1,8 @@ state: | INSERT INTO `users` (id,oauth_id,photo_url,name,session_token,is_activated,is_admin) VALUES (5,"test_oauth_id","https://photos.com","test","secretToken",true,true); - INSERT INTO `hosts` (id, name, identifier, created_at, last_modified_at) - VALUES (1010,"db1","EXISTING-HOST", "2024-01-22 14:51:13", "2024-01-22 14:51:13"); + INSERT INTO `hosts` (id, name, identifier, platform, created_at, last_modified_at) + VALUES (1010,"db1","EXISTING-HOST", "PLATFORM_UNSPECIFIED", "2024-01-22 14:51:13", "2024-01-22 14:51:13"); INSERT INTO `beacons` (id, name, identifier, beacon_host, created_at, last_modified_at) VALUES (1337,"delightful-lich","ABCDEFG-123456",1010, "2024-01-22 14:51:13", "2024-01-22 14:51:13"); INSERT INTO `tags` (id, name, kind) diff --git a/tavern/internal/graphql/testdata/mutations/updateTome/PermissionDenied.yml b/tavern/internal/graphql/testdata/mutations/updateTome/PermissionDenied.yml index bad0289b9..8c4a812bf 100644 --- a/tavern/internal/graphql/testdata/mutations/updateTome/PermissionDenied.yml +++ b/tavern/internal/graphql/testdata/mutations/updateTome/PermissionDenied.yml @@ -1,8 +1,8 @@ state: | INSERT INTO `users` (id,oauth_id,photo_url,name,session_token,is_activated,is_admin) VALUES (5,"test_oauth_id","https://photos.com","test","secretToken",true,false); - INSERT INTO `hosts` (id, name, identifier, created_at, last_modified_at) - VALUES (1010,"db1","EXISTING-HOST", "2024-01-22 14:51:13", "2024-01-22 14:51:13"); + INSERT INTO `hosts` (id, name, identifier, platform, created_at, last_modified_at) + VALUES (1010,"db1","EXISTING-HOST", "PLATFORM_UNSPECIFIED", "2024-01-22 14:51:13", "2024-01-22 14:51:13"); INSERT INTO `beacons` (id, name, identifier, beacon_host, created_at, last_modified_at) VALUES (1337,"delightful-lich","ABCDEFG-123456",1010, "2024-01-22 14:51:13", "2024-01-22 14:51:13"); INSERT INTO `tomes` (id, name, description, author, eldritch, hash, created_at, last_modified_at) diff --git a/tavern/internal/graphql/testdata/mutations/updateTome/Singular.yml b/tavern/internal/graphql/testdata/mutations/updateTome/Singular.yml index 91731d025..4f560085b 100644 --- a/tavern/internal/graphql/testdata/mutations/updateTome/Singular.yml +++ b/tavern/internal/graphql/testdata/mutations/updateTome/Singular.yml @@ -1,8 +1,8 @@ state: | INSERT INTO `users` (id,oauth_id,photo_url,name,session_token,is_activated,is_admin) VALUES (5,"test_oauth_id","https://photos.com","test","secretToken",true,true); - INSERT INTO `hosts` (id, name, identifier, created_at, last_modified_at) - VALUES (1010,"db1","EXISTING-HOST", "2024-01-22 14:51:13", "2024-01-22 14:51:13"); + INSERT INTO `hosts` (id, name, identifier, platform, created_at, last_modified_at) + VALUES (1010,"db1","EXISTING-HOST", "PLATFORM_UNSPECIFIED", "2024-01-22 14:51:13", "2024-01-22 14:51:13"); INSERT INTO `beacons` (id, name, identifier, beacon_host, created_at, last_modified_at) VALUES (1337,"delightful-lich","ABCDEFG-123456",1010, "2024-01-22 14:51:13", "2024-01-22 14:51:13"); INSERT INTO `tomes` (id, name, description, author, eldritch, hash, created_at, last_modified_at) diff --git a/tavern/internal/graphql/testdata/queries/beacons/FilterByID.yml b/tavern/internal/graphql/testdata/queries/beacons/FilterByID.yml index 79baffb2a..18abc61b9 100644 --- a/tavern/internal/graphql/testdata/queries/beacons/FilterByID.yml +++ b/tavern/internal/graphql/testdata/queries/beacons/FilterByID.yml @@ -1,8 +1,8 @@ state: | INSERT INTO `users` (id,oauth_id,photo_url,name,session_token,is_activated,is_admin) VALUES (5,"test_oauth_id","https://photos.com","test","secretToken",true,true); - INSERT INTO `hosts` (id, name, identifier, created_at, last_modified_at) - VALUES (1010,"db1","EXISTING-HOST", "2024-01-22 14:51:13", "2024-01-22 14:51:13"); + INSERT INTO `hosts` (id, name, identifier, platform, created_at, last_modified_at) + VALUES (1010,"db1","EXISTING-HOST", "PLATFORM_UNSPECIFIED", "2024-01-22 14:51:13", "2024-01-22 14:51:13"); INSERT INTO `beacons` (id, name, identifier, beacon_host, created_at, last_modified_at) VALUES (1337,"delightful-lich","ABCDEFG-123456",1010, "2024-01-22 14:51:13", "2024-01-22 14:51:13"); INSERT INTO `beacons` (id, name, identifier, beacon_host, created_at, last_modified_at) diff --git a/tavern/internal/graphql/testdata/queries/beacons/Singular.yml b/tavern/internal/graphql/testdata/queries/beacons/Singular.yml index 1d40ff666..d0038dad5 100644 --- a/tavern/internal/graphql/testdata/queries/beacons/Singular.yml +++ b/tavern/internal/graphql/testdata/queries/beacons/Singular.yml @@ -1,8 +1,8 @@ state: | INSERT INTO `users` (id,oauth_id,photo_url,name,session_token,is_activated,is_admin) VALUES (5,"test_oauth_id","https://photos.com","test","secretToken",true,true); - INSERT INTO `hosts` (id, name, identifier, created_at, last_modified_at) - VALUES (1010,"db1","EXISTING-HOST", "2024-01-22 14:51:13", "2024-01-22 14:51:13"); + INSERT INTO `hosts` (id, name, identifier, platform, created_at, last_modified_at) + VALUES (1010,"db1","EXISTING-HOST", "PLATFORM_UNSPECIFIED", "2024-01-22 14:51:13", "2024-01-22 14:51:13"); INSERT INTO `beacons` (id, name, identifier, beacon_host, interval, created_at, last_modified_at) VALUES (1337,"delightful-lich","ABCDEFG-123456",1010, 120, "2024-01-22 14:51:13", "2024-01-22 14:51:13"); requestor: diff --git a/tavern/internal/graphql/testdata/queries/hosts/Multiple.yml b/tavern/internal/graphql/testdata/queries/hosts/Multiple.yml index be70186b8..416417595 100644 --- a/tavern/internal/graphql/testdata/queries/hosts/Multiple.yml +++ b/tavern/internal/graphql/testdata/queries/hosts/Multiple.yml @@ -1,10 +1,10 @@ state: | INSERT INTO `users` (id,oauth_id,photo_url,name,session_token,is_activated,is_admin) VALUES (5,"test_oauth_id","https://photos.com","test","secretToken",true,true); - INSERT INTO `hosts` (id, name, identifier, created_at, last_modified_at) - VALUES (1010,"db1","EXISTING-HOST", "2024-01-22 14:51:13", "2024-01-22 14:51:13"); - INSERT INTO `hosts` (id, name, identifier, created_at, last_modified_at) - VALUES (1011,"db2","EXISTING-HOST2", "2024-01-22 14:51:13", "2024-01-22 14:51:13"); + INSERT INTO `hosts` (id, name, identifier, platform, created_at, last_modified_at) + VALUES (1010,"db1","EXISTING-HOST", "PLATFORM_UNSPECIFIED", "2024-01-22 14:51:13", "2024-01-22 14:51:13"); + INSERT INTO `hosts` (id, name, identifier, platform, created_at, last_modified_at) + VALUES (1011,"db2","EXISTING-HOST2", "PLATFORM_UNSPECIFIED", "2024-01-22 14:51:13", "2024-01-22 14:51:13"); requestor: session_token: secretToken query: | diff --git a/tavern/internal/graphql/testdata/queries/hosts/Singular.yml b/tavern/internal/graphql/testdata/queries/hosts/Singular.yml index 75325fe53..5b29b8422 100644 --- a/tavern/internal/graphql/testdata/queries/hosts/Singular.yml +++ b/tavern/internal/graphql/testdata/queries/hosts/Singular.yml @@ -1,8 +1,8 @@ state: | INSERT INTO `users` (id,oauth_id,photo_url,name,session_token,is_activated,is_admin) VALUES (5,"test_oauth_id","https://photos.com","test","secretToken",true,true); - INSERT INTO `hosts` (id, name, identifier, created_at, last_modified_at) - VALUES (1010,"db1","EXISTING-HOST", "2024-01-22 14:51:13", "2024-01-22 14:51:13"); + INSERT INTO `hosts` (id, name, identifier, platform, created_at, last_modified_at) + VALUES (1010,"db1","EXISTING-HOST", "PLATFORM_UNSPECIFIED", "2024-01-22 14:51:13", "2024-01-22 14:51:13"); requestor: session_token: secretToken query: | diff --git a/tavern/internal/graphql/testdata/queries/quests/FilterByID.yml b/tavern/internal/graphql/testdata/queries/quests/FilterByID.yml index 7c289d3a4..6ec3223ae 100644 --- a/tavern/internal/graphql/testdata/queries/quests/FilterByID.yml +++ b/tavern/internal/graphql/testdata/queries/quests/FilterByID.yml @@ -1,8 +1,8 @@ state: | INSERT INTO `users` (id,oauth_id,photo_url,name,session_token,is_activated,is_admin) VALUES (5,"test_oauth_id","https://photos.com","test","secretToken",true,true); - INSERT INTO `hosts` (id, name, identifier, created_at, last_modified_at) - VALUES (1010,"db1","EXISTING-HOST", "2024-01-22 14:51:13", "2024-01-22 14:51:13"); + INSERT INTO `hosts` (id, name, identifier, platform, created_at, last_modified_at) + VALUES (1010,"db1","EXISTING-HOST", "PLATFORM_UNSPECIFIED", "2024-01-22 14:51:13", "2024-01-22 14:51:13"); INSERT INTO `beacons` (id, name, identifier, beacon_host, created_at, last_modified_at) VALUES (1337,"delightful-lich","ABCDEFG-123456",1010, "2024-01-22 14:51:13", "2024-01-22 14:51:13"); INSERT INTO `tomes` (id, name, description, author, eldritch, hash, created_at, last_modified_at) diff --git a/tavern/internal/graphql/testdata/queries/quests/Singular.yml b/tavern/internal/graphql/testdata/queries/quests/Singular.yml index 7ce88ef2e..df04abe34 100644 --- a/tavern/internal/graphql/testdata/queries/quests/Singular.yml +++ b/tavern/internal/graphql/testdata/queries/quests/Singular.yml @@ -1,8 +1,8 @@ state: | INSERT INTO `users` (id,oauth_id,photo_url,name,session_token,is_activated,is_admin) VALUES (5,"test_oauth_id","https://photos.com","test","secretToken",true,true); - INSERT INTO `hosts` (id, name, identifier, created_at, last_modified_at) - VALUES (1010,"db1","EXISTING-HOST", "2024-01-22 14:51:13", "2024-01-22 14:51:13"); + INSERT INTO `hosts` (id, name, identifier, platform, created_at, last_modified_at) + VALUES (1010,"db1","EXISTING-HOST", "PLATFORM_UNSPECIFIED", "2024-01-22 14:51:13", "2024-01-22 14:51:13"); INSERT INTO `beacons` (id, name, identifier, beacon_host, created_at, last_modified_at) VALUES (1337,"delightful-lich","ABCDEFG-123456",1010, "2024-01-22 14:51:13", "2024-01-22 14:51:13"); INSERT INTO `tomes` (id, name, description, author, eldritch, hash, created_at, last_modified_at) diff --git a/tavern/internal/graphql/testdata/queries/tasks/BackwardPaginate.yml b/tavern/internal/graphql/testdata/queries/tasks/BackwardPaginate.yml index 471758300..5c39a7b8f 100644 --- a/tavern/internal/graphql/testdata/queries/tasks/BackwardPaginate.yml +++ b/tavern/internal/graphql/testdata/queries/tasks/BackwardPaginate.yml @@ -1,8 +1,8 @@ state: | INSERT INTO `users` (id,oauth_id,photo_url,name,session_token,is_activated,is_admin) VALUES (5,"test_oauth_id","https://photos.com","test","secretToken",true,true); - INSERT INTO `hosts` (id, name, identifier, created_at, last_modified_at) - VALUES (1010,"db1","EXISTING-HOST", "2024-01-22 14:51:13", "2024-01-22 14:51:13"); + INSERT INTO `hosts` (id, name, identifier, platform, created_at, last_modified_at) + VALUES (1010,"db1","EXISTING-HOST", "PLATFORM_UNSPECIFIED", "2024-01-22 14:51:13", "2024-01-22 14:51:13"); INSERT INTO `beacons` (id, name, identifier, beacon_host, created_at, last_modified_at) VALUES (1337,"delightful-lich","ABCDEFG-123456",1010, "2024-01-22 14:51:13", "2024-01-22 14:51:13"); INSERT INTO `tomes` (id, name, description, author, eldritch, hash, created_at, last_modified_at) diff --git a/tavern/internal/graphql/testdata/queries/tasks/FilterByID.yml b/tavern/internal/graphql/testdata/queries/tasks/FilterByID.yml index 5c20f75c6..76e033b52 100644 --- a/tavern/internal/graphql/testdata/queries/tasks/FilterByID.yml +++ b/tavern/internal/graphql/testdata/queries/tasks/FilterByID.yml @@ -1,8 +1,8 @@ state: | INSERT INTO `users` (id,oauth_id,photo_url,name,session_token,is_activated,is_admin) VALUES (5,"test_oauth_id","https://photos.com","test","secretToken",true,true); - INSERT INTO `hosts` (id, name, identifier, created_at, last_modified_at) - VALUES (1010,"db1","EXISTING-HOST", "2024-01-22 14:51:13", "2024-01-22 14:51:13"); + INSERT INTO `hosts` (id, name, identifier, platform, created_at, last_modified_at) + VALUES (1010,"db1","EXISTING-HOST", "PLATFORM_UNSPECIFIED", "2024-01-22 14:51:13", "2024-01-22 14:51:13"); INSERT INTO `beacons` (id, name, identifier, beacon_host, created_at, last_modified_at) VALUES (1337,"delightful-lich","ABCDEFG-123456",1010, "2024-01-22 14:51:13", "2024-01-22 14:51:13"); INSERT INTO `tomes` (id, name, description, author, eldritch, hash, created_at, last_modified_at) diff --git a/tavern/internal/graphql/testdata/queries/tasks/ForwardPaginate.yml b/tavern/internal/graphql/testdata/queries/tasks/ForwardPaginate.yml index e99709b77..68d880bdc 100644 --- a/tavern/internal/graphql/testdata/queries/tasks/ForwardPaginate.yml +++ b/tavern/internal/graphql/testdata/queries/tasks/ForwardPaginate.yml @@ -1,8 +1,8 @@ state: | INSERT INTO `users` (id,oauth_id,photo_url,name,session_token,is_activated,is_admin) VALUES (5,"test_oauth_id","https://photos.com","test","secretToken",true,true); - INSERT INTO `hosts` (id, name, identifier, created_at, last_modified_at) - VALUES (1010,"db1","EXISTING-HOST", "2024-01-22 14:51:13", "2024-01-22 14:51:13"); + INSERT INTO `hosts` (id, name, identifier, platform, created_at, last_modified_at) + VALUES (1010,"db1","EXISTING-HOST", "PLATFORM_UNSPECIFIED", "2024-01-22 14:51:13", "2024-01-22 14:51:13"); INSERT INTO `beacons` (id, name, identifier, beacon_host, created_at, last_modified_at) VALUES (1337,"delightful-lich","ABCDEFG-123456",1010, "2024-01-22 14:51:13", "2024-01-22 14:51:13"); INSERT INTO `tomes` (id, name, description, author, eldritch, hash, created_at, last_modified_at) diff --git a/tavern/internal/graphql/testdata/queries/tasks/Multiple.yml b/tavern/internal/graphql/testdata/queries/tasks/Multiple.yml index 3e657341b..65ad8fea3 100644 --- a/tavern/internal/graphql/testdata/queries/tasks/Multiple.yml +++ b/tavern/internal/graphql/testdata/queries/tasks/Multiple.yml @@ -1,8 +1,8 @@ state: | INSERT INTO `users` (id,oauth_id,photo_url,name,session_token,is_activated,is_admin) VALUES (5,"test_oauth_id","https://photos.com","test","secretToken",true,true); - INSERT INTO `hosts` (id, name, identifier, created_at, last_modified_at) - VALUES (1010,"db1","EXISTING-HOST", "2024-01-22 14:51:13", "2024-01-22 14:51:13"); + INSERT INTO `hosts` (id, name, identifier, platform, created_at, last_modified_at) + VALUES (1010,"db1","EXISTING-HOST", "PLATFORM_UNSPECIFIED", "2024-01-22 14:51:13", "2024-01-22 14:51:13"); INSERT INTO `beacons` (id, name, identifier, beacon_host, created_at, last_modified_at) VALUES (1337,"delightful-lich","ABCDEFG-123456",1010, "2024-01-22 14:51:13", "2024-01-22 14:51:13"); INSERT INTO `tomes` (id, name, description, author, eldritch, hash, created_at, last_modified_at) diff --git a/tavern/internal/graphql/testdata/queries/tasks/OrderByPaginate.yml b/tavern/internal/graphql/testdata/queries/tasks/OrderByPaginate.yml index 4af7f9829..10e765514 100644 --- a/tavern/internal/graphql/testdata/queries/tasks/OrderByPaginate.yml +++ b/tavern/internal/graphql/testdata/queries/tasks/OrderByPaginate.yml @@ -1,8 +1,8 @@ state: | INSERT INTO `users` (id,oauth_id,photo_url,name,session_token,is_activated,is_admin) VALUES (5,"test_oauth_id","https://photos.com","test","secretToken",true,true); - INSERT INTO `hosts` (id, name, identifier, created_at, last_modified_at) - VALUES (1010,"db1","EXISTING-HOST", "2024-01-22 14:51:13", "2024-01-22 14:51:13"); + INSERT INTO `hosts` (id, name, identifier, platform, created_at, last_modified_at) + VALUES (1010,"db1","EXISTING-HOST", "PLATFORM_UNSPECIFIED", "2024-01-22 14:51:13", "2024-01-22 14:51:13"); INSERT INTO `beacons` (id, name, identifier, beacon_host, created_at, last_modified_at) VALUES (1337,"delightful-lich","ABCDEFG-123456",1010, "2024-01-22 14:51:13", "2024-01-22 14:51:13"); INSERT INTO `tomes` (id, name, description, author, eldritch, hash, created_at, last_modified_at) diff --git a/tavern/internal/graphql/testdata/queries/tasks/Singular.yml b/tavern/internal/graphql/testdata/queries/tasks/Singular.yml index 5f3de51d8..918c5ff3b 100644 --- a/tavern/internal/graphql/testdata/queries/tasks/Singular.yml +++ b/tavern/internal/graphql/testdata/queries/tasks/Singular.yml @@ -1,8 +1,8 @@ state: | INSERT INTO `users` (id,oauth_id,photo_url,name,session_token,is_activated,is_admin) VALUES (5,"test_oauth_id","https://photos.com","test","secretToken",true,true); - INSERT INTO `hosts` (id, name, identifier, created_at, last_modified_at) - VALUES (1010,"db1","EXISTING-HOST", "2024-01-22 14:51:13", "2024-01-22 14:51:13"); + INSERT INTO `hosts` (id, name, identifier, platform, created_at, last_modified_at) + VALUES (1010,"db1","EXISTING-HOST", "PLATFORM_UNSPECIFIED", "2024-01-22 14:51:13", "2024-01-22 14:51:13"); INSERT INTO `beacons` (id, name, identifier, beacon_host, created_at, last_modified_at) VALUES (1337,"delightful-lich","ABCDEFG-123456",1010, "2024-01-22 14:51:13", "2024-01-22 14:51:13"); INSERT INTO `tomes` (id, name, description, author, eldritch, hash, created_at, last_modified_at) diff --git a/tavern/internal/www/schema.graphql b/tavern/internal/www/schema.graphql index c37c4412e..243f87f31 100644 --- a/tavern/internal/www/schema.graphql +++ b/tavern/internal/www/schema.graphql @@ -224,7 +224,7 @@ type File implements Node { name: String! """The size of the file in bytes""" size: Int! - """A SHA3 digest of the content field""" + """A SHA3-256 digest of the content field""" hash: String! tomes: [Tome!] } @@ -338,8 +338,176 @@ type Host implements Node { tags: [Tag!] """Beacons that are present on this host system.""" beacons: [Beacon!] + """Files reported on this host system.""" + files: [HostFile!] """Processes reported as running on this host system.""" - processes: [Process!] + processes: [HostProcess!] +} +type HostFile implements Node { + id: ID! + """Timestamp of when this ent was created""" + createdAt: Time! + """Timestamp of when this ent was last updated""" + lastModifiedAt: Time! + """Path to the file on the host system.""" + path: String! + """User who owns the file on the host system.""" + owner: String + """Group who owns the file on the host system.""" + group: String + """Permissions for the file on the host system.""" + permissions: String + """The size of the file in bytes""" + size: Int! + """A SHA3-256 digest of the content field""" + hash: String + """Host the file was reported on.""" + host: Host! + """Task that reported this file.""" + task: Task! +} +"""Ordering options for HostFile connections""" +input HostFileOrder { + """The ordering direction.""" + direction: OrderDirection! = ASC + """The field by which to order HostFiles.""" + field: HostFileOrderField! +} +"""Properties by which HostFile connections can be ordered.""" +enum HostFileOrderField { + CREATED_AT + LAST_MODIFIED_AT + NAME + SIZE +} +""" +HostFileWhereInput is used for filtering HostFile objects. +Input was generated by ent. +""" +input HostFileWhereInput { + not: HostFileWhereInput + and: [HostFileWhereInput!] + or: [HostFileWhereInput!] + """id field predicates""" + id: ID + idNEQ: ID + idIn: [ID!] + idNotIn: [ID!] + idGT: ID + idGTE: ID + idLT: ID + idLTE: ID + """created_at field predicates""" + createdAt: Time + createdAtNEQ: Time + createdAtIn: [Time!] + createdAtNotIn: [Time!] + createdAtGT: Time + createdAtGTE: Time + createdAtLT: Time + createdAtLTE: Time + """last_modified_at field predicates""" + lastModifiedAt: Time + lastModifiedAtNEQ: Time + lastModifiedAtIn: [Time!] + lastModifiedAtNotIn: [Time!] + lastModifiedAtGT: Time + lastModifiedAtGTE: Time + lastModifiedAtLT: Time + lastModifiedAtLTE: Time + """path field predicates""" + path: String + pathNEQ: String + pathIn: [String!] + pathNotIn: [String!] + pathGT: String + pathGTE: String + pathLT: String + pathLTE: String + pathContains: String + pathHasPrefix: String + pathHasSuffix: String + pathEqualFold: String + pathContainsFold: String + """owner field predicates""" + owner: String + ownerNEQ: String + ownerIn: [String!] + ownerNotIn: [String!] + ownerGT: String + ownerGTE: String + ownerLT: String + ownerLTE: String + ownerContains: String + ownerHasPrefix: String + ownerHasSuffix: String + ownerIsNil: Boolean + ownerNotNil: Boolean + ownerEqualFold: String + ownerContainsFold: String + """group field predicates""" + group: String + groupNEQ: String + groupIn: [String!] + groupNotIn: [String!] + groupGT: String + groupGTE: String + groupLT: String + groupLTE: String + groupContains: String + groupHasPrefix: String + groupHasSuffix: String + groupIsNil: Boolean + groupNotNil: Boolean + groupEqualFold: String + groupContainsFold: String + """permissions field predicates""" + permissions: String + permissionsNEQ: String + permissionsIn: [String!] + permissionsNotIn: [String!] + permissionsGT: String + permissionsGTE: String + permissionsLT: String + permissionsLTE: String + permissionsContains: String + permissionsHasPrefix: String + permissionsHasSuffix: String + permissionsIsNil: Boolean + permissionsNotNil: Boolean + permissionsEqualFold: String + permissionsContainsFold: String + """size field predicates""" + size: Int + sizeNEQ: Int + sizeIn: [Int!] + sizeNotIn: [Int!] + sizeGT: Int + sizeGTE: Int + sizeLT: Int + sizeLTE: Int + """hash field predicates""" + hash: String + hashNEQ: String + hashIn: [String!] + hashNotIn: [String!] + hashGT: String + hashGTE: String + hashLT: String + hashLTE: String + hashContains: String + hashHasPrefix: String + hashHasSuffix: String + hashIsNil: Boolean + hashNotNil: Boolean + hashEqualFold: String + hashContainsFold: String + """host edge predicates""" + hasHost: Boolean + hasHostWith: [HostWhereInput!] + """task edge predicates""" + hasTask: Boolean + hasTaskWith: [TaskWhereInput!] } """Ordering options for Host connections""" input HostOrder { @@ -355,12 +523,230 @@ enum HostOrderField { LAST_SEEN_AT } """HostPlatform is enum for the field platform""" -enum HostPlatform @goModel(model: "realm.pub/tavern/internal/ent/host.Platform") { - Windows - Linux - MacOS - BSD - Unknown +enum HostPlatform @goModel(model: "realm.pub/tavern/internal/c2/c2pb.Host_Platform") { + PLATFORM_BSD + PLATFORM_UNSPECIFIED + PLATFORM_WINDOWS + PLATFORM_LINUX + PLATFORM_MACOS +} +type HostProcess implements Node { + id: ID! + """Timestamp of when this ent was created""" + createdAt: Time! + """Timestamp of when this ent was last updated""" + lastModifiedAt: Time! + """ID of the process.""" + pid: Int! + """ID of the parent process.""" + ppid: Int! + """The name of the process.""" + name: String! + """The user the process is running as.""" + principal: String! + """The path to the process executable.""" + path: String + """The command used to execute the process.""" + cmd: String + """The environment variables set for the process.""" + env: String + """The current working directory for the process.""" + cwd: String + """Current process status.""" + status: HostProcessStatus! + """Host the process was reported on.""" + host: Host! + """Task that reported this process.""" + task: Task! +} +"""Ordering options for HostProcess connections""" +input HostProcessOrder { + """The ordering direction.""" + direction: OrderDirection! = ASC + """The field by which to order HostProcesses.""" + field: HostProcessOrderField! +} +"""Properties by which HostProcess connections can be ordered.""" +enum HostProcessOrderField { + CREATED_AT + LAST_MODIFIED_AT + PROCESS_ID + PARENT_PROCESS_ID + NAME +} +"""HostProcessStatus is enum for the field status""" +enum HostProcessStatus @goModel(model: "realm.pub/tavern/internal/c2/c2pb.Process_Status") { + STATUS_STOP + STATUS_TRACING + STATUS_WAKE_KILL + STATUS_UNKNOWN + STATUS_IDLE + STATUS_SLEEP + STATUS_WAKING + STATUS_UNSPECIFIED + STATUS_PARKED + STATUS_LOCK_BLOCKED + STATUS_DEAD + STATUS_ZOMBIE + STATUS_UNINTERUPTIBLE_DISK_SLEEP + STATUS_RUN +} +""" +HostProcessWhereInput is used for filtering HostProcess objects. +Input was generated by ent. +""" +input HostProcessWhereInput { + not: HostProcessWhereInput + and: [HostProcessWhereInput!] + or: [HostProcessWhereInput!] + """id field predicates""" + id: ID + idNEQ: ID + idIn: [ID!] + idNotIn: [ID!] + idGT: ID + idGTE: ID + idLT: ID + idLTE: ID + """created_at field predicates""" + createdAt: Time + createdAtNEQ: Time + createdAtIn: [Time!] + createdAtNotIn: [Time!] + createdAtGT: Time + createdAtGTE: Time + createdAtLT: Time + createdAtLTE: Time + """last_modified_at field predicates""" + lastModifiedAt: Time + lastModifiedAtNEQ: Time + lastModifiedAtIn: [Time!] + lastModifiedAtNotIn: [Time!] + lastModifiedAtGT: Time + lastModifiedAtGTE: Time + lastModifiedAtLT: Time + lastModifiedAtLTE: Time + """pid field predicates""" + pid: Int + pidNEQ: Int + pidIn: [Int!] + pidNotIn: [Int!] + pidGT: Int + pidGTE: Int + pidLT: Int + pidLTE: Int + """ppid field predicates""" + ppid: Int + ppidNEQ: Int + ppidIn: [Int!] + ppidNotIn: [Int!] + ppidGT: Int + ppidGTE: Int + ppidLT: Int + ppidLTE: Int + """name field predicates""" + name: String + nameNEQ: String + nameIn: [String!] + nameNotIn: [String!] + nameGT: String + nameGTE: String + nameLT: String + nameLTE: String + nameContains: String + nameHasPrefix: String + nameHasSuffix: String + nameEqualFold: String + nameContainsFold: String + """principal field predicates""" + principal: String + principalNEQ: String + principalIn: [String!] + principalNotIn: [String!] + principalGT: String + principalGTE: String + principalLT: String + principalLTE: String + principalContains: String + principalHasPrefix: String + principalHasSuffix: String + principalEqualFold: String + principalContainsFold: String + """path field predicates""" + path: String + pathNEQ: String + pathIn: [String!] + pathNotIn: [String!] + pathGT: String + pathGTE: String + pathLT: String + pathLTE: String + pathContains: String + pathHasPrefix: String + pathHasSuffix: String + pathIsNil: Boolean + pathNotNil: Boolean + pathEqualFold: String + pathContainsFold: String + """cmd field predicates""" + cmd: String + cmdNEQ: String + cmdIn: [String!] + cmdNotIn: [String!] + cmdGT: String + cmdGTE: String + cmdLT: String + cmdLTE: String + cmdContains: String + cmdHasPrefix: String + cmdHasSuffix: String + cmdIsNil: Boolean + cmdNotNil: Boolean + cmdEqualFold: String + cmdContainsFold: String + """env field predicates""" + env: String + envNEQ: String + envIn: [String!] + envNotIn: [String!] + envGT: String + envGTE: String + envLT: String + envLTE: String + envContains: String + envHasPrefix: String + envHasSuffix: String + envIsNil: Boolean + envNotNil: Boolean + envEqualFold: String + envContainsFold: String + """cwd field predicates""" + cwd: String + cwdNEQ: String + cwdIn: [String!] + cwdNotIn: [String!] + cwdGT: String + cwdGTE: String + cwdLT: String + cwdLTE: String + cwdContains: String + cwdHasPrefix: String + cwdHasSuffix: String + cwdIsNil: Boolean + cwdNotNil: Boolean + cwdEqualFold: String + cwdContainsFold: String + """status field predicates""" + status: HostProcessStatus + statusNEQ: HostProcessStatus + statusIn: [HostProcessStatus!] + statusNotIn: [HostProcessStatus!] + """host edge predicates""" + hasHost: Boolean + hasHostWith: [HostWhereInput!] + """task edge predicates""" + hasTask: Boolean + hasTaskWith: [TaskWhereInput!] } """ HostWhereInput is used for filtering Host objects. @@ -465,9 +851,12 @@ input HostWhereInput { """beacons edge predicates""" hasBeacons: Boolean hasBeaconsWith: [BeaconWhereInput!] + """files edge predicates""" + hasFiles: Boolean + hasFilesWith: [HostFileWhereInput!] """processes edge predicates""" hasProcesses: Boolean - hasProcessesWith: [ProcessWhereInput!] + hasProcessesWith: [HostProcessWhereInput!] } """ An object with an ID. @@ -498,116 +887,6 @@ type PageInfo { """When paginating forwards, the cursor to continue.""" endCursor: Cursor } -type Process implements Node { - id: ID! - """Timestamp of when this ent was created""" - createdAt: Time! - """Timestamp of when this ent was last updated""" - lastModifiedAt: Time! - """ID of the process.""" - pid: Int! - """The name of the process.""" - name: String! - """The user the process is running as.""" - principal: String! - """Host the process was reported on.""" - host: Host! - """Task that reported this process.""" - task: Task! -} -"""Ordering options for Process connections""" -input ProcessOrder { - """The ordering direction.""" - direction: OrderDirection! = ASC - """The field by which to order Processes.""" - field: ProcessOrderField! -} -"""Properties by which Process connections can be ordered.""" -enum ProcessOrderField { - CREATED_AT - LAST_MODIFIED_AT - PROCESS_ID - NAME -} -""" -ProcessWhereInput is used for filtering Process objects. -Input was generated by ent. -""" -input ProcessWhereInput { - not: ProcessWhereInput - and: [ProcessWhereInput!] - or: [ProcessWhereInput!] - """id field predicates""" - id: ID - idNEQ: ID - idIn: [ID!] - idNotIn: [ID!] - idGT: ID - idGTE: ID - idLT: ID - idLTE: ID - """created_at field predicates""" - createdAt: Time - createdAtNEQ: Time - createdAtIn: [Time!] - createdAtNotIn: [Time!] - createdAtGT: Time - createdAtGTE: Time - createdAtLT: Time - createdAtLTE: Time - """last_modified_at field predicates""" - lastModifiedAt: Time - lastModifiedAtNEQ: Time - lastModifiedAtIn: [Time!] - lastModifiedAtNotIn: [Time!] - lastModifiedAtGT: Time - lastModifiedAtGTE: Time - lastModifiedAtLT: Time - lastModifiedAtLTE: Time - """pid field predicates""" - pid: Int - pidNEQ: Int - pidIn: [Int!] - pidNotIn: [Int!] - pidGT: Int - pidGTE: Int - pidLT: Int - pidLTE: Int - """name field predicates""" - name: String - nameNEQ: String - nameIn: [String!] - nameNotIn: [String!] - nameGT: String - nameGTE: String - nameLT: String - nameLTE: String - nameContains: String - nameHasPrefix: String - nameHasSuffix: String - nameEqualFold: String - nameContainsFold: String - """principal field predicates""" - principal: String - principalNEQ: String - principalIn: [String!] - principalNotIn: [String!] - principalGT: String - principalGTE: String - principalLT: String - principalLTE: String - principalContains: String - principalHasPrefix: String - principalHasSuffix: String - principalEqualFold: String - principalContainsFold: String - """host edge predicates""" - hasHost: Boolean - hasHostWith: [HostWhereInput!] - """task edge predicates""" - hasTask: Boolean - hasTaskWith: [TaskWhereInput!] -} type Query { """Fetches an object given its ID.""" node( @@ -814,8 +1093,10 @@ type Task implements Node { error: String quest: Quest! beacon: Beacon! + """Files that have been reported by this task.""" + reportedFiles: [HostFile!] """Processes that have been reported by this task.""" - reportedProcesses: [Process!] + reportedProcesses: [HostProcess!] } """A connection to a list of items.""" type TaskConnection { @@ -964,9 +1245,12 @@ input TaskWhereInput { """beacon edge predicates""" hasBeacon: Boolean hasBeaconWith: [BeaconWhereInput!] + """reported_files edge predicates""" + hasReportedFiles: Boolean + hasReportedFilesWith: [HostFileWhereInput!] """reported_processes edge predicates""" hasReportedProcesses: Boolean - hasReportedProcessesWith: [ProcessWhereInput!] + hasReportedProcessesWith: [HostProcessWhereInput!] } type Tome implements Node { id: ID! @@ -1179,6 +1463,9 @@ input UpdateHostInput { addBeaconIDs: [ID!] removeBeaconIDs: [ID!] clearBeacons: Boolean + addFileIDs: [ID!] + removeFileIDs: [ID!] + clearFiles: Boolean addProcessIDs: [ID!] removeProcessIDs: [ID!] clearProcesses: Boolean diff --git a/tavern/test_data.go b/tavern/test_data.go index ffb7e3e6a..57230e0e6 100644 --- a/tavern/test_data.go +++ b/tavern/test_data.go @@ -12,6 +12,7 @@ import ( "net" "time" + "realm.pub/tavern/internal/c2/c2pb" "realm.pub/tavern/internal/ent" "realm.pub/tavern/internal/ent/tag" "realm.pub/tavern/internal/namegen" @@ -39,15 +40,15 @@ func createTestData(ctx context.Context, client *ent.Client) { SetName(fmt.Sprintf("Group-%d", groupNum)). SaveX(ctx) - for _, svcTag := range svcTags { + for i, svcTag := range svcTags { hostName := fmt.Sprintf("Group %d - %s", groupNum, svcTag.Name) hostID := newRandomIdentifier() hostIP := newRandomIP() - testHost := client.Host.Create(). SetName(hostName). SetIdentifier(hostID). SetPrimaryIP(hostIP). + SetPlatform(c2pb.Host_Platform(i%len(c2pb.Host_Platform_value))). AddTags(svcTag, gTag). SaveX(ctx)